mini增加网络请求和板载显示绘制指针

This commit is contained in:
Irene-Maxine
2024-09-20 23:18:24 +08:00
parent fbbf82d4a4
commit 61ae2048fb
14 changed files with 50609 additions and 126 deletions

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

@@ -1454,3 +1454,19 @@ export const onboard_tft_display_shape_circle = {
}); });
} }
}; };
export const draw_pointer = {
init: function() {
this.setColour(DISPLAY_ONBOARD_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.DRAW_POINTER)
.appendField(Blockly.Msg.DRAW_POINTER_ANGLE);
this.appendValueInput('angle');
this.appendDummyInput()
.appendField('°');
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.DRAW_POINTER_TOOLTIP);
}
};

View File

@@ -123,59 +123,6 @@ export const network_wifi_connect = {
} }
}; };
export const urequests_wifi_connect = {
init: function () {
this.setColour(NETWORK_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_UREQUESTS_CONNECT_WIFI);
this.appendValueInput('WIFINAME')
.setCheck(String)
.appendField(Blockly.Msg.HTML_NAME);
this.appendValueInput('PASSWORD')
.setCheck(String)
.appendField(Blockly.Msg.HTML_PASSWORD);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.MIXLY_ESP32_IOT_WIFI_CONNECT_TOOLTIP);
}
};
export const urequests_wifi_url = {
init: function () {
this.setColour(NETWORK_HUE);
this.appendValueInput('URL')
.setCheck(String)
.appendField('URL');
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip(Blockly.Msg.MIXLY_UREQUESTS_URL_TOOLTIP);
}
};
export const urequests_connect_url = {
init: function () {
this.setColour(NETWORK_HUE);
this.appendValueInput('url')
.appendField(Blockly.Msg.MIXLY_ESP32_CONNECT_URL_TOOLTIP);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.MIXLY_ESP32_UREQUESTS_URL_TOOLTIP);
}
};
export const urequests_response = {
init: function () {
this.setColour(NETWORK_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ESP32_URL_REPONSE);
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip(Blockly.Msg.MIXLY_ESP32_URL_REPONSE_TOOLTIP);
}
};
export const network_get_connect = { export const network_get_connect = {
init: function () { init: function () {
this.setColour(NETWORK_HUE); this.setColour(NETWORK_HUE);
@@ -565,3 +512,62 @@ export const ntptime_address = {
this.setOutput(true); this.setOutput(true);
} }
}; };
const COMMUNICATE_HUE = '#3288dd';
export const requests_get2 = {
init: function() {
this.setColour(COMMUNICATE_HUE);
this.appendValueInput("URL")
.appendField(Blockly.Msg.DISPLAY_IMAGE_LET2)
.setCheck(String);
this.appendDummyInput("")
.appendField(Blockly.Msg.blockpy_CONDUCT)
.appendField(new Blockly.FieldDropdown([["get", "get"], ["head", "head"], ["delete", "delete"]]), 'TYPE')
.appendField(Blockly.Msg.blockpy_REQUESTS)
.appendField(Blockly.Msg.MIXPY_REQUESTS_GET_RESULT)
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip("");
},
};
export const requests_post = {
init: function() {
this.setColour(COMMUNICATE_HUE);
this.appendValueInput("URL")
.appendField(Blockly.Msg.DISPLAY_IMAGE_LET2)
.setCheck(String);
this.appendDummyInput("")
.appendField(Blockly.Msg.blockpy_CONDUCT)
.appendField(new Blockly.FieldDropdown([["post", "post"], ["put", "put"], ["patch", "patch"]]), 'TYPE')
.appendField(Blockly.Msg.blockpy_REQUESTS)
this.appendValueInput("data")
.appendField(Blockly.Msg.blockpy_REQUESTS+Blockly.Msg.OLED_STRING)
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXPY_REQUESTS_GET_RESULT)
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip("");
},
};
export const requests_attribute2 = {
init: function() {
this.appendValueInput('VAL')
var attr =
[[Blockly.Msg.blockpy_REQUESTS_GET_ATTR_TEXT, 'text'],
[Blockly.Msg.blockpy_REQUESTS_GET_ATTR_JSON,'json()'],
[Blockly.Msg.blockpy_REQUESTS_GET_ATTR_STATUS_CODE, 'status_code'],
[Blockly.Msg.blockpy_REQUESTS_GET_ATTR_CONTENT, 'content']
,[Blockly.Msg.MIXPY_TEXT_ENCODE, 'encoding']];
this.setColour(COMMUNICATE_HUE);
this.appendDummyInput("")
.appendField(Blockly.Msg.MIXLY_MICROBIT_JS_GET)
.appendField(new Blockly.FieldDropdown(attr), 'ATTR')
this.setInputsInline(true);
this.setOutput(true, String);
}
};

View File

@@ -914,3 +914,11 @@ export const onboard_tft_display_shape_circle = function (block, generator) {
} }
return code; return code;
} }
export const draw_pointer = function(_, generator) {
var version = Boards.getSelectedBoardKey().split(':')[2]
generator.definitions_['import_'+version+'_onboard_matrix'] = "from "+version+" import onboard_matrix";
var angle = generator.valueToCode(this, 'angle', generator.ORDER_ASSIGNMENT);
var code = "onboard_matrix.pointern(angle=" + angle + ")\n";
return code;
}

View File

@@ -230,29 +230,30 @@ export const ntptime_address = function (_, generator) {
return [code, generator.ORDER_ATOMIC]; return [code, generator.ORDER_ATOMIC];
} }
export const urequests_wifi_connect = function (_, generator) { export const requests_get2 = function(_, generator) {
generator.definitions_['import_urequests'] = "import urequests"; generator.definitions_['import_urequests'] = "import urequests";
var username = generator.valueToCode(this, 'WIFINAME', generator.ORDER_ATOMIC); var dropdown_type = this.getFieldValue('TYPE');
var password = generator.valueToCode(this, 'PASSWORD', generator.ORDER_ATOMIC); var str =generator.valueToCode(this, 'URL', generator.ORDER_ATOMIC) ;
var code = 'wifi.connect(' + username + ',' + password + ')\n'; var code= 'urequests.'+dropdown_type+'(' + str + ')';
return code;
}
export const urequests_wifi_url = function (_, generator) {
generator.definitions_['import_urequests'] = "import urequests";
var url = generator.valueToCode(this, 'URL', generator.ORDER_ATOMIC);
var code = url;
return [code,generator.ORDER_ATOMIC]; return [code,generator.ORDER_ATOMIC];
}
export const urequests_connect_url = function (_, generator) { };
generator.definitions_['import_urequests'] = "import urequests";
var url = generator.valueToCode(this, 'url', generator.ORDER_ATOMIC);
return 'response=urequests.get('+url+')\n';
}
export const urequests_response = function (_, generator) { export const requests_attribute2 = function(_, generator) {
generator.definitions_['import_urequests'] = "import urequests"; generator.definitions_['import_urequests'] = "import urequests";
var code = 'res=response.text'; var varName = generator.valueToCode(this, 'VAL', generator.ORDER_ASSIGNMENT) || '0';
var attr = this.getFieldValue('ATTR');
var code=varName+"." + attr;
return [code,generator.ORDER_ATOMIC]; return [code,generator.ORDER_ATOMIC];
} };
export const requests_post = function(_, generator) {
generator.definitions_['import_urequests'] = "import urequests";
var dropdown_type = this.getFieldValue('TYPE');
var str = generator.valueToCode(this, 'URL', generator.ORDER_ATOMIC) ;
var data = generator.valueToCode(this, 'data', generator.ORDER_ATOMIC) ;
var code= 'urequests.'+dropdown_type+'(' + str +',data='+data+ ')';
return [code,generator.ORDER_ATOMIC];
};

View File

@@ -350,3 +350,11 @@ div.blocklyToolboxDiv > div.blocklyToolboxContents > div:nth-child(12) > div.blo
background:url('../../../../common/media/mark/factory4.png') no-repeat; background:url('../../../../common/media/mark/factory4.png') no-repeat;
background-size: 100% auto; background-size: 100% auto;
} }
#catCommunicate.blocklyTreeRow > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
background:url('../../../../common/media/mark/requests.png') no-repeat;
background-size: 100% auto;
}
#catCommunicate.blocklyTreeRow.blocklyTreeSelected > div.blocklyTreeRowContentContainer > span.blocklyTreeIcon{
background:url('../../../../common/media/mark/requests2.png') no-repeat;
background-size: 100% auto;
}

View File

@@ -1855,17 +1855,21 @@
</block> </block>
<block type="display_bright_screen"> <block type="display_bright_screen">
<value name="x"> <value name="x">
<shadow type="math_number"> <shadow type="math_number">
<field name="NUM">0.5</field> <field name="NUM">0.5</field>
</shadow> </shadow>
</value> </value>
</block> </block>
<block type="display_get_screen_pixel"> <block type="display_get_screen_pixel"></block>
</block>
<block type="display_clear"></block> <block type="display_clear"></block>
<block type="draw_pointer">
<value name="angle">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
</block>
</category> </category>
<category id="catME_GO" colour="100" m-show='micropython:esp32c2:mixgo_mini'> <category id="catME_GO" colour="100" m-show='micropython:esp32c2:mixgo_mini'>
@@ -6494,37 +6498,44 @@
</shadow> </shadow>
</value> </value>
</block> </block>
<block type="urequests_wifi_connect"> </category>
<value name="WIFINAME"> <category id="catCommunicate" colour="#3288dd">
<shadow type="text"> <block type="variables_set">
<field name="TEXT">wifi-name</field> <field name="VAR">response</field>
</shadow> <value name="VALUE">
</value> <block type="requests_get2">
<value name="PASSWORD">
<shadow type="text">
<field name="TEXT">wifi-password</field>
</shadow>
</value>
</block>
<block type="urequests_wifi_url">
<value name="URL"> <value name="URL">
<shadow type="text"> <shadow type="text">
<field name="TEXT">url</field> <field name="TEXT">http://mixio.mixly.cn</field>
</shadow> </shadow>
</value> </value>
</block> </block>
<block type="urequests_connect_url"> </value>
<value name="url"> </block>
<block type="urequests_wifi_url"> <block type="variables_set">
<field name="VAR">response</field>
<value name="VALUE">
<block type="requests_post">
<value name="URL"> <value name="URL">
<shadow type="text"> <shadow type="text">
<field name="TEXT">url</field> <field name="TEXT">http://mixio.mixly.cn</field>
</shadow>
</value>
<value name="data">
<shadow type="text">
<field name="TEXT"></field>
</shadow> </shadow>
</value> </value>
</block> </block>
</value> </value>
</block> </block>
<block type="urequests_response"></block> <block type="requests_attribute2">
<value name="VAL">
<shadow type="variables_get">
<field name="VAR">response</field>
</shadow>
</value>
</block>
</category> </category>
<category id="catFactory" name="Factory" colour="#777777"> <category id="catFactory" name="Factory" colour="#777777">

View File

@@ -3630,12 +3630,6 @@ En.MIXLY_DUTY_RATIO = "value,frequency";
En.MIXLY_OP_GARBAGE_COLLECT = "operate garbage collection"; En.MIXLY_OP_GARBAGE_COLLECT = "operate garbage collection";
En.MIXLY_GET_MEM_ALLOC = "get the allocated memory(Bytes)"; En.MIXLY_GET_MEM_ALLOC = "get the allocated memory(Bytes)";
En.MIXLY_GET_MEM_FREE = "get the free memory (Bytes)"; En.MIXLY_GET_MEM_FREE = "get the free memory (Bytes)";
En.MIXLY_ESP32_UREQUESTS_CONNECT_WIFI = "connect to wifi network";
En.MIXLY_UREQUESTS_URL_TOOLTIP = "the url used to initiate a network request";
En.MIXLY_ESP32_CONNECT_URL_TOOLTIP = "initiate a network request";
En.MIXLY_ESP32_UREQUESTS_URL_TOOLTIP = "initiate a network request through the API URL";
En.MIXLY_ESP32_URL_REPONSE = "API return data";
En.MIXLY_ESP32_URL_REPONSE_TOOLTIP = "get the data returned by the API";
En.MIXLY_GET_UNIQUE_IDEN = "Obtain the unique identifier of the main control board"; En.MIXLY_GET_UNIQUE_IDEN = "Obtain the unique identifier of the main control board";
En.MIXLY_KEYBOARD_INPUT = "keyboard input"; En.MIXLY_KEYBOARD_INPUT = "keyboard input";
En.MIXLY_SPECIAL_KEY = "special key"; En.MIXLY_SPECIAL_KEY = "special key";
@@ -3664,4 +3658,8 @@ En.GENERALKEY_CONTAINER_TOOLTIP = "Add, remove, or rearrange sections to reconfi
En.GENERALKEY_CREATE_EMPTY_TITLE = "Empty key combinations"; En.GENERALKEY_CREATE_EMPTY_TITLE = "Empty key combinations";
En.GENERALKEY_CREATE_WITH_INPUT_WITH = "combinate the normal keys"; 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"; En.GENERALKEY_TUPLE_CREATE_TOOLTIP = "combinate the keys as a tuple, and up to 3 keys can be combined";
En.DRAW_POINTER = "drawn pointer";
En.DRAW_POINTER_ANGLE = "angle(0~359)";
En.DRAW_POINTER_TOOLTIP = "The range of drawing pointer angles is 0~359°";
En.blockpy_REQUESTS_GET_ATTR_JSON = 'Response content JSON deserialization';
})(); })();

View File

@@ -3778,12 +3778,6 @@ ZhHans.MIXLY_DUTY_RATIO = "(值,频率)";
ZhHans.MIXLY_OP_GARBAGE_COLLECT = "运行垃圾回收"; ZhHans.MIXLY_OP_GARBAGE_COLLECT = "运行垃圾回收";
ZhHans.MIXLY_GET_MEM_ALLOC = "获取已使用内存容量Bytes"; ZhHans.MIXLY_GET_MEM_ALLOC = "获取已使用内存容量Bytes";
ZhHans.MIXLY_GET_MEM_FREE = "获取未使用内存容量Bytes"; ZhHans.MIXLY_GET_MEM_FREE = "获取未使用内存容量Bytes";
ZhHans.MIXLY_ESP32_UREQUESTS_CONNECT_WIFI = "连接Wi-Fi网络";
ZhHans.MIXLY_UREQUESTS_URL_TOOLTIP = "用于发起网络请求的URL";
ZhHans.MIXLY_ESP32_CONNECT_URL_TOOLTIP = "发起网络请求";
ZhHans.MIXLY_ESP32_UREQUESTS_URL_TOOLTIP = "通过API的URL发起网络请求";
ZhHans.MIXLY_ESP32_URL_REPONSE = "API返回数据";
ZhHans.MIXLY_ESP32_URL_REPONSE_TOOLTIP = "获得API返回的数据";
ZhHans.MIXLY_GET_UNIQUE_IDEN = "获取主控板的唯一标识"; ZhHans.MIXLY_GET_UNIQUE_IDEN = "获取主控板的唯一标识";
ZhHans.MIXLY_KEYBOARD_INPUT = "键盘输入"; ZhHans.MIXLY_KEYBOARD_INPUT = "键盘输入";
ZhHans.MIXLY_SPECIAL_KEY = "特殊按键"; ZhHans.MIXLY_SPECIAL_KEY = "特殊按键";
@@ -3812,4 +3806,8 @@ ZhHans.GENERALKEY_CONTAINER_TOOLTIP = "增加、删除或重新排列各部分
ZhHans.GENERALKEY_CREATE_EMPTY_TITLE = "空按键组合"; ZhHans.GENERALKEY_CREATE_EMPTY_TITLE = "空按键组合";
ZhHans.GENERALKEY_CREATE_WITH_INPUT_WITH = "组合普通按键为"; ZhHans.GENERALKEY_CREATE_WITH_INPUT_WITH = "组合普通按键为";
ZhHans.GENERALKEY_TUPLE_CREATE_TOOLTIP = "组合按键为元组最多可组合3个按键"; ZhHans.GENERALKEY_TUPLE_CREATE_TOOLTIP = "组合按键为元组最多可组合3个按键";
ZhHans.DRAW_POINTER = "绘制指针";
ZhHans.DRAW_POINTER_ANGLE = "角度(0~359)";
ZhHans.DRAW_POINTER_TOOLTIP = "绘制指针角度的范围为 0~359°";
ZhHans.blockpy_REQUESTS_GET_ATTR_JSON = '响应内容json反序列化';
})(); })();

View File

@@ -3633,12 +3633,6 @@ ZhHant.MIXLY_DUTY_RATIO = "(值,頻率)";
ZhHant.MIXLY_OP_GARBAGE_COLLECT = "運行垃圾回收"; ZhHant.MIXLY_OP_GARBAGE_COLLECT = "運行垃圾回收";
ZhHant.MIXLY_GET_MEM_ALLOC = "獲取已使用内存容量Bytes"; ZhHant.MIXLY_GET_MEM_ALLOC = "獲取已使用内存容量Bytes";
ZhHant.MIXLY_GET_MEM_FREE = "獲取未使用内存容量Bytes"; ZhHant.MIXLY_GET_MEM_FREE = "獲取未使用内存容量Bytes";
ZhHant.MIXLY_ESP32_UREQUESTS_CONNECT_WIFI = "連接Wi-Fi網絡";
ZhHant.MIXLY_UREQUESTS_URL_TOOLTIP = "用於發起網絡請求的URL";
ZhHant.MIXLY_ESP32_CONNECT_URL_TOOLTIP = "發起網絡請求";
ZhHant.MIXLY_ESP32_UREQUESTS_URL_TOOLTIP = "通過API的URL發起網絡請求";
ZhHant.MIXLY_ESP32_URL_REPONSE = "API返回數據";
ZhHant.MIXLY_ESP32_URL_REPONSE_TOOLTIP = "獲得API返回的數據";
ZhHant.MIXLY_GET_UNIQUE_IDEN = "獲取主控板的唯一標識"; ZhHant.MIXLY_GET_UNIQUE_IDEN = "獲取主控板的唯一標識";
ZhHant.MIXLY_KEYBOARD_INPUT = "鍵盤輸入"; ZhHant.MIXLY_KEYBOARD_INPUT = "鍵盤輸入";
ZhHant.MIXLY_SPECIAL_KEY = "特殊按鍵"; ZhHant.MIXLY_SPECIAL_KEY = "特殊按鍵";
@@ -3667,4 +3661,8 @@ ZhHant.GENERALKEY_CONTAINER_TOOLTIP = "增加、刪除或重新排列各部分
ZhHant.GENERALKEY_CREATE_EMPTY_TITLE = "空按鍵組合"; ZhHant.GENERALKEY_CREATE_EMPTY_TITLE = "空按鍵組合";
ZhHant.GENERALKEY_CREATE_WITH_INPUT_WITH = "組合普通按鍵為"; ZhHant.GENERALKEY_CREATE_WITH_INPUT_WITH = "組合普通按鍵為";
ZhHant.GENERALKEY_TUPLE_CREATE_TOOLTIP = "組合按鍵為元組最多可組合3個按鍵"; ZhHant.GENERALKEY_TUPLE_CREATE_TOOLTIP = "組合按鍵為元組最多可組合3個按鍵";
ZhHant.DRAW_POINTER = "繪製指針";
ZhHant.DRAW_POINTER_ANGLE = "角度(0~359)";
ZhHant.DRAW_POINTER_TOOLTIP = "繪製指針角度的範圍為 0~359°";
ZhHant.blockpy_REQUESTS_GET_ATTR_JSON = '響應内容json反序列化';
})(); })();