|
@@ -3150,6 +3150,28 @@ Blockly.Blocks["V831_code_scanning_network"] = {
|
|
|
}
|
|
|
}
|
|
|
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`
|
|
|
+ Blockly.Python.definitions_['v831_import_time'] = `import time`
|
|
|
+ Blockly.Python.definitions_['v831_import_display'] = `from maix import display`;
|
|
|
+ Blockly.Python.definitions_['v831_import_image'] = `from maix import image`;
|
|
|
+ Blockly.Python.definitions_['v831_import_camera'] = `from maix import camera`;
|
|
|
+ Blockly.Python.definitions_['lcd_invert_init_new'] = `ScreenOrientation = False
|
|
|
+def lcdRotationNew(inputImg):
|
|
|
+ global SETVFLIP,SETHMIRROT,ScreenOrientation
|
|
|
+ imageRotationBuffer = inputImg.crop(0, 0, 320, 240)
|
|
|
+ if ScreenOrientation:
|
|
|
+ imgRotationAim = image.new(size = (240, 320))
|
|
|
+ rotationAngle = 90
|
|
|
+ GETROTATION = imageRotationBuffer.rotate(+rotationAngle, adjust=1)
|
|
|
+ else:
|
|
|
+ imgRotationAim = image.new(size = (320, 240))
|
|
|
+ GETROTATION = imageRotationBuffer
|
|
|
+
|
|
|
+ GETROTATION = imgRotationAim.draw_image(GETROTATION,0,0,alpha=1)
|
|
|
+ return GETROTATION
|
|
|
+`
|
|
|
Blockly.Python.definitions_['wifi_is_content'] = `
|
|
|
def wifi_is_content():
|
|
|
global getDateNum
|
|
@@ -3188,6 +3210,28 @@ def wifi_is_content():
|
|
|
}else{
|
|
|
str = "请扫描平台Wi-Fi二维码联网"
|
|
|
}
|
|
|
+ Blockly.Python.definitions_[`v831_display_show_canvas`] = `def v831_display_show_canvas(displayShow,_canvas_x,_canvas_y):
|
|
|
+ global ScreenOrientation,cameraSize
|
|
|
+ try:
|
|
|
+ if ScreenOrientation:
|
|
|
+ displayShowCanvas = image.new(size = (240, 320))
|
|
|
+ displayShowCanvas.draw_rectangle(0,0,240,320, color=(0,0,0), thickness=-1)
|
|
|
+ displayShowCanvas.draw_image(displayShow,_canvas_x,_canvas_y,alpha=1)
|
|
|
+ displayShowVER = displayShowCanvas.crop(0,0,240,320)
|
|
|
+ displayShowVER = displayShowVER.rotate(-90, adjust=1)
|
|
|
+ display.show(displayShowVER)
|
|
|
+ else:
|
|
|
+ displayShowCanvas = image.new(size = (320, 240))
|
|
|
+ displayShowCanvas.draw_rectangle(0,0,320,240, color=(0,0,0), thickness=-1)
|
|
|
+ displayShowCanvas.draw_image(displayShow,_canvas_x,_canvas_y,alpha=1)
|
|
|
+ display.show(displayShowCanvas)
|
|
|
+ except:
|
|
|
+ displayShowCanvas = image.new(size = (320, 240))
|
|
|
+ displayShowCanvas.draw_rectangle(0,0,320,240, color=(0,0,0), thickness=-1)
|
|
|
+ displayShowCanvas.draw_image(displayShow,_canvas_x,_canvas_y,alpha=1)
|
|
|
+ display.show(displayShowCanvas)
|
|
|
+
|
|
|
+`
|
|
|
Blockly.Python.addFunction("codeScanningNetwork",`def codeScanningNetwork():
|
|
|
if wifi_is_content():
|
|
|
stateNetwork = 1
|
|
@@ -3196,7 +3240,7 @@ def wifi_is_content():
|
|
|
CODERESULT = ""
|
|
|
while True:
|
|
|
if stateNetwork == 0:
|
|
|
- canvas = getLcdRotation(camera.capture())
|
|
|
+ canvas = lcdRotationNew(camera.capture())
|
|
|
qrCode = canvas.find_qrcodes()
|
|
|
canvas.draw_rectangle(0,0, 0+320,0+ 20, color=(0,0,0), thickness=-1)
|
|
|
canvas.draw_string(50,0, "${str}", scale = 1, color = (255,255,255) , thickness = 1)
|
|
@@ -3204,7 +3248,7 @@ def wifi_is_content():
|
|
|
canvas.draw_string((i["x"]),(i["y"]), (i["payload"]), scale = 1, color = (255,0,0) , thickness = 1)
|
|
|
canvas.draw_rectangle((i["x"]),(i["y"]), (i["x"])+(i["w"]),(i["y"])+ (i["h"]), color=(255,0,0), thickness=1)
|
|
|
CODERESULT = (i["payload"]).split(";")
|
|
|
- v831_display_show_canvas(canvas)
|
|
|
+ v831_display_show_canvas(canvas,0,0)
|
|
|
if CODERESULT != "":
|
|
|
WiFiSSID = CODERESULT[0][5 : ]
|
|
|
WiFiPSD = CODERESULT[1][5 : ]
|
|
@@ -3220,7 +3264,8 @@ def wifi_is_content():
|
|
|
break
|
|
|
`
|
|
|
)
|
|
|
- var code = "codeScanningNetwork()\n"
|
|
|
+ var code = `image.load_freetype("/root/preset/fonts/simhei.ttf")
|
|
|
+codeScanningNetwork()\n`
|
|
|
return code;
|
|
|
}
|
|
|
|