IUNO-TDM / PumpControl

An executable for decrypting and running recipe programs on the cocktail mixer
GNU General Public License v3.0
1 stars 3 forks source link

add support for LED, button and switches GPIOs #29

Closed bockha closed 6 years ago

bockha commented 6 years ago

The new MotorShield contains three input connectors and one output connector. The inputs are thought to be connected to a startbutton and door switches, the output is thought to control the illumination of the startbutton.

The pump control shall be enhanced to publish changes of the inputs using the websocket interface. It shall also be enhanced to enable the control of the startbutton illumination over the websocket.

GPIO mode usage
GPIO23 GPIO04 GPIO23 input + pull up cabinet door switch
GPIO22 GPIO04 input + pull up juice door switch
GPIO04 GPIO23 GPIO22 input + pull up startbutton
GPIO24 output illumination of startbutton

gpios

bockha commented 6 years ago

article about internal pull_up and pull_down

internal pullup using pigpio

goergch commented 6 years ago

for IUNO-TDM/MixerControl#117 we need a interface in the pumpcontrol to read and write GPIO Pins.

reading and writing should be possible via the REST API. There should also be events, triggered by changing read signals. this should be implemented in the websocket interface

Configuration and API design should be discussed before implementing the feature

goergch commented 6 years ago

The user of PumpControl (like the MixerControl) should not know the GPIO PIN numbers. These should be configured in the settings file with the following keys:

io = gpio
io-config = <config as single-lined json>

where the single-lined json config string has a structure like this (not single lined for better readability:

[
    {
        "name":"start_button",
        "pin":23,
        "type":"input_pullup",
        "polarity":"active_low"
    },
    {
        "name":"start_button_illumination",
        "pin":24,
        "type":"output",
        "polarity":"active_high"
    },
    {
        "name":"cabinet_door_switch",
        "pin":4,
        "type":"input_pullup",
        "polarity":"active_low"
    },
    {
        "name":"juice_door_switch",
        "pin":22,
        "type":"input_pullup",
        "polarity":"active_low"
    }
]
goergch commented 6 years ago

The REST interface should be extended by the following routes:

general:

GET /io-description returns:
[
    {
        "name":"cabinet_door_switch",
        "type":"input"
    },
    {
        "name:"juice_door_switch",
        "type":"input"
    },
    {
        "name":"start_button",
        "type":"input"
    },
    {
        "name":"start_button_illumination",
        "type":"output"
    }
]

for output-pins:

PUT /io/<name> body:[on|off]
GET /io/<name> returns:[on|off]

for input-pins:

GET /io/<name> returns:[on|off]
goergch commented 6 years ago

The websocket interface should send messages, when an input value changes or on initial connection. Message format:

input: {
    "name":"start_button"
    "value":false
}