diff --git a/boards/default_src/micropython/blocks/actuator_onboard.js b/boards/default_src/micropython/blocks/actuator_onboard.js index ba4e63d6..224018ae 100644 --- a/boards/default_src/micropython/blocks/actuator_onboard.js +++ b/boards/default_src/micropython/blocks/actuator_onboard.js @@ -1838,3 +1838,16 @@ export const record_audio = { this.setInputsInline(true); } }; + +export const set_music_volume ={ + init: function () { + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendValueInput('percent') + .appendField(Blockly.Msg.MIXLY_MUSIC_VOLUME_SET); + this.appendDummyInput() + .appendField('%'); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setInputsInline(true); + } +}; \ No newline at end of file diff --git a/boards/default_src/micropython/blocks/network.js b/boards/default_src/micropython/blocks/network.js index 88ff44cf..e59ef096 100644 --- a/boards/default_src/micropython/blocks/network.js +++ b/boards/default_src/micropython/blocks/network.js @@ -195,6 +195,9 @@ export const network_ap_connect = { this.appendValueInput('essid') .setCheck(String) .appendField(Blockly.Msg.MIXLY_NETWORK_WIFI_ESSID); + this.appendValueInput('password') + .setCheck(String) + .appendField(Blockly.Msg.MIXLY_NETWORK_WIFI_ESSID); this.appendValueInput('channel') .setCheck(Number) .appendField(Blockly.Msg.MIXLY_NETWORK_WIFI_CHANNEL); diff --git a/boards/default_src/micropython/blocks/system.js b/boards/default_src/micropython/blocks/system.js index d8fa8e35..94f9de74 100644 --- a/boards/default_src/micropython/blocks/system.js +++ b/boards/default_src/micropython/blocks/system.js @@ -133,6 +133,9 @@ export const timer = { } }; +/** + * @deprecated To be removed in the future + */ export const system_timer = { init: function () { this.setColour(SYSTEM_HUE); @@ -176,6 +179,9 @@ export const system_ticks_diff = { } }; +/** + * @deprecated To be removed in the future + */ export const system_timer_init = { init: function () { this.setColour(SYSTEM_HUE); @@ -190,6 +196,35 @@ export const system_timer_init = { } }; +export const set_system_timer = { + init: function () { + this.setColour(SYSTEM_HUE); + this.appendValueInput('VAR') + .appendField("Timer") + .setCheck("var") + .appendField(Blockly.Msg.MIXLY_SETUP); + this.appendValueInput("PIN") + .appendField("ID") + .setCheck(Number); + this.appendValueInput("period") + .setAlign(Blockly.inputs.Align.RIGHT) + .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_PERIOD_MIL) + .setCheck(Number); + this.appendDummyInput("") + .appendField(Blockly.Msg.MIXLY_mSecond) + .appendField(Blockly.Msg.MIXLY_MODE) + .appendField(new Blockly.FieldDropdown([ + [Blockly.Msg.MIXLY_PYTHON_ONE_SHOT, "ONE_SHOT"], + [Blockly.Msg.MIXLY_PYTHON_PERIODIC, "PERIODIC"] + ]), "mode"); + this.appendValueInput('callback') + .appendField(Blockly.Msg.MIXLY_DO) + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setTooltip(Blockly.Msg.MIXLY_ESP32_SYSTEM_TIMER_TOOLTIP); + } +}; + export const system_wdt_init = { init: function () { this.setColour(SYSTEM_HUE); diff --git a/boards/default_src/micropython/generators/actuator_onboard.js b/boards/default_src/micropython/generators/actuator_onboard.js index f5e956bf..f9a305c1 100644 --- a/boards/default_src/micropython/generators/actuator_onboard.js +++ b/boards/default_src/micropython/generators/actuator_onboard.js @@ -790,4 +790,12 @@ export const record_audio = function (_,generator){ var t = generator.valueToCode(this, 'time', generator.ORDER_ATOMIC); var code = 'onboard_bot.mic_pga('+str+','+ t +')\n'; return code; +} + +export const set_music_volume = function (_,generator){ + var version = Boards.getSelectedBoardKey().split(':')[2] + generator.definitions_['import_' + version + '_onboard_music'] = 'from ' + version + ' import onboard_music'; + var p = generator.valueToCode(this, 'percent', generator.ORDER_ATOMIC); + var code = 'onboard_music.volume('+p+')\n'; + return code; } \ No newline at end of file diff --git a/boards/default_src/micropython/generators/network.js b/boards/default_src/micropython/generators/network.js index 5e7c0a54..217b095b 100644 --- a/boards/default_src/micropython/generators/network.js +++ b/boards/default_src/micropython/generators/network.js @@ -77,8 +77,9 @@ export const network_ap_connect = function (_, generator) { // generator.setups_['class_wlan'] ='ap = network.WLAN(network.AP_IF)\n'+'ap.active(True)\n'; var varName = generator.valueToCode(this, 'VAR', generator.ORDER_ATOMIC); var essid = generator.valueToCode(this, 'essid', generator.ORDER_ATOMIC); + var pw = generator.valueToCode(this, 'password', generator.ORDER_ATOMIC); var channel = generator.valueToCode(this, 'channel', generator.ORDER_ATOMIC); - return "" + varName + ".config(essid = " + essid + ", channel=" + channel + ")\n"; + return "" + varName + ".config(essid = " + essid + ", channel=" + channel + ",password="+ pw +")\n"; } export const network_scan = function (_, generator) { diff --git a/boards/default_src/micropython/generators/system.js b/boards/default_src/micropython/generators/system.js index 5c28b2a6..de7dd76b 100644 --- a/boards/default_src/micropython/generators/system.js +++ b/boards/default_src/micropython/generators/system.js @@ -135,6 +135,37 @@ export const timer = function (_, generator) { return code; } + +export const set_system_timer = function (_, generator) { + generator.definitions_['import_machine'] = 'import machine'; + var v = generator.valueToCode(this, "VAR", generator.ORDER_NONE) || "None"; + var i = generator.valueToCode(this, "ID", generator.ORDER_NONE) || "None"; + var period = generator.valueToCode(this, "period", generator.ORDER_NONE) || "0"; + var mode = this.getFieldValue('mode'); + var callback = generator.valueToCode(this, "callback", generator.ORDER_NONE) || "None"; + var code = v + " = machine.Timer("+ i +",period = " + period + ", mode=machine.Timer." + mode + ", callback=" + callback + ")\n"; + return code; +} + +export const system_ticks_diff = function (_, generator) { + generator.definitions_['import_time'] = 'import time'; + var end = generator.valueToCode(this, "END", generator.ORDER_NONE) || "0"; + var start = generator.valueToCode(this, "START", generator.ORDER_NONE) || "0"; + var code = "time.ticks_diff(" + end + ", " + start + ")"; + return [code, generator.ORDER_ATOMIC]; +} +/** + * @deprecated To be removed in the future + */ +export const system_timer_init = function (_, generator) { + var v = generator.valueToCode(this, 'SUB', generator.ORDER_ATOMIC); + generator.definitions_['import_machine'] = 'import machine'; + var code = v + ' = machine.Timer(0)\n'; + return code; +} +/** + * @deprecated To be removed in the future + */ export const system_timer = function (_, generator) { generator.definitions_['import_machine'] = 'import machine'; var v = generator.valueToCode(this, "VAR", generator.ORDER_NONE) || "None"; @@ -147,22 +178,6 @@ export const system_timer = function (_, generator) { var code = v + ".init(period = " + period + ", mode=machine.Timer." + mode + ", callback=" + callback + ")\n"; return code; } - -export const system_ticks_diff = function (_, generator) { - generator.definitions_['import_time'] = 'import time'; - var end = generator.valueToCode(this, "END", generator.ORDER_NONE) || "0"; - var start = generator.valueToCode(this, "START", generator.ORDER_NONE) || "0"; - var code = "time.ticks_diff(" + end + ", " + start + ")"; - return [code, generator.ORDER_ATOMIC]; -} - -export const system_timer_init = function (_, generator) { - var v = generator.valueToCode(this, 'SUB', generator.ORDER_ATOMIC); - generator.definitions_['import_machine'] = 'import machine'; - var code = v + ' = machine.Timer(0)\n'; - return code; -} - export const system_wdt_init = function (_, generator) { generator.definitions_['import_machine'] = 'import machine'; var period = generator.valueToCode(this, "period", generator.ORDER_NONE) || "0"; diff --git a/boards/default_src/micropython_educore/template.xml b/boards/default_src/micropython_educore/template.xml index a687c581..93cfd57c 100644 --- a/boards/default_src/micropython_educore/template.xml +++ b/boards/default_src/micropython_educore/template.xml @@ -6896,6 +6896,11 @@ 127.16.0.8 + + + 123456 + + 1 @@ -6939,6 +6944,11 @@ SmallCabbage + + + 123456 + + 1 diff --git a/boards/default_src/micropython_esp32/blocks/pins.js b/boards/default_src/micropython_esp32/blocks/pins.js index 4a536910..e75a1690 100644 --- a/boards/default_src/micropython_esp32/blocks/pins.js +++ b/boards/default_src/micropython_esp32/blocks/pins.js @@ -398,4 +398,18 @@ export const pins_digital_dot = { .appendField(new Blockly.FieldDropdown(Profile.default.digital_dot), 'PIN'); this.setOutput(true, Number); } +}; + +export const timer_id_pin = { + init: function () { + this.setColour(PINS_HUE); + this.appendDummyInput("") + .appendField(new Blockly.FieldDropdown([ + ["0","0"], + ["1","1"], + ["2","2"], + ["3","3"] + ]), 'PIN'); + this.setOutput(true, Number); + } }; \ No newline at end of file diff --git a/boards/default_src/micropython_esp32/generators/pins.js b/boards/default_src/micropython_esp32/generators/pins.js index 3346a7c4..c5d93981 100644 --- a/boards/default_src/micropython_esp32/generators/pins.js +++ b/boards/default_src/micropython_esp32/generators/pins.js @@ -36,4 +36,5 @@ export const pins_tone_notes = pins_digital; export const pins_radio_power = pins_digital; export const pins_radio_datarate = pins_digital; export const pins_one_more = pins_digital; -export const pins_digital_dot = pins_digital; \ No newline at end of file +export const pins_digital_dot = pins_digital; +export const timer_id_pin = pins_digital; \ No newline at end of file diff --git a/boards/default_src/micropython_esp32/template.xml b/boards/default_src/micropython_esp32/template.xml index deba6299..31e611b5 100644 --- a/boards/default_src/micropython_esp32/template.xml +++ b/boards/default_src/micropython_esp32/template.xml @@ -237,17 +237,14 @@ - - + + tim - - - - - tim + + @@ -257,7 +254,7 @@ - tim_callback + tim_6 @@ -265,7 +262,7 @@ - tim_callback + tim_6 @@ -1712,6 +1709,13 @@ + + + + 100 + + + @@ -6768,6 +6772,11 @@ 127.16.0.8 + + + 123456 + + 1 @@ -6811,6 +6820,11 @@ SmallCabbage + + + 123456 + + 1 diff --git a/boards/default_src/micropython_esp32c2/blocks/pins.js b/boards/default_src/micropython_esp32c2/blocks/pins.js index c0563193..b9f34710 100644 --- a/boards/default_src/micropython_esp32c2/blocks/pins.js +++ b/boards/default_src/micropython_esp32c2/blocks/pins.js @@ -398,4 +398,15 @@ export const pins_digital_dot = { .appendField(new Blockly.FieldDropdown(Profile.default.digital_dot), 'PIN'); this.setOutput(true, Number); } +}; + +export const timer_id_pin = { + init: function () { + this.setColour(PINS_HUE); + this.appendDummyInput("") + .appendField(new Blockly.FieldDropdown([ + ["0","0"] + ]), 'PIN'); + this.setOutput(true, Number); + } }; \ No newline at end of file diff --git a/boards/default_src/micropython_esp32c2/generators/pins.js b/boards/default_src/micropython_esp32c2/generators/pins.js index d3ec0760..f86ff386 100644 --- a/boards/default_src/micropython_esp32c2/generators/pins.js +++ b/boards/default_src/micropython_esp32c2/generators/pins.js @@ -46,4 +46,5 @@ export const pins_tone_notes = pins_digital; export const pins_radio_power = pins_digital; export const pins_radio_datarate = pins_digital; export const pins_one_more = pins_digital; -export const pins_digital_dot = pins_digital; \ No newline at end of file +export const pins_digital_dot = pins_digital; +export const timer_id_pin = pins_digital; \ No newline at end of file diff --git a/boards/default_src/micropython_esp32c2/template.xml b/boards/default_src/micropython_esp32c2/template.xml index a878de7c..f5a0bb55 100644 --- a/boards/default_src/micropython_esp32c2/template.xml +++ b/boards/default_src/micropython_esp32c2/template.xml @@ -212,17 +212,14 @@ - - + + tim - - - - - tim + + @@ -232,7 +229,7 @@ - tim_callback + tim_6 @@ -1776,6 +1773,13 @@ + + + + 100 + + + + + + + 100 + + + @@ -6688,6 +6699,11 @@ 127.16.0.8 + + + 123456 + + 1 @@ -6731,6 +6747,11 @@ SmallCabbage + + + 123456 + + 1 diff --git a/boards/default_src/micropython_esp32c3/blocks/pins.js b/boards/default_src/micropython_esp32c3/blocks/pins.js index d662dc1a..666fc5f5 100644 --- a/boards/default_src/micropython_esp32c3/blocks/pins.js +++ b/boards/default_src/micropython_esp32c3/blocks/pins.js @@ -398,4 +398,16 @@ export const pins_digital_dot = { .appendField(new Blockly.FieldDropdown(Profile.default.digital_dot), 'PIN'); this.setOutput(true, Number); } +}; + +export const timer_id_pin = { + init: function () { + this.setColour(PINS_HUE); + this.appendDummyInput("") + .appendField(new Blockly.FieldDropdown([ + ["0","0"], + ["1","1"] + ]), 'PIN'); + this.setOutput(true, Number); + } }; \ No newline at end of file diff --git a/boards/default_src/micropython_esp32c3/generators/pins.js b/boards/default_src/micropython_esp32c3/generators/pins.js index d3ec0760..f86ff386 100644 --- a/boards/default_src/micropython_esp32c3/generators/pins.js +++ b/boards/default_src/micropython_esp32c3/generators/pins.js @@ -46,4 +46,5 @@ export const pins_tone_notes = pins_digital; export const pins_radio_power = pins_digital; export const pins_radio_datarate = pins_digital; export const pins_one_more = pins_digital; -export const pins_digital_dot = pins_digital; \ No newline at end of file +export const pins_digital_dot = pins_digital; +export const timer_id_pin = pins_digital; \ No newline at end of file diff --git a/boards/default_src/micropython_esp32c3/template.xml b/boards/default_src/micropython_esp32c3/template.xml index c8f06683..3ac0cf2d 100644 --- a/boards/default_src/micropython_esp32c3/template.xml +++ b/boards/default_src/micropython_esp32c3/template.xml @@ -212,17 +212,14 @@ - - + + tim - - - - - tim + + @@ -232,7 +229,7 @@ - tim_callback + tim_6 @@ -1700,6 +1697,13 @@ + + + + 100 + + + @@ -1823,8 +1827,13 @@ - - + + + + 100 + + + + + + + 100 + + + @@ -6575,6 +6591,11 @@ 127.16.0.8 + + + 123456 + + 1 @@ -6618,6 +6639,11 @@ SmallCabbage + + + 123456 + + 1 diff --git a/boards/default_src/micropython_esp32s2/blocks/pins.js b/boards/default_src/micropython_esp32s2/blocks/pins.js index d662dc1a..d46361c9 100644 --- a/boards/default_src/micropython_esp32s2/blocks/pins.js +++ b/boards/default_src/micropython_esp32s2/blocks/pins.js @@ -398,4 +398,18 @@ export const pins_digital_dot = { .appendField(new Blockly.FieldDropdown(Profile.default.digital_dot), 'PIN'); this.setOutput(true, Number); } +}; + +export const timer_id_pin = { + init: function () { + this.setColour(PINS_HUE); + this.appendDummyInput("") + .appendField(new Blockly.FieldDropdown([ + ["0","0"], + ["1","1"], + ["2","2"], + ["3","3"] + ]), 'PIN'); + this.setOutput(true, Number); + } }; \ No newline at end of file diff --git a/boards/default_src/micropython_esp32s2/generators/pins.js b/boards/default_src/micropython_esp32s2/generators/pins.js index 09b566e5..959f3cca 100644 --- a/boards/default_src/micropython_esp32s2/generators/pins.js +++ b/boards/default_src/micropython_esp32s2/generators/pins.js @@ -46,4 +46,5 @@ export const pins_tone_notes = pins_digital; export const pins_radio_power = pins_digital; export const pins_radio_datarate = pins_digital; export const pins_one_more = pins_digital; -export const pins_digital_dot = pins_digital; \ No newline at end of file +export const pins_digital_dot = pins_digital; +export const timer_id_pin = pins_digital; \ No newline at end of file diff --git a/boards/default_src/micropython_esp32s2/template.xml b/boards/default_src/micropython_esp32s2/template.xml index f2f6f3c6..94ccb6c7 100644 --- a/boards/default_src/micropython_esp32s2/template.xml +++ b/boards/default_src/micropython_esp32s2/template.xml @@ -237,17 +237,14 @@ - - + + tim - - - - - tim + + @@ -257,7 +254,7 @@ - tim_callback + tim_6 @@ -1651,6 +1648,13 @@ + + + + 100 + + + @@ -4268,6 +4272,13 @@ + + + + 100 + + + @@ -6304,6 +6315,11 @@ 127.16.0.8 + + + 123456 + + 1 @@ -6347,6 +6363,11 @@ SmallCabbage + + + 123456 + + 1 diff --git a/boards/default_src/micropython_esp32s3/blocks/pins.js b/boards/default_src/micropython_esp32s3/blocks/pins.js index d662dc1a..d46361c9 100644 --- a/boards/default_src/micropython_esp32s3/blocks/pins.js +++ b/boards/default_src/micropython_esp32s3/blocks/pins.js @@ -398,4 +398,18 @@ export const pins_digital_dot = { .appendField(new Blockly.FieldDropdown(Profile.default.digital_dot), 'PIN'); this.setOutput(true, Number); } +}; + +export const timer_id_pin = { + init: function () { + this.setColour(PINS_HUE); + this.appendDummyInput("") + .appendField(new Blockly.FieldDropdown([ + ["0","0"], + ["1","1"], + ["2","2"], + ["3","3"] + ]), 'PIN'); + this.setOutput(true, Number); + } }; \ No newline at end of file diff --git a/boards/default_src/micropython_esp32s3/generators/pins.js b/boards/default_src/micropython_esp32s3/generators/pins.js index c6ac1ec2..3fd1b85c 100644 --- a/boards/default_src/micropython_esp32s3/generators/pins.js +++ b/boards/default_src/micropython_esp32s3/generators/pins.js @@ -46,6 +46,7 @@ export const pins_radio_power = pins_digital; export const pins_radio_datarate = pins_digital; export const pins_one_more = pins_digital; export const pins_digital_dot = pins_digital; +export const timer_id_pin = pins_digital; export const pins_builtinimg = function (_, generator) { const PIN_VALUE = this.getFieldValue('PIN'); diff --git a/boards/default_src/micropython_esp32s3/template.xml b/boards/default_src/micropython_esp32s3/template.xml index e9b608bb..2547d3d6 100644 --- a/boards/default_src/micropython_esp32s3/template.xml +++ b/boards/default_src/micropython_esp32s3/template.xml @@ -237,17 +237,14 @@ - - + + tim - - - - - tim + + @@ -257,7 +254,7 @@ - tim_callback + tim_6 @@ -1826,6 +1823,13 @@ + + + + 100 + + + @@ -4997,6 +5001,20 @@ + + + + 100 + + + + + + + 100 + + + @@ -7058,6 +7076,11 @@ 127.16.0.8 + + + 123456 + + 1 @@ -7101,6 +7124,11 @@ SmallCabbage + + + 123456 + + 1 diff --git a/boards/default_src/micropython_robot/template.xml b/boards/default_src/micropython_robot/template.xml index dc3ad3c7..64fc8c46 100644 --- a/boards/default_src/micropython_robot/template.xml +++ b/boards/default_src/micropython_robot/template.xml @@ -5354,6 +5354,11 @@ 127.16.0.8 + + + 123456 + + 1 @@ -5397,6 +5402,11 @@ SmallCabbage + + + 123456 + + 1 diff --git a/common/msg/blockly/en.js b/common/msg/blockly/en.js index 9a8095b7..7bbec795 100644 --- a/common/msg/blockly/en.js +++ b/common/msg/blockly/en.js @@ -3973,4 +3973,5 @@ En.MIXLY_JPG_base64_CODE= "JPG's base64 code"; En.MIXLY_IMAGE_OF_FILE = 'code data of image file'; En.MIXLY_ENABLE_STATUS = 'enable status'; En.MIXLY_MICROPHONE_AMPLIFICATION = 'microphone amplification'; +En.MIXLY_MUSIC_VOLUME_SET = 'set music volume'; })(); diff --git a/common/msg/blockly/zh-hans.js b/common/msg/blockly/zh-hans.js index 71b51b53..c5176fa0 100644 --- a/common/msg/blockly/zh-hans.js +++ b/common/msg/blockly/zh-hans.js @@ -3691,7 +3691,7 @@ ZhHans.MIXBOT = '超霸大师'; ZhHans.MICROPYTHON_BITBOT_SHUTDOWN_TOOLTIP = '仅电池供电下,将关机断电。USB供电下,只是关闭电机输出。'; ZhHans.ONBOARD_TFT_DISPLAY_SHAPE_RECT_MESSAGE0 = '绘制 %1 矩形 %2 x %3 y %4 宽 %5 高 %6 颜色 %7 实时刷新: %8'; ZhHans.ONBOARD_TFT_DISPLAY_HVLINE_MESSAGE0 = '绘制 %1 线 %2 x %3 y %4 长度%5 颜色 %6 实时刷新: %7'; -ZhHans.mpython_display_line_MESSAGE0 ='绘制 线条%1 x1%2 y1 %3 到 x2 %4 y2 %5 颜色 %6 实时刷新: %7'; +ZhHans.mpython_display_line_MESSAGE0 ='绘制 线条%1 x1%2 y1 %3 到 x2 %4 y2 %5 颜色 %6'; ZhHans.MIXLY_TOUCH_SLIDE = "滑动触摸"; ZhHans.MIXLY_TOUCH_SLIDE_TOOLTIP = "触摸值,默认接近0,往IO3方向触摸滑动值变大,往IO4方向触摸滑动值变小。"; ZhHans.MIXLY_EXTERN_SONAR = "超声波传感器"; @@ -4132,4 +4132,5 @@ ZhHans.MIXLY_JPG_base64_CODE= 'JPG的base64编码'; ZhHans.MIXLY_IMAGE_OF_FILE = '图像文件编码数据'; ZhHans.MIXLY_ENABLE_STATUS = '使能状态'; ZhHans.MIXLY_MICROPHONE_AMPLIFICATION = '麦克风放大倍数'; +ZhHans.MIXLY_MUSIC_VOLUME_SET = '音量调节'; })(); \ No newline at end of file diff --git a/common/msg/blockly/zh-hant.js b/common/msg/blockly/zh-hant.js index 43bfd21e..a8634fe3 100644 --- a/common/msg/blockly/zh-hant.js +++ b/common/msg/blockly/zh-hant.js @@ -4127,4 +4127,5 @@ ZhHant.MIXLY_JPG_base64_CODE= 'JPG的base64編碼'; ZhHant.MIXLY_IMAGE_OF_FILE = '圖像文件編碼數據'; ZhHant.MIXLY_ENABLE_STATUS = '使能狀態'; ZhHant.MIXLY_MICROPHONE_AMPLIFICATION = '麥克風放大倍數'; +ZhHant.MIXLY_MUSIC_VOLUME_SET = '音量調節'; })();