qr_reader_board
Last Modified: 2024-03-17 07:09:02
Created On: 2023-12-10 15:58:46
Owned By: evezor
Created By: anfro
Contributors: anfro, evezor
Public: True
Executable
# --------------------------------------
# qr_reader_board
# 65f6970e1d39b69dcanv
__canvas_id__ = '65f6970e1d39b69d'
# __version__ = TODO: add this
# --------------------------------------
def _trigger(event, trigger):
import uasyncio as asyncio
async def hold_trigger():
trigger(True) # trigger has inverted logic
await asyncio.sleep(4) # wait for 3 seconds
trigger(False)
if event:
asyncio.get_event_loop()
asyncio.create_task(hold_trigger())
from floe import FP
from QrReader import QrReader
from PWM import PWM
from NeoPixel import NeoPixel
from Variable import Variable
from DigitalOutput import DigitalOutput
from DigitalInput import DigitalInput
from CodeBlock import CodeBlock
from HbtLed import HbtLed
from ESP32Core import ESP32Core
from CANBus import CANBus
def setup(iris):
CANBus(name="CANBus", pid=6545, rx=16, tx=4, adr=25, bus=0, baud=250000, rx_queue=25, terminal_debug=False, debug=False, active=True, bcast=False, iris=iris)
CodeBlock(name="_trigger", pid=59148, code=_trigger, kwargs=[FP(50038)], datatype="None", iris=iris)
DigitalInput(name="button_a", pid=12156, pin=22, pullup='pullup', debounce=200, invert=True, initial_value=False, datatype="bool", debug=False, active=True, bcast=True, iris=iris)
DigitalInput(name="function_button", pid=2276, pin=36, pullup='None', debounce=200, invert=True, initial_value=False, datatype="bool", debug=False, active=True, bcast=True, iris=iris)
DigitalInput(name="led", pid=39697, pin=26, pullup='None', debounce=200, invert=True, initial_value=False, datatype="bool", debug=False, active=True, bcast=True, iris=iris)
DigitalInput(name="read", pid=10879, pin=23, pullup='pullup', debounce=200, invert=True, initial_value=False, datatype="bool", debug=True, active=True, bcast=True, iris=iris)
DigitalOutput(name="can_slp", pid=11397, pin=2, invert=False, initial_value=False, datatype="bool", debug=False, active=True, bcast=False, iris=iris)
DigitalOutput(name="led_a", pid=58642, pin=18, invert=False, initial_value=False, datatype="bool", debug=False, active=True, bcast=False, iris=iris)
DigitalOutput(name="trigger", pid=50038, pin=32, invert=True, initial_value=False, datatype="bool", debug=False, active=True, bcast=False, iris=iris)
ESP32Core(name="ESP32Core", pid=6074, wifi=False, hbt_led=FP(50487), neo_status=FP(47403), function_button=FP(2276), bus=FP(6545), zorg=None, webserver=None, debug=False, active=True, bcast=False, iris=iris)
HbtLed(name="HbtLed", pid=50487, pin=5, delay=1000, datatype="int", debug=False, active=True, bcast=False, iris=iris)
NeoPixel(name="neo_status", pid=47403, pin=17, number_of_pixels=1, animation=0, delay=200, animations=None, datatype="rgb", debug=False, active=True, bcast=False, iris=iris)
PWM(name="buzzer", pid=15083, pin=25, freq=FP(8105), duty=FP(41548), duty_min=0, duty_max=1, invert_duty=False, datatype="bool", debug=False, active=True, bcast=False, iris=iris)
QrReader(name="QrReader", pid=56632, rx=19, tx=21, uart=1, buzzer_obj=FP(15083), buzz_on_read=True, datatype="string", debug=True, active=True, bcast=True, iris=iris)
Variable(name="buzz_pitch", pid=8105, state=2500, datatype="int", constant=False, debug=False, active=True, bcast=True, iris=iris)
Variable(name="do_trigger", pid=46562, state=False, datatype="bool", constant=False, debug=False, active=True, bcast=True, iris=iris)
Variable(name="volume", pid=41548, state=0.5, datatype="float", constant=False, debug=False, active=True, bcast=True, iris=iris)
iris.add_hots({"58642": [39697], "50038": [10879], "59148": [46562]})
Canvas View:
Dependencies:
["QrReader", "PWM", "NeoPixel", "Variable", "DigitalOutput", "DigitalInput", "CodeBlock", "HbtLed", "Parameter", "FileReceiver", "ESP32Core", "CANBus"]
Uppie code:
this code is used as the constructor in this canvas is dropped on a canvas above
{
"canvas_id": "65d3b29277cc78a8canv",
"zorg": false,
"busses": {
"CANBus": "25"
},
"ports": [
{
"name": "button_a",
"reference_id": "50d58f6b-d694-8d2e-f93b-692b3768a751",
"pid": 12156,
"type": "output",
"datatype": "bool",
"parameter_type": "DigitalInput"
},
{
"name": "led_a",
"reference_id": "5e31e4ba-5c90-13c6-ac67-6790ecdc6c82",
"pid": 58642,
"type": "input",
"datatype": "bool",
"parameter_type": "DigitalOutput"
},
{
"name": "trigger",
"reference_id": "c1104e25-bf88-5072-96b1-0d954228c16e",
"pid": 50038,
"type": "input",
"datatype": "bool",
"parameter_type": "DigitalOutput"
},
{
"name": "QrReader",
"reference_id": "a66e64ac-9c3d-0b0e-0f47-373c5655b318",
"pid": 56632,
"type": "output",
"datatype": "string",
"parameter_type": "QrReader"
},
{
"name": "buzzer",
"reference_id": "05ff7224-fa89-3826-b2f5-891d98300673",
"pid": 15083,
"type": "input",
"datatype": "bool",
"parameter_type": "PWM"
},
{
"name": "do_trigger",
"reference_id": "666dd955-967d-a5f4-6171-c6ae7f9b6075",
"pid": 46562,
"type": "both",
"datatype": "bool",
"parameter_type": "Variable"
}
]
}
Uppie subs:
{}
Canvas code:
[
{
"type": "CanvasID",
"id": "65f6970e1d39b69dcanv",
"x": 26.786299999999983,
"y": 24.64382824707031,
"selectable": false,
"draggable": true,
"text": "CanvasID: 65f6970e1d39b69dcanv",
"canvas_type": "core"
},
{
"type": "Parameter",
"name": "ESP32Core",
"id": "9e65d461-88ea-d923-2508-c70738045031",
"ParameterType": "ESP32Core",
"datatype": null,
"pid": "6074",
"x": 1869.3853,
"y": 304.9602,
"width": 95,
"height": 164,
"constants": {
"wifi": false
},
"up_data": {
"can_go_up": false,
"up": false
},
"debug": false,
"active": true,
"broadcast": false
},
{
"type": "Parameter",
"name": "function_button",
"id": "755f08c5-a527-574e-94c4-ec22787d7c83",
"ParameterType": "DigitalInput",
"datatype": "bool",
"pid": 2276,
"x": 1582.3853,
"y": 290.30179999999996,
"width": 95,
"height": 51,
"constants": {
"pin": "36",
"pullup": "None",
"debounce": 200
},
"up_data": {
"can_go_up": true,
"type": "output",
"order": 999,
"up": false
},
"debug": false,
"active": true,
"broadcast": true
},
{
"type": "Parameter",
"name": "neo_status",
"id": "c02b1b9a-83a0-4dc8-6c78-b233f6794e97",
"ParameterType": "NeoPixel",
"datatype": "rgb",
"pid": 47403,
"x": 1559.3853,
"y": 223.30179999999996,
"width": 73,
"height": 40,
"constants": {
"pin": "17",
"number_of_pixels": 1
},
"up_data": {
"can_go_up": true,
"type": "input",
"order": 999,
"up": false
},
"debug": false,
"active": true,
"broadcast": false
},
{
"type": "Parameter",
"name": "CANBus",
"id": "094dfcb9-7772-56e1-d37f-10f852b3fd3e",
"ParameterType": "CANBus",
"datatype": null,
"pid": 6545,
"x": 1611.3853,
"y": 393.201,
"width": 79,
"height": 43,
"constants": {
"rx": "16",
"tx": "4",
"adr": "25",
"bus": "0",
"baud": 250000,
"rx_queue": 25
},
"up_data": {
"can_go_up": false,
"up": false
},
"debug": false,
"active": true,
"broadcast": false
},
{
"type": "NotePad",
"id": "d62904e5-41be-2090-31f2-f67f776f676e",
"x": 1832.940868701172,
"y": 231.30179999999996,
"width": 218,
"height": 25,
"ports": [],
"text": "Core Components"
},
{
"type": "Parameter",
"name": "HbtLed",
"id": "7906fc95-7e4b-9ed1-dab9-abd07d17d0c2",
"ParameterType": "HbtLed",
"datatype": "int",
"pid": 50487,
"x": 1548.0333,
"y": 139.02221298828124,
"width": 74,
"height": 40,
"constants": {
"pin": "5"
},
"up_data": {
"can_go_up": false,
"up": false
},
"debug": false,
"active": true,
"broadcast": false
},
{
"type": "Parameter",
"name": "can_slp",
"id": "3a429d50-899d-cb28-be24-195f5663a9ee",
"ParameterType": "DigitalOutput",
"datatype": "bool",
"pid": 11397,
"x": 1896.0742,
"y": 139.02221298828124,
"width": 95,
"height": 50,
"constants": {
"pin": "2"
},
"up_data": {
"can_go_up": true,
"type": "input",
"order": 999,
"up": false
},
"debug": false,
"active": true,
"broadcast": false
},
{
"type": "Parameter",
"name": "read",
"id": "703080b8-387a-a806-2b5d-cb80328856c3",
"ParameterType": "DigitalInput",
"datatype": "bool",
"pid": 10879,
"x": 199.38739999999996,
"y": 715.1613000000001,
"width": 90,
"height": 45,
"constants": {
"pin": "23",
"pullup": "pullup",
"debounce": 200
},
"up_data": {
"can_go_up": true,
"type": "output",
"order": 999,
"up": false
},
"debug": true,
"active": true,
"broadcast": true
},
{
"type": "NotePad",
"id": "d670df26-810d-29b5-3998-4b162120166e",
"x": 451.5203335876465,
"y": 668.4889129882812,
"width": 218,
"height": 35,
"ports": [],
"text": "Trigger"
},
{
"type": "Parameter",
"name": "button_a",
"id": "50d58f6b-d694-8d2e-f93b-692b3768a751",
"ParameterType": "DigitalInput",
"datatype": "bool",
"pid": 12156,
"x": 342.5482,
"y": 233.23281298828124,
"width": 90,
"height": 45,
"constants": {
"pin": "22",
"pullup": "pullup",
"debounce": 200
},
"up_data": {
"can_go_up": true,
"type": "output",
"order": 999,
"up": true
},
"debug": false,
"active": true,
"broadcast": true
},
{
"type": "Parameter",
"name": "led",
"id": "4d86a02f-ead4-b58b-35d0-d9e54fb14e24",
"ParameterType": "DigitalInput",
"datatype": "bool",
"pid": 39697,
"x": 201.92919999999992,
"y": 495.3748999999999,
"width": 90,
"height": 45,
"constants": {
"pin": "26",
"pullup": "None",
"debounce": 200
},
"up_data": {
"can_go_up": true,
"type": "output",
"order": 999,
"up": false
},
"debug": false,
"active": true,
"broadcast": true
},
{
"type": "Parameter",
"name": "led_a",
"id": "5e31e4ba-5c90-13c6-ac67-6790ecdc6c82",
"ParameterType": "DigitalOutput",
"datatype": "bool",
"pid": 58642,
"x": 461.66960000000006,
"y": 492.8748999999999,
"width": 95,
"height": 50,
"constants": {
"pin": "18"
},
"up_data": {
"can_go_up": true,
"type": "input",
"order": 999,
"up": true
},
"debug": false,
"active": true,
"broadcast": false
},
{
"type": "Parameter",
"name": "trigger",
"id": "c1104e25-bf88-5072-96b1-0d954228c16e",
"ParameterType": "DigitalOutput",
"datatype": "bool",
"pid": 50038,
"x": 451.5203335876465,
"y": 732.2984129882813,
"width": 95,
"height": 50,
"constants": {
"pin": "32"
},
"up_data": {
"can_go_up": true,
"type": "input",
"order": 999,
"up": true
},
"debug": false,
"active": true,
"broadcast": false
},
{
"type": "Boolean",
"id": "80b9e966-3e65-e936-88f9-d05f3db1dffd",
"state": "True",
"x": 264.87210000000005,
"y": 791.6629000000001,
"width": 65,
"height": 20
},
{
"type": "Parameter",
"name": "QrReader",
"id": "a66e64ac-9c3d-0b0e-0f47-373c5655b318",
"ParameterType": "QrReader",
"datatype": "string",
"pid": 56632,
"x": 1298.1425000000002,
"y": 529.4555129882813,
"width": 90,
"height": 45,
"constants": {
"rx": "19",
"tx": "21",
"uart": 1
},
"up_data": {
"can_go_up": true,
"type": "output",
"order": 999,
"up": true
},
"debug": true,
"active": true,
"broadcast": true
},
{
"type": "Parameter",
"name": "buzzer",
"id": "05ff7224-fa89-3826-b2f5-891d98300673",
"ParameterType": "PWM",
"datatype": "bool",
"pid": 15083,
"x": 1024.1968,
"y": 569.7100129882813,
"width": 85,
"height": 65,
"constants": {
"pin": "25"
},
"up_data": {
"can_go_up": true,
"type": "input",
"order": 999,
"up": true
},
"debug": false,
"active": true,
"broadcast": false
},
{
"type": "Variable",
"id": "94200d4a-defe-0890-87e5-4221598261c9",
"name": "buzz_pitch",
"class": "Int",
"datatype": "int",
"state": "2500",
"pid": 8105,
"up_data": {
"type": "both",
"order": 999,
"up": false
},
"constant": false,
"x": 803.1648999999999,
"y": 529.4555129882813,
"width": 53,
"height": 31,
"debug": false,
"active": true,
"broadcast": true
},
{
"type": "Variable",
"id": "ed3b01be-c278-804c-8384-55fe28af2a95",
"name": "volume",
"class": "Float",
"datatype": "float",
"state": ".5",
"pid": 41548,
"up_data": {
"type": "both",
"order": 999,
"up": false
},
"constant": false,
"x": 808.2724999999999,
"y": 605.7100129882813,
"width": 53,
"height": 29,
"debug": false,
"active": true,
"broadcast": true
},
{
"type": "NotePad",
"id": "963a9f33-94b7-356f-b261-b9da2d962811",
"x": 241.74921835327154,
"y": 435.3516131744384,
"width": 192,
"height": 25,
"ports": [],
"text": "QR Reader will pulse led onread"
},
{
"type": "NotePad",
"id": "abef62e7-37d2-ab51-602e-327837485eab",
"x": 211.2476183532715,
"y": 656.2545261627197,
"width": 192,
"height": 25,
"ports": [],
"text": "Button"
},
{
"type": "NotePad",
"id": "45f1c230-3787-6632-4d97-7f37fd9910b7",
"x": 353.5884183532715,
"y": 170.6556282470703,
"width": 192,
"height": 25,
"ports": [],
"text": "Button"
},
{
"type": "NotePad",
"id": "2d24446f-6689-db73-3ac2-b3fdd7b67b99",
"x": 1100.8115999999998,
"y": 468.6859999999999,
"width": 192,
"height": 25,
"ports": [],
"text": "Reader"
},
{
"type": "Variable",
"id": "666dd955-967d-a5f4-6171-c6ae7f9b6075",
"name": "do_trigger",
"class": "Bool",
"datatype": "bool",
"state": "False",
"pid": 46562,
"up_data": {
"type": "both",
"order": 999,
"up": true
},
"constant": false,
"x": 110.24761835327149,
"y": 972.3333129882812,
"width": 100,
"height": 40,
"debug": false,
"active": true,
"broadcast": true
},
{
"type": "CodeBlock",
"name": "_trigger",
"pid": 59148,
"kwargs": [
"trigger"
],
"iris": false,
"id": "e1fadb85-7f26-3996-c34c-4ac4e684f066",
"x": 342.61341797180177,
"y": 894.3333129882812,
"code": "import uasyncio as asyncio\n\nasync def hold_trigger():\n trigger(True) # trigger has inverted logic\n await asyncio.sleep(4) # wait for 3 seconds\n trigger(False)\n\nif event:\n asyncio.get_event_loop()\n asyncio.create_task(hold_trigger())\n\n\n"
},
{
"type": "HoverConnection",
"id": "825c8068-d774-af1f-4d9a-32a158ca9744",
"bus": "local",
"vertex": [
{
"x": 1622.0333,
"y": 159.02221298828124
},
{
"x": 1794.3853,
"y": 159.02221298828124
},
{
"x": 1794.3853,
"y": 328.38877142857143
},
{
"x": 1869.3853,
"y": 328.38877142857143
}
],
"source": {
"node": "7906fc95-7e4b-9ed1-dab9-abd07d17d0c2",
"port": "self"
},
"target": {
"node": "9e65d461-88ea-d923-2508-c70738045031",
"port": "hbt_led"
}
},
{
"type": "HoverConnection",
"id": "e1802d26-2cd8-ecf4-96fb-41f5ae3837f6",
"bus": "local",
"vertex": [
{
"x": 329.87210000000005,
"y": 801.6629000000001
},
{
"x": 349.8721000000001,
"y": 801.6629000000001
},
{
"x": 349.8721000000001,
"y": 757.2984129882813
},
{
"x": 451.5203335876465,
"y": 757.2984129882813
}
],
"source": {
"node": "80b9e966-3e65-e936-88f9-d05f3db1dffd",
"port": "output0"
},
"target": {
"node": "c1104e25-bf88-5072-96b1-0d954228c16e",
"port": "invert"
}
},
{
"type": "HoverConnection",
"id": "3f658083-625d-614a-c703-d4270120db8f",
"bus": "local",
"vertex": [
{
"x": 1690.3853,
"y": 414.701
},
{
"x": 1759.8853,
"y": 414.701
},
{
"x": 1759.8853,
"y": 398.6744857142857
},
{
"x": 1869.3853,
"y": 398.6744857142857
}
],
"source": {
"node": "094dfcb9-7772-56e1-d37f-10f852b3fd3e",
"port": "self"
},
"target": {
"node": "9e65d461-88ea-d923-2508-c70738045031",
"port": "bus"
}
},
{
"type": "HoverConnection",
"id": "97fff088-fa3a-42c0-5d06-82c0330c3491",
"bus": "local",
"vertex": [
{
"x": 861.2724999999999,
"y": 620.2100129882813
},
{
"x": 935.10925,
"y": 620.2100129882813
},
{
"x": 935.10925,
"y": 597.5671558454242
},
{
"x": 1024.1968,
"y": 597.5671558454242
}
],
"source": {
"node": "ed3b01be-c278-804c-8384-55fe28af2a95",
"port": "output0"
},
"target": {
"node": "05ff7224-fa89-3826-b2f5-891d98300673",
"port": "duty"
}
},
{
"type": "HoverConnection",
"id": "ffd0802c-feff-a634-5ec0-184cabfd1b90",
"bus": "local",
"vertex": [
{
"x": 210.2476183532715,
"y": 992.3333129882812
},
{
"x": 299.4305181625366,
"y": 992.3333129882812
},
{
"x": 299.4305181625366,
"y": 946.3333129882812
},
{
"x": 342.61341797180177,
"y": 946.3333129882812
}
],
"source": {
"node": "666dd955-967d-a5f4-6171-c6ae7f9b6075",
"port": "output0"
},
"target": {
"node": "e1fadb85-7f26-3996-c34c-4ac4e684f066",
"port": "input"
}
},
{
"type": "HoverConnection",
"id": "48bda09c-944b-2a98-c352-7d38201dcbad",
"bus": "local",
"vertex": [
{
"x": 1109.1968,
"y": 613.0433463216146
},
{
"x": 1180.7934500000003,
"y": 613.0433463216146
},
{
"x": 1180.7934500000003,
"y": 551.9555129882813
},
{
"x": 1298.1425000000002,
"y": 551.9555129882813
}
],
"source": {
"node": "05ff7224-fa89-3826-b2f5-891d98300673",
"port": "self"
},
"target": {
"node": "a66e64ac-9c3d-0b0e-0f47-373c5655b318",
"port": "buzzer_obj"
}
},
{
"type": "HoverConnection",
"id": "2b775f03-5aa3-3fe4-bb75-ac541beaf49c",
"bus": "local",
"vertex": [
{
"x": 1632.3853,
"y": 249.96846666666661
},
{
"x": 1776.3853,
"y": 249.96846666666661
},
{
"x": 1776.3853,
"y": 351.8173428571428
},
{
"x": 1869.3853,
"y": 351.8173428571428
}
],
"source": {
"node": "c02b1b9a-83a0-4dc8-6c78-b233f6794e97",
"port": "self"
},
"target": {
"node": "9e65d461-88ea-d923-2508-c70738045031",
"port": "neo_status"
}
},
{
"type": "HoverConnection",
"id": "65be2b61-ca8d-e5e3-81ff-af3dd48ce324",
"bus": "local",
"vertex": [
{
"x": 1677.3853,
"y": 307.30179999999996
},
{
"x": 1757.3853,
"y": 307.30179999999996
},
{
"x": 1757.3853,
"y": 375.24591428571426
},
{
"x": 1869.3853,
"y": 375.24591428571426
}
],
"source": {
"node": "755f08c5-a527-574e-94c4-ec22787d7c83",
"port": "event"
},
"target": {
"node": "9e65d461-88ea-d923-2508-c70738045031",
"port": "function_button"
}
},
{
"type": "HoverConnection",
"id": "a276fc2a-f831-3c3c-87b6-96ba79e63f72",
"bus": "local",
"vertex": [
{
"x": 289.38739999999996,
"y": 730.1613000000001
},
{
"x": 360.8922000000001,
"y": 730.1613000000001
},
{
"x": 360.8922000000001,
"y": 744.7984129882813
},
{
"x": 451.5203335876465,
"y": 744.7984129882813
}
],
"source": {
"node": "703080b8-387a-a806-2b5d-cb80328856c3",
"port": "event"
},
"target": {
"node": "c1104e25-bf88-5072-96b1-0d954228c16e",
"port": "input"
}
},
{
"type": "HoverConnection",
"id": "cb0d7f2f-7bba-d940-0a25-5b70f4340010",
"bus": "local",
"vertex": [
{
"x": 291.9291999999999,
"y": 510.3748999999999
},
{
"x": 378.8689999999999,
"y": 510.3748999999999
},
{
"x": 378.8689999999999,
"y": 505.3748999999999
},
{
"x": 461.66960000000006,
"y": 505.3748999999999
}
],
"source": {
"node": "4d86a02f-ead4-b58b-35d0-d9e54fb14e24",
"port": "event"
},
"target": {
"node": "5e31e4ba-5c90-13c6-ac67-6790ecdc6c82",
"port": "input"
}
},
{
"type": "HoverConnection",
"id": "24bdc346-2099-4493-7e3c-fae1ac38b8a3",
"bus": "local",
"vertex": [
{
"x": 856.1648999999999,
"y": 544.9555129882813
},
{
"x": 941.4517499999998,
"y": 544.9555129882813
},
{
"x": 941.4517499999998,
"y": 588.2814415597098
},
{
"x": 1024.1968,
"y": 588.2814415597098
}
],
"source": {
"node": "94200d4a-defe-0890-87e5-4221598261c9",
"port": "output0"
},
"target": {
"node": "05ff7224-fa89-3826-b2f5-891d98300673",
"port": "freq"
}
}
]