fix(boards): 修复micropython_esp32c5下 板载显示 转代码异常

This commit is contained in:
王立帮
2026-01-12 09:26:40 +08:00
parent 3cc7584660
commit 18ea44a38e
3 changed files with 35 additions and 44 deletions

View File

@@ -10,9 +10,9 @@ export const display_show_image = {
.setCheck([String, "esp32_image", "List", 'Tuple']) .setCheck([String, "esp32_image", "List", 'Tuple'])
.appendField(Blockly.Msg.MIXLY_ESP32_SHOW_IMAGE_OR_STRING); .appendField(Blockly.Msg.MIXLY_ESP32_SHOW_IMAGE_OR_STRING);
var version = Boards.getSelectedBoardKey() var version = Boards.getSelectedBoardKey()
if (JSFuncs.getPlatform() === 'Python ESP32-S3') { if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) {
this.appendValueInput('boolean') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(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_YES, "True"],
[Blockly.Msg.MICROPYTHON_DISPLAY_NO, "False"] [Blockly.Msg.MICROPYTHON_DISPLAY_NO, "False"]
]), 'center') ]), 'center')
if (JSFuncs.getPlatform() === 'Python ESP32-S3') { if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) {
this.appendValueInput('boolean') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(true, null); this.setNextStatement(true, null);
@@ -97,11 +97,11 @@ export const display_scroll_way = {
this.appendDummyInput() this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_SETTING + Blockly.Msg.MIXLY_DISPLAY_SCROLL_WAY) .appendField(Blockly.Msg.MIXLY_SETTING + Blockly.Msg.MIXLY_DISPLAY_SCROLL_WAY)
.appendField(new Blockly.FieldDropdown([ .appendField(new Blockly.FieldDropdown([
[Blockly.Msg.MIXLY_GAME_UP,"0"], [Blockly.Msg.MIXLY_GAME_UP, "0"],
[Blockly.Msg.MIXLY_GAME_DOWN,"1"], [Blockly.Msg.MIXLY_GAME_DOWN, "1"],
[Blockly.Msg.MIXLY_GAME_RIGHT,"2"], [Blockly.Msg.MIXLY_GAME_RIGHT, "2"],
[Blockly.Msg.MIXLY_GAME_LEFT,"3"] [Blockly.Msg.MIXLY_GAME_LEFT, "3"]
]),"way");; ]), "way");
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(true, null); this.setNextStatement(true, null);
this.setInputsInline(true); this.setInputsInline(true);
@@ -301,10 +301,9 @@ export const display_shift = {
.setCheck(Number); .setCheck(Number);
this.appendDummyInput('') this.appendDummyInput('')
.appendField(Blockly.Msg.DISPLAY_IMAGE_UNIT) .appendField(Blockly.Msg.DISPLAY_IMAGE_UNIT)
var version = Boards.getSelectedBoardKey() if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) {
if (JSFuncs.getPlatform() === 'Python ESP32-S3') {
this.appendValueInput('boolean') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
var thisBlock = this; var thisBlock = this;
this.setTooltip(function () { this.setTooltip(function () {
@@ -394,10 +393,9 @@ export const display_clear = {
this.setColour(DISPLAY_ONBOARD_HUE); this.setColour(DISPLAY_ONBOARD_HUE);
this.appendDummyInput() this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_MICROBIT_Clear_display); .appendField(Blockly.Msg.MIXLY_MICROBIT_Clear_display);
var version = Boards.getSelectedBoardKey() if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) {
if (JSFuncs.getPlatform() === 'Python ESP32-S3') {
this.appendValueInput('boolean') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(true, null); this.setNextStatement(true, null);
@@ -1114,10 +1112,9 @@ export const onboard_tft_show_image_xy = {
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_NUMBER); .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_NUMBER);
this.appendValueInput('VAR') this.appendValueInput('VAR')
.appendField(Blockly.Msg.HTML_COLOUR); .appendField(Blockly.Msg.HTML_COLOUR);
var version = Boards.getSelectedBoardKey() if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) {
if (JSFuncs.getPlatform() === 'Python ESP32-S3') {
this.appendValueInput('boolean') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize ); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(true, null); this.setNextStatement(true, null);
@@ -1169,10 +1166,9 @@ export const onboard_tft_show_image_or_string_delay = {
]), 'center') ]), 'center')
this.appendValueInput('VAR') this.appendValueInput('VAR')
.appendField(Blockly.Msg.HTML_COLOUR); .appendField(Blockly.Msg.HTML_COLOUR);
var version = Boards.getSelectedBoardKey() if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) {
if (JSFuncs.getPlatform() === 'Python ESP32-S3') {
this.appendValueInput('boolean') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(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); .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_MONITOR_PLOT_POINT_Y);
this.appendValueInput('VAR') this.appendValueInput('VAR')
.appendField(Blockly.Msg.HTML_COLOUR); .appendField(Blockly.Msg.HTML_COLOUR);
var version = Boards.getSelectedBoardKey() if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) {
if (JSFuncs.getPlatform() === 'Python ESP32-S3') {
this.appendValueInput('boolean') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(true, null); this.setNextStatement(true, null);
@@ -1402,10 +1397,9 @@ export const onboard_tft_fill = {
this.setColour(DISPLAY_ONBOARD_HUE); this.setColour(DISPLAY_ONBOARD_HUE);
this.appendValueInput('VAR') this.appendValueInput('VAR')
.appendField(Blockly.Msg.MIXLY_SCREEN_FILL); .appendField(Blockly.Msg.MIXLY_SCREEN_FILL);
var version = Boards.getSelectedBoardKey() if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) {
if (JSFuncs.getPlatform() === 'Python ESP32-S3') {
this.appendValueInput('boolean') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(true, null); this.setNextStatement(true, null);
@@ -1596,10 +1590,9 @@ export const onboard_tft_show_texts = {
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_NUMBER); .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_NUMBER);
this.appendValueInput('VAR') this.appendValueInput('VAR')
.appendField(Blockly.Msg.HTML_COLOUR); .appendField(Blockly.Msg.HTML_COLOUR);
var version = Boards.getSelectedBoardKey() if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) {
if (JSFuncs.getPlatform() === 'Python ESP32-S3') {
this.appendValueInput('boolean') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(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 () { init: function () {
this.setColour(DISPLAY_ONBOARD_HUE); this.setColour(DISPLAY_ONBOARD_HUE);
this.appendValueInput('direct') this.appendValueInput('direct')
.appendField(Blockly.Msg.OLED_BITMAP) .appendField(Blockly.Msg.OLED_BITMAP)
.appendField(Blockly.Msg.MIXLY_QR_CODE); .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') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
this.setPreviousStatement(true); this.setPreviousStatement(true);
this.setNextStatement(true); this.setNextStatement(true);
@@ -1642,16 +1635,16 @@ export const onboard_tft_show_qrcode_details = {
this.appendDummyInput("") this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_ERROR_RATE) .appendField(Blockly.Msg.MIXLY_ERROR_RATE)
.appendField(new Blockly.FieldDropdown([ .appendField(new Blockly.FieldDropdown([
["0","7%"], ["0", "7%"],
["1","15%"], ["1", "15%"],
["2","25%"], ["2", "25%"],
["3","30"] ["3", "30"]
]),"correct"); ]), "correct");
this.appendValueInput('VAR') this.appendValueInput('VAR')
.appendField(Blockly.Msg.HTML_COLOUR); .appendField(Blockly.Msg.HTML_COLOUR);
if (JSFuncs.getPlatform() === 'Python ESP32-S3') { if (['Python ESP32-S3', 'Python ESP32-C5'].includes(JSFuncs.getPlatform())) {
this.appendValueInput('boolean') this.appendValueInput('boolean')
.appendField( Blockly.Msg.MIXLY_synchronize); .appendField(Blockly.Msg.MIXLY_synchronize);
} }
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(true, null); this.setNextStatement(true, null);

View File

@@ -586,9 +586,8 @@ export const MIXIO_REPORT_IMAGE_DATA = function (_, generator) {
return [code, generator.ORDER_ATOMIC]; return [code, generator.ORDER_ATOMIC];
} }
//simplified part //simplified part
export const CREATE_CAMERA_SIMPLE = function (_, generator) { export const CREATE_CAMERA_SIMPLE = function (_, generator) {
var version = Boards.getSelectedBoardKey().split(':')[2];
generator.definitions_['import_Camera_FrameSize'] = 'from camera import Camera,FrameSize'; generator.definitions_['import_Camera_FrameSize'] = 'from camera import Camera,FrameSize';
var cmd = this.getFieldValue('cmd'); var cmd = this.getFieldValue('cmd');
var code = 'camera = Camera(FrameSize.' + cmd + ', hmirror=False,vflip=False)\n'; var code = 'camera = Camera(FrameSize.' + cmd + ', hmirror=False,vflip=False)\n';

View File

@@ -1136,7 +1136,7 @@ export const draw_pointer = function (_, generator) {
generator.definitions_['import_' + version + '_onboard_matrix'] = "from " + version + " import onboard_matrix"; generator.definitions_['import_' + version + '_onboard_matrix'] = "from " + version + " import onboard_matrix";
var angle = generator.valueToCode(this, 'angle', generator.ORDER_ASSIGNMENT); var angle = generator.valueToCode(this, 'angle', generator.ORDER_ASSIGNMENT);
var code = "onboard_matrix.pointern(angle=" + angle + ")\n"; var code = "onboard_matrix.pointern(angle=" + angle + ")\n";
} }
return code; return code;
} }
@@ -1187,7 +1187,6 @@ export const onboard_tft_show_qrcode = function (_, generator) {
var version = Boards.getSelectedBoardKey().split(':')[2]; var version = Boards.getSelectedBoardKey().split(':')[2];
generator.definitions_['import_' + version + '_onboard_tft'] = "from " + version + " import onboard_tft"; generator.definitions_['import_' + version + '_onboard_tft'] = "from " + version + " import onboard_tft";
var direct = generator.valueToCode(this, 'direct', generator.ORDER_ATOMIC); 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'; var code = 'onboard_tft.qrcode(' + direct + ')\n';
return code; return code;
} }