|
@@ -267,12 +267,12 @@ sys.path.append("/root/")`
|
|
|
os.system("echo PG6 5 > /sys/kernel/debug/sunxi_pinctrl/function")
|
|
|
os.system("echo PG7 5 > /sys/kernel/debug/sunxi_pinctrl/function")
|
|
|
`)
|
|
|
- Blockly.Python.addVariable(`pinMode${value_name}`,`pinMode("${value_name}","0")`,true)
|
|
|
+ Blockly.Python.addVariable(`pinMode${value_name}`, `pinMode("${value_name}","0")`, true)
|
|
|
code = `digitalRead("${value_name}")`
|
|
|
}
|
|
|
- else if(value_name == 7 || value_name == 8 || value_name == 13) {
|
|
|
+ else if (value_name == 7 || value_name == 8 || value_name == 13) {
|
|
|
Blockly.Python.definitions_['v831_import_CocoPi_BUTTON'] = `from CocoPi import BUTTON `;
|
|
|
- Blockly.Python.addFunction("getBUTTONNum",`def getBUTTONNum(data):
|
|
|
+ Blockly.Python.addFunction("getBUTTONNum", `def getBUTTONNum(data):
|
|
|
if data:
|
|
|
return 1
|
|
|
else:
|
|
@@ -280,7 +280,7 @@ sys.path.append("/root/")`
|
|
|
`)
|
|
|
Blockly.Python.addVariable('_Math_gpio_' + value_name, `_Math_gpio_${value_name} = BUTTON(${value_name})`, true);
|
|
|
code = `getBUTTONNum(_Math_gpio_${value_name}.is_pressed())`;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
let gpioNum = value_name - 21
|
|
|
Blockly.Python.definitions_['v831_import_CocoPi_extGpio'] = `from CocoPi import extGpio`;
|
|
|
Blockly.Python.definitions_['v831_import_CocoPi_extGpio_init'] = `InputGpio = extGpio()`;
|
|
@@ -498,8 +498,8 @@ sys.path.append("/root/")`
|
|
|
Blockly.Python.addVariable('MATHOUT' + value_name, `MATHOUT${value_name} = multiFuncGpio(${value_name - 1},3)`, true);
|
|
|
code = `MATHOUT${value_name}.digitalWrite(${high_low})
|
|
|
`
|
|
|
- } else if (value_name == "PG6" || value_name == "PG7" ||value_name == "PC0" || value_name == "PC1" || value_name == "PC2" || value_name == "PC3") {
|
|
|
-
|
|
|
+ } else if (value_name == "PG6" || value_name == "PG7" || value_name == "PC0" || value_name == "PC1" || value_name == "PC2" || value_name == "PC3") {
|
|
|
+
|
|
|
Blockly.Python.addFunction("pinMode", `def pinMode(pin,mode):
|
|
|
os.system(f"echo {pin} {mode} > /sys/kernel/debug/sunxi_pinctrl/function")
|
|
|
`)
|
|
@@ -528,7 +528,7 @@ sys.path.append("/root/")`
|
|
|
os.system("echo PG6 5 > /sys/kernel/debug/sunxi_pinctrl/function")
|
|
|
os.system("echo PG7 5 > /sys/kernel/debug/sunxi_pinctrl/function")
|
|
|
`)
|
|
|
- Blockly.Python.addVariable(`pinModeOut${value_name}`,`pinMode("${value_name}","1")`,false)
|
|
|
+ Blockly.Python.addVariable(`pinModeOut${value_name}`, `pinMode("${value_name}","1")`, false)
|
|
|
code = `digitalWrite("${value_name}","${high_low}")
|
|
|
`
|
|
|
} else {
|
|
@@ -3138,7 +3138,7 @@ Blockly.Python['esp32_main_controller_wifi_enable_hotspot_mode'] = function (blo
|
|
|
};
|
|
|
|
|
|
Blockly.Blocks["V831_code_scanning_network"] = {
|
|
|
- init:function(){
|
|
|
+ init: function () {
|
|
|
this.appendDummyInput()
|
|
|
.appendField(Blockly.Msg.V831_code_scanning_network);
|
|
|
this.setInputsInline(false);
|
|
@@ -3149,7 +3149,7 @@ Blockly.Blocks["V831_code_scanning_network"] = {
|
|
|
this.setHelpUrl("");
|
|
|
}
|
|
|
}
|
|
|
-Blockly.Python["V831_code_scanning_network"] = function(block){
|
|
|
+Blockly.Python["V831_code_scanning_network"] = function (block) {
|
|
|
Blockly.Python.definitions_['v831_import_mjpg'] = `from maix import mjpg`
|
|
|
Blockly.Python.definitions_['v831_import_utils'] = `from maix import utils`
|
|
|
Blockly.Python.definitions_['v831_import_base64'] = `import base64`
|
|
@@ -3203,11 +3203,11 @@ def wifi_is_content():
|
|
|
`
|
|
|
let language = localStorage.getItem('handPyLanguage')
|
|
|
let str = ""
|
|
|
- if(language == "zh-hant"){
|
|
|
+ if (language == "zh-hant") {
|
|
|
str = "請掃描平臺Wi-Fi二維碼聯網"
|
|
|
- }else if(language =="en"){
|
|
|
+ } else if (language == "en") {
|
|
|
str = "Please scan the platform Wi-Fi QR code for networking"
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
str = "请扫描平台Wi-Fi二维码联网"
|
|
|
}
|
|
|
Blockly.Python.definitions_[`v831_display_show_canvas`] = `def v831_display_show_canvas(displayShow,_canvas_x,_canvas_y):
|
|
@@ -3232,7 +3232,7 @@ def wifi_is_content():
|
|
|
display.show(displayShowCanvas)
|
|
|
|
|
|
`
|
|
|
- Blockly.Python.addFunction("codeScanningNetwork",`def codeScanningNetwork():
|
|
|
+ Blockly.Python.addFunction("codeScanningNetwork", `def codeScanningNetwork():
|
|
|
if wifi_is_content():
|
|
|
stateNetwork = 1
|
|
|
else:
|
|
@@ -3263,7 +3263,7 @@ def wifi_is_content():
|
|
|
elif stateNetwork == 1:
|
|
|
break
|
|
|
`
|
|
|
-)
|
|
|
+ )
|
|
|
var code = `image.load_freetype("/root/preset/fonts/simhei.ttf")
|
|
|
codeScanningNetwork()\n`
|
|
|
return code;
|
|
@@ -6143,6 +6143,57 @@ Blockly.Python['esp32_network_http_get'] = function (block) {
|
|
|
return code;
|
|
|
};
|
|
|
|
|
|
+Blockly.Blocks['cocopi_email_send'] = {
|
|
|
+ init: function () {
|
|
|
+ this.appendDummyInput()
|
|
|
+ .appendField(Blockly.Msg.send_email_title);
|
|
|
+ this.appendValueInput("email")
|
|
|
+ .setCheck(null)
|
|
|
+ .appendField(Blockly.Msg.send_email_to);
|
|
|
+ this.appendValueInput("email_content")
|
|
|
+ .setCheck(null)
|
|
|
+ .appendField(Blockly.Msg.send_email_content);
|
|
|
+ this.setOutput(true);
|
|
|
+ // this.setPreviousStatement(true, null);
|
|
|
+ // this.setNextStatement(true, null);
|
|
|
+ this.setColour(NETWORK_BLOCK_COLOR);
|
|
|
+ this.setTooltip(Blockly.Msg.Esp32_Network_Http_Get_TOOLTIP);
|
|
|
+ this.setHelpUrl("");
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+Blockly.Python['cocopi_email_send'] = function (block) {
|
|
|
+ var Email = Blockly.Python.valueToCode(block, 'email', Blockly.Python.ORDER_ATOMIC);
|
|
|
+ var EmailContent = Blockly.Python.valueToCode(block, 'email_content', Blockly.Python.ORDER_ATOMIC);
|
|
|
+
|
|
|
+ Blockly.Python.definitions_['v831_import_requests'] = `import requests`
|
|
|
+ Blockly.Python.definitions_['v831_import_json'] = `import json`;
|
|
|
+ // TODO: Assemble Python into code variable.
|
|
|
+ Blockly.Python.addFunction(`send_email`, `def send_email(email,content):
|
|
|
+ params = {
|
|
|
+ "email": email,
|
|
|
+ "content": content,
|
|
|
+ "subject":"训练平台",
|
|
|
+ "content_type":'plain'
|
|
|
+ }
|
|
|
+ emailURL = "https://traininguser-api.cocorobo.cn/sendEmail"
|
|
|
+ try:
|
|
|
+ r = requests.post(emailURL,json=params)
|
|
|
+ print(json.loads(r.text))
|
|
|
+ if json.loads(r.text)["FunctionResponse"] == "发送成功":
|
|
|
+ return True
|
|
|
+ else:
|
|
|
+ return False
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return False
|
|
|
+ `)
|
|
|
+
|
|
|
+ var code = `send_email(${Email},${EmailContent})`;
|
|
|
+ return [code, Blockly.Python.ORDER_NONE];
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
Blockly.Blocks['esp32_network_http_post'] = {
|
|
|
init: function () {
|
|
@@ -7347,7 +7398,7 @@ Blockly.Python['turtle_clear'] = function (block) {
|
|
|
Blockly.Blocks['v831_room_water_temperature'] = {
|
|
|
init: function () {
|
|
|
this.appendDummyInput("")
|
|
|
- .appendField("IIC"+Blockly.Msg.room_water_temperature_text);
|
|
|
+ .appendField("IIC" + Blockly.Msg.room_water_temperature_text);
|
|
|
|
|
|
// this.setInputsInline(true);
|
|
|
this.setOutput(true);
|
|
@@ -7519,11 +7570,11 @@ Blockly.Python['v831_room_water_temperature'] = function (block) {
|
|
|
|
|
|
ds = Ds18b20("/dev/ttyS1")
|
|
|
`;
|
|
|
-// Blockly.Python.addFunction("getRoomWaterTemperature", `def getRoomWaterTemperature():
|
|
|
-// serial_num = ds.get_single_rom_code()
|
|
|
-// temperature = ds.get_temperature()
|
|
|
-// return temperature
|
|
|
-// `, true)
|
|
|
+ // Blockly.Python.addFunction("getRoomWaterTemperature", `def getRoomWaterTemperature():
|
|
|
+ // serial_num = ds.get_single_rom_code()
|
|
|
+ // temperature = ds.get_temperature()
|
|
|
+ // return temperature
|
|
|
+ // `, true)
|
|
|
var code = 'ds.get_temperature()';
|
|
|
return [code, Blockly.Python.ORDER_ATOMIC];
|
|
|
};
|
|
@@ -7532,10 +7583,10 @@ Blockly.Blocks['v831_set_real_time_clock'] = {
|
|
|
init: function () {
|
|
|
let nowDate = new Date();
|
|
|
this.appendDummyInput()
|
|
|
- .appendField("IIC"+Blockly.Msg.time_set_current_date_title)
|
|
|
+ .appendField("IIC" + Blockly.Msg.time_set_current_date_title)
|
|
|
.appendField(new Blockly.FieldTextInput(nowDate.getFullYear()), "year")
|
|
|
.appendField(Blockly.Msg.time_get_current_date_y)
|
|
|
- .appendField(new Blockly.FieldTextInput(nowDate.getMonth()+1), "month")
|
|
|
+ .appendField(new Blockly.FieldTextInput(nowDate.getMonth() + 1), "month")
|
|
|
.appendField(Blockly.Msg.time_get_current_date_m)
|
|
|
.appendField(new Blockly.FieldTextInput(nowDate.getDate()), "day")
|
|
|
.appendField(Blockly.Msg.time_get_current_date_d)
|
|
@@ -7790,7 +7841,7 @@ rtc.setSeconds(${seconds})\n`;
|
|
|
Blockly.Blocks['v831_real_time_clock'] = {
|
|
|
init: function () {
|
|
|
this.appendDummyInput()
|
|
|
- .appendField("IIC"+Blockly.Msg.RTC_getDateTime)
|
|
|
+ .appendField("IIC" + Blockly.Msg.RTC_getDateTime)
|
|
|
.appendField(new Blockly.FieldDropdown([
|
|
|
[Blockly.Msg.time_get_current_date_y, "getYear"],
|
|
|
[Blockly.Msg.time_get_current_date_m, "getMonth"],
|