Skip to content

Commit 16010ef

Browse files
committed
Add some functions about shared data in microbit_more
1 parent c65019a commit 16010ef

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/lib/ruby-generator/microbit_more.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,22 @@ export default function (Generator) {
143143
};
144144

145145
Generator.microbitMore_getPinEventTimestamp = function (block) {
146-
block.isStatement = true;
147146
const pin = Generator.valueToCode(block, 'PIN', Generator.ORDER_NONE) || null;
148147
const event = Generator.getFieldValue(block, 'EVENT') || null;
149148
return `microbit_more.get_pin_event_timestamp(${pin}, ${event})\n`;
150149
};
151150

151+
Generator.microbitMore_getSharedData = function (block) {
152+
const index = Generator.valueToCode(block, 'INDEX', Generator.ORDER_NONE) || null;
153+
return `microbit_more.get_shared_data(${index})\n`;
154+
};
155+
156+
Generator.microbitMore_setSharedData = function (block) {
157+
const index = Generator.valueToCode(block, 'INDEX', Generator.ORDER_NONE) || null;
158+
const value = Generator.valueToCode(block, 'VALUE', Generator.ORDER_NONE) || null;
159+
return `microbit_more.get_shared_data(${index}, ${value})\n`;
160+
};
161+
152162
Generator.microbitMore_menu_buttons = function (block) {
153163
const buttons = Generator.quote_(Generator.getFieldValue(block, 'buttons') || 'A');
154164
return [buttons, Generator.ORDER_ATOMIC];
@@ -209,6 +219,16 @@ export default function (Generator) {
209219
return [pinEventTimestampMenu, Generator.ORDER_ATOMIC];
210220
};
211221

222+
Generator.microbitMore_menu_sharedDataIndex = function (block) {
223+
const sharedDataIndex = Generator.getFieldValue(block, 'sharedDataIndex') || 'absolute';
224+
return [sharedDataIndex, Generator.ORDER_ATOMIC];
225+
};
226+
227+
Generator.microbitMore_menu_axis = function (block) {
228+
const axis = Generator.getFieldValue(block, 'axis') || '0';
229+
return [axis, Generator.ORDER_ATOMIC];
230+
};
231+
212232
Generator.matrix = function (block) {
213233
let matrix = Generator.getFieldValue(block, 'MATRIX') || '0000000000000000000000000';
214234
matrix = matrix.replace(/0/g, '.');

0 commit comments

Comments
 (0)