IoAbstraction
Public Types | Public Member Functions | Protected Attributes | List of all members
AnalogInEvent Class Reference

#include <DeviceEvents.h>

Inheritance diagram for AnalogInEvent:

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
 

Detailed Description

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:

Member Enumeration Documentation

◆ AnalogEventMode

Describes the way in which the Analog event should trigger.

Enumerator
ANALOGIN_EXCEEDS 

Trigger the event when it exceeds the threshold

ANALOGIN_BELOW 

Trigger the event when it goes below the threshold

ANALOGIN_CHANGE 

Trigger the event when it changes by more than threshold

Constructor & Destructor Documentation

◆ AnalogInEvent() [1/2]

AnalogInEvent::AnalogInEvent ( AnalogDevice device,
pinid_t  inputPin,
float  threshold,
AnalogEventMode  mode_,
uint32_t  pollInterval_ 
)
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

Parameters
devicethe analog device as a reference
inputPinthe pin to read from
thresholdthe 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

◆ AnalogInEvent() [2/2]

AnalogInEvent::AnalogInEvent ( AnalogDevice device,
pinid_t  inputPin,
float  threshold,
AnalogEventMode  mode_,
uint32_t  pollInterval_ 
)
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.

Parameters
devicethe analog device
inputPinthe pin to read from
thresholdthe 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

Member Function Documentation

◆ setPollInterval()

void AnalogInEvent::setPollInterval ( uint32_t  micros)
inline

Change to another polling interval

Parameters
microsthe new polling interval in microseconds

◆ timeOfNextCheck()

uint32_t AnalogInEvent::timeOfNextCheck ( )
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.

Returns
the configured poll interval.

◆ isConditionTrue()

bool AnalogInEvent::isConditionTrue ( )
inline

Checks if the condition for the event is met, IE if the analog in value is within the range for the interrupt.

Returns
true if the condition is met, otherwise false.

◆ readingAvailable()

void AnalogInEvent::readingAvailable ( )
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


The documentation for this class was generated from the following file: