时间元组转字符串

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -719,4 +719,15 @@ export const tuple_totuple = {
this.setOutput(true);
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

@@ -289,4 +289,10 @@ export const tuple_get_random_item = function (_, generator) {
export const tuple_totuple = function (_, generator) {
var str = generator.valueToCode(this, 'VAR', generator.ORDER_ATOMIC) || '0'
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];
}