diff --git a/boards/default_src/micropython/blocks/display_onboard.js b/boards/default_src/micropython/blocks/display_onboard.js index 889927a3..732ea087 100644 --- a/boards/default_src/micropython/blocks/display_onboard.js +++ b/boards/default_src/micropython/blocks/display_onboard.js @@ -10,9 +10,9 @@ export const display_show_image = { .setCheck([String, "esp32_image", "List", 'Tuple']) .appendField(Blockly.Msg.MIXLY_ESP32_SHOW_IMAGE_OR_STRING); var version = Boards.getSelectedBoardKey() - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize); + .appendField(Blockly.Msg.MIXLY_synchronize); } this.setPreviousStatement(true, null); this.setNextStatement(true, null); @@ -38,9 +38,9 @@ export const display_show_image_or_string_delay = { [Blockly.Msg.MICROPYTHON_DISPLAY_YES, "True"], [Blockly.Msg.MICROPYTHON_DISPLAY_NO, "False"] ]), 'center') - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize); + .appendField(Blockly.Msg.MIXLY_synchronize); } this.setPreviousStatement(true, null); this.setNextStatement(true, null); @@ -97,11 +97,11 @@ export const display_scroll_way = { this.appendDummyInput() .appendField(Blockly.Msg.MIXLY_SETTING + Blockly.Msg.MIXLY_DISPLAY_SCROLL_WAY) .appendField(new Blockly.FieldDropdown([ - [Blockly.Msg.MIXLY_GAME_UP,"0"], - [Blockly.Msg.MIXLY_GAME_DOWN,"1"], - [Blockly.Msg.MIXLY_GAME_RIGHT,"2"], - [Blockly.Msg.MIXLY_GAME_LEFT,"3"] - ]),"way");; + [Blockly.Msg.MIXLY_GAME_UP, "0"], + [Blockly.Msg.MIXLY_GAME_DOWN, "1"], + [Blockly.Msg.MIXLY_GAME_RIGHT, "2"], + [Blockly.Msg.MIXLY_GAME_LEFT, "3"] + ]), "way"); this.setPreviousStatement(true, null); this.setNextStatement(true, null); this.setInputsInline(true); @@ -301,10 +301,9 @@ export const display_shift = { .setCheck(Number); this.appendDummyInput('') .appendField(Blockly.Msg.DISPLAY_IMAGE_UNIT) - var version = Boards.getSelectedBoardKey() - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize); + .appendField(Blockly.Msg.MIXLY_synchronize); } var thisBlock = this; this.setTooltip(function () { @@ -394,10 +393,9 @@ export const display_clear = { this.setColour(DISPLAY_ONBOARD_HUE); this.appendDummyInput() .appendField(Blockly.Msg.MIXLY_MICROBIT_Clear_display); - var version = Boards.getSelectedBoardKey() - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize); + .appendField(Blockly.Msg.MIXLY_synchronize); } this.setPreviousStatement(true, null); this.setNextStatement(true, null); @@ -1114,10 +1112,9 @@ export const onboard_tft_show_image_xy = { .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_NUMBER); this.appendValueInput('VAR') .appendField(Blockly.Msg.HTML_COLOUR); - var version = Boards.getSelectedBoardKey() - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize ); + .appendField(Blockly.Msg.MIXLY_synchronize); } this.setPreviousStatement(true, null); this.setNextStatement(true, null); @@ -1169,10 +1166,9 @@ export const onboard_tft_show_image_or_string_delay = { ]), 'center') this.appendValueInput('VAR') .appendField(Blockly.Msg.HTML_COLOUR); - var version = Boards.getSelectedBoardKey() - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize); + .appendField(Blockly.Msg.MIXLY_synchronize); } this.setPreviousStatement(true, null); this.setNextStatement(true, null); @@ -1385,10 +1381,9 @@ export const onboard_tft_bright_point = { .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_MONITOR_PLOT_POINT_Y); this.appendValueInput('VAR') .appendField(Blockly.Msg.HTML_COLOUR); - var version = Boards.getSelectedBoardKey() - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize); + .appendField(Blockly.Msg.MIXLY_synchronize); } this.setPreviousStatement(true, null); this.setNextStatement(true, null); @@ -1402,10 +1397,9 @@ export const onboard_tft_fill = { this.setColour(DISPLAY_ONBOARD_HUE); this.appendValueInput('VAR') .appendField(Blockly.Msg.MIXLY_SCREEN_FILL); - var version = Boards.getSelectedBoardKey() - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize); + .appendField(Blockly.Msg.MIXLY_synchronize); } this.setPreviousStatement(true, null); this.setNextStatement(true, null); @@ -1596,10 +1590,9 @@ export const onboard_tft_show_texts = { .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_NUMBER); this.appendValueInput('VAR') .appendField(Blockly.Msg.HTML_COLOUR); - var version = Boards.getSelectedBoardKey() - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize); + .appendField(Blockly.Msg.MIXLY_synchronize); } this.setPreviousStatement(true, null); this.setNextStatement(true, null); @@ -1607,15 +1600,15 @@ export const onboard_tft_show_texts = { } }; -export const onboard_tft_show_qrcode = { +export const onboard_tft_show_qrcode = { init: function () { this.setColour(DISPLAY_ONBOARD_HUE); this.appendValueInput('direct') .appendField(Blockly.Msg.OLED_BITMAP) .appendField(Blockly.Msg.MIXLY_QR_CODE); - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize); + .appendField(Blockly.Msg.MIXLY_synchronize); } this.setPreviousStatement(true); this.setNextStatement(true); @@ -1642,16 +1635,16 @@ export const onboard_tft_show_qrcode_details = { this.appendDummyInput("") .appendField(Blockly.Msg.MIXLY_ERROR_RATE) .appendField(new Blockly.FieldDropdown([ - ["0","7%"], - ["1","15%"], - ["2","25%"], - ["3","30"] - ]),"correct"); + ["0", "7%"], + ["1", "15%"], + ["2", "25%"], + ["3", "30"] + ]), "correct"); this.appendValueInput('VAR') .appendField(Blockly.Msg.HTML_COLOUR); - if (JSFuncs.getPlatform() === 'Python ESP32-S3') { + if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) { this.appendValueInput('boolean') - .appendField( Blockly.Msg.MIXLY_synchronize); + .appendField(Blockly.Msg.MIXLY_synchronize); } this.setPreviousStatement(true, null); this.setNextStatement(true, null); diff --git a/boards/default_src/micropython/generators/ai_local.js b/boards/default_src/micropython/generators/ai_local.js index 457bfd0c..52ef84fb 100644 --- a/boards/default_src/micropython/generators/ai_local.js +++ b/boards/default_src/micropython/generators/ai_local.js @@ -586,9 +586,8 @@ export const MIXIO_REPORT_IMAGE_DATA = function (_, generator) { return [code, generator.ORDER_ATOMIC]; } -//simplified part +//simplified part export const CREATE_CAMERA_SIMPLE = function (_, generator) { - var version = Boards.getSelectedBoardKey().split(':')[2]; generator.definitions_['import_Camera_FrameSize'] = 'from camera import Camera,FrameSize'; var cmd = this.getFieldValue('cmd'); var code = 'camera = Camera(FrameSize.' + cmd + ', hmirror=False,vflip=False)\n'; diff --git a/boards/default_src/micropython/generators/display_onboard.js b/boards/default_src/micropython/generators/display_onboard.js index 670bc2f9..2d846e0c 100644 --- a/boards/default_src/micropython/generators/display_onboard.js +++ b/boards/default_src/micropython/generators/display_onboard.js @@ -1136,7 +1136,7 @@ export const draw_pointer = function (_, generator) { generator.definitions_['import_' + version + '_onboard_matrix'] = "from " + version + " import onboard_matrix"; var angle = generator.valueToCode(this, 'angle', generator.ORDER_ASSIGNMENT); var code = "onboard_matrix.pointern(angle=" + angle + ")\n"; - } + } return code; } @@ -1187,7 +1187,6 @@ export const onboard_tft_show_qrcode = function (_, generator) { var version = Boards.getSelectedBoardKey().split(':')[2]; generator.definitions_['import_' + version + '_onboard_tft'] = "from " + version + " import onboard_tft"; var direct = generator.valueToCode(this, 'direct', generator.ORDER_ATOMIC); - var bool = generator.valueToCode(this, 'boolean', generator.ORDER_ATOMIC) || 'True'; var code = 'onboard_tft.qrcode(' + direct + ')\n'; return code; }