analog_io_board

Last Modified: 2024-03-17 07:09:42

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

Owned By: evezor

Created By: anfro

Contributors: anfro, evezor

Public: True


Executable


        
# --------------------------------------
#   analog_io_board
#   65f6973664f81eb2canv
__canvas_id__ = '65f6973664f81eb2'
# __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 AnalogInput import AnalogInput
from CANBus import CANBus
def setup(iris):
  AnalogInput(name="analog1", pid=45053, pin=33, ring_size=10, noise_reduction=100, delay=50, datatype="float", debug=False, active=True, bcast=True, iris=iris)
  AnalogInput(name="analog2", pid=46887, pin=32, ring_size=10, noise_reduction=100, delay=50, datatype="float", debug=False, active=True, bcast=True, iris=iris)
  AnalogInput(name="analog3", pid=17178, pin=35, ring_size=10, noise_reduction=100, delay=50, datatype="float", debug=False, active=True, bcast=True, iris=iris)
  AnalogInput(name="analog4", pid=43008, pin=34, ring_size=10, noise_reduction=100, delay=50, datatype="float", debug=False, active=True, bcast=True, iris=iris)
  CANBus(name="CANBus", pid=6545, rx=16, tx=4, adr=18, bus=0, baud=250000, rx_queue=25, terminal_debug=False, debug=False, active=True, bcast=False, 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="input1", pid=29989, pin=25, pullup='pullup', debounce=200, invert=True, initial_value=False, datatype="bool", debug=False, active=True, bcast=True, iris=iris)
  DigitalInput(name="input2", pid=39132, pin=26, pullup='pullup', debounce=200, invert=True, initial_value=False, datatype="bool", debug=False, active=True, bcast=True, iris=iris)
  DigitalInput(name="input3", pid=10879, pin=18, pullup='pullup', debounce=200, invert=True, initial_value=False, datatype="bool", debug=False, active=True, bcast=True, iris=iris)
  DigitalInput(name="input4", pid=53788, pin=27, pullup='pullup', 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="output1", pid=34645, pin=19, invert=False, initial_value=False, datatype="bool", debug=False, active=True, bcast=False, iris=iris)
  DigitalOutput(name="output2", pid=41646, pin=21, invert=False, initial_value=False, datatype="bool", debug=False, active=True, bcast=False, iris=iris)
  DigitalOutput(name="output3", pid=56094, pin=22, invert=False, initial_value=False, datatype="bool", debug=False, active=True, bcast=False, iris=iris)
  DigitalOutput(name="output4", pid=43505, 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({})


      

Canvas View:


Dependencies:


["NeoPixel", "DigitalOutput", "DigitalInput", "HbtLed", "Parameter", "FileReceiver", "ESP32Core", "AnalogInput", "CANBus"]
    

Uppie code:

this code is used as the constructor in this canvas is dropped on a canvas above

{
  "canvas_id": "65d349f5f865a801canv",
  "zorg": false,
  "busses": {
    "CANBus": "18"
  },
  "ports": [
    {
      "name": "analog1",
      "reference_id": "adf7f98e-c0bf-201c-9be5-1b5437d755c8",
      "pid": 45053,
      "type": "output",
      "datatype": "float",
      "parameter_type": "AnalogInput"
    },
    {
      "name": "analog2",
      "reference_id": "dca9cbba-921f-3e68-ebd1-db86ba6674f4",
      "pid": 46887,
      "type": "output",
      "datatype": "float",
      "parameter_type": "AnalogInput"
    },
    {
      "name": "analog3",
      "reference_id": "f8642941-7324-a908-3a4c-2d1a5b0b605a",
      "pid": 17178,
      "type": "output",
      "datatype": "float",
      "parameter_type": "AnalogInput"
    },
    {
      "name": "analog4",
      "reference_id": "3964c31d-2918-b210-4532-37f127e78c23",
      "pid": 43008,
      "type": "output",
      "datatype": "float",
      "parameter_type": "AnalogInput"
    },
    {
      "name": "input1",
      "reference_id": "4ccb6a31-495e-fb36-3826-ca1c061c4da8",
      "pid": 29989,
      "type": "output",
      "datatype": "bool",
      "parameter_type": "DigitalInput"
    },
    {
      "name": "input2",
      "reference_id": "c62362b7-c36a-20e3-9ca3-ef14d8de772b",
      "pid": 39132,
      "type": "output",
      "datatype": "bool",
      "parameter_type": "DigitalInput"
    },
    {
      "name": "input3",
      "reference_id": "703080b8-387a-a806-2b5d-cb80328856c3",
      "pid": 10879,
      "type": "output",
      "datatype": "bool",
      "parameter_type": "DigitalInput"
    },
    {
      "name": "input4",
      "reference_id": "75a5d433-8b6a-bd03-f38e-b0b4c3d8803f",
      "pid": 53788,
      "type": "output",
      "datatype": "bool",
      "parameter_type": "DigitalInput"
    },
    {
      "name": "output1",
      "reference_id": "96906580-3660-5cf8-b9b3-166f6e6ea5ca",
      "pid": 34645,
      "type": "input",
      "datatype": "bool",
      "parameter_type": "DigitalOutput"
    },
    {
      "name": "output2",
      "reference_id": "6fbbd229-fc4a-97f9-9c6f-97000dd02f35",
      "pid": 41646,
      "type": "input",
      "datatype": "bool",
      "parameter_type": "DigitalOutput"
    },
    {
      "name": "output3",
      "reference_id": "43362a2a-22f5-3d89-faf0-017c9d8a2d3a",
      "pid": 56094,
      "type": "input",
      "datatype": "bool",
      "parameter_type": "DigitalOutput"
    },
    {
      "name": "output4",
      "reference_id": "9168f000-faea-9edf-99db-601cf242d227",
      "pid": 43505,
      "type": "input",
      "datatype": "bool",
      "parameter_type": "DigitalOutput"
    }
  ]
}
    

Uppie subs:


{}
    

Canvas code:


[
  {
    "type": "CanvasID",
    "id": "65f6973664f81eb2canv",
    "x": 26.786299999999983,
    "y": 24.64382824707031,
    "selectable": false,
    "draggable": true,
    "text": "CanvasID: 65f6973664f81eb2canv",
    "canvas_type": "core"
  },
  {
    "type": "Parameter",
    "name": "ESP32Core",
    "id": "9e65d461-88ea-d923-2508-c70738045031",
    "ParameterType": "ESP32Core",
    "datatype": null,
    "pid": "6074",
    "x": 2417.9577,
    "y": 272.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": 2130.9577,
    "y": 257.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": 2107.9577,
    "y": 190.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": 2159.9577,
    "y": 360.51210000000003,
    "width": 79,
    "height": 43,
    "constants": {
      "rx": "16",
      "tx": "4",
      "adr": "18",
      "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": 2367.4577,
    "y": 187.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": 2096.6057,
    "y": 106.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": 2417.9577,
    "y": 90.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": "analog1",
    "id": "adf7f98e-c0bf-201c-9be5-1b5437d755c8",
    "ParameterType": "AnalogInput",
    "datatype": "float",
    "pid": 45053,
    "x": 310.12559999999996,
    "y": 171.6105129882813,
    "width": 91,
    "height": 45,
    "constants": {
      "pin": "33",
      "ring_size": 10,
      "noise_reduction": 100
    },
    "up_data": {
      "can_go_up": true,
      "type": "output",
      "order": 999,
      "up": true
    },
    "debug": false,
    "active": true,
    "broadcast": true
  },
  {
    "type": "Parameter",
    "name": "analog2",
    "id": "dca9cbba-921f-3e68-ebd1-db86ba6674f4",
    "ParameterType": "AnalogInput",
    "datatype": "float",
    "pid": 46887,
    "x": 307.62559999999996,
    "y": 322.42251298828137,
    "width": 96,
    "height": 41,
    "constants": {
      "pin": "32",
      "ring_size": 10,
      "noise_reduction": 100
    },
    "up_data": {
      "can_go_up": true,
      "type": "output",
      "order": 999,
      "up": true
    },
    "debug": false,
    "active": true,
    "broadcast": true
  },
  {
    "type": "Parameter",
    "name": "analog3",
    "id": "f8642941-7324-a908-3a4c-2d1a5b0b605a",
    "ParameterType": "AnalogInput",
    "datatype": "float",
    "pid": 17178,
    "x": 308.12559999999996,
    "y": 448.0265129882813,
    "width": 95,
    "height": 46,
    "constants": {
      "pin": "35",
      "ring_size": 10,
      "noise_reduction": 100
    },
    "up_data": {
      "can_go_up": true,
      "type": "output",
      "order": 999,
      "up": true
    },
    "debug": false,
    "active": true,
    "broadcast": true
  },
  {
    "type": "Parameter",
    "name": "analog4",
    "id": "3964c31d-2918-b210-4532-37f127e78c23",
    "ParameterType": "AnalogInput",
    "datatype": "float",
    "pid": 43008,
    "x": 308.62559999999996,
    "y": 586.4185129882813,
    "width": 94,
    "height": 44,
    "constants": {
      "pin": "34",
      "ring_size": 10,
      "noise_reduction": 100
    },
    "up_data": {
      "can_go_up": true,
      "type": "output",
      "order": 999,
      "up": true
    },
    "debug": false,
    "active": true,
    "broadcast": true
  },
  {
    "type": "Parameter",
    "name": "input1",
    "id": "4ccb6a31-495e-fb36-3826-ca1c061c4da8",
    "ParameterType": "DigitalInput",
    "datatype": "bool",
    "pid": 29989,
    "x": 591.5,
    "y": 171.6105129882813,
    "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": "input2",
    "id": "c62362b7-c36a-20e3-9ca3-ef14d8de772b",
    "ParameterType": "DigitalInput",
    "datatype": "bool",
    "pid": 39132,
    "x": 591.5,
    "y": 314.51210000000003,
    "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": "Parameter",
    "name": "input3",
    "id": "703080b8-387a-a806-2b5d-cb80328856c3",
    "ParameterType": "DigitalInput",
    "datatype": "bool",
    "pid": 10879,
    "x": 591.5,
    "y": 448.5265129882813,
    "width": 90,
    "height": 45,
    "constants": {
      "pin": "18",
      "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": "input4",
    "id": "75a5d433-8b6a-bd03-f38e-b0b4c3d8803f",
    "ParameterType": "DigitalInput",
    "datatype": "bool",
    "pid": 53788,
    "x": 595,
    "y": 583.8333129882812,
    "width": 90,
    "height": 45,
    "constants": {
      "pin": "27",
      "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": "output1",
    "id": "96906580-3660-5cf8-b9b3-166f6e6ea5ca",
    "ParameterType": "DigitalOutput",
    "datatype": "bool",
    "pid": 34645,
    "x": 878.5,
    "y": 169.1105129882813,
    "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": "output2",
    "id": "6fbbd229-fc4a-97f9-9c6f-97000dd02f35",
    "ParameterType": "DigitalOutput",
    "datatype": "bool",
    "pid": 41646,
    "x": 878.5,
    "y": 312.01210000000003,
    "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": "output3",
    "id": "43362a2a-22f5-3d89-faf0-017c9d8a2d3a",
    "ParameterType": "DigitalOutput",
    "datatype": "bool",
    "pid": 56094,
    "x": 878.5,
    "y": 443.5265129882813,
    "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": "output4",
    "id": "9168f000-faea-9edf-99db-601cf242d227",
    "ParameterType": "DigitalOutput",
    "datatype": "bool",
    "pid": 43505,
    "x": 878.5,
    "y": 583.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": "HoverConnection",
    "id": "825c8068-d774-af1f-4d9a-32a158ca9744",
    "bus": "local",
    "vertex": [
      {
        "x": 2170.6057,
        "y": 126.33331298828125
      },
      {
        "x": 2342.9577,
        "y": 126.33331298828125
      },
      {
        "x": 2342.9577,
        "y": 295.69987142857144
      },
      {
        "x": 2417.9577,
        "y": 295.69987142857144
      }
    ],
    "source": {
      "node": "7906fc95-7e4b-9ed1-dab9-abd07d17d0c2",
      "port": "self"
    },
    "target": {
      "node": "9e65d461-88ea-d923-2508-c70738045031",
      "port": "hbt_led"
    }
  },
  {
    "type": "HoverConnection",
    "id": "65be2b61-ca8d-e5e3-81ff-af3dd48ce324",
    "bus": "local",
    "vertex": [
      {
        "x": 2225.9577,
        "y": 274.61289999999997
      },
      {
        "x": 2305.9577,
        "y": 274.61289999999997
      },
      {
        "x": 2305.9577,
        "y": 342.5570142857143
      },
      {
        "x": 2417.9577,
        "y": 342.5570142857143
      }
    ],
    "source": {
      "node": "755f08c5-a527-574e-94c4-ec22787d7c83",
      "port": "event"
    },
    "target": {
      "node": "9e65d461-88ea-d923-2508-c70738045031",
      "port": "function_button"
    }
  },
  {
    "type": "HoverConnection",
    "id": "2b775f03-5aa3-3fe4-bb75-ac541beaf49c",
    "bus": "local",
    "vertex": [
      {
        "x": 2180.9577,
        "y": 217.27956666666662
      },
      {
        "x": 2324.9577,
        "y": 217.27956666666662
      },
      {
        "x": 2324.9577,
        "y": 319.12844285714283
      },
      {
        "x": 2417.9577,
        "y": 319.12844285714283
      }
    ],
    "source": {
      "node": "c02b1b9a-83a0-4dc8-6c78-b233f6794e97",
      "port": "self"
    },
    "target": {
      "node": "9e65d461-88ea-d923-2508-c70738045031",
      "port": "neo_status"
    }
  },
  {
    "type": "HoverConnection",
    "id": "3f658083-625d-614a-c703-d4270120db8f",
    "bus": "local",
    "vertex": [
      {
        "x": 2238.9577,
        "y": 382.01210000000003
      },
      {
        "x": 2308.4577,
        "y": 382.01210000000003
      },
      {
        "x": 2308.4577,
        "y": 365.9855857142857
      },
      {
        "x": 2417.9577,
        "y": 365.9855857142857
      }
    ],
    "source": {
      "node": "094dfcb9-7772-56e1-d37f-10f852b3fd3e",
      "port": "self"
    },
    "target": {
      "node": "9e65d461-88ea-d923-2508-c70738045031",
      "port": "bus"
    }
  }
]