diff --git a/boards/default_src/micropython/blocks/actuator_onboard.js b/boards/default_src/micropython/blocks/actuator_onboard.js index 96ddb451..f79f00c9 100644 --- a/boards/default_src/micropython/blocks/actuator_onboard.js +++ b/boards/default_src/micropython/blocks/actuator_onboard.js @@ -1356,4 +1356,164 @@ export const analog_keyboard_str = { this.setNextStatement(true); this.setInputsInline(true); } -}; \ No newline at end of file +}; + +export const analog_ble_keyboard_init = { + init:function(){ + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.LISTS_SET_INDEX_SET+ Blockly.Msg.MIXLY_BLUETOOTH +Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_KEYBOARD); + this.appendValueInput('kname') + .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_SYSTEM_DEVICE_NAME); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setInputsInline(true); + } +} + +export const ble_keyboard_get_mac = { + init:function(){ + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_GET+Blockly.Msg.MIXLY_BLUETOOTH +Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_KEYBOARD+Blockly.Msg.MIXLY_BELONG+Blockly.Msg.MIXLY_ETHERNET_MAC_ADDRESS); + this.setOutput(true); + this.setInputsInline(true); + } +} + +export const ble_keyboard_connect = { + init:function(){ + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_BLUETOOTH +Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_KEYBOARD+Blockly.Msg.MIXLY_IS_CONNECT); + this.setOutput(true); + this.setInputsInline(true); + } +} + +export const analog_ble_keyboard_input = { + init: function () { + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_BLUETOOTH+Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_KEYBOARD) + .appendField(Blockly.Msg.MIXLY_SEND_KEYBOARD); + this.appendValueInput('special'); + this.appendValueInput('general'); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_RELEASE) + .appendField(new Blockly.FieldDropdown([ + [Blockly.Msg.MICROPYTHON_DISPLAY_YES, "True"], + [Blockly.Msg.MICROPYTHON_DISPLAY_NO, "False"] + ]),'release'); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setInputsInline(true); + this.setTooltip(Blockly.Msg.MIXLY_BLUETOOTH+Blockly.Msg.ANALOG+ Blockly.Msg.MIXLY_KEYBOARD_INPUT); + } +}; + +export const analog_ble_keyboard_str = { + init:function(){ + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_BLUETOOTH+Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_KEYBOARD); + this.appendValueInput('str') + .appendField(Blockly.Msg.MIXLY_SEND_KEYBOARD +Blockly.Msg.MIXLY_STR_PRINT); + this.appendValueInput('time') + .appendField(Blockly.Msg.MIXLY_STR_PRINT_TIME_DELAY); + this.appendDummyInput() + .appendField('ms'); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setInputsInline(true); + } +} + +export const analog_ble_keyboard_send_battery = { + init:function(){ + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_BLUETOOTH+Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_KEYBOARD); + this.appendValueInput('battery') + .appendField(Blockly.Msg.MIXLY_SEND_KEYBOARD+Blockly.Msg.MIXLY_BELONG+Blockly.Msg.MIXLY_BATTERY+Blockly.Msg.LISTS_SET_INDEX_INPUT_TO); + this.appendDummyInput() + .appendField('%'); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setInputsInline(true); + } +} + +export const analog_ble_mouse_init = { + init:function(){ + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.LISTS_SET_INDEX_SET+ Blockly.Msg.MIXLY_BLUETOOTH +Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_MOUSE); + this.appendValueInput('name') + .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_SYSTEM_DEVICE_NAME); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setInputsInline(true); + } +} + +export const ble_mouse_get_mac = { + init:function(){ + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_GET+Blockly.Msg.MIXLY_BLUETOOTH +Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_MOUSE+Blockly.Msg.MIXLY_BELONG+Blockly.Msg.MIXLY_ETHERNET_MAC_ADDRESS); + this.setOutput(true); + this.setInputsInline(true); + } +} + +export const ble_mouse_connect = { + init:function(){ + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_BLUETOOTH +Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_MOUSE+Blockly.Msg.MIXLY_IS_CONNECT); + this.setOutput(true); + this.setInputsInline(true); + } +} + +export const analog_ble_mouse_input = { + init: function () { + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_BLUETOOTH+Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_MOUSE) + .appendField(Blockly.Msg.MIXLY_SEND +Blockly.Msg.MIXLY_MOUSE_INPUT); + this.appendValueInput('key'); + this.appendValueInput('x') + .appendField(Blockly.Msg.MIXLY_X_CHANGES); + this.appendValueInput('y') + .appendField(Blockly.Msg.MIXLY_Y_CHANGES); + this.appendValueInput('wheel') + .appendField(Blockly.Msg.MIXLY_WHEEL_CHANGES); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_RELEASE) + .appendField(new Blockly.FieldDropdown([ + [Blockly.Msg.MICROPYTHON_DISPLAY_YES, "True"], + [Blockly.Msg.MICROPYTHON_DISPLAY_NO, "False"] + ]),'release'); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setInputsInline(true); + this.setTooltip(Blockly.Msg.MIXLY_BLUETOOTH+Blockly.Msg.ANALOG + Blockly.Msg.MIXLY_KEYBOARD_INPUT); + } +}; + +export const analog_ble_mouse_send_battery = { + init:function(){ + this.setColour(ACTUATOR_ONBOARD_HUE); + this.appendDummyInput() + .appendField(Blockly.Msg.MIXLY_BLUETOOTH+Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_MOUSE); + this.appendValueInput('battery') + .appendField(Blockly.Msg.MIXLY_SEND+Blockly.Msg.MIXLY_MOUSE+Blockly.Msg.MIXLY_BELONG+Blockly.Msg.MIXLY_BATTERY+Blockly.Msg.LISTS_SET_INDEX_INPUT_TO); + 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/generators/actuator_onboard.js b/boards/default_src/micropython/generators/actuator_onboard.js index 39b6dcc0..84e7e712 100644 --- a/boards/default_src/micropython/generators/actuator_onboard.js +++ b/boards/default_src/micropython/generators/actuator_onboard.js @@ -505,4 +505,84 @@ export const general_key_tuple = function (_, generator) { } return [code, generator.ORDER_ATOMIC]; -}; \ No newline at end of file +}; + +export const analog_ble_keyboard_init = function(_, generator){ + generator.definitions_['import_ble_keyboard'] = 'from ble_hid_keyboard import Keyboard'; + var kname = generator.valueToCode(this, 'kname', generator.ORDER_ATOMIC) + var code = 'ble_keyboard=Keyboard('+kname+')\n'; + return code; +} + +export const ble_keyboard_get_mac = function(_, generator){ + generator.definitions_['import_ble_keyboard'] = 'from ble_hid_keyboard import Keyboard'; + var code = 'ble_keyboard.mac'; + return[code, generator.ORDER_ATOMIC]; +} + +export const ble_keyboard_connect = function(_, generator){ + generator.definitions_['import_ble_keyboard'] = 'from ble_hid_keyboard import Keyboard'; + var code = 'ble_keyboard.is_connected()'; + return[code, generator.ORDER_ATOMIC]; +} + +export const analog_ble_keyboard_input = function (_, generator) { + var sp = generator.valueToCode(this, 'special', generator.ORDER_ATOMIC); + var ge = generator.valueToCode(this, 'general', generator.ORDER_ATOMIC); + var re = this.getFieldValue('release'); + generator.definitions_['import_ble_keyboard'] = 'from ble_hid_keyboard import Keyboard'; + var code = "ble_keyboard.notify_hid("+sp+","+ge+","+re+")\n"; + return code; +} + +export const analog_ble_keyboard_str = function (_, generator) { + var str = generator.valueToCode(this, 'str', generator.ORDER_ATOMIC); + var t = generator.valueToCode(this, 'time', generator.ORDER_ATOMIC); + generator.definitions_['import_ble_keyboard'] = 'from ble_hid_keyboard import Keyboard'; + var code = "ble_keyboard.notify_str("+str+",delay="+t+")\n"; + return code; +} + +export const analog_ble_keyboard_send_battery = function (_, generator) { + var b = generator.valueToCode(this, 'battery', generator.ORDER_ATOMIC); + generator.definitions_['import_ble_keyboard'] = 'from ble_hid_keyboard import Keyboard'; + var code = "ble_keyboard.notify_battery("+b+")\n"; + return code; +} + +export const analog_ble_mouse_init = function(_, generator){ + generator.definitions_['import_ble_mouse'] = 'from ble_hid_mouse import Mouse'; + var name = generator.valueToCode(this, 'name', generator.ORDER_ATOMIC) + var code = 'ble_mouse=Mouse('+name+')\n'; + return code; +} + +export const ble_mouse_get_mac = function(_, generator){ + generator.definitions_['import_ble_mouse'] = 'from ble_hid_mouse import Mouse'; + var code = 'ble_mouse.mac'; + return[code, generator.ORDER_ATOMIC]; +} + +export const ble_mouse_connect = function(_, generator){ + generator.definitions_['import_ble_mouse'] = 'from ble_hid_mouse import Mouse'; + var code = 'ble_mouse.is_connected()'; + return[code, generator.ORDER_ATOMIC]; +} + +export const analog_ble_mouse_input = function (_, generator) { + var key = generator.valueToCode(this, 'key', generator.ORDER_ATOMIC); + var x = generator.valueToCode(this, 'x', generator.ORDER_ATOMIC); + var y = generator.valueToCode(this, 'y', generator.ORDER_ATOMIC); + var wheel = generator.valueToCode(this, 'wheel', generator.ORDER_ATOMIC); + var re = this.getFieldValue('release'); + generator.definitions_['import_ble_mouse'] = 'from ble_hid_mouse import Mouse'; + var code = "ble_mouse.notify_hid("+key+",("+x+","+y+"),"+wheel+","+re+")\n"; + return code; +} + +export const analog_ble_mouse_send_battery = function (_, generator) { + var b = generator.valueToCode(this, 'battery', generator.ORDER_ATOMIC); + generator.definitions_['import_ble_mouse'] = 'from ble_hid_mouse import Mouse'; + var code = "ble_mouse.notify_battery("+b+")\n"; + return code; +} diff --git a/boards/default_src/micropython_esp32/template.xml b/boards/default_src/micropython_esp32/template.xml index fe5cb506..ccb6bbc2 100644 --- a/boards/default_src/micropython_esp32/template.xml +++ b/boards/default_src/micropython_esp32/template.xml @@ -1704,6 +1704,78 @@ + + + + ble_keyboard + + + + + + + + + + + + + + + + + + + Hello, Mixly! + + + + + 10 + + + + + + + 10 + + + + + + + ble_Mouse + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + diff --git a/boards/default_src/micropython_esp32c2/template.xml b/boards/default_src/micropython_esp32c2/template.xml index c62b6c00..77e05008 100644 --- a/boards/default_src/micropython_esp32c2/template.xml +++ b/boards/default_src/micropython_esp32c2/template.xml @@ -1751,6 +1751,78 @@ + + + + ble_keyboard + + + + + + + + + + + + + + + + + + + Hello, Mixly! + + + + + 10 + + + + + + + 10 + + + + + + + ble_Mouse + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + diff --git a/boards/default_src/micropython_esp32c3/template.xml b/boards/default_src/micropython_esp32c3/template.xml index 85784468..b21c6247 100644 --- a/boards/default_src/micropython_esp32c3/template.xml +++ b/boards/default_src/micropython_esp32c3/template.xml @@ -1697,6 +1697,78 @@ + + + + ble_keyboard + + + + + + + + + + + + + + + + + + + Hello, Mixly! + + + + + 10 + + + + + + + 10 + + + + + + + ble_Mouse + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + diff --git a/boards/default_src/micropython_esp32s3/template.xml b/boards/default_src/micropython_esp32s3/template.xml index 34ab1c09..9f1659e9 100644 --- a/boards/default_src/micropython_esp32s3/template.xml +++ b/boards/default_src/micropython_esp32s3/template.xml @@ -1725,9 +1725,79 @@ + + + + + ble_keyboard + + + + + + + + + + + + + + + + + + + Hello, Mixly! + + + + + 10 + + + + + + + 10 + + + + + + + ble_Mouse + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + - - diff --git a/common/msg/blockly/en.js b/common/msg/blockly/en.js index eeb72eeb..d3bab69a 100644 --- a/common/msg/blockly/en.js +++ b/common/msg/blockly/en.js @@ -3741,4 +3741,11 @@ En.MIXLY_DRAW_POINTER_DU = "(°)"; En.MIXLY_TEMPERATURE_UNIT_ = "(℃)"; En.MIXLY_PRESSURE_UNIT = "(hpa)"; En.MIXLY_PARAMETER_FREE = "all of the information(dictionary type)"; +En.MIXLY_KEYBOARD = "keyboard"; +En.MIXLY_IS_CONNECT = "whether be connected"; +En.MIXLY_SEND_KEYBOARD = "send keyboard"; +En.MIXLY_BATTERY ="battery level"; +En.MIXLY_RANGE_OF_BATTERY = "the range of battery level is 0~100%"; +En.MIXLY_MOUSE = "mouse"; +En.MIXLY_SEND = "send"; })(); \ No newline at end of file diff --git a/common/msg/blockly/zh-hans.js b/common/msg/blockly/zh-hans.js index 7c83654b..1520a17c 100644 --- a/common/msg/blockly/zh-hans.js +++ b/common/msg/blockly/zh-hans.js @@ -3889,4 +3889,11 @@ ZhHans.MIXLY_DRAW_POINTER_DU = "(°)"; ZhHans.MIXLY_TEMPERATURE_UNIT_ = "(℃)"; ZhHans.MIXLY_PRESSURE_UNIT = "(hpa)"; ZhHans.MIXLY_PARAMETER_FREE = "全部信息(字典类型)"; +ZhHans.MIXLY_KEYBOARD = "键盘"; +ZhHans.MIXLY_IS_CONNECT = "是否被设备连接"; +ZhHans.MIXLY_SEND_KEYBOARD = "发送键盘"; +ZhHans.MIXLY_BATTERY ="电池电量"; +ZhHans.MIXLY_RANGE_OF_BATTERY = "电池的电量范围为 0~100%"; +ZhHans.MIXLY_MOUSE = "鼠标"; +ZhHans.MIXLY_SEND = "发送"; })(); \ No newline at end of file diff --git a/common/msg/blockly/zh-hant.js b/common/msg/blockly/zh-hant.js index a616f774..2cd9c4d2 100644 --- a/common/msg/blockly/zh-hant.js +++ b/common/msg/blockly/zh-hant.js @@ -3744,4 +3744,11 @@ ZhHant.MIXLY_DRAW_POINTER_DU = "(°)"; ZhHant.MIXLY_TEMPERATURE_UNIT_ = "(℃)"; ZhHant.MIXLY_PRESSURE_UNIT = "(hpa)"; ZhHant.MIXLY_PARAMETER_FREE = "全部信息(字典類型)"; +ZhHant.MIXLY_KEYBOARD = "鍵盤"; +ZhHant.MIXLY_IS_CONNECT = "是否被設備連接"; +ZhHant.MIXLY_SEND_KEYBOARD = "發送鍵盤"; +ZhHant.MIXLY_BATTERY ="電池電量"; +ZhHant.MIXLY_RANGE_OF_BATTERY = "電池的電量範圍為 0~100%"; +ZhHant.MIXLY_MOUSE = "鼠標"; +ZhHant.MIXLY_SEND = "發送"; })(); \ No newline at end of file