时间元组转字符串

This commit is contained in:
Irene-Maxine
2025-02-22 12:49:30 +08:00
parent e090ccbc68
commit 321ed7438d
15 changed files with 54300 additions and 111 deletions

View File

@@ -1,82 +0,0 @@
{
"ble_central": {
"__require__": [
"time",
"gc",
"bluetooth",
"micropython",
"ubinascii",
"ble_advertising"
],
"__file__": true,
"__size__": 7378,
"__name__": "ble_central.py"
},
"mini_bot": {
"__require__": [
"time",
"math",
"esp",
"micropython",
"framebuf"
],
"__file__": true,
"__size__": 12529,
"__name__": "mini_bot.py"
},
"mini_g2": {
"__require__": [
"gc",
"machine",
"rc522"
],
"__file__": true,
"__size__": 544,
"__name__": "mini_g2.py"
},
"mini_go": {
"__require__": [
"time",
"gc",
"math",
"tm1931",
"machine"
],
"__file__": true,
"__size__": 8481,
"__name__": "mini_go.py"
},
"mixgo_mini": {
"__require__": [
"time",
"gc",
"esp32",
"machine",
"ws2812x",
"musicx",
"sc7a20",
"ap3216c",
"mini_bot"
],
"__file__": true,
"__size__": 4611,
"__name__": "mixgo_mini.py"
},
"musicx": {
"__require__": [
"time"
],
"__file__": true,
"__size__": 3545,
"__name__": "musicx.py"
},
"ws2812x": {
"__require__": [
"time",
"machine"
],
"__file__": true,
"__size__": 1881,
"__name__": "ws2812x.py"
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -587,7 +587,7 @@ export const onboard_RTC_get_time_str = function(_,generator){
export const onboard_RTC_get_timetuple_to_str = function(_,generator){ export const onboard_RTC_get_timetuple_to_str = function(_,generator){
generator.definitions_['import_rtctime'] = 'import rtctime'; generator.definitions_['import_rtctime'] = 'import rtctime';
var ct = generator.valueToCode(this, 'CONTENT', generator.ORDER_ATOMIC); var ct = generator.valueToCode(this, 'CONTENT', generator.ORDER_ATOMIC);
var code = 'rtctime.strtime(('+ ct +'))'; var code = 'rtctime.strtime('+ ct +')';
return [code, generator.ORDER_ATOMIC]; return [code, generator.ORDER_ATOMIC];
} }

View File

@@ -1580,8 +1580,8 @@
</block> </block>
<block type="onboard_RTC_settime_string"> <block type="onboard_RTC_settime_string">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="text"> <shadow type="tuple_input">
<field name="TEXT">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>
@@ -1601,8 +1601,8 @@
</block> </block>
<block type="onboard_RTC_get_timetuple_to_str"> <block type="onboard_RTC_get_timetuple_to_str">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="math_number"> <shadow type="tuple_input">
<field name="NUM">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>

View File

@@ -1484,8 +1484,8 @@
</block> </block>
<block type="onboard_RTC_settime_string" m-hide="micropython:esp32:mixgo_pe"> <block type="onboard_RTC_settime_string" m-hide="micropython:esp32:mixgo_pe">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="text"> <shadow type="tuple_input">
<field name="TEXT">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>
@@ -1505,8 +1505,8 @@
</block> </block>
<block type="onboard_RTC_get_timetuple_to_str"> <block type="onboard_RTC_get_timetuple_to_str">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="math_number"> <shadow type="tuple_input">
<field name="NUM">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>

View File

@@ -1419,7 +1419,7 @@
<block type="sensor_mixgocar_pin_near_state_change" <block type="sensor_mixgocar_pin_near_state_change"
m-show='micropython:esp32c3:mixgocar_c3'></block> m-show='micropython:esp32c3:mixgocar_c3'></block>
<block type="sensor_mixgocar_battery_left" m-show='micropython:esp32c3:mixgocar_c3'></block> <block type="sensor_mixgocar_battery_left" m-show='micropython:esp32c3:mixgocar_c3'></block>
--> -->
<block type="sensor_mixgo_pin_near_single" m-show='micropython:esp32c2:mixgo_mini'></block> <block type="sensor_mixgo_pin_near_single" m-show='micropython:esp32c2:mixgo_mini'></block>
<block type="sensor_LTR308" m-show='micropython:esp32c2:mixgo_mini'></block> <block type="sensor_LTR308" m-show='micropython:esp32c2:mixgo_mini'></block>
<block type="sensor_eulerangles" m-show="micropython:esp32c2:mixgo_mini"></block> <block type="sensor_eulerangles" m-show="micropython:esp32c2:mixgo_mini"></block>
@@ -1503,8 +1503,8 @@
</block> </block>
<block type="onboard_RTC_settime_string"> <block type="onboard_RTC_settime_string">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="text"> <shadow type="tuple_input">
<field name="TEXT">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>
@@ -1524,8 +1524,8 @@
</block> </block>
<block type="onboard_RTC_get_timetuple_to_str"> <block type="onboard_RTC_get_timetuple_to_str">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="math_number"> <shadow type="tuple_input">
<field name="NUM">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>

View File

@@ -1493,8 +1493,8 @@
</block> </block>
<block type="onboard_RTC_settime_string"> <block type="onboard_RTC_settime_string">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="text"> <shadow type="tuple_input">
<field name="TEXT">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>
@@ -1514,8 +1514,8 @@
</block> </block>
<block type="onboard_RTC_get_timetuple_to_str"> <block type="onboard_RTC_get_timetuple_to_str">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="math_number"> <shadow type="tuple_input">
<field name="NUM">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>

View File

@@ -1459,8 +1459,8 @@
</block> </block>
<block type="onboard_RTC_settime_string"> <block type="onboard_RTC_settime_string">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="text"> <shadow type="tuple_input">
<field name="TEXT">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>
@@ -1480,8 +1480,8 @@
</block> </block>
<block type="onboard_RTC_get_timetuple_to_str"> <block type="onboard_RTC_get_timetuple_to_str">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="math_number"> <shadow type="tuple_input">
<field name="NUM">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>

View File

@@ -1513,8 +1513,8 @@
</block> </block>
<block type="onboard_RTC_settime_string"> <block type="onboard_RTC_settime_string">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="text"> <shadow type="tuple_input">
<field name="TEXT">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>
@@ -1534,8 +1534,8 @@
</block> </block>
<block type="onboard_RTC_get_timetuple_to_str"> <block type="onboard_RTC_get_timetuple_to_str">
<value name="CONTENT"> <value name="CONTENT">
<shadow type="math_number"> <shadow type="tuple_input">
<field name="NUM">2023,1,1,12,0,0</field> <field name="TUPLE">2023,1,1,12,0,0</field>
</shadow> </shadow>
</value> </value>
</block> </block>

View File

@@ -720,3 +720,14 @@ export const tuple_totuple = {
this.setTooltip(Blockly.Msg.MIXLY_PYTHON_TOOLTIP_TOTUPLE); this.setTooltip(Blockly.Msg.MIXLY_PYTHON_TOOLTIP_TOTUPLE);
} }
}; };
export const tuple_input = {
init: function () {
this.setColour(TUPLE_HUE);
this.appendDummyInput("")
.appendField('(')
.appendField(new Blockly.FieldTextInput('0,0,0'),"CONTENT")
.appendField(')');
this.setOutput(true);
}
};

View File

@@ -290,3 +290,9 @@ export const tuple_totuple = function (_, generator) {
var str = generator.valueToCode(this, 'VAR', generator.ORDER_ATOMIC) || '0' var str = generator.valueToCode(this, 'VAR', generator.ORDER_ATOMIC) || '0'
return ['tuple(' + str + ')', generator.ORDER_ATOMIC]; return ['tuple(' + str + ')', generator.ORDER_ATOMIC];
} }
export const tuple_input = function (_, generator) {
var text = this.getFieldValue('CONTENT');
var code = '(' + text + ')';
return [code, generator.ORDER_ATOMIC];
}