|
LightHub 4.6.0
Open-source smart home controller firmware
|
LightHub input system (digital/analog pins, sensors, encoders). More...
Go to the source code of this file.
Classes | |
| union | inStore |
| Per-input runtime state, packed into the JSON object's valueint. More... | |
| class | Input |
| A single LightHub input (digital/analog pin, sensor, encoder, ...). More... | |
| class | readCache |
| Cache of raw pin reads to avoid multiple GPIO/I2C accesses within one poll cycle. More... | |
Macros | |
| #define | IN_ACTIVE_HIGH 2 |
| #define | IN_ANALOG 64 |
| #define | IN_RE 32 |
| #define | IN_I2C 128 |
| #define | IN_PUSH_ON 0 |
| #define | IN_PUSH_TOGGLE 1 |
| #define | IN_DHT22 4 |
| #define | IN_CCS811 5 |
| #define | IN_HDC1080 6 |
| #define | IN_ULTRASONIC 7 |
| #define | IN_COUNTER 8 |
| #define | IN_UPTIME 16 |
| #define | IS_IDLE 0 |
| #define | IS_PRESSED 1 |
| #define | IS_RELEASED 2 |
| #define | IS_LONG 3 |
| #define | IS_REPEAT 4 |
| #define | IS_WAITPRESS 5 |
| #define | IS_PRESSED2 6 |
| #define | IS_RELEASED2 7 |
| #define | IS_LONG2 8u |
| #define | IS_REPEAT2 9u |
| #define | IS_PRESSED3 10u |
| #define | IS_LONG3 11u |
| #define | IS_REPEAT3 12u |
| #define | IS_WAITRELEASE 13u |
| #define | IS_REQSTATE 0xFF |
| #define | IS_NOP 0xF |
| #define | SAME_STATE_ATTEMPTS 2 |
| Debounce: number of identical reads / analog samples before a state change. | |
| #define | ANALOG_STATE_ATTEMPTS 6 |
| #define | ANALOG_NOIZE 1 |
| Analog noise threshold (ADC steps). | |
| #define | CHECK_SENSOR 1 |
| #define | CHECK_INPUT 2 |
| #define | CHECK_INTERRUPT 3 |
| #define | CHECK_ULTRASONIC 4 |
| #define | T_LONG 1000 |
| #define | T_IDLE 600 |
| #define | T_RPT 300 |
| #define | T_RPT_PULSE 150 |
| #define | T_REPEAT 30000 |
Variables | |
| aJsonObject * | inputs |
| readCache | inCache |
LightHub input system (digital/analog pins, sensors, encoders).
Every physical input (button, switch, analog pin, rotary encoder, DHT22/CCS811/HDC1080 sensor, counter, uptime) is an Input entry of the global inputs JSON object. An input debounces its signal, runs an IS_* state machine and executes the actions configured in the "act" field (commands to items / emit topics). The runtime state of each input is packed into the inStore union stored in the JSON object itself.
| #define ANALOG_NOIZE 1 |
Analog noise threshold (ADC steps).
| #define ANALOG_STATE_ATTEMPTS 6 |
| #define CHECK_INPUT 2 |
| #define CHECK_INTERRUPT 3 |
| #define CHECK_SENSOR 1 |
Poll causes (see Input::Poll()):
| #define CHECK_ULTRASONIC 4 |
| #define IN_ACTIVE_HIGH 2 |
Input type flags (bitmask, combined with "|"):
Sensor types (no GPIO edge, polled in the CHECK_SENSOR cycle):
Examples: 0 - plain button (default), 1 - toggle button, 2 - active-high switch, 64 - analog input, 66 - active-high analog input, 32 (IN_RE) combined with 0/1 - rotary encoder, 128 - I2C expander button.
| #define IN_ANALOG 64 |
| #define IN_CCS811 5 |
| #define IN_COUNTER 8 |
| #define IN_DHT22 4 |
| #define IN_HDC1080 6 |
| #define IN_I2C 128 |
| #define IN_PUSH_ON 0 |
| #define IN_PUSH_TOGGLE 1 |
| #define IN_RE 32 |
| #define IN_ULTRASONIC 7 |
| #define IN_UPTIME 16 |
| #define IS_IDLE 0 |
Input state machine states (IS_*):
| #define IS_LONG 3 |
| #define IS_LONG2 8u |
| #define IS_LONG3 11u |
| #define IS_NOP 0xF |
| #define IS_PRESSED 1 |
| #define IS_PRESSED2 6 |
| #define IS_PRESSED3 10u |
| #define IS_RELEASED 2 |
| #define IS_RELEASED2 7 |
| #define IS_REPEAT 4 |
| #define IS_REPEAT2 9u |
| #define IS_REPEAT3 12u |
| #define IS_REQSTATE 0xFF |
| #define IS_WAITPRESS 5 |
| #define IS_WAITRELEASE 13u |
| #define SAME_STATE_ATTEMPTS 2 |
Debounce: number of identical reads / analog samples before a state change.
| #define T_IDLE 600 |
| #define T_LONG 1000 |
Timing parameters (ms): long press, idle, auto-repeat period, repeat pulse, max repeat.
| #define T_REPEAT 30000 |
| #define T_RPT 300 |
| #define T_RPT_PULSE 150 |
|
extern |
|
extern |