@@ -7,162 +7,162 @@ export default function (Generator) {
7
7
Generator . microbitMore_whenButtonPressed = function ( block ) {
8
8
block . isStatement = true ;
9
9
const btn = Generator . valueToCode ( block , 'BTN' , Generator . ORDER_NONE ) || null ;
10
- return `${ Generator . spriteName ( ) } .when(:microbit_more_button_pressed , ${ btn } ) do\n` ;
10
+ return `${ Generator . spriteName ( ) } .when(:mbit_more_button_pressed , ${ btn } ) do\n` ;
11
11
} ;
12
12
13
13
Generator . microbitMore_isButtonPressed = function ( block ) {
14
14
const btn = Generator . valueToCode ( block , 'BTN' , Generator . ORDER_NONE ) || null ;
15
- return `microbit_more .button_pressed?(${ btn } )\n` ;
15
+ return `mbit_more .button_pressed?(${ btn } )\n` ;
16
16
} ;
17
17
18
18
Generator . microbitMore_whenGesture = function ( block ) {
19
19
block . isStatement = true ;
20
20
const gesture = Generator . valueToCode ( block , 'GESTURE' , Generator . ORDER_NONE ) || null ;
21
- return `${ Generator . spriteName ( ) } .when(:microbit_more_gesture , ${ gesture } ) do\n` ;
21
+ return `${ Generator . spriteName ( ) } .when(:mbit_more_gesture , ${ gesture } ) do\n` ;
22
22
} ;
23
23
24
24
Generator . microbitMore_displaySymbol = function ( block ) {
25
25
let matrix = Generator . valueToCode ( block , 'MATRIX' , Generator . ORDER_NONE ) || null ;
26
26
matrix = Generator . prefixLines ( matrix , Generator . INDENT ) ;
27
- return `microbit_more .display(\n${ matrix } \n)\n` ;
27
+ return `mbit_more .display(\n${ matrix } \n)\n` ;
28
28
} ;
29
29
30
30
Generator . microbitMore_displayText = function ( block ) {
31
31
const text = Generator . valueToCode ( block , 'TEXT' , Generator . ORDER_NONE ) || null ;
32
- return `microbit_more .display_text(${ text } )\n` ;
32
+ return `mbit_more .display_text(${ text } )\n` ;
33
33
} ;
34
34
35
35
Generator . microbitMore_displayClear = function ( ) {
36
- return `microbit_more .clear_display\n` ;
36
+ return `mbit_more .clear_display\n` ;
37
37
} ;
38
38
39
39
Generator . microbitMore_whenTilted = function ( block ) {
40
40
block . isStatement = true ;
41
41
const direction = Generator . valueToCode ( block , 'DIRECTION' , Generator . ORDER_NONE ) || null ;
42
- return `${ Generator . spriteName ( ) } .when(:microbit_more_tilted , ${ direction } ) do\n` ;
42
+ return `${ Generator . spriteName ( ) } .when(:mbit_more_tilted , ${ direction } ) do\n` ;
43
43
} ;
44
44
45
45
Generator . microbitMore_isTilted = function ( block ) {
46
46
const direction = Generator . valueToCode ( block , 'DIRECTION' , Generator . ORDER_NONE ) || null ;
47
- return [ `microbit_more .tilted?(${ direction } )` , Generator . ORDER_ATOMIC ] ;
47
+ return [ `mbit_more .tilted?(${ direction } )` , Generator . ORDER_ATOMIC ] ;
48
48
} ;
49
49
50
50
Generator . microbitMore_getTiltAngle = function ( block ) {
51
51
const direction = Generator . valueToCode ( block , 'DIRECTION' , Generator . ORDER_NONE ) || null ;
52
- return [ `microbit_more .tilt_angle(${ direction } )` , Generator . ORDER_ATOMIC ] ;
52
+ return [ `mbit_more .tilt_angle(${ direction } )` , Generator . ORDER_ATOMIC ] ;
53
53
} ;
54
54
55
55
Generator . microbitMore_whenPinConnected = function ( block ) {
56
56
block . isStatement = true ;
57
57
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
58
- return `${ Generator . spriteName ( ) } .when(:microbit_more_pin_connected , ${ pin } ) do\n` ;
58
+ return `${ Generator . spriteName ( ) } .when(:mbit_more_pin_connected , ${ pin } ) do\n` ;
59
59
} ;
60
60
61
61
Generator . microbitMore_isPinConnected = function ( block ) {
62
62
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
63
- return `microbit_more .pin_connected?(${ pin } )\n` ;
63
+ return `mbit_more .pin_connected?(${ pin } )\n` ;
64
64
} ;
65
65
66
66
Generator . microbitMore_getLightLevel = function ( ) {
67
- return `microbit_more .light_level\n` ;
67
+ return `mbit_more .light_level\n` ;
68
68
} ;
69
69
70
70
Generator . microbitMore_getTemperature = function ( ) {
71
- return `microbit_more .temperature\n` ;
71
+ return `mbit_more .temperature\n` ;
72
72
} ;
73
73
74
74
Generator . microbitMore_getCompassHeading = function ( ) {
75
- return `microbit_more .compass_heading\n` ;
75
+ return `mbit_more .compass_heading\n` ;
76
76
} ;
77
77
78
78
Generator . microbitMore_getPitch = function ( ) {
79
- return `microbit_more .pitch\n` ;
79
+ return `mbit_more .pitch\n` ;
80
80
} ;
81
81
82
82
Generator . microbitMore_getRoll = function ( ) {
83
- return `microbit_more .roll\n` ;
83
+ return `mbit_more .roll\n` ;
84
84
} ;
85
85
86
86
Generator . microbitMore_getMagneticForce = function ( block ) {
87
87
const axis = Generator . valueToCode ( block , 'AXIS' , Generator . ORDER_NONE ) || null ;
88
- return `microbit_more .get_magnetic_force(${ axis } )\n` ;
88
+ return `mbit_more .get_magnetic_force(${ axis } )\n` ;
89
89
} ;
90
90
91
91
Generator . microbitMore_getAcceleration = function ( block ) {
92
92
const axis = Generator . valueToCode ( block , 'AXIS' , Generator . ORDER_NONE ) || null ;
93
- return `microbit_more .get_acceleration(${ axis } )\n` ;
93
+ return `mbit_more .get_acceleration(${ axis } )\n` ;
94
94
} ;
95
95
96
96
Generator . microbitMore_getAnalogValue = function ( block ) {
97
97
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
98
- return `microbit_more .get_analog_value(${ pin } )\n` ;
98
+ return `mbit_more .get_analog_value(${ pin } )\n` ;
99
99
} ;
100
100
101
101
Generator . microbitMore_getDigitalValue = function ( block ) {
102
102
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
103
- return `microbit_more .get_digital_value(${ pin } )\n` ;
103
+ return `mbit_more .get_digital_value(${ pin } )\n` ;
104
104
} ;
105
105
106
106
Generator . microbitMore_setPinMode = function ( block ) {
107
107
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
108
- const mode = Generator . getFieldValue ( block , 'MODE' ) || null ;
109
- return `microbit_more .set_pin_mode(${ pin } , ${ mode } )\n` ;
108
+ const mode = Generator . quote_ ( Generator . getFieldValue ( block , 'MODE' ) ) || null ;
109
+ return `mbit_more .set_pin_mode(${ pin } , ${ mode } )\n` ;
110
110
} ;
111
111
112
112
Generator . microbitMore_setOutput = function ( block ) {
113
113
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
114
114
const level = Generator . valueToCode ( block , 'LEVEL' , Generator . ORDER_NONE ) || null ;
115
- return `microbit_more .set_output(${ pin } , ${ level } )\n` ;
115
+ return `mbit_more .set_output(${ pin } , ${ level } )\n` ;
116
116
} ;
117
117
118
118
Generator . microbitMore_setPWM = function ( block ) {
119
119
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
120
120
const level = Generator . valueToCode ( block , 'LEVEL' , Generator . ORDER_NONE ) || null ;
121
- return `microbit_more .set_pwm(${ pin } , ${ level } )\n` ;
121
+ return `mbit_more .set_pwm(${ pin } , ${ level } )\n` ;
122
122
} ;
123
123
124
124
Generator . microbitMore_setServo = function ( block ) {
125
125
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
126
126
const angle = Generator . valueToCode ( block , 'ANGLE' , Generator . ORDER_NONE ) || null ;
127
127
const range = Generator . valueToCode ( block , 'RANGE' , Generator . ORDER_NONE ) || 2000 ;
128
128
const center = Generator . valueToCode ( block , 'CENTER' , Generator . ORDER_NONE ) || 1500 ;
129
- return `microbit_more .set_servo(${ pin } , ${ angle } , ${ range } , ${ center } )\n` ;
129
+ return `mbit_more .set_servo(${ pin } , ${ angle } , ${ range } , ${ center } )\n` ;
130
130
} ;
131
131
132
132
Generator . microbitMore_setPinEventType = function ( block ) {
133
133
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
134
134
const eventType = Generator . getFieldValue ( block , 'EVENT_TYPE' ) || null ;
135
- return `microbit_more .set_pin_event_type(${ pin } , ${ eventType } )\n` ;
135
+ return `mbit_more .set_pin_event_type(${ pin } , ${ eventType } )\n` ;
136
136
} ;
137
137
138
138
Generator . microbitMore_whenPinEvent = function ( block ) {
139
139
block . isStatement = true ;
140
140
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
141
141
const event = Generator . getFieldValue ( block , 'EVENT' ) || null ;
142
- return `${ Generator . spriteName ( ) } .when(:microbit_more_pin_event , ${ pin } , ${ event } ) do\n` ;
142
+ return `${ Generator . spriteName ( ) } .when(:mbit_more_pin_event , ${ pin } , ${ event } ) do\n` ;
143
143
} ;
144
144
145
145
Generator . microbitMore_getPinEventTimestamp = function ( block ) {
146
146
const pin = Generator . valueToCode ( block , 'PIN' , Generator . ORDER_NONE ) || null ;
147
147
const event = Generator . getFieldValue ( block , 'EVENT' ) || null ;
148
- return `microbit_more .get_pin_event_timestamp(${ pin } , ${ event } )\n` ;
148
+ return `mbit_more .get_pin_event_timestamp(${ pin } , ${ event } )\n` ;
149
149
} ;
150
150
151
151
Generator . microbitMore_getSharedData = function ( block ) {
152
152
const index = Generator . valueToCode ( block , 'INDEX' , Generator . ORDER_NONE ) || null ;
153
- return `microbit_more .get_shared_data(${ index } )\n` ;
153
+ return `mbit_more .get_shared_data(${ index } )\n` ;
154
154
} ;
155
155
156
156
Generator . microbitMore_setSharedData = function ( block ) {
157
157
const index = Generator . valueToCode ( block , 'INDEX' , Generator . ORDER_NONE ) || null ;
158
158
const value = Generator . valueToCode ( block , 'VALUE' , Generator . ORDER_NONE ) || null ;
159
- return `microbit_more.get_shared_data (${ index } , ${ value } )\n` ;
159
+ return `mbit_more.set_shared_data (${ index } , ${ value } )\n` ;
160
160
} ;
161
161
162
162
Generator . microbitMore_whenConnectionChanged = function ( block ) {
163
163
block . isStatement = true ;
164
164
const state = Generator . getFieldValue ( block , 'STATE' ) || null ;
165
- return `${ Generator . spriteName ( ) } .when(:microbit_more_connection_changed , ${ state } ) do\n` ;
165
+ return `${ Generator . spriteName ( ) } .when(:mbit_more_connection_changed , ${ state } ) do\n` ;
166
166
} ;
167
167
168
168
Generator . microbitMore_menu_buttons = function ( block ) {
@@ -186,12 +186,12 @@ export default function (Generator) {
186
186
} ;
187
187
188
188
Generator . microbitMore_menu_touchPins = function ( block ) {
189
- const touchPins = Generator . quote_ ( Generator . getFieldValue ( block , 'touchPins' ) || '0' ) ;
189
+ const touchPins = Generator . getFieldValue ( block , 'touchPins' ) || 0 ;
190
190
return [ touchPins , Generator . ORDER_ATOMIC ] ;
191
191
} ;
192
192
193
193
Generator . microbitMore_menu_gpio = function ( block ) {
194
- const gpio = Generator . quote_ ( Generator . getFieldValue ( block , 'gpio' ) || '0' ) ;
194
+ const gpio = Generator . getFieldValue ( block , 'gpio' ) || 0 ;
195
195
return [ gpio , Generator . ORDER_ATOMIC ] ;
196
196
} ;
197
197
@@ -201,7 +201,7 @@ export default function (Generator) {
201
201
} ;
202
202
203
203
Generator . microbitMore_menu_analogIn = function ( block ) {
204
- const analogIn = Generator . quote_ ( Generator . getFieldValue ( block , 'analogIn' ) || '0' ) ;
204
+ const analogIn = Generator . getFieldValue ( block , 'analogIn' ) || 0 ;
205
205
return [ analogIn , Generator . ORDER_ATOMIC ] ;
206
206
} ;
207
207
@@ -211,12 +211,12 @@ export default function (Generator) {
211
211
} ;
212
212
213
213
Generator . microbitMore_menu_digitalValue = function ( block ) {
214
- const digitalValue = Generator . quote_ ( Generator . getFieldValue ( block , 'digitalValue' ) || '0' ) ;
214
+ const digitalValue = Generator . getFieldValue ( block , 'digitalValue' ) || 0 ;
215
215
return [ digitalValue , Generator . ORDER_ATOMIC ] ;
216
216
} ;
217
217
218
218
Generator . microbitMore_menu_pinEventTypeMenu = function ( block ) {
219
- const pinEventTypeMenu = Generator . quote_ ( Generator . getFieldValue ( block , 'pinEventTypeMenu' ) || 0 ) ;
219
+ const pinEventTypeMenu = Generator . getFieldValue ( block , 'pinEventTypeMenu' ) || 0 ;
220
220
return [ pinEventTypeMenu , Generator . ORDER_ATOMIC ] ;
221
221
} ;
222
222
@@ -226,12 +226,12 @@ export default function (Generator) {
226
226
} ;
227
227
228
228
Generator . microbitMore_menu_sharedDataIndex = function ( block ) {
229
- const sharedDataIndex = Generator . getFieldValue ( block , 'sharedDataIndex' ) || 'absolute' ;
229
+ const sharedDataIndex = Generator . quote_ ( Generator . getFieldValue ( block , 'sharedDataIndex' ) || 'absolute' ) ;
230
230
return [ sharedDataIndex , Generator . ORDER_ATOMIC ] ;
231
231
} ;
232
232
233
233
Generator . microbitMore_menu_connectionStateMenu = function ( block ) {
234
- const connectionStateMenu = Generator . getFieldValue ( block , 'connectionStateMenu' ) || 'connected' ;
234
+ const connectionStateMenu = Generator . quote_ ( Generator . getFieldValue ( block , 'connectionStateMenu' ) || 'connected' ) ;
235
235
return [ connectionStateMenu , Generator . ORDER_ATOMIC ] ;
236
236
} ;
237
237
0 commit comments