Skip to content

Commit

Permalink
mfix dc blocks and new attach servo
Browse files Browse the repository at this point in the history
  • Loading branch information
cparrapa committed Jun 11, 2021
1 parent e45d35d commit 732bdf8
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 39 deletions.
49 changes: 41 additions & 8 deletions www/blocs&generateurs/motor.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Blockly.Arduino["moteur_dc_init"]=function(block){
Blockly.Blocks["moteur_dc"]={init:function(){
this.appendDummyInput().appendField(new Blockly.FieldImage('media/motorDC.png', 33, 33, "*")).appendField(Blockly.Msg.moteur);
this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(new Blockly.FieldDropdown([[Blockly.Msg.right,"6"],[Blockly.Msg.left,"5"],[Blockly.Msg.LetR,"11"]]), "MOTEUR");
this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.direction).appendField(new Blockly.FieldDropdown(Blockly.Msg.FIELDDROPDOWN_av_ar), "ETAT");
this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.direction).appendField(new Blockly.FieldDropdown([[Blockly.Msg.AV,"1"],[Blockly.Msg.AR,"0"]]), "ETAT");
this.appendValueInput('speed').setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.vitesse);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
Expand All @@ -61,14 +61,30 @@ Blockly.Arduino["moteur_dc"]=function(block){
var dropdown_etat=block.getFieldValue("ETAT");
var value_vitesse=Blockly.Arduino.valueToCode(block, "speed");
if (dropdown_moteur=="11") {
return "digitalWrite(l298n_in1,LOW);\ndigitalWrite(l298n_in2,"+dropdown_etat+");\nanalogWrite(l298n_ena,("+value_vitesse+"));\ndigitalWrite(l298n_in3,LOW);\ndigitalWrite(l298n_in4,"+dropdown_etat+");\nanalogWrite(l298n_enb,("+value_vitesse+"));\n"
if (dropdown_etat=="1"){
var code= "digitalWrite(l298n_in1,LOW);\ndigitalWrite(l298n_in2,HIGH);\nanalogWrite(l298n_ena,("+value_vitesse+"));\ndigitalWrite(l298n_in3,LOW);\ndigitalWrite(l298n_in4,HIGH);\nanalogWrite(l298n_enb,("+value_vitesse+"));\n"
}
else if (dropdown_etat=="0"){
var code= "digitalWrite(l298n_in1,HIGH);\ndigitalWrite(l298n_in2,LOW);\nanalogWrite(l298n_ena,("+value_vitesse+"));\ndigitalWrite(l298n_in3,HIGH);\ndigitalWrite(l298n_in4,HIGH);\nanalogWrite(l298n_enb,("+value_vitesse+"));\n"
}
}
if (dropdown_moteur=="6") {
return "digitalWrite(l298n_in1,LOW);\ndigitalWrite(l298n_in2,"+dropdown_etat+");\nanalogWrite(l298n_ena,("+value_vitesse+"));\n"
}
if (dropdown_moteur=="5") {
return "digitalWrite(l298n_in3,LOW);\ndigitalWrite(l298n_in4,"+dropdown_etat+");\nanalogWrite(l298n_enB,("+value_vitesse +"));\n"
}
if (dropdown_etat=="1"){
var code= "digitalWrite(l298n_in1,LOW);\ndigitalWrite(l298n_in2,HIGH);\nanalogWrite(l298n_ena,("+value_vitesse+"));\n"
}
else if (dropdown_etat=="0"){
var code= "digitalWrite(l298n_in1,HIGH);\ndigitalWrite(l298n_in2,LOW);\nanalogWrite(l298n_ena,("+value_vitesse+"));\n"
}
}
if (dropdown_moteur=="5") {
if (dropdown_etat=="1"){
var code= "digitalWrite(l298n_in3,LOW);\ndigitalWrite(l298n_in4,HIGH);\nanalogWrite(l298n_enb,("+value_vitesse +"));\n"
}
else if (dropdown_etat=="0"){
var code= "digitalWrite(l298n_in3,HIGH);\ndigitalWrite(l298n_in4,LOW);\nanalogWrite(l298n_enb,("+value_vitesse +"));\n"
}
}
return code
};

Blockly.Python["moteur_dc"]=function(){return ""};
Expand Down Expand Up @@ -250,6 +266,23 @@ Blockly.Arduino.definitions_["var_servo" + value_pin]="Servo servo_" + value_pin
Blockly.Arduino.setups_["setup_servo_" + value_pin]="servo_" + value_pin + ".attach(" + value_pin + ");";
return "servo_" + value_pin + ".writeMicroseconds(" + value_degree + ");\n"
};
Blockly.Blocks["servo_attach"]={init:function(){
this.appendDummyInput().appendField(new Blockly.FieldImage('media/servo.png', 33, 33, "*")).appendField("Attach Servo");
this.appendValueInput("PIN", "Number").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.pin);
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour("#2d2dd1");
this.setHelpUrl(Blockly.Msg.HELPURL);
this.setTooltip(Blockly.Msg.ARDUINO_SERVO_MOVE_TOOLTIP)}
};
Blockly.Arduino["servo_attach"]=function(block){
var value_pin=Blockly.Arduino.valueToCode(block, "PIN", Blockly.Arduino.ORDER_ATOMIC);
Blockly.Arduino.includes_["define_servo"]="#include <Servo.h>";
Blockly.Arduino.definitions_["var_servo" + value_pin]="Servo servo_" + value_pin + ";";
Blockly.Arduino.setups_["setup_servo_" + value_pin]="servo_" + value_pin + ".attach(" + value_pin + ");";
return "servo_" + value_pin + ".attach();\n"
};

Blockly.Blocks["servo_detach"]={init:function(){
this.appendDummyInput().appendField(new Blockly.FieldImage('media/servo.png', 33, 33, "*")).appendField("Detach Servo");
Expand Down Expand Up @@ -359,7 +392,7 @@ return "servo_" + value_pin + ".write(90);\n"
Blockly.Blocks['servo_2wheels'] = { init: function() {
this.appendDummyInput().appendField(new Blockly.FieldImage('media/otto_wheels.png', 33, 33, "*"));
this.appendValueInput("PINL", "Number").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.pin+" "+Blockly.Msg.left);
this.appendValueInput("PINR", "Number").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.pin+" "+Blockly.Msg.right)
this.appendValueInput("PINR", "Number").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.right)
this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(new Blockly.FieldDropdown(Blockly.Msg.OTTO9_MOVEW_CHOICE), "otto_move_sens");
this.appendDummyInput() .setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.OTTO9_MOVE_SPEED_TEXT) .appendField(new Blockly.FieldDropdown(Blockly.Msg.OTTO9_MOVEW_SPEED_CHOICE), "otto_move_speed");
this.appendDummyInput() .setAlign(Blockly.ALIGN_RIGHT) .appendField(Blockly.Msg.m_pap_step) .appendField(new Blockly.FieldNumber("1"), "time");
Expand Down
27 changes: 14 additions & 13 deletions www/lang/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

var Code = {};
Code.LANGUAGE_NAME = {
'en': 'English',
'es': 'Español',
'pt': 'Português',
'it': 'Italiano',
'fr': 'Français',
'de': 'Deutsch',
'cz': 'Čeština',
'pl': 'Polski',
'hu': 'Magyar',
'tr': 'Türk',
'ru': 'Pусский',
'heb': 'עִברִית',
'cn': '中文'
'en': '🇬🇧 English',
'es': '🇪🇸 Español',
'pt': '🇵🇹 Português',
'it': '🇮🇹 Italiano',
'fr': '🇫🇷 Français',
'de': '🇩🇪 Deutsch',
'cz': '🇨🇿 Čeština',
'pl': '🇵🇱 Polski',
'hu': '🇭🇺 Magyar',
'tr': '🇹🇷 Türk',
'ru': '🇷🇺 Pусский',
'heb': '🇮🇱 עִברִית',
'zh': '🇹🇼 漢語',
'cn': '🇨🇳 汉语'
};
Code.LANGUAGE_RTL = ['ar', 'fa', 'he'];
Code.getLang = function() {
Expand Down
30 changes: 15 additions & 15 deletions www/lang/msg_en.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ var MSG = {
  btn_variable: "👌 OK",
  btn_close: "Close",
  btn_valid: "Accept",
  btn_config: "Settings",
  btn_about: "About",
  btn_new: "New",
  btn_fakeload: "Open",
  btn_example: "Examples",
  btn_term: "Serial monitor",
  btn_config: "⚙️ Settings",
  btn_about: "⏱️ About",
  btn_new: "📄 New",
  btn_fakeload: "📂 Open",
  btn_example: "🎓 Examples",
  btn_term: "🔍 Serial monitor",
  btn_factory: "Block factory",
  btn_saveXML: "Save",
  btn_print: "Screenshot",
  btn_preview_ino: "Arduino Code Preview",
  btn_saveXML: "💾 Save",
  btn_print: "📷 Screenshot",
  btn_preview_ino: "👩‍💻 Arduino Code Preview",
  btn_preview_py: "Python Code Preview",
  btn_save_ino: "Save as .INO",
  btn_save_py: "Save as .PY",
  btn_save_ino: "💾 Save as .INO",
  btn_save_py: "💾 Save as .PY",
btn_copy:" Copy to clipboard ",
  btn_undo: "Undo (ctrl + z)",
  btn_redo: "Redo (ctrl + y)",
btn_search: "Search",
btn_search: "🔎 Search",
  span_update: "Check for startup updates",
  span_blocklino: " Otto Blockly",
  span_verify_update: "Check now",
  span_verify_update: "☑️ Check now",
  span_site: " Website",
  span_forum: " Forum",
  span_forum: " Community",
  span_contact: " Report issues",
  span_languageMenu: "Language:",
  span_toolbox_all: "ALL",
Expand All @@ -36,7 +36,7 @@ var MSG = {
  cardLabel: "Available boards",
  aboutcardLabel: "Board ...",
  usbLabel: "USB",
  aboutusbLabel: "Communication between the board and the computer",
  aboutusbLabel: "🔌 Communication between the board and the computer",
  variablebody: "Name for the variable",
  labelToolboxDefinition: "Level:",
  httpRequestError: "There was a problem with the request.",
Expand Down
Binary file removed www/media/rs027.png
Binary file not shown.
Binary file removed www/media/rs040.jpg
Binary file not shown.
9 changes: 6 additions & 3 deletions www/toolbox/toolbox_arduino_all.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<toolbox>
<parametre id="defaultCategories1">CAT_ARDUINO,CAT_OTTO,CAT_ARDUINO_TIME,CAT_ARDUINO_IN,CAT_LOGIC,CAT_MATH</parametre>
<parametre id="defaultCategories2">CAT_ARDUINO,CAT_OTTO,CAT_ARDUINO_TIME,CAT_ARDUINO_IN,CAT_LOGIC,CAT_MATH,CAT_TEXT,CAT_FUNCTIONS,CAT_VARIABLES,CAT_SENSORS,CAT_actionneur,CAT_LED,CAT_Displays,CAT_com</parametre>
<parametre id="defaultCategories2">CAT_ARDUINO,CAT_OTTO,CAT_ARDUINO_TIME,CAT_ARDUINO_IN,CAT_LOGIC,CAT_MATH,CAT_TEXT,CAT_FUNCTIONS,CAT_VARIABLES,CAT_SENSORS,CAT_actionneur,CAT_LED,CAT_Displays,CAT_AUDIO,CAT_com</parametre>
<parametre id="defaultCategories3">CAT_ARDUINO,CAT_OTTO,CAT_ARDUINO_TIME,CAT_ARDUINO_IN,CAT_LOGIC,CAT_MATH,CAT_TEXT,CAT_FUNCTIONS,CAT_VARIABLES,CAT_TAB,CAT_SENSORS,CAT_actionneur,CAT_LED,CAT_Displays,CAT_AUDIO,CAT_com,CAT_KEYBOARD,CAT_MUVISION</parametre>


Expand Down Expand Up @@ -364,10 +364,13 @@
<block type="servo_read_degrees">
<value name="PIN"><shadow type="math_number"> <field name="NUM">2</field></shadow></value>
</block>
<block type="servo_attached">
<block type="servo_detach">
<value name="PIN"><shadow type="math_number"> <field name="NUM">2</field></shadow></value>
</block>
<block type="servo_attach">
<value name="PIN"><shadow type="math_number"> <field name="NUM">2</field></shadow></value>
</block>
<block type="servo_detach">
<block type="servo_attached">
<value name="PIN"><shadow type="math_number"> <field name="NUM">2</field></shadow></value>
</block>
<block type="servo_PWM">
Expand Down

0 comments on commit 732bdf8

Please sign in to comment.