#include <DeviceEvents.h>
Public Types | |
enum | AnalogEventMode { ANALOGIN_EXCEEDS , ANALOGIN_BELOW , ANALOGIN_CHANGE } |
Public Member Functions | |
AnalogInEvent (AnalogDevice &device, pinid_t inputPin, float threshold, AnalogEventMode mode_, uint32_t pollInterval_) | |
AnalogInEvent (AnalogDevice *device, pinid_t inputPin, float threshold, AnalogEventMode mode_, uint32_t pollInterval_) | |
void | setPollInterval (uint32_t micros) |
uint32_t | timeOfNextCheck () override |
bool | isConditionTrue () |
void | readingAvailable () |
Protected Attributes | |
float | analogThreshold |
float | lastReading |
An event that triggers when a certain analog condition is reached, based on a made and a threshold. It can either poll the analog in pin by setting the poll interval to a small value, or can be interrupt driven by calling the readingAvailable
method from the ISR, you can even use a combination of the two. The exec
method must be implemented by the implementor.
There are three possible combinations:
|
inline |
Constructs the abstract analog event class. Providing the analog pin to read from and the mode for triggering. This constructor allows for use of a reference instead of pointer for analog device
device | the analog device as a reference |
inputPin | the pin to read from |
threshold | the value at which to trigger the event. |
mode_ | one of the values in enum AnalogEventMode |
pollInterval_ | the interval on which taskManager should check if the event needs to trigger |
|
inline |
Constructs the abstract analog event class. Providing the analog pin to read from and the mode for triggering. This constructor takes a pointer to the analog device.
device | the analog device |
inputPin | the pin to read from |
threshold | the value at which to trigger the event. |
mode_ | one of the values in enum AnalogEventMode |
pollInterval_ | the interval on which taskManager should check if the event needs to trigger |
|
inline |
Change to another polling interval
micros | the new polling interval in microseconds |
|
inlineoverride |
Implementation of the method that checks the analog reading against the condition for this instance. If the condition is met, then it triggers the event, which stays latched until the condition is no longer met, and then it is unlatched.
|
inline |
Checks if the condition for the event is met, IE if the analog in value is within the range for the interrupt.
|
inline |
Non-polling case, change interrupt attached to analog pin. We've been notified that a reading available from interrupt, tell taskmanager to run event evaluation now. This will cause all events to run a check followed by the trigger if needed. Completely safe to call from interrupts and other threads