|
LightHub 4.6.0
Open-source smart home controller firmware
|
A single LightHub input (digital/analog pin, sensor, encoder, ...). More...
#include <inputs.h>
Public Member Functions | |
| Input (aJsonObject *obj, aJsonObject *configObj=NULL) | |
| Create an input from its JSON object. | |
| Input (char *name) | |
| Create an input by name from the global inputs object. | |
| boolean | isValid () |
| void | onContactChanged (int newValue) |
| void | onAnalogChanged (itemCmd newValue) |
| int | Poll (short cause) |
| void | setup () |
| void | stop () |
Static Public Member Functions | |
| static void | onCounterChanged (int i) |
| static void | onCounterChanged0 () |
| static void | onCounterChanged1 () |
| static void | onCounterChanged2 () |
| static void | onCounterChanged3 () |
| static void | onCounterChanged4 () |
| static void | onCounterChanged5 () |
Public Attributes | |
| aJsonObject * | inputObj |
| Pointer to the input's JSON object in the global inputs tree. | |
| uint8_t | inType |
| Input type (IN_* flags). | |
| uint8_t | pin |
| First pin number. | |
| uint8_t | pin2 |
| Second pin number (rotary encoder, ...). | |
| inStore * | store |
| Runtime state, packed in the JSON object's valueint. | |
Protected Member Functions | |
| void | Parse (aJsonObject *configObj=NULL) |
| void | contactPoll (short cause) |
| void | analogPoll (short cause) |
| void | dht22Poll () |
| void | counterPoll () |
| void | attachInterruptPinIrq (int realPin, int irq) |
| unsigned long | nextPollTime () const |
| void | setNextPollTime (unsigned long pollTime) |
| void | uptimePoll () |
| bool | publishDataToDomoticz (int, aJsonObject *, const char *format,...) |
| char * | getIdxField () |
| bool | changeState (uint8_t newState, short cause, aJsonObject *currentInputObject, bool contactState, bool calledOnTimer=false) |
| void | setupRotaryEncoder () |
| aJsonObject * | getCurrentInput () |
| bool | setCurrentInput (aJsonObject *obj) |
| bool | setCurrentInput (int n) |
| bool | setCurrentInput (char *name) |
| bool | checkInstructions (aJsonObject *obj) |
A single LightHub input (digital/analog pin, sensor, encoder, ...).
Input reads one physical input, debounces it, runs the IS_* state machine and executes the actions (commands) configured in the "act" field of the input's JSON object. Supported types are defined by the IN_* flags: buttons, switches, analog inputs, rotary encoders, DHT22/CCS811/HDC1080 sensors, hardware counters and uptime.
| Input::Input | ( | aJsonObject * | obj, |
| aJsonObject * | configObj = NULL ) |
Create an input from its JSON object.
| obj | - the input object (or a nested "act" sub-object) |
| configObj | - object holding the "T"/"#" fields (defaults to obj) |
| Input::Input | ( | char * | name | ) |
Create an input by name from the global inputs object.
|
protected |
Sample the analog value with noise filtering; fire actions on change.
|
protected |
Attach a rising-edge ISR to a counter pin.
|
protected |
Apply a new IS_* state: debouncing, delayed-state handling and execution of the actions configured for the state.
|
protected |
Process the "activate" instruction: switch to another input.
|
protected |
Debounce the contact and advance the IS_* state machine; fire actions on state change.
|
protected |
Publish the hardware counter value to the emit topic.
|
protected |
Read the DHT22 temperature/humidity, execute the temp/hum actions and emit.
|
protected |
|
protected |
| boolean Input::isValid | ( | ) |
|
protected |
| void Input::onAnalogChanged | ( | itemCmd | newValue | ) |
ISR entry for an analog/encoder change carrying the new value.
| void Input::onContactChanged | ( | int | newValue | ) |
ISR entry: raw digital edge; the state change is applied on the next Poll().
|
inlinestatic |
ISR handler: increment a hardware counter value.
|
static |
ISR handlers for counter interrupt numbers 0..5.
|
static |
|
static |
|
static |
|
static |
|
static |
|
protected |
Parse the "T" (type) and "#" (pin / [pin, pin2]) fields of the input object.
| int Input::Poll | ( | short | cause | ) |
Poll the input by cause: CHECK_INPUT/CHECK_INTERRUPT for contacts, CHECK_SENSOR for sensors, CHECK_ULTRASONIC for ultrasonic.
|
protected |
Publish a sensor value in the Domoticz JSON format to the emit topic.
|
protected |
Select the active sub-input of an "act" group by object.
|
protected |
Select the active sub-input of an "act" group by name.
|
protected |
Select the active sub-input of an "act" group by 1-based index.
|
protected |
Set the timestamp of the next allowed poll for this pin.
| void Input::setup | ( | ) |
Initialize pin modes / sensor drivers.
|
protected |
Create the RotaryEncoder instance for an IN_RE input.
| void Input::stop | ( | ) |
Release resources (e.g. delete the rotary encoder instance).
|
protected |
Publish the system uptime (millis) to the emit topic.
| aJsonObject* Input::inputObj |
Pointer to the input's JSON object in the global inputs tree.
| uint8_t Input::inType |
Input type (IN_* flags).
| uint8_t Input::pin |
First pin number.
| uint8_t Input::pin2 |
Second pin number (rotary encoder, ...).
| inStore* Input::store |
Runtime state, packed in the JSON object's valueint.