Skip to content

Commit 5628f30

Browse files
committed
merge feature/atmega
1 parent c5fe1b3 commit 5628f30

File tree

4 files changed

+112
-1
lines changed

4 files changed

+112
-1
lines changed

src/assets/toolbox_adv.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@
321321
</block>
322322
<block type="coderbot_audio_listen"></block>
323323
</category>
324+
<category name="Estensioni I/O" colour="240">
325+
<block type="coderbot_atmega_get_input"></block>
326+
<block type="coderbot_atmega_set_output"></block>
327+
</category>
324328
<category name="Music" colour="345">
325329
<block type="coderbot_music_note_adv"></block>
326330
<block type="coderbot_music_instrument_adv"></block>

src/components/Activity.vue

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,6 +2089,74 @@ export default {
20892089
var code = 'get_bot().get_mpu_temp()';
20902090
return [code, Blockly.Python.ORDER_ATOMIC];
20912091
};
2092+
2093+
Blockly.Blocks['coderbot_atmega_get_input'] = {
2094+
/**
2095+
* Block for get_input function.
2096+
* @this Blockly.Block
2097+
*/
2098+
init: function() {
2099+
this.setHelpUrl(Blockly.Msg.LOGIC_BOOLEAN_HELPURL);
2100+
this.setColour(240);
2101+
this.appendDummyInput()
2102+
.appendField(Blockly.Msg.CODERBOT_ATMEGA_READ)
2103+
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.CODERBOT_ATMEGA_AI_1, "0"],
2104+
[Blockly.Msg.CODERBOT_ATMEGA_AI_2, "1"],
2105+
[Blockly.Msg.CODERBOT_ATMEGA_DI_3, "2"],
2106+
[Blockly.Msg.CODERBOT_ATMEGA_DI_4, "3"],
2107+
[Blockly.Msg.CODERBOT_ATMEGA_DI_5, "4"],
2108+
[Blockly.Msg.CODERBOT_ATMEGA_DI_6, "5"],]), 'INPUT');
2109+
this.setOutput(true, 'Number');
2110+
this.setTooltip(Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP);
2111+
}
2112+
};
2113+
2114+
Blockly.Python['coderbot_atmega_get_input'] = function(block) {
2115+
// input index: 0, 1 are Analogs, 2..5 are Digital
2116+
var input = block.getFieldValue('INPUT');
2117+
var code = 'get_atmega().get_input(' + input + ')';
2118+
return [code, Blockly.Python.ORDER_ATOMIC];
2119+
};
2120+
2121+
Blockly.Blocks['coderbot_atmega_set_output'] = {
2122+
/**
2123+
* Block for set_output function.
2124+
* @this Blockly.Block
2125+
*/
2126+
init: function() {
2127+
this.setHelpUrl(Blockly.Msg.LOGIC_BOOLEAN_HELPURL);
2128+
this.setColour(240);
2129+
this.appendDummyInput()
2130+
.appendField(Blockly.Msg.CODERBOT_ATMEGA_WRITE)
2131+
.appendField(new Blockly.FieldDropdown([[Blockly.Msg.CODERBOT_ATMEGA_DO_1, "0"],
2132+
[Blockly.Msg.CODERBOT_ATMEGA_DO_2, "1"],
2133+
[Blockly.Msg.CODERBOT_ATMEGA_DO_3, "2"],
2134+
[Blockly.Msg.CODERBOT_ATMEGA_DO_4, "3"],
2135+
[Blockly.Msg.CODERBOT_ATMEGA_DO_5, "4"],
2136+
[Blockly.Msg.CODERBOT_ATMEGA_DO_6, "5"],
2137+
[Blockly.Msg.CODERBOT_ATMEGA_DO_7, "6"],
2138+
[Blockly.Msg.CODERBOT_ATMEGA_DO_8, "7"],
2139+
[Blockly.Msg.CODERBOT_ATMEGA_DO_9, "8"],
2140+
[Blockly.Msg.CODERBOT_ATMEGA_DO_10, "9"],
2141+
[Blockly.Msg.CODERBOT_ATMEGA_DO_11, "10"],]), 'OUTPUT');
2142+
this.appendValueInput('VALUE')
2143+
.setCheck('Boolean')
2144+
.appendField(Blockly.Msg.CODERBOT_ATMEGA_VALUE);
2145+
this.setInputsInline(true);
2146+
this.setPreviousStatement(true);
2147+
this.setNextStatement(true);
2148+
this.setTooltip(Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP);
2149+
}
2150+
};
2151+
2152+
Blockly.Python['coderbot_atmega_set_output'] = function(block) {
2153+
// input index: 0, 10 are Digital
2154+
var output = block.getFieldValue('OUTPUT');
2155+
var value = Blockly.Python.valueToCode(block, 'VALUE',
2156+
Blockly.Python.ORDER_NONE) || '\'\'';
2157+
var code = 'get_atmega().set_output(' + output + ', ' + value + ')\n';
2158+
return code;
2159+
};
20922160
},
20932161
20942162
toggleSidebar() {

static/js/blockly/bot_en.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,23 @@ Blockly.Msg.CODERBOT_EVENT_PUBLISH = "publish";
9292
Blockly.Msg.CODERBOT_EVENT_ON_TOPIC = "on topic";
9393
Blockly.Msg.CODERBOT_EVENT_GENERATOR = "event generator";
9494
Blockly.Msg.CODERBOT_CONVERSATION_PARSE = "parse";
95-
95+
Blockly.Msg.CODERBOT_ATMEGA_READ = "Read";
96+
Blockly.Msg.CODERBOT_ATMEGA_VALUE = "Value";
97+
Blockly.Msg.CODERBOT_ATMEGA_AI_1 = "Analog Input 1";
98+
Blockly.Msg.CODERBOT_ATMEGA_AI_2 = "Analog Input 2";
99+
Blockly.Msg.CODERBOT_ATMEGA_DI_3 = "Digital Input 1";
100+
Blockly.Msg.CODERBOT_ATMEGA_DI_4 = "Digital Input 2";
101+
Blockly.Msg.CODERBOT_ATMEGA_DI_5 = "Digital Input3";
102+
Blockly.Msg.CODERBOT_ATMEGA_DI_6 = "Digital Input 4";
103+
Blockly.Msg.CODERBOT_ATMEGA_WRITE = "Write";
104+
Blockly.Msg.CODERBOT_ATMEGA_DO_1 = "Digital Output 1";
105+
Blockly.Msg.CODERBOT_ATMEGA_DO_2 = "Digital Output 2";
106+
Blockly.Msg.CODERBOT_ATMEGA_DO_3 = "Digital Output 3";
107+
Blockly.Msg.CODERBOT_ATMEGA_DO_4 = "Digital Output 4";
108+
Blockly.Msg.CODERBOT_ATMEGA_DO_5 = "Digital Output 5";
109+
Blockly.Msg.CODERBOT_ATMEGA_DO_6 = "Digital Output 6";
110+
Blockly.Msg.CODERBOT_ATMEGA_DO_7 = "Digital Output 7";
111+
Blockly.Msg.CODERBOT_ATMEGA_DO_8 = "Digital Output 8";
112+
Blockly.Msg.CODERBOT_ATMEGA_DO_9 = "Digital Output 9";
113+
Blockly.Msg.CODERBOT_ATMEGA_DO_10 = "Digital Output 10";
114+
Blockly.Msg.CODERBOT_ATMEGA_DO_11 = "Digital Output 11";

static/js/blockly/bot_it.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,23 @@ Blockly.Msg.CODERBOT_EVENT_PUBLISH = "pubblica";
9292
Blockly.Msg.CODERBOT_EVENT_ON_TOPIC = "sul topic";
9393
Blockly.Msg.CODERBOT_EVENT_GENERATOR = "genera eventi";
9494
Blockly.Msg.CODERBOT_CONVERSATION_PARSE = "interpreta";
95+
Blockly.Msg.CODERBOT_ATMEGA_READ = "Leggi";
96+
Blockly.Msg.CODERBOT_ATMEGA_VALUE = "Valore";
97+
Blockly.Msg.CODERBOT_ATMEGA_AI_1 = "Analog Input 1";
98+
Blockly.Msg.CODERBOT_ATMEGA_AI_2 = "Analog Input 2";
99+
Blockly.Msg.CODERBOT_ATMEGA_DI_3 = "Digital Input 1";
100+
Blockly.Msg.CODERBOT_ATMEGA_DI_4 = "Digital Input 2";
101+
Blockly.Msg.CODERBOT_ATMEGA_DI_5 = "Digital Input3";
102+
Blockly.Msg.CODERBOT_ATMEGA_DI_6 = "Digital Input 4";
103+
Blockly.Msg.CODERBOT_ATMEGA_WRITE = "Scrivi";
104+
Blockly.Msg.CODERBOT_ATMEGA_DO_1 = "Digital Output 1";
105+
Blockly.Msg.CODERBOT_ATMEGA_DO_2 = "Digital Output 2";
106+
Blockly.Msg.CODERBOT_ATMEGA_DO_3 = "Digital Output 3";
107+
Blockly.Msg.CODERBOT_ATMEGA_DO_4 = "Digital Output 4";
108+
Blockly.Msg.CODERBOT_ATMEGA_DO_5 = "Digital Output 5";
109+
Blockly.Msg.CODERBOT_ATMEGA_DO_6 = "Digital Output 6";
110+
Blockly.Msg.CODERBOT_ATMEGA_DO_7 = "Digital Output 7";
111+
Blockly.Msg.CODERBOT_ATMEGA_DO_8 = "Digital Output 8";
112+
Blockly.Msg.CODERBOT_ATMEGA_DO_9 = "Digital Output 9";
113+
Blockly.Msg.CODERBOT_ATMEGA_DO_10 = "Digital Output 10";
114+
Blockly.Msg.CODERBOT_ATMEGA_DO_11 = "Digital Output 11";

0 commit comments

Comments
 (0)