Ladies and gents,
I'm building an ESP8266 based system that connects to wifi and offers the ability to define the port configuration of up to 8 MCP23017 port expanders to react as outputs on websockets.
All works great so far.
Now i want to extend the project to also allow setting up the up to 128 MCP23017 i/Os as outputs OR Inputs by the user per REST API.
To be able to react on those - runtime (re)defined port configurations i need to have an way to get the Interrupts of each of those pins and figure out, which "button was pressed / released".
So it is NOT an option to assign the IOs to ISR in code as the user might reconfigure the setup in case he wants to reconnect the LEDs / Buttons in a different way.
For the output config for instance:
- i read the config from disk and setup wifi, websocket client, and port configurations
- i connect to Wifi
- i connect to websocket server
- i subscribe to websocket events and declare on which received value which LED (connected to any of the MCP23017 GPIOs) should switch on. This definition is included in the config from step 1 and can be redefined during runtime by a REST PUT request to /config sending a new configuration and resetting the system afterwards.
Example Config:
{
"system": {
"hostname": "myPanel"
},
"server": {
"address": "192.168.178.5",
"port": 2048,
"path": "/fsuipc",
"protocol": "fsuipc",
"reconnectInterval": 5000
},
"io": [
{
"i2cAddress": 32,
"out": [
{
"port": 6,
"variable": "ParkingBrake_Position"
},
{
"port": 7,
"variable": "SWS_LIGHTING_Switch_Light_Landing",
"truthyValue": 2
},
{
"port": 16,
"variable": "A320_Neo_MFD_Range"
},
{
"port": 17,
"variable": "A320_Neo_EFIS_RANGE"
},
{
"port": 6,
"variable": "Sim_Paused",
"address": 612,
"type": "uint",
"size": 2,
"truthyValue": 4
},
{
"port": 17,
"variable": "parking",
"address": 3018,
"type": "uint",
"size": 2
},
{
"port": 7,
"variable": "fuelpump",
"address": 12548,
"type": "uint",
"size": 1
}
],
"in": [
{
"port": 14,
"variable": "APU Start Switch"
},
{
"port": 15,
"variable": "APU Master Switch"
}
]
},
{
"i2cAddress": 38,
"out": [
{
"port": 12,
"variable": "APU Master Switch"
},
{
"port": 13,
"variable": "APU Start Switch"
}
]
}
]
}
So now i want to be able to fire an event in case on MCP23017 i2C Address 32 Port 14 a button is pressed (falling edge) so that i'm able to send a websocket message referring to the defined variable "APU Start Switch".
Do you already have any tutorial, guidance etc. to get into that?
Thanks a lot and best regards,
Joe