@@ -36,16 +36,16 @@ Blockly.Arduino.otto_init = function() {
36
36
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
37
37
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
38
38
39
- Blockly . Arduino . definitions_ [ 'define_define_otto_ascii' ] = '/*\n --------------- \n | O O |\n |---------------|\n YR ==> | | <== YL \n --------------- \n || ||\n || ||\n RR ==> ----- ----- <== RL \n |----- -----|\n*/\n' ;
39
+ Blockly . Arduino . definitions_ [ 'define_define_otto_ascii' ] = '/*\n --------------- \n | O O |\n |---------------|\n RIGHT LEG ==> | | <== LEFT LEG \n --------------- \n || ||\n || ||\n RIGHT FOOT ==> ----- ----- <== LEFT FOOT \n |----- -----|\n*/\n' ;
40
40
41
- Blockly . Arduino . definitions_ [ 'define_define_otto_init_yl' ] = '#define OTTO_PIN_YL ' + dropdown_yl ;
42
- Blockly . Arduino . definitions_ [ 'define_define_otto_init_yr' ] = '#define OTTO_PIN_YR ' + dropdown_yr ;
43
- Blockly . Arduino . definitions_ [ 'define_define_otto_init_rl' ] = '#define OTTO_PIN_RL ' + dropdown_rl ;
44
- Blockly . Arduino . definitions_ [ 'define_define_otto_init_rr' ] = '#define OTTO_PIN_RR ' + dropdown_rr ;
41
+ Blockly . Arduino . definitions_ [ 'define_define_otto_init_yl' ] = '#define OTTO_PIN_LEFT_LEG ' + dropdown_yl ;
42
+ Blockly . Arduino . definitions_ [ 'define_define_otto_init_yr' ] = '#define OTTO_PIN_RIGHT_LEG ' + dropdown_yr ;
43
+ Blockly . Arduino . definitions_ [ 'define_define_otto_init_rl' ] = '#define OTTO_PIN_LEFT_FOOT ' + dropdown_rl ;
44
+ Blockly . Arduino . definitions_ [ 'define_define_otto_init_rr' ] = '#define OTTO_PIN_RIGHT_FOOT ' + dropdown_rr ;
45
45
46
- Blockly . Arduino . setups_ [ 'setup_otto_init' ] = '__otto.initLegs(OTTO_PIN_YL, OTTO_PIN_YR, OTTO_PIN_RL, OTTO_PIN_RR , false);' ;
46
+ Blockly . Arduino . setups_ [ 'setup_otto_init' ] = '__otto.initLegs(OTTO_PIN_LEFT_LEG, OTTO_PIN_RIGHT_LEG, OTTO_PIN_LEFT_FOOT, OTTO_PIN_RIGHT_FOOT , false);' ;
47
47
48
- var code = ''
48
+ var code = '' ;
49
49
return code ;
50
50
} ;
51
51
@@ -59,14 +59,18 @@ Blockly.Arduino.otto_calibrate = function(){
59
59
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
60
60
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
61
61
62
- Blockly . Arduino . definitions_ [ 'define_define_otto_trim_yl' ] = '#define OTTO_TRIM_YL ' + yl ;
63
- Blockly . Arduino . definitions_ [ 'define_define_otto_trim_yr' ] = '#define OTTO_TRIM_YR ' + yr ;
64
- Blockly . Arduino . definitions_ [ 'define_define_otto_trim_rl' ] = '#define OTTO_TRIM_RL ' + rl ;
65
- Blockly . Arduino . definitions_ [ 'define_define_otto_trim_rr' ] = '#define OTTO_TRIM_RR ' + rr ;
62
+ Blockly . Arduino . definitions_ [ 'define_define_otto_trim_yl' ] = '#define OTTO_TRIM_LEFT_LEG ' + yl ;
63
+ Blockly . Arduino . definitions_ [ 'define_define_otto_trim_yr' ] = '#define OTTO_TRIM_RIGHT_LEG ' + yr ;
64
+ Blockly . Arduino . definitions_ [ 'define_define_otto_trim_rl' ] = '#define OTTO_TRIM_LEFT_FOOT ' + rl ;
65
+ Blockly . Arduino . definitions_ [ 'define_define_otto_trim_rr' ] = '#define OTTO_TRIM_RIGHT_FOOT ' + rr ;
66
66
67
- Blockly . Arduino . setups_ [ 'setup_otto_trim' ] = '__otto.setTrims(OTTO_TRIM_YL, OTTO_TRIM_YR, OTTO_TRIM_RL, OTTO_TRIM_RR);' ;
67
+ if ( 'setup_otto_init' in Blockly . Arduino . setups_ ) {
68
+ Blockly . Arduino . setups_ [ 'setup_otto_init' ] = '__otto.initLegs(OTTO_PIN_LEFT_LEG, OTTO_PIN_RIGHT_LEG, OTTO_PIN_LEFT_FOOT, OTTO_PIN_RIGHT_FOOT, true);' ;
69
+ }
68
70
69
- var code = ''
71
+ Blockly . Arduino . setups_ [ 'setup_otto_trim' ] = '__otto.setTrims(OTTO_TRIM_LEFT_LEG, OTTO_TRIM_RIGHT_LEG, OTTO_TRIM_LEFT_FOOT, OTTO_TRIM_RIGHT_FOOT);' ;
72
+
73
+ var code = '' ;
70
74
return code ;
71
75
} ;
72
76
@@ -75,7 +79,7 @@ Blockly.Arduino.otto_home = function(){
75
79
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
76
80
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
77
81
78
- var code = '__otto.home();\n'
82
+ var code = '__otto.home();\n' ;
79
83
return code ;
80
84
} ;
81
85
@@ -88,7 +92,7 @@ Blockly.Arduino.otto_walk = function(){
88
92
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
89
93
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
90
94
91
- var code = '__otto.walk(' + distance + ', ' + duration + ', ' + dropdown_direction + ');\n'
95
+ var code = '__otto.walk(' + distance + ', ' + duration + ', ' + dropdown_direction + ');\n' ;
92
96
return code ;
93
97
} ;
94
98
@@ -101,7 +105,7 @@ Blockly.Arduino.otto_turn = function(){
101
105
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
102
106
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
103
107
104
- var code = '__otto.turn(' + distance + ', ' + duration + ', ' + dropdown_direction + ');\n'
108
+ var code = '__otto.turn(' + distance + ', ' + duration + ', ' + dropdown_direction + ');\n' ;
105
109
return code ;
106
110
} ;
107
111
@@ -114,7 +118,7 @@ Blockly.Arduino.otto_bend = function(){
114
118
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
115
119
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
116
120
117
- var code = '__otto.bend(' + distance + ', ' + duration + ', ' + dropdown_direction + ');\n'
121
+ var code = '__otto.bend(' + distance + ', ' + duration + ', ' + dropdown_direction + ');\n' ;
118
122
return code ;
119
123
} ;
120
124
@@ -127,7 +131,7 @@ Blockly.Arduino.otto_shake_leg = function(){
127
131
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
128
132
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
129
133
130
- var code = '__otto.shakeLeg(' + distance + ', ' + duration + ', ' + dropdown_direction + ');\n'
134
+ var code = '__otto.shakeLeg(' + distance + ', ' + duration + ', ' + dropdown_direction + ');\n' ;
131
135
return code ;
132
136
} ;
133
137
@@ -141,7 +145,7 @@ Blockly.Arduino.otto_freestyle = function(){
141
145
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
142
146
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
143
147
144
- var code = '__otto.' + dropdown_style + '(' + distance + ', ' + duration + ', ' + height + ');\n'
148
+ var code = '__otto.' + dropdown_style + '(' + distance + ', ' + duration + ', ' + height + ');\n' ;
145
149
return code ;
146
150
} ;
147
151
@@ -155,7 +159,7 @@ Blockly.Arduino.otto_moonwalk = function(){
155
159
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
156
160
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
157
161
158
- var code = '__otto.moonwalker(' + distance + ', ' + duration + ', ' + height + ', ' + dropdown_direction + ');\n'
162
+ var code = '__otto.moonwalker(' + distance + ', ' + duration + ', ' + height + ', ' + dropdown_direction + ');\n' ;
159
163
return code ;
160
164
} ;
161
165
@@ -169,7 +173,7 @@ Blockly.Arduino.otto_crusaito = function(){
169
173
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
170
174
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
171
175
172
- var code = '__otto.crusaito(' + distance + ', ' + duration + ', ' + height + ', ' + dropdown_direction + ');\n'
176
+ var code = '__otto.crusaito(' + distance + ', ' + duration + ', ' + height + ', ' + dropdown_direction + ');\n' ;
173
177
return code ;
174
178
} ;
175
179
@@ -183,7 +187,7 @@ Blockly.Arduino.otto_flapping = function(){
183
187
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
184
188
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
185
189
186
- var code = '__otto.flapping(' + distance + ', ' + duration + ', ' + height + ', ' + dropdown_direction + ');\n'
190
+ var code = '__otto.flapping(' + distance + ', ' + duration + ', ' + height + ', ' + dropdown_direction + ');\n' ;
187
191
return code ;
188
192
} ;
189
193
@@ -201,12 +205,12 @@ Blockly.Arduino.otto_ultrasonic_init = function() {
201
205
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
202
206
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
203
207
204
- Blockly . Arduino . definitions_ [ 'define_define_otto_ultrasonic_init_trigger' ] = '#define OTTO_PIN_TRIGGER ' + dropdown_trigger ;
205
- Blockly . Arduino . definitions_ [ 'define_define_otto_ultrasonic_init_echo' ] = '#define OTTO_PIN_ECHO ' + dropdown_echo ;
208
+ Blockly . Arduino . definitions_ [ 'define_define_otto_ultrasonic_init_trigger' ] = '#define OTTO_PIN_ULTRASONIC_TRIGGER ' + dropdown_trigger ;
209
+ Blockly . Arduino . definitions_ [ 'define_define_otto_ultrasonic_init_echo' ] = '#define OTTO_PIN_ULTRASONIC_ECHO ' + dropdown_echo ;
206
210
207
- Blockly . Arduino . setups_ [ 'setup_otto_ultrasonic_init' ] = '__otto.initUltrasonic(OTTO_PIN_TRIGGER, OTTO_PIN_ECHO );' ;
211
+ Blockly . Arduino . setups_ [ 'setup_otto_ultrasonic_init' ] = '__otto.initUltrasonic(OTTO_PIN_ULTRASONIC_TRIGGER, OTTO_PIN_ULTRASONIC_ECHO );' ;
208
212
209
- var code = ''
213
+ var code = '' ;
210
214
return code ;
211
215
} ;
212
216
@@ -215,7 +219,7 @@ Blockly.Arduino.otto_ultrasonic_distance = function() {
215
219
Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
216
220
Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
217
221
218
- var code = '__otto.getDistance()'
222
+ var code = '__otto.getDistance()' ;
219
223
return [ code , Blockly . Arduino . ORDER_ATOMIC ] ;
220
224
} ;
221
225
@@ -230,7 +234,7 @@ Blockly.Arduino.otto_buzzer_init = function() {
230
234
231
235
Blockly . Arduino . setups_ [ 'setup_otto_buzzer_init' ] = '__otto.initBuzzer(OTTO_PIN_BUZZER);' ;
232
236
233
- var code = ''
237
+ var code = '' ;
234
238
return code ;
235
239
} ;
236
240
@@ -244,3 +248,34 @@ Blockly.Arduino.otto_buzzer_sing = function() {
244
248
var code = '__otto.sing(' + dropdown_sing + ');\n' ;
245
249
return code ;
246
250
} ;
251
+
252
+ Blockly . Arduino . otto_mouth = function ( ) {
253
+
254
+ var dropdown_mouth = this . getFieldValue ( 'MOUTH' ) ;
255
+
256
+ Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
257
+ Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
258
+
259
+ var code = '__otto.putMouth(' + dropdown_mouth + ');\n' ;
260
+ return code ;
261
+ } ;
262
+
263
+ Blockly . Arduino . otto_led_matrix_init = function ( ) {
264
+
265
+ var dropdown_din = this . getFieldValue ( 'DIN' ) ;
266
+ var dropdown_cs = this . getFieldValue ( 'CS' ) ;
267
+ var dropdown_clk = this . getFieldValue ( 'CLK' ) ;
268
+ var dropdown_dir = this . getFieldValue ( 'DIR' ) ;
269
+
270
+ Blockly . Arduino . definitions_ [ 'define_include_otto' ] = '#include <Otto.h>\n' ;
271
+ Blockly . Arduino . definitions_ [ 'define_define_otto_item' ] = 'Otto __otto;\n' ;
272
+
273
+ Blockly . Arduino . definitions_ [ 'define_define_otto_led_matrix_init_din' ] = '#define OTTO_PIN_LED_DIN ' + dropdown_din ;
274
+ Blockly . Arduino . definitions_ [ 'define_define_otto_led_matrix_init_din' ] = '#define OTTO_PIN_LED_CS_PIN ' + dropdown_cs ;
275
+ Blockly . Arduino . definitions_ [ 'define_define_otto_led_matrix_init_din' ] = '#define OTTO_PIN_LED_CLK_PIN ' + dropdown_clk ;
276
+
277
+ Blockly . Arduino . setups_ [ 'setup_otto_led_matrix_init' ] = '__otto.initLEDMatrix(OTTO_PIN_LED_DIN, OTTO_PIN_LED_CS_PIN, ' + dropdown_dir + ');' ;
278
+
279
+ var code = '' ;
280
+ return code ;
281
+ } ;
0 commit comments