From 263a9254261278e779f2e5a8812b503b96ad074b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com>
Date: Tue, 9 Sep 2025 23:15:45 +0800
Subject: [PATCH] =?UTF-8?q?feat(boards):=20xpython=20=E6=96=87=E6=9C=AC?=
=?UTF-8?q?=E5=88=86=E7=B1=BB=E4=B8=8B=E6=B7=BB=E5=8A=A0=20`=E5=AD=97?=
=?UTF-8?q?=E8=8A=82=E4=B8=B2`?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../micropython_educore/template.xml | 3 ++
.../micropython_esp32/template.xml | 3 ++
.../micropython_esp32c2/template.xml | 3 ++
.../micropython_esp32c3/template.xml | 3 ++
.../micropython_esp32s2/template.xml | 3 ++
.../micropython_esp32s3/template.xml | 3 ++
.../micropython_k210_mixgoai/template.xml | 3 ++
.../template.xml | 3 ++
.../template.xml | 3 ++
.../micropython_robot/template.xml | 3 ++
boards/default_src/python/blocks/text.js | 31 +++++++++++++++++++
boards/default_src/python/generators/text.js | 5 +++
boards/default_src/python_mixpy/template.xml | 3 ++
.../default_src/python_pyodide/template.xml | 3 ++
boards/default_src/python_skulpt/template.xml | 3 ++
.../python_skulpt_car/template.xml | 3 ++
.../python_skulpt_mixtoy/template.xml | 3 ++
common/msg/blockly/en.js | 19 +++++++-----
common/msg/blockly/zh-hans.js | 3 ++
common/msg/blockly/zh-hant.js | 19 +++++++-----
20 files changed, 106 insertions(+), 16 deletions(-)
diff --git a/boards/default_src/micropython_educore/template.xml b/boards/default_src/micropython_educore/template.xml
index 93cfd57c..2ff4b4aa 100644
--- a/boards/default_src/micropython_educore/template.xml
+++ b/boards/default_src/micropython_educore/template.xml
@@ -527,6 +527,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/micropython_esp32/template.xml b/boards/default_src/micropython_esp32/template.xml
index d2d1c92c..11770862 100644
--- a/boards/default_src/micropython_esp32/template.xml
+++ b/boards/default_src/micropython_esp32/template.xml
@@ -548,6 +548,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/micropython_esp32c2/template.xml b/boards/default_src/micropython_esp32c2/template.xml
index 9d2a84c4..7cc0aa16 100644
--- a/boards/default_src/micropython_esp32c2/template.xml
+++ b/boards/default_src/micropython_esp32c2/template.xml
@@ -522,6 +522,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/micropython_esp32c3/template.xml b/boards/default_src/micropython_esp32c3/template.xml
index 19f5ae97..425631e4 100644
--- a/boards/default_src/micropython_esp32c3/template.xml
+++ b/boards/default_src/micropython_esp32c3/template.xml
@@ -522,6 +522,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/micropython_esp32s2/template.xml b/boards/default_src/micropython_esp32s2/template.xml
index db2b6100..3dda5e3a 100644
--- a/boards/default_src/micropython_esp32s2/template.xml
+++ b/boards/default_src/micropython_esp32s2/template.xml
@@ -548,6 +548,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/micropython_esp32s3/template.xml b/boards/default_src/micropython_esp32s3/template.xml
index f4006f3c..1bfcef95 100644
--- a/boards/default_src/micropython_esp32s3/template.xml
+++ b/boards/default_src/micropython_esp32s3/template.xml
@@ -548,6 +548,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/micropython_k210_mixgoai/template.xml b/boards/default_src/micropython_k210_mixgoai/template.xml
index 40f6aeae..c5c437fb 100644
--- a/boards/default_src/micropython_k210_mixgoai/template.xml
+++ b/boards/default_src/micropython_k210_mixgoai/template.xml
@@ -504,6 +504,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/micropython_nrf51822_microbit/template.xml b/boards/default_src/micropython_nrf51822_microbit/template.xml
index 15c01dd2..b2e031f7 100644
--- a/boards/default_src/micropython_nrf51822_microbit/template.xml
+++ b/boards/default_src/micropython_nrf51822_microbit/template.xml
@@ -360,6 +360,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/micropython_nrf51822_mithoncc/template.xml b/boards/default_src/micropython_nrf51822_mithoncc/template.xml
index d6e05c3c..40b14378 100644
--- a/boards/default_src/micropython_nrf51822_mithoncc/template.xml
+++ b/boards/default_src/micropython_nrf51822_mithoncc/template.xml
@@ -286,6 +286,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/micropython_robot/template.xml b/boards/default_src/micropython_robot/template.xml
index 89f53a59..e6878c45 100644
--- a/boards/default_src/micropython_robot/template.xml
+++ b/boards/default_src/micropython_robot/template.xml
@@ -538,6 +538,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/python/blocks/text.js b/boards/default_src/python/blocks/text.js
index 2a0b1abf..eadbb6f3 100644
--- a/boards/default_src/python/blocks/text.js
+++ b/boards/default_src/python/blocks/text.js
@@ -65,6 +65,37 @@ export const text_textarea = {
}
};
+export const text_bytes = {
+ /**
+ * Block for text value.
+ * @this Blockly.Block
+ */
+ init: function () {
+ this.setColour(TEXTS_HUE);
+ this.appendDummyInput()
+ .appendField(Blockly.Msg.MIXLY_TEXT_BYTES)
+ .appendField(this.newQuote_(true))
+ .appendField(new Blockly.FieldTextInput(''), 'TEXT')
+ .appendField(this.newQuote_(false));
+ this.setOutput(true, String);
+ this.setTooltip(Blockly.Msg.TEXT_TEXT_TOOLTIP);
+ },
+ /**
+ * Create an image of an open or closed quote.
+ * @param {boolean} open True if open quote, false if closed.
+ * @return {!Blockly.FieldImage} The field image of the quote.
+ * @private
+ */
+ newQuote_: function (open) {
+ if (open == this.RTL) {
+ var file = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==';
+ } else {
+ var file = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC';
+ }
+ return new Blockly.FieldImage(file, 12, 12, '"');
+ }
+};
+
Blockly.FieldTextInput.char_validator = function (text) {
if (text.length > 1) {
if (text.charAt(0) === "\\") {
diff --git a/boards/default_src/python/generators/text.js b/boards/default_src/python/generators/text.js
index 6b0cc455..522ebf6f 100644
--- a/boards/default_src/python/generators/text.js
+++ b/boards/default_src/python/generators/text.js
@@ -14,6 +14,11 @@ export const text_textarea = function (_, generator) {
return [code, generator.ORDER_ATOMIC];
}
+export const text_bytes = function (_, generator) {
+ const text = this.getFieldValue('TEXT');
+ return [`b'${text}'`, generator.ORDER_ATOMIC];
+}
+
export const text_char = function (_, generator) {
var code = '\'' + this.getFieldValue('TEXT') + '\'';
return [code, generator.ORDER_ATOMIC];
diff --git a/boards/default_src/python_mixpy/template.xml b/boards/default_src/python_mixpy/template.xml
index 79d3cfab..3c87e325 100644
--- a/boards/default_src/python_mixpy/template.xml
+++ b/boards/default_src/python_mixpy/template.xml
@@ -473,6 +473,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/python_pyodide/template.xml b/boards/default_src/python_pyodide/template.xml
index d5f80f09..9001fdcb 100644
--- a/boards/default_src/python_pyodide/template.xml
+++ b/boards/default_src/python_pyodide/template.xml
@@ -473,6 +473,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/python_skulpt/template.xml b/boards/default_src/python_skulpt/template.xml
index 944ed22a..f1bc3176 100644
--- a/boards/default_src/python_skulpt/template.xml
+++ b/boards/default_src/python_skulpt/template.xml
@@ -398,6 +398,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/python_skulpt_car/template.xml b/boards/default_src/python_skulpt_car/template.xml
index ef5730bd..ae7d1bfa 100644
--- a/boards/default_src/python_skulpt_car/template.xml
+++ b/boards/default_src/python_skulpt_car/template.xml
@@ -356,6 +356,9 @@
+
+ Mixly
+
diff --git a/boards/default_src/python_skulpt_mixtoy/template.xml b/boards/default_src/python_skulpt_mixtoy/template.xml
index 43d7794d..09fe6798 100644
--- a/boards/default_src/python_skulpt_mixtoy/template.xml
+++ b/boards/default_src/python_skulpt_mixtoy/template.xml
@@ -356,6 +356,9 @@ type="application/javascript"> -->
+
+ Mixly
+
diff --git a/common/msg/blockly/en.js b/common/msg/blockly/en.js
index a568cfb0..f066337b 100644
--- a/common/msg/blockly/en.js
+++ b/common/msg/blockly/en.js
@@ -3978,12 +3978,15 @@ En.MIXLY_MICROPHONE_AMPLIFICATION = 'microphone amplification';
En.MIXLY_MUSIC_VOLUME_SET = 'set music volume';
En.MIXLY_HOTSPOT= 'hot spot';
En.MIXLY_NAME = 'name';
-En.MIXLY_Service_quality_display= "service quality",
-En.MIXLY_AT_MOST_ONCE= "At most once",
-En.MIXLY_AT_LEAST_ONCE= "At least once",
-En.MIXLY_ONLY_ONCE= "Only once",
-En.MIXLY_ADD= "Append",
-En.MIXLY_R_W= "Readable and Writable, Error if File Does Not Exist",
-En.MIXLY_W_R= "Readable and Writable, Create if File Does Not Exist",
-En.MIXLY_A_R= "Appendable and Writable, Create if File Does Not Exist"
+En.MIXLY_Service_quality_display = "service quality";
+En.MIXLY_AT_MOST_ONCE = "At most once";
+En.MIXLY_AT_LEAST_ONCE = "At least once";
+En.MIXLY_ONLY_ONCE = "Only once";
+En.MIXLY_ADD = "Append";
+En.MIXLY_R_W = "Readable and Writable, Error if File Does Not Exist";
+En.MIXLY_W_R = "Readable and Writable, Create if File Does Not Exist";
+En.MIXLY_A_R = "Appendable and Writable, Create if File Does Not Exist";
+En.MIXLY_TEXT_BYTES = 'bytes';
+En.MIXLY_TEXT_BYTE_ARRAY = 'bytearray';
+
})();
diff --git a/common/msg/blockly/zh-hans.js b/common/msg/blockly/zh-hans.js
index c5023d3a..e70246cf 100644
--- a/common/msg/blockly/zh-hans.js
+++ b/common/msg/blockly/zh-hans.js
@@ -4145,4 +4145,7 @@ ZhHans.MIXLY_ADD = '追加';
ZhHans.MIXLY_R_W ='可读可写,文件若不存在就报错';
ZhHans.MIXLY_W_R = '可读可写,文件若不存在就创建';
ZhHans.MIXLY_A_R = '可追加可写,文件若不存在就创建';
+ZhHans.MIXLY_TEXT_BYTES = '字节串';
+ZhHans.MIXLY_TEXT_BYTE_ARRAY = '字节数组';
+
})();
\ No newline at end of file
diff --git a/common/msg/blockly/zh-hant.js b/common/msg/blockly/zh-hant.js
index 01a58bfe..db2715ec 100644
--- a/common/msg/blockly/zh-hant.js
+++ b/common/msg/blockly/zh-hant.js
@@ -4132,12 +4132,15 @@ ZhHant.MIXLY_MICROPHONE_AMPLIFICATION = '麥克風放大倍數';
ZhHant.MIXLY_MUSIC_VOLUME_SET = '音量調節';
ZhHant.MIXLY_HOTSPOT= '熱點';
ZhHant.MIXLY_NAME = '名稱';
-ZhHant.MIXLY_Service_quality_display= "服務質量";
-ZhHant.MIXLY_AT_MOST_ONCE= "至多一次";
-ZhHant.MIXLY_AT_LEAST_ONCE= "至少一次";
-ZhHant.MIXLY_ONLY_ONCE= "僅一次";
-ZhHant.MIXLY_ADD= "追加";
-ZhHant.MIXLY_R_W= "可讀可寫,文件若不存在就報錯";
-ZhHant.MIXLY_W_R= "可讀可寫,文件若不存在就創建";
-ZhHant.MIXLY_A_R= "可追加可寫,文件若不存在就創建";
+ZhHant.MIXLY_Service_quality_display = "服務質量";
+ZhHant.MIXLY_AT_MOST_ONCE = "至多一次";
+ZhHant.MIXLY_AT_LEAST_ONCE = "至少一次";
+ZhHant.MIXLY_ONLY_ONCE = "僅一次";
+ZhHant.MIXLY_ADD = "追加";
+ZhHant.MIXLY_R_W = "可讀可寫,文件若不存在就報錯";
+ZhHant.MIXLY_W_R = "可讀可寫,文件若不存在就創建";
+ZhHant.MIXLY_A_R = "可追加可寫,文件若不存在就創建";
+ZhHant.MIXLY_TEXT_BYTES = '位元組字串';
+ZhHant.MIXLY_TEXT_BYTE_ARRAY = '位元組數組';
+
})();