relay4x_board

Last Modified: 2024-03-17 07:10:02

Created On: 2023-12-10 15:58:46

Owned By: evezor

Created By: anfro

Contributors: anfro, evezor

Public: True


Executable


        
# --------------------------------------
#   relay4x_board
#   65f6974af642fe7ccanv
__canvas_id__ = '65f6974af642fe7c'
# __version__ = TODO: add this
# --------------------------------------
from floe import FP

from NeoPixel import NeoPixel
from DigitalOutput import DigitalOutput
from DigitalInput import DigitalInput
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=27, bus=0, baud=250000, rx_queue=25, terminal_debug=False, debug=False, active=True, bcast=False, iris=iris)
  DigitalInput(name="button1", pid=10879, pin=26, pullup='pullup', debounce=200, invert=True, initial_value=False, datatype="bool", debug=False, active=True, bcast=True, iris=iris)
  DigitalInput(name="button2", pid=12156, pin=25, pullup='pullup', debounce=200, invert=True, initial_value=False, datatype="bool", debug=False, active=True, bcast=True, iris=iris)
  DigitalInput(name="button3", pid=39697, pin=33, pullup='pullup', debounce=200, invert=True, initial_value=False, datatype="bool", debug=False, active=True, bcast=True, iris=iris)
  DigitalInput(name="button4", pid=30594, pin=32, 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)
  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="relay1", pid=58642, pin=22, invert=False, initial_value=False, datatype="bool", debug=False, active=True, bcast=False, iris=iris)
  DigitalOutput(name="relay2", pid=11654, pin=21, invert=False, initial_value=False, datatype="bool", debug=False, active=True, bcast=False, iris=iris)
  DigitalOutput(name="relay3", pid=32431, pin=19, invert=False, initial_value=False, datatype="bool", debug=False, active=True, bcast=False, iris=iris)
  DigitalOutput(name="relay4", pid=16864, pin=23, invert=False, 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)
  iris.add_hots({"58642": [10879], "11654": [12156], "32431": [39697], "16864": [30594]})


      

Canvas View:


Dependencies:


["NeoPixel", "DigitalOutput", "DigitalInput", "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": "65d399bbb489068dcanv",
  "zorg": false,
  "busses": {
    "CANBus": "27"
  },
  "ports": [
    {
      "name": "button1",
      "reference_id": "703080b8-387a-a806-2b5d-cb80328856c3",
      "pid": 10879,
      "type": "output",
      "datatype": "bool",
      "parameter_type": "DigitalInput"
    },
    {
      "name": "button2",
      "reference_id": "50d58f6b-d694-8d2e-f93b-692b3768a751",
      "pid": 12156,
      "type": "output",
      "datatype": "bool",
      "parameter_type": "DigitalInput"
    },
    {
      "name": "button3",
      "reference_id": "4d86a02f-ead4-b58b-35d0-d9e54fb14e24",
      "pid": 39697,
      "type": "output",
      "datatype": "bool",
      "parameter_type": "DigitalInput"
    },
    {
      "name": "button4",
      "reference_id": "14bc7d91-dd44-6fe2-4060-d1b3b5cb3041",
      "pid": 30594,
      "type": "output",
      "datatype": "bool",
      "parameter_type": "DigitalInput"
    },
    {
      "name": "relay1",
      "reference_id": "5e31e4ba-5c90-13c6-ac67-6790ecdc6c82",
      "pid": 58642,
      "type": "input",
      "datatype": "bool",
      "parameter_type": "DigitalOutput"
    },
    {
      "name": "relay2",
      "reference_id": "8f743264-448f-9ac2-c041-7cdf785e45e7",
      "pid": 11654,
      "type": "input",
      "datatype": "bool",
      "parameter_type": "DigitalOutput"
    },
    {
      "name": "relay3",
      "reference_id": "9bb636fa-f35c-3de1-d2c2-ecebfa469a8f",
      "pid": 32431,
      "type": "input",
      "datatype": "bool",
      "parameter_type": "DigitalOutput"
    },
    {
      "name": "relay4",
      "reference_id": "f9c11c7d-7762-41f5-d972-b08f85de6b5b",
      "pid": 16864,
      "type": "input",
      "datatype": "bool",
      "parameter_type": "DigitalOutput"
    }
  ]
}
    

Uppie subs:


{}
    

Canvas code:


[
  {
    "type": "CanvasID",
    "id": "65f6974af642fe7ccanv",
    "x": 26.786299999999983,
    "y": 24.64382824707031,
    "selectable": false,
    "draggable": true,
    "text": "CanvasID: 65f6974af642fe7ccanv",
    "canvas_type": "core"
  },
  {
    "type": "Parameter",
    "name": "ESP32Core",
    "id": "9e65d461-88ea-d923-2508-c70738045031",
    "ParameterType": "ESP32Core",
    "datatype": null,
    "pid": "6074",
    "x": 1660.9577,
    "y": 278.2713,
    "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": 1373.9577,
    "y": 263.61289999999997,
    "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": 1350.9577,
    "y": 196.61289999999997,
    "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": 1402.9577,
    "y": 366.51210000000003,
    "width": 79,
    "height": 43,
    "constants": {
      "rx": "16",
      "tx": "4",
      "adr": "27",
      "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": 1610.4577,
    "y": 193.3641,
    "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": 1339.6057,
    "y": 112.33331298828125,
    "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": 1660.9577,
    "y": 96.36410000000001,
    "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": "button1",
    "id": "703080b8-387a-a806-2b5d-cb80328856c3",
    "ParameterType": "DigitalInput",
    "datatype": "bool",
    "pid": 10879,
    "x": 213.6168,
    "y": 250.5793000000001,
    "width": 90,
    "height": 45,
    "constants": {
      "pin": "26",
      "pullup": "pullup",
      "debounce": 200
    },
    "up_data": {
      "can_go_up": true,
      "type": "output",
      "order": 999,
      "up": true
    },
    "debug": false,
    "active": true,
    "broadcast": true
  },
  {
    "type": "NotePad",
    "id": "d670df26-810d-29b5-3998-4b162120166e",
    "x": 222.09180038146974,
    "y": 153.99492824707022,
    "width": 218,
    "height": 35,
    "ports": [],
    "text": "Buttons"
  },
  {
    "type": "Parameter",
    "name": "button2",
    "id": "50d58f6b-d694-8d2e-f93b-692b3768a751",
    "ParameterType": "DigitalInput",
    "datatype": "bool",
    "pid": 12156,
    "x": 213.6168,
    "y": 351.9005129882812,
    "width": 90,
    "height": 45,
    "constants": {
      "pin": "25",
      "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": "button3",
    "id": "4d86a02f-ead4-b58b-35d0-d9e54fb14e24",
    "ParameterType": "DigitalInput",
    "datatype": "bool",
    "pid": 39697,
    "x": 213.6168,
    "y": 454.5793000000001,
    "width": 90,
    "height": 45,
    "constants": {
      "pin": "33",
      "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": "button4",
    "id": "14bc7d91-dd44-6fe2-4060-d1b3b5cb3041",
    "ParameterType": "DigitalInput",
    "datatype": "bool",
    "pid": 30594,
    "x": 213.6168,
    "y": 561.9005129882812,
    "width": 90,
    "height": 45,
    "constants": {
      "pin": "32",
      "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": "relay1",
    "id": "5e31e4ba-5c90-13c6-ac67-6790ecdc6c82",
    "ParameterType": "DigitalOutput",
    "datatype": "bool",
    "pid": 58642,
    "x": 493.5,
    "y": 231.61289999999997,
    "width": 95,
    "height": 50,
    "constants": {
      "pin": "22"
    },
    "up_data": {
      "can_go_up": true,
      "type": "input",
      "order": 999,
      "up": true
    },
    "debug": false,
    "active": true,
    "broadcast": false
  },
  {
    "type": "Parameter",
    "name": "relay2",
    "id": "8f743264-448f-9ac2-c041-7cdf785e45e7",
    "ParameterType": "DigitalOutput",
    "datatype": "bool",
    "pid": 11654,
    "x": 493.5,
    "y": 349.4005129882812,
    "width": 95,
    "height": 50,
    "constants": {
      "pin": "21"
    },
    "up_data": {
      "can_go_up": true,
      "type": "input",
      "order": 999,
      "up": true
    },
    "debug": false,
    "active": true,
    "broadcast": false
  },
  {
    "type": "Parameter",
    "name": "relay3",
    "id": "9bb636fa-f35c-3de1-d2c2-ecebfa469a8f",
    "ParameterType": "DigitalOutput",
    "datatype": "bool",
    "pid": 32431,
    "x": 493.5,
    "y": 463.83331298828125,
    "width": 95,
    "height": 50,
    "constants": {
      "pin": "19"
    },
    "up_data": {
      "can_go_up": true,
      "type": "input",
      "order": 999,
      "up": true
    },
    "debug": false,
    "active": true,
    "broadcast": false
  },
  {
    "type": "Parameter",
    "name": "relay4",
    "id": "f9c11c7d-7762-41f5-d972-b08f85de6b5b",
    "ParameterType": "DigitalOutput",
    "datatype": "bool",
    "pid": 16864,
    "x": 493.5,
    "y": 579.8333129882812,
    "width": 95,
    "height": 50,
    "constants": {
      "pin": "23"
    },
    "up_data": {
      "can_go_up": true,
      "type": "input",
      "order": 999,
      "up": true
    },
    "debug": false,
    "active": true,
    "broadcast": false
  },
  {
    "type": "NotePad",
    "id": "a2e31f60-6bca-7b41-61b5-d209ce680ed1",
    "x": 507.4833335876465,
    "y": 155.49492824707022,
    "width": 218,
    "height": 25,
    "ports": [],
    "text": "Relays"
  },
  {
    "type": "HoverConnection",
    "id": "759572d1-790c-ffdb-2563-75807154d4b6",
    "bus": "local",
    "vertex": [
      {
        "x": 303.6168,
        "y": 265.5793000000001
      },
      {
        "x": 398.5584,
        "y": 265.5793000000001
      },
      {
        "x": 398.5584,
        "y": 244.11289999999997
      },
      {
        "x": 493.5,
        "y": 244.11289999999997
      }
    ],
    "source": {
      "node": "703080b8-387a-a806-2b5d-cb80328856c3",
      "port": "event"
    },
    "target": {
      "node": "5e31e4ba-5c90-13c6-ac67-6790ecdc6c82",
      "port": "input"
    }
  },
  {
    "type": "HoverConnection",
    "id": "65be2b61-ca8d-e5e3-81ff-af3dd48ce324",
    "bus": "local",
    "vertex": [
      {
        "x": 1468.9577,
        "y": 280.61289999999997
      },
      {
        "x": 1548.9577,
        "y": 280.61289999999997
      },
      {
        "x": 1548.9577,
        "y": 348.5570142857143
      },
      {
        "x": 1660.9577,
        "y": 348.5570142857143
      }
    ],
    "source": {
      "node": "755f08c5-a527-574e-94c4-ec22787d7c83",
      "port": "event"
    },
    "target": {
      "node": "9e65d461-88ea-d923-2508-c70738045031",
      "port": "function_button"
    }
  },
  {
    "type": "HoverConnection",
    "id": "d51ea806-d43c-a64a-1288-4c2df2ca9137",
    "bus": "local",
    "vertex": [
      {
        "x": 303.6168,
        "y": 576.9005129882812
      },
      {
        "x": 398.5584,
        "y": 576.9005129882812
      },
      {
        "x": 398.5584,
        "y": 592.3333129882812
      },
      {
        "x": 493.5,
        "y": 592.3333129882812
      }
    ],
    "source": {
      "node": "14bc7d91-dd44-6fe2-4060-d1b3b5cb3041",
      "port": "event"
    },
    "target": {
      "node": "f9c11c7d-7762-41f5-d972-b08f85de6b5b",
      "port": "input"
    }
  },
  {
    "type": "HoverConnection",
    "id": "89865277-5693-8482-e0db-8a321ca74f7a",
    "bus": "local",
    "vertex": [
      {
        "x": 303.6168,
        "y": 366.9005129882812
      },
      {
        "x": 398.5584,
        "y": 366.9005129882812
      },
      {
        "x": 398.5584,
        "y": 361.9005129882812
      },
      {
        "x": 493.5,
        "y": 361.9005129882812
      }
    ],
    "source": {
      "node": "50d58f6b-d694-8d2e-f93b-692b3768a751",
      "port": "event"
    },
    "target": {
      "node": "8f743264-448f-9ac2-c041-7cdf785e45e7",
      "port": "input"
    }
  },
  {
    "type": "HoverConnection",
    "id": "3f658083-625d-614a-c703-d4270120db8f",
    "bus": "local",
    "vertex": [
      {
        "x": 1481.9577,
        "y": 388.01210000000003
      },
      {
        "x": 1551.4577,
        "y": 388.01210000000003
      },
      {
        "x": 1551.4577,
        "y": 371.9855857142857
      },
      {
        "x": 1660.9577,
        "y": 371.9855857142857
      }
    ],
    "source": {
      "node": "094dfcb9-7772-56e1-d37f-10f852b3fd3e",
      "port": "self"
    },
    "target": {
      "node": "9e65d461-88ea-d923-2508-c70738045031",
      "port": "bus"
    }
  },
  {
    "type": "HoverConnection",
    "id": "af24722c-d638-8647-3ca7-1f10b412a768",
    "bus": "local",
    "vertex": [
      {
        "x": 303.6168,
        "y": 469.5793000000001
      },
      {
        "x": 398.5584,
        "y": 469.5793000000001
      },
      {
        "x": 398.5584,
        "y": 476.33331298828125
      },
      {
        "x": 493.5,
        "y": 476.33331298828125
      }
    ],
    "source": {
      "node": "4d86a02f-ead4-b58b-35d0-d9e54fb14e24",
      "port": "event"
    },
    "target": {
      "node": "9bb636fa-f35c-3de1-d2c2-ecebfa469a8f",
      "port": "input"
    }
  },
  {
    "type": "HoverConnection",
    "id": "825c8068-d774-af1f-4d9a-32a158ca9744",
    "bus": "local",
    "vertex": [
      {
        "x": 1413.6057,
        "y": 132.33331298828125
      },
      {
        "x": 1585.9577,
        "y": 132.33331298828125
      },
      {
        "x": 1585.9577,
        "y": 301.69987142857144
      },
      {
        "x": 1660.9577,
        "y": 301.69987142857144
      }
    ],
    "source": {
      "node": "7906fc95-7e4b-9ed1-dab9-abd07d17d0c2",
      "port": "self"
    },
    "target": {
      "node": "9e65d461-88ea-d923-2508-c70738045031",
      "port": "hbt_led"
    }
  },
  {
    "type": "HoverConnection",
    "id": "2b775f03-5aa3-3fe4-bb75-ac541beaf49c",
    "bus": "local",
    "vertex": [
      {
        "x": 1423.9577,
        "y": 223.27956666666662
      },
      {
        "x": 1567.9577,
        "y": 223.27956666666662
      },
      {
        "x": 1567.9577,
        "y": 325.12844285714283
      },
      {
        "x": 1660.9577,
        "y": 325.12844285714283
      }
    ],
    "source": {
      "node": "c02b1b9a-83a0-4dc8-6c78-b233f6794e97",
      "port": "self"
    },
    "target": {
      "node": "9e65d461-88ea-d923-2508-c70738045031",
      "port": "neo_status"
    }
  }
]