feat(boards): 调整micropython下 创建图像 图形块
This commit is contained in:
@@ -158,6 +158,24 @@ export const display_image_create = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const display_bitmap_create = {
|
||||||
|
init: function () {
|
||||||
|
this.appendDummyInput('')
|
||||||
|
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_MONITOR_CREATE_IMAGE)
|
||||||
|
this.appendDummyInput('')
|
||||||
|
.setAlign(Blockly.inputs.Align.CENTRE)
|
||||||
|
.appendField(new Blockly.FieldBitmap(display_bitmap_create.BITMAP, null, {
|
||||||
|
filledColor: '#000',
|
||||||
|
emptyColor: '#5ba5a5',
|
||||||
|
bgColor: '#e5e7f1'
|
||||||
|
}), 'BITMAP');
|
||||||
|
this.setOutput(true);
|
||||||
|
this.setColour(DISPLAY_ONBOARD_HUE);
|
||||||
|
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_Create_image1);
|
||||||
|
},
|
||||||
|
BITMAP: Array.from({ length: 12 }, () => new Array(32).fill(0))
|
||||||
|
};
|
||||||
|
|
||||||
export const display_image_builtins = {
|
export const display_image_builtins = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.jsonInit({
|
this.jsonInit({
|
||||||
@@ -373,6 +391,24 @@ export const mixgome_display_image_create = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const mixgome_display_bitmap_create = {
|
||||||
|
init: function () {
|
||||||
|
this.appendDummyInput('')
|
||||||
|
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_MONITOR_CREATE_IMAGE)
|
||||||
|
this.appendDummyInput('')
|
||||||
|
.setAlign(Blockly.inputs.Align.CENTRE)
|
||||||
|
.appendField(new Blockly.FieldBitmap(mixgome_display_bitmap_create.BITMAP, null, {
|
||||||
|
filledColor: '#000',
|
||||||
|
emptyColor: '#5ba5a5',
|
||||||
|
bgColor: '#e5e7f1'
|
||||||
|
}), 'BITMAP');
|
||||||
|
this.setOutput(true);
|
||||||
|
this.setColour(DISPLAY_ONBOARD_HUE);
|
||||||
|
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_Create_image1);
|
||||||
|
},
|
||||||
|
BITMAP: Array.from({ length: 5 }, () => new Array(8).fill(0))
|
||||||
|
};
|
||||||
|
|
||||||
export const mixgomini_display_image_create = {
|
export const mixgomini_display_image_create = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendDummyInput('')
|
this.appendDummyInput('')
|
||||||
@@ -392,6 +428,24 @@ export const mixgomini_display_image_create = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const mixgomini_display_bitmap_create = {
|
||||||
|
init: function () {
|
||||||
|
this.appendDummyInput('')
|
||||||
|
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_MONITOR_CREATE_IMAGE)
|
||||||
|
this.appendDummyInput('')
|
||||||
|
.setAlign(Blockly.inputs.Align.CENTRE)
|
||||||
|
.appendField(new Blockly.FieldBitmap(mixgomini_display_bitmap_create.BITMAP, null, {
|
||||||
|
filledColor: '#000',
|
||||||
|
emptyColor: '#5ba5a5',
|
||||||
|
bgColor: '#e5e7f1'
|
||||||
|
}), 'BITMAP');
|
||||||
|
this.setOutput(true);
|
||||||
|
this.setColour(DISPLAY_ONBOARD_HUE);
|
||||||
|
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_Create_image1);
|
||||||
|
},
|
||||||
|
BITMAP: Array.from({ length: 8 }, () => new Array(12).fill(0))
|
||||||
|
};
|
||||||
|
|
||||||
export const mixgo_display_image_create_new = {
|
export const mixgo_display_image_create_new = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendDummyInput('')
|
this.appendDummyInput('')
|
||||||
@@ -411,6 +465,24 @@ export const mixgo_display_image_create_new = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const mixgo_display_bitmap_create = {
|
||||||
|
init: function () {
|
||||||
|
this.appendDummyInput('')
|
||||||
|
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_MONITOR_CREATE_IMAGE)
|
||||||
|
this.appendDummyInput('')
|
||||||
|
.setAlign(Blockly.inputs.Align.CENTRE)
|
||||||
|
.appendField(new Blockly.FieldBitmap(mixgo_display_bitmap_create.BITMAP, null, {
|
||||||
|
filledColor: '#000',
|
||||||
|
emptyColor: '#5ba5a5',
|
||||||
|
bgColor: '#e5e7f1'
|
||||||
|
}), 'BITMAP');
|
||||||
|
this.setOutput(true);
|
||||||
|
this.setColour(DISPLAY_ONBOARD_HUE);
|
||||||
|
this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_Create_image1);
|
||||||
|
},
|
||||||
|
BITMAP: Array.from({ length: 8 }, () => new Array(16).fill(0))
|
||||||
|
};
|
||||||
|
|
||||||
export const mixgome_display_font = {
|
export const mixgome_display_font = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.setColour(DISPLAY_ONBOARD_HUE);
|
this.setColour(DISPLAY_ONBOARD_HUE);
|
||||||
|
|||||||
@@ -222,6 +222,29 @@ export const display_image_create = function (block, generator) {
|
|||||||
return [code, generator.ORDER_ATOMIC];
|
return [code, generator.ORDER_ATOMIC];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const display_bitmap_create = function (block, generator) {
|
||||||
|
const BITMAP = block.getFieldValue('BITMAP');
|
||||||
|
const data = [];
|
||||||
|
for (let i = 0; i < 12; i++) {
|
||||||
|
for (let j = 0; j < 4; j++) {
|
||||||
|
let temp = 0;
|
||||||
|
let str = '';
|
||||||
|
for (let k = 0; k < 8; k++) {
|
||||||
|
if (!BITMAP[i][j * 8 + k]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
temp |= BITMAP[i][j * 8 + k] << k;
|
||||||
|
}
|
||||||
|
str = temp.toString(16);
|
||||||
|
if (str.length == 1) {
|
||||||
|
str = '0' + str;
|
||||||
|
}
|
||||||
|
data.push('0x' + str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [`[${data.join(',')}]`, generator.ORDER_ATOMIC];
|
||||||
|
}
|
||||||
|
|
||||||
export const display_clear = function (block, generator) {
|
export const display_clear = function (block, generator) {
|
||||||
var version = Boards.getSelectedBoardKey().split(':')[2];
|
var version = Boards.getSelectedBoardKey().split(':')[2];
|
||||||
if (version == 'mpython') {
|
if (version == 'mpython') {
|
||||||
@@ -382,6 +405,27 @@ export const mixgome_display_image_create = function (block, generator) {
|
|||||||
return [code, generator.ORDER_ATOMIC];
|
return [code, generator.ORDER_ATOMIC];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const mixgome_display_bitmap_create = function (block, generator) {
|
||||||
|
const BITMAP = block.getFieldValue('BITMAP');
|
||||||
|
const data = [];
|
||||||
|
for (let i = 0; i < 5; i++) {
|
||||||
|
let temp = 0;
|
||||||
|
let str = '';
|
||||||
|
for (let k = 0; k < 8; k++) {
|
||||||
|
if (!BITMAP[i][k]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
temp |= BITMAP[i][k] << k;
|
||||||
|
}
|
||||||
|
str = temp.toString(16);
|
||||||
|
if (str.length == 1) {
|
||||||
|
str = '0' + str;
|
||||||
|
}
|
||||||
|
data.push('\\x' + str);
|
||||||
|
}
|
||||||
|
return [`bytearray(b'${data.join('')}')`, generator.ORDER_ATOMIC];
|
||||||
|
}
|
||||||
|
|
||||||
export const mixgomini_display_image_create = function (block, generator) {
|
export const mixgomini_display_image_create = function (block, generator) {
|
||||||
var blinkColor = '#ff0000';
|
var blinkColor = '#ff0000';
|
||||||
var code = '';
|
var code = '';
|
||||||
@@ -400,6 +444,27 @@ export const mixgomini_display_image_create = function (block, generator) {
|
|||||||
return [code, generator.ORDER_ATOMIC];
|
return [code, generator.ORDER_ATOMIC];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const mixgomini_display_bitmap_create = function (block, generator) {
|
||||||
|
const BITMAP = block.getFieldValue('BITMAP');
|
||||||
|
const data = [];
|
||||||
|
for (let i = 0; i < 12; i++) {
|
||||||
|
let temp = 0;
|
||||||
|
let str = '';
|
||||||
|
for (let k = 0; k < 8; k++) {
|
||||||
|
if (!BITMAP[k][i]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
temp |= BITMAP[k][i] << k;
|
||||||
|
}
|
||||||
|
str = temp.toString(16);
|
||||||
|
if (str.length == 1) {
|
||||||
|
str = '0' + str;
|
||||||
|
}
|
||||||
|
data.push('\\x' + str);
|
||||||
|
}
|
||||||
|
return [`bytearray(b'${data.join('')}')`, generator.ORDER_ATOMIC];
|
||||||
|
}
|
||||||
|
|
||||||
export const mixgome_display_font = function (a, generator) {
|
export const mixgome_display_font = function (a, generator) {
|
||||||
var version = Boards.getSelectedBoardKey().split(':')[2];
|
var version = Boards.getSelectedBoardKey().split(':')[2];
|
||||||
generator.definitions_['import_' + version + '_onboard_matrix'] = "from " + version + " import onboard_matrix";
|
generator.definitions_['import_' + version + '_onboard_matrix'] = "from " + version + " import onboard_matrix";
|
||||||
@@ -444,6 +509,29 @@ export const mixgo_display_image_create_new = function (block, generator) {
|
|||||||
return [code, generator.ORDER_ATOMIC];
|
return [code, generator.ORDER_ATOMIC];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const mixgo_display_bitmap_create = function (block, generator) {
|
||||||
|
const BITMAP = block.getFieldValue('BITMAP');
|
||||||
|
const data = [];
|
||||||
|
for (let i = 0; i < 8; i++) {
|
||||||
|
for (let j = 0; j < 2; j++) {
|
||||||
|
let temp = 0;
|
||||||
|
let str = '';
|
||||||
|
for (let k = 0; k < 8; k++) {
|
||||||
|
if (!BITMAP[i][j * 8 + k]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
temp |= BITMAP[i][j * 8 + k] << k;
|
||||||
|
}
|
||||||
|
str = temp.toString(16);
|
||||||
|
if (str.length == 1) {
|
||||||
|
str = '0' + str;
|
||||||
|
}
|
||||||
|
data.push('\\x' + str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [`bytearray(b'${data.join('')}')`, generator.ORDER_ATOMIC];
|
||||||
|
}
|
||||||
|
|
||||||
//mpython
|
//mpython
|
||||||
export const mpython_pbm_image = function (_, generator) {
|
export const mpython_pbm_image = function (_, generator) {
|
||||||
const PIN_VALUE = this.getFieldValue('path');
|
const PIN_VALUE = this.getFieldValue('path');
|
||||||
|
|||||||
@@ -2001,7 +2001,7 @@
|
|||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="mixgomini_display_image_create" m-show='micropython:esp32c2:mixgo_mini'></block>
|
<block type="mixgomini_display_bitmap_create" m-show='micropython:esp32c2:mixgo_mini'></block>
|
||||||
<block type="image_arithmetic">
|
<block type="image_arithmetic">
|
||||||
<value name="A">
|
<value name="A">
|
||||||
<shadow type="pins_builtinimg"></shadow>
|
<shadow type="pins_builtinimg"></shadow>
|
||||||
@@ -4986,8 +4986,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
<block type="display_image_create"></block>
|
<block type="display_bitmap_create"></block>
|
||||||
<!-- <block type="mixgo_display_image_create_new"></block> -->
|
|
||||||
<block type="display_matrix_extern_image_builtins">
|
<block type="display_matrix_extern_image_builtins">
|
||||||
<value name="SUB">
|
<value name="SUB">
|
||||||
<shadow type="variables_get">
|
<shadow type="variables_get">
|
||||||
|
|||||||
@@ -1777,8 +1777,8 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="mixgome_display_font" m-show='micropython:esp32:mixgo_pe'></block>
|
<block type="mixgome_display_font" m-show='micropython:esp32:mixgo_pe'></block>
|
||||||
<block type="mixgome_display_image_create" m-show='micropython:esp32:mixgo_pe'></block>
|
<block type="mixgome_display_bitmap_create" m-show='micropython:esp32:mixgo_pe'></block>
|
||||||
<block type="mixgo_display_image_create_new" m-show='micropython:esp32:mixgo'></block>
|
<block type="mixgo_display_bitmap_create" m-show='micropython:esp32:mixgo'></block>
|
||||||
<block type="display_image_builtins" m-hide='micropython:esp32:mixgo_pe'></block>
|
<block type="display_image_builtins" m-hide='micropython:esp32:mixgo_pe'></block>
|
||||||
<block type="display_image_builtins_all" m-show='micropython:esp32:mixgo_pe'></block>
|
<block type="display_image_builtins_all" m-show='micropython:esp32:mixgo_pe'></block>
|
||||||
<block type="image_arithmetic">
|
<block type="image_arithmetic">
|
||||||
@@ -4813,8 +4813,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
<block type="display_image_create"></block>
|
<block type="display_bitmap_create"></block>
|
||||||
<!-- <block type="mixgo_display_image_create_new"></block> -->
|
|
||||||
<block type="display_matrix_extern_image_builtins">
|
<block type="display_matrix_extern_image_builtins">
|
||||||
<value name="SUB">
|
<value name="SUB">
|
||||||
<shadow type="variables_get">
|
<shadow type="variables_get">
|
||||||
|
|||||||
@@ -1825,7 +1825,7 @@
|
|||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="mixgomini_display_image_create" m-show='micropython:esp32c2:mixgo_mini'></block>
|
<block type="mixgomini_display_bitmap_create" m-show='micropython:esp32c2:mixgo_mini'></block>
|
||||||
<block type="display_image_builtins_all" m-show='micropython:esp32c2:mixgo_mini'></block>
|
<block type="display_image_builtins_all" m-show='micropython:esp32c2:mixgo_mini'></block>
|
||||||
<block type="image_arithmetic">
|
<block type="image_arithmetic">
|
||||||
<value name="A">
|
<value name="A">
|
||||||
@@ -4671,8 +4671,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
<block type="display_image_create"></block>
|
<block type="display_bitmap_create"></block>
|
||||||
<!-- <block type="mixgo_display_image_create_new"></block> -->
|
|
||||||
<block type="display_matrix_extern_image_builtins">
|
<block type="display_matrix_extern_image_builtins">
|
||||||
<value name="SUB">
|
<value name="SUB">
|
||||||
<shadow type="variables_get">
|
<shadow type="variables_get">
|
||||||
|
|||||||
@@ -1769,8 +1769,8 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="mixgome_display_font" m-show='micropython:esp32c3:mixgo_me'></block>
|
<block type="mixgome_display_font" m-show='micropython:esp32c3:mixgo_me'></block>
|
||||||
<block type="mixgome_display_image_create" m-show='micropython:esp32c3:mixgo_me'></block>
|
<block type="mixgome_display_bitmap_create" m-show='micropython:esp32c3:mixgo_me'></block>
|
||||||
<block type="display_image_create" m-show='micropython:esp32c3:mixgo_cc'></block>
|
<block type="display_bitmap_create" m-show='micropython:esp32c3:mixgo_cc'></block>
|
||||||
<block type="display_image_builtins" m-show='micropython:esp32c3:mixgo_cc'></block>
|
<block type="display_image_builtins" m-show='micropython:esp32c3:mixgo_cc'></block>
|
||||||
<block type="display_image_builtins_all" m-show='micropython:esp32c3:mixgo_me'></block>
|
<block type="display_image_builtins_all" m-show='micropython:esp32c3:mixgo_me'></block>
|
||||||
<block type="image_arithmetic">
|
<block type="image_arithmetic">
|
||||||
@@ -4621,8 +4621,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
<block type="display_image_create"></block>
|
<block type="display_bitmap_create"></block>
|
||||||
<!-- <block type="mixgo_display_image_create_new"></block> -->
|
|
||||||
<block type="display_matrix_extern_image_builtins">
|
<block type="display_matrix_extern_image_builtins">
|
||||||
<value name="SUB">
|
<value name="SUB">
|
||||||
<shadow type="variables_get">
|
<shadow type="variables_get">
|
||||||
|
|||||||
@@ -1714,7 +1714,7 @@
|
|||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="mixgo_display_image_create_new" m-show='micropython:esp32s2:mixgo_ce'></block>
|
<block type="mixgo_display_bitmap_create" m-show='micropython:esp32s2:mixgo_ce'></block>
|
||||||
<block type="display_image_builtins_all"></block>
|
<block type="display_image_builtins_all"></block>
|
||||||
|
|
||||||
<block type="image_arithmetic">
|
<block type="image_arithmetic">
|
||||||
@@ -4347,8 +4347,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
<block type="display_image_create"></block>
|
<block type="display_bitmap_create"></block>
|
||||||
<!-- <block type="mixgo_display_image_create_new"></block> -->
|
|
||||||
<block type="display_matrix_extern_image_builtins">
|
<block type="display_matrix_extern_image_builtins">
|
||||||
<value name="SUB">
|
<value name="SUB">
|
||||||
<shadow type="variables_get">
|
<shadow type="variables_get">
|
||||||
|
|||||||
@@ -5036,8 +5036,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
<block type="display_image_create"></block>
|
<block type="display_image_create_bitmap"></block>
|
||||||
<!-- <block type="mixgo_display_image_create_new"></block> -->
|
|
||||||
<block type="display_matrix_extern_image_builtins">
|
<block type="display_matrix_extern_image_builtins">
|
||||||
<value name="SUB">
|
<value name="SUB">
|
||||||
<shadow type="variables_get">
|
<shadow type="variables_get">
|
||||||
|
|||||||
@@ -3456,7 +3456,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
<block type="display_image_create"></block>
|
<block type="display_bitmap_create"></block>
|
||||||
<block type="display_matrix_extern_image_builtins">
|
<block type="display_matrix_extern_image_builtins">
|
||||||
<value name="SUB">
|
<value name="SUB">
|
||||||
<shadow type="variables_get">
|
<shadow type="variables_get">
|
||||||
|
|||||||
Reference in New Issue
Block a user