Update: 更新micropython板卡

This commit is contained in:
王立帮
2024-09-13 08:56:36 +08:00
7 changed files with 256 additions and 63 deletions

View File

@@ -104,7 +104,6 @@ export const actuator_mixgo_zero_led_color = {
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_LCD_SETCOLOR)
.appendField(new Blockly.FieldDropdown([
[Blockly.Msg.MIXLY_LIGHT_OFF, "0"],
[Blockly.Msg.MIXLY_LIGHT_RED, "1"],
[Blockly.Msg.MIXLY_LIGHT_GREEN, "2"],
[Blockly.Msg.MIXLY_LIGHT_BLUE, "3"],
@@ -1005,10 +1004,8 @@ export const analog_keyboard_input = {
this.setColour(ACTUATOR_ONBOARD_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_KEYBOARD_INPUT);
this.appendValueInput('special')
.appendField(Blockly.Msg.MIXLY_SPECIAL_KEY);
this.appendValueInput('general')
.appendField(Blockly.Msg.MIXLY_GENERAL_KEY);
this.appendValueInput('special');
this.appendValueInput('general');
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_RELEASE)
.appendField(new Blockly.FieldDropdown([
@@ -1026,6 +1023,7 @@ export const special_key = {
init: function () {
this.setColour(ACTUATOR_ONBOARD_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_SPECIAL_KEY)
.appendField(new Blockly.FieldDropdown([
[Blockly.Msg.MIXLY_SPECIAL_KEY0,"0"],
[Blockly.Msg.MIXLY_SPECIAL_KEY1, "1"],
@@ -1045,6 +1043,7 @@ export const general_key = {
init: function () {
this.setColour(ACTUATOR_ONBOARD_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_GENERAL_KEY)
.appendField(new Blockly.FieldDropdown([
[Blockly.Msg.MIXLY_SPECIAL_KEY0,"0"],
['A', "0x04"],
@@ -1073,32 +1072,32 @@ export const general_key = {
['X', "0x1B"],
['Y', "0x1C"],
['Z', "0x1D"],
['ONE', "0x1E"],
['TWO', "0x1F"],
['THREE', "0x20"],
['FOUR', "0x21"],
['FIVE', "0x22"],
['SIX', "0x23"],
['SEVEN', "0x24"],
['EIGHT', "0x25"],
['NINE', "0x26"],
['ZERO', "0x27"],
['1', "0x1E"],
['2', "0x1F"],
['3', "0x20"],
['4', "0x21"],
['5', "0x22"],
['6', "0x23"],
['7', "0x24"],
['8', "0x25"],
['9', "0x26"],
['0', "0x27"],
['ENTER', "0x28"],
['ESC', "0x29"],
['BACKSPACE', "0x2A"],
['TAB', "0x2B"],
['SPACE', "0x2C"],
['MINUS', "0x2D"],
['EQUAL', "0x2E"],
['LEFT_BRACE', "0x2F"],
['RIGHT_BRACE', "0x30"],
['BACKSLASH', "0x31"],
['SEMICOLON', "0x33"],
['QUOTE', "0x34"],
['TILDE', "0x35"],
['COMMA', "0x36"],
['PERIOD', "0x37"],
['SLASH', "0x38"],
['-', "0x2D"],
['=', "0x2E"],
['{', "0x2F"],
['}', "0x30"],
['\\', "0x31"],
[';', "0x33"],
['"', "0x34"],
['`', "0x35"],
[',', "0x36"],
['.', "0x37"],
['/', "0x38"],
['CAPS_LOCK', "0x39"],
['F1', "0x3A"],
['F2', "0x3B"],
@@ -1126,39 +1125,192 @@ export const general_key = {
['DOWN', "0x51"],
['UP', "0x52"],
['NUM_LOCK', "0x53"],
['NUMPAD_SLASH', "0x54"],
['NUMPAD_ASTERISK', "0x55"],
['NUMPAD_MINUS', "0x56"],
['NUMPAD_PLUS', "0x57"],
['NUMPAD_ENTER', "0x58"],
['NUMPAD_1', "0x59"],
['NUMPAD_2', "0x5A"],
['NUMPAD_3', "0x5B"],
['NUMPAD_4', "0x5C"],
['NUMPAD_5', "0x5D"],
['NUMPAD_6', "0x5E"],
['NUMPAD_7', "0x5F"],
['NUMPAD_8', "0x60"],
['NUMPAD_9', "0x61"],
['NUMPAD_0', "0x62"],
['NUMPAD_PERIOD', "0x63"]
['/', "0x54"],
['*', "0x55"],
['-', "0x56"],
['+', "0x57"],
['ENTER', "0x58"],
['1', "0x59"],
['2', "0x5A"],
['3', "0x5B"],
['4', "0x5C"],
['5', "0x5D"],
['6', "0x5E"],
['7', "0x5F"],
['8', "0x60"],
['9', "0x61"],
['0', "0x62"],
['.', "0x63"]
]), 'op')
this.setOutput(true);
}
};
export const general_key_tuple = {
init: function () {
this.setColour(ACTUATOR_ONBOARD_HUE);
this.itemCount_ = 2;
this.updateShape_();
this.setOutput(true);
this.setMutator(new Blockly.icons.MutatorIcon(['generalkey_create_with_item'], this));
this.setTooltip(Blockly.Msg.GENERALKEY_TUPLE_CREATE_TOOLTIP);
},
mutationToDom: function() {
var container = document.createElement('mutation');
container.setAttribute('items', this.itemCount_);
return container;
},
/**
* Parse XML to restore the list inputs.
* @param {!Element} xmlElement XML storage element.
* @this Blockly.Block
*/
domToMutation: function(xmlElement) {
this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
this.updateShape_();
},
/**
* Populate the mutator's dialog with this block's components.
* @param {!Blockly.Workspace} workspace Mutator's workspace.
* @return {!Blockly.Block} Root block in mutator.
* @this Blockly.Block
*/
decompose: function(workspace) {
var containerBlock =
workspace.newBlock('generalkey_container');
containerBlock.initSvg();
var connection = containerBlock.getInput('STACK').connection;
for (var i = 0; i < this.itemCount_; i++) {
var itemBlock = workspace.newBlock('generalkey_create_with_item');
itemBlock.initSvg();
connection.connect(itemBlock.previousConnection);
connection = itemBlock.nextConnection;
}
return containerBlock;
},
/**
* Reconfigure this block based on the mutator dialog's components.
* @param {!Blockly.Block} containerBlock Root block in mutator.
* @this Blockly.Block
*/
compose: function(containerBlock) {
var itemBlock = containerBlock.getInputTargetBlock('STACK');
// Count number of inputs.
var connections = [];
var i = 0;
while (itemBlock) {
connections[i] = itemBlock.valueConnection_;
itemBlock = itemBlock.nextConnection &&
itemBlock.nextConnection.targetBlock();
i++;
}
this.itemCount_ = i;
this.updateShape_();
// Reconnect any child blocks.
for (var i = 0; i < this.itemCount_; i++) {
if (connections[i]) {
this.getInput('ADD' + i).connection.connect(connections[i]);
}
}
},
/**
* Store pointers to any connected child blocks.
* @param {!Blockly.Block} containerBlock Root block in mutator.
* @this Blockly.Block
*/
saveConnections: function(containerBlock) {
var itemBlock = containerBlock.getInputTargetBlock('STACK');
var i = 0;
while (itemBlock) {
var input = this.getInput('ADD' + i);
itemBlock.valueConnection_ = input && input.connection.targetConnection;
i++;
itemBlock = itemBlock.nextConnection &&
itemBlock.nextConnection.targetBlock();
}
},
/**
* Modify this block to have the correct number of inputs.
* @private
* @this Blockly.Block
*/
updateShape_: function() {
// Delete everything.
if (this.getInput('EMPTY')) {
this.removeInput('EMPTY');
} else {
var i = 0;
while (this.getInput('ADD' + i)) {
this.removeInput('ADD' + i);
i++;
}
}
// Rebuild block.
if (this.itemCount_ == 0) {
this.appendDummyInput('EMPTY')
.appendField(Blockly.Msg.GENERALKEY_CREATE_EMPTY_TITLE);
} else {
for (var i = 0; i < this.itemCount_; i++) {
var input = this.appendValueInput('ADD' + i);
if (i == 0) {
input.appendField(Blockly.Msg.GENERALKEY_CREATE_WITH_INPUT_WITH);
}
}
}
},
getVars: function() {
return [this.getFieldValue('VAR')];
},
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setTitleValue(newName, 'VAR');
}
}
};
export const generalkey_container = {
/**
* Mutator block for list container.
* @this Blockly.Block
*/
init: function() {
this.setColour(ACTUATOR_EXTERN_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_GENERAL_KEY);
this.appendStatementInput('STACK');
this.setTooltip(Blockly.Msg.GENERALKEY_CONTAINER_TOOLTIP);
this.contextMenu = false;
}
};
export const generalkey_create_with_item = {
/**
* Mutator bolck for adding items.
* @this Blockly.Block
*/
init: function() {
this.setColour(ACTUATOR_EXTERN_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.blockpy_SET_VARIABLES_NAME);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.TUPLE_CREATE_WITH_ITEM_TOOLTIP);
this.contextMenu = false;
}
};
export const analog_mouse_input = {
init: function () {
this.setColour(ACTUATOR_ONBOARD_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.ANALOG+Blockly.Msg.MIXLY_MOUSE_INPUT);
this.appendValueInput('key')
.appendField(Blockly.Msg.MIXLY_MOUSE_KEYS);
this.appendValueInput('key');
this.appendValueInput('x')
.appendField(Blockly.Msg.MIXLY_X_Y_CHANGES+'x:');
.appendField(Blockly.Msg.MIXLY_X_CHANGES);
this.appendValueInput('y')
.appendField('y:');
.appendField(Blockly.Msg.MIXLY_Y_CHANGES);
this.appendValueInput('wheel')
.appendField(Blockly.Msg.MIXLY_WHEEL_CHANGES);
this.appendDummyInput()
@@ -1178,6 +1330,7 @@ export const mouse_key = {
init: function () {
this.setColour(ACTUATOR_ONBOARD_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MOUSE_KEYS)
.appendField(new Blockly.FieldDropdown([
[Blockly.Msg.MIXLY_SPECIAL_KEY0,"0"],
[Blockly.Msg.MIXLY_MOUSE_LEFT_KEY, "1"],

View File

@@ -450,7 +450,7 @@ export const analog_keyboard_input = function (_, generator) {
var ge = generator.valueToCode(this, 'general', generator.ORDER_ATOMIC);
var re = this.getFieldValue('release');
generator.definitions_['import_' + version + '_onboard_bot'] = 'from ' + version + ' import onboard_bot';
var code = "hid_keyboard(special="+sp+",general="+ge+",release="+re+")\n";
var code = "hid_keyboard("+sp+","+ge+","+re+")\n";
return code;
}
@@ -488,4 +488,22 @@ export const analog_keyboard_str = function (_, generator) {
generator.definitions_['import_' + version + '_onboard_bot'] = 'from ' + version + ' import onboard_bot';
var code = "onboard_bot.hid_keyboard_str("+str+",delay="+t+")\n";
return code;
}
}
export const general_key_tuple = function(_, generator) {
// Create a list with any number of elements of any type.
var dropdown_type = this.getFieldValue('TYPE');
var code = new Array(this.itemCount_);
var default_value = '0';
for (var n = 0; n < this.itemCount_; n++) {
code[n] = generator.valueToCode(this, 'ADD' + n,
generator.ORDER_NONE) || default_value;
}
if (this.itemCount_!=1){
var code = '(' + code.join(', ') + ')';}
else {
var code = '(' + code.join(', ') + ',)';}
return [code, generator.ORDER_ATOMIC];
};

View File

@@ -228,7 +228,6 @@ class BOT035(FrameBuffer):
"""Reset SPK, PWM, HID registers to default state"""
self._i2c.writeto_mem(_BOT035_ADDRESS, _BOT035_SPK, b'\x0A\x00\x00\x00\x20\x4E\x64\x64')
if self._version: self._i2c.writeto_mem(_BOT035_ADDRESS, _BOT035_KB, bytes(9))
def get_brightness(self):
return self._brightness

View File

@@ -1703,18 +1703,25 @@
</block>
<block type="analog_keyboard_input" m-show="micropython:esp32c2:mixgo_mini">
<value name="special">
<shadow type="special_key">
</shadow>
<block type="special_key">
</block>
</value>
<value name="general">
<shadow type="general_key">
</shadow>
<block type="general_key">
</block>
</value>
</block>
<block type="general_key_tuple" m-show="micropython:esp32c2:mixgo_mini">
<value name="general">
<block type="general_key">
</block>
</value>
</block>
<block type="analog_mouse_input" m-show="micropython:esp32c2:mixgo_mini">
<value name="key">
<shadow type="mouse_key">
</shadow>
<block type="mouse_key">
</block>
</value>
<value name="x">
<shadow type="math_number">
@@ -1737,6 +1744,7 @@
</value>
<value name="time">
<shadow type="math_number">
<field name="NUM">10</field>
</shadow>
</value>
</block>

View File

@@ -3641,7 +3641,7 @@ En.MIXLY_KEYBOARD_INPUT = "keyboard input";
En.MIXLY_SPECIAL_KEY = "special key";
En.MIXLY_GENERAL_KEY = "general key";
En.MIXLY_RELEASE = "automatic release";
En.MIXLY_SPECIAL_KEY0 = "no operation (release)";
En.MIXLY_SPECIAL_KEY0 = "no operation";
En.MIXLY_SPECIAL_KEY1 = "Left Control key";
En.MIXLY_SPECIAL_KEY2 = "Left Shift key";
En.MIXLY_SPECIAL_KEY4 = "Left Alt key";
@@ -3652,11 +3652,16 @@ En.MIXLY_SPECIAL_KEY64 = "Right Alt key";
En.MIXLY_SPECIAL_KEY128 = "Right Windows key";
En.MIXLY_MOUSE_INPUT = "mouse input";
En.MIXLY_MOUSE_KEYS = "mouse button";
En.MIXLY_X_Y_CHANGES = "change in the x and y axes ";
En.MIXLY_X_CHANGES = "change in the x axe ";
En.MIXLY_Y_CHANGES = "change in the y axe ";
En.MIXLY_MOUSE_LEFT_KEY = "left key";
En.MIXLY_MOUSE_RIGHT_KEY = "right key";
En.MIXLY_MOUSE_MID_KEY = "middle key";
En.MIXLY_WHEEL_CHANGES = "roller change amount";
En.MIXLY_STR_PRINT = "character input";
En.MIXLY_STR_PRINT_TIME_DELAY = "per character interval";
En.GENERALKEY_CONTAINER_TOOLTIP = "Add, remove, or rearrange sections to reconfigure the key combination.";
En.GENERALKEY_CREATE_EMPTY_TITLE = "Empty key combinations";
En.GENERALKEY_CREATE_WITH_INPUT_WITH = "combinate the normal keys";
En.GENERALKEY_TUPLE_CREATE_TOOLTIP = "combinate the keys as a tuple, and up to 3 keys can be combined";
})();

View File

@@ -3789,7 +3789,7 @@ ZhHans.MIXLY_KEYBOARD_INPUT = "键盘输入";
ZhHans.MIXLY_SPECIAL_KEY = "特殊按键";
ZhHans.MIXLY_GENERAL_KEY = "普通按键";
ZhHans.MIXLY_RELEASE = "自动释放";
ZhHans.MIXLY_SPECIAL_KEY0 = "无操作(释放)";
ZhHans.MIXLY_SPECIAL_KEY0 = "无操作";
ZhHans.MIXLY_SPECIAL_KEY1 = "左Control键";
ZhHans.MIXLY_SPECIAL_KEY2 = "左Shift键";
ZhHans.MIXLY_SPECIAL_KEY4 = "左Alt键";
@@ -3800,11 +3800,16 @@ ZhHans.MIXLY_SPECIAL_KEY64 = "右Alt键";
ZhHans.MIXLY_SPECIAL_KEY128 = "右Windows键";
ZhHans.MIXLY_MOUSE_INPUT = "鼠标输入";
ZhHans.MIXLY_MOUSE_KEYS = "鼠标按键";
ZhHans.MIXLY_X_Y_CHANGES = "x、y轴改变量 ";
ZhHans.MIXLY_X_CHANGES = "x轴移动 ";
ZhHans.MIXLY_Y_CHANGES = "y轴移动 ";
ZhHans.MIXLY_MOUSE_LEFT_KEY = "左键";
ZhHans.MIXLY_MOUSE_RIGHT_KEY = "右键";
ZhHans.MIXLY_MOUSE_MID_KEY = "中键";
ZhHans.MIXLY_WHEEL_CHANGES = "滚轮改变量";
ZhHans.MIXLY_WHEEL_CHANGES = "滚轮滚动";
ZhHans.MIXLY_STR_PRINT = "字符输入";
ZhHans.MIXLY_STR_PRINT_TIME_DELAY = "每个字符间隔";
ZhHans.GENERALKEY_CONTAINER_TOOLTIP = "增加、删除或重新排列各部分以此重新配置这个按键组合。";
ZhHans.GENERALKEY_CREATE_EMPTY_TITLE = "空按键组合";
ZhHans.GENERALKEY_CREATE_WITH_INPUT_WITH = "组合普通按键为";
ZhHans.GENERALKEY_TUPLE_CREATE_TOOLTIP = "组合按键为元组最多可组合3个按键";
})();

View File

@@ -3644,7 +3644,7 @@ ZhHant.MIXLY_KEYBOARD_INPUT = "鍵盤輸入";
ZhHant.MIXLY_SPECIAL_KEY = "特殊按鍵";
ZhHant.MIXLY_GENERAL_KEY = "普通按鍵";
ZhHant.MIXLY_RELEASE = "自動釋放";
ZhHant.MIXLY_SPECIAL_KEY0 = "無操作(釋放)";
ZhHant.MIXLY_SPECIAL_KEY0 = "無操作";
ZhHant.MIXLY_SPECIAL_KEY1 = "左Control鍵";
ZhHant.MIXLY_SPECIAL_KEY2 = "左Shift鍵";
ZhHant.MIXLY_SPECIAL_KEY4 = "左Alt鍵";
@@ -3655,11 +3655,16 @@ ZhHant.MIXLY_SPECIAL_KEY64 = "右Alt鍵";
ZhHant.MIXLY_SPECIAL_KEY128 = "右Windows鍵";
ZhHant.MIXLY_MOUSE_INPUT = "鼠標輸入";
ZhHant.MIXLY_MOUSE_KEYS = "鼠標按鍵";
ZhHant.MIXLY_X_Y_CHANGES = "x、y軸改變量 ";
ZhHant.MIXLY_X_CHANGES = "x軸移動 ";
ZhHant.MIXLY_Y_CHANGES = "y軸移動 ";
ZhHant.MIXLY_MOUSE_LEFT_KEY = "左鍵";
ZhHant.MIXLY_MOUSE_RIGHT_KEY = "右鍵";
ZhHant.MIXLY_MOUSE_MID_KEY = "中鍵";
ZhHant.MIXLY_WHEEL_CHANGES = "滾輪改變量";
ZhHant.MIXLY_WHEEL_CHANGES = "滾輪滑動";
ZhHant.MIXLY_STR_PRINT = "字符輸入";
ZhHant.MIXLY_STR_PRINT_TIME_DELAY = "每個字符間隔";
ZhHant.GENERALKEY_CONTAINER_TOOLTIP = "增加、刪除或重新排列各部分以此重新配置這個按鍵組合。";
ZhHant.GENERALKEY_CREATE_EMPTY_TITLE = "空按鍵組合";
ZhHant.GENERALKEY_CREATE_WITH_INPUT_WITH = "組合普通按鍵為";
ZhHant.GENERALKEY_TUPLE_CREATE_TOOLTIP = "組合按鍵為元組最多可組合3個按鍵";
})();