6 #ifndef IOABSTRACTION_DEVICEEVENTS_H
7 #define IOABSTRACTION_DEVICEEVENTS_H
14 #include "TaskManagerIO.h"
15 #include "PlatformDetermination.h"
46 uint32_t pollInterval;
50 float analogThreshold;
63 uint32_t pollInterval_) : BaseEvent() {
64 analogThreshold = threshold;
67 pollInterval = pollInterval_;
68 analogDevice = &device;
83 uint32_t pollInterval_) : BaseEvent() {
84 analogThreshold = threshold;
87 pollInterval = pollInterval_;
88 analogDevice = device;
98 pollInterval = micros;
108 lastReading = analogDevice->getCurrentFloat(analogPin);
110 if (analogTrigger && !latched) {
114 else if(!analogTrigger && latched) {
126 return lastReading < analogThreshold;
129 return lastReading > analogThreshold;
132 auto change = abs(analogThreshold - lastReading);
133 return change > analogThreshold;
144 taskManager.triggerEvents();
Contains a series of helper classes for dealing with analog devices, these are compatible across a wi...
Definition: AnalogDeviceAbstraction.h:31
Definition: DeviceEvents.h:30
bool isConditionTrue()
Definition: DeviceEvents.h:124
AnalogInEvent(AnalogDevice *device, pinid_t inputPin, float threshold, AnalogEventMode mode_, uint32_t pollInterval_)
Definition: DeviceEvents.h:82
void setPollInterval(uint32_t micros)
Definition: DeviceEvents.h:97
AnalogInEvent(AnalogDevice &device, pinid_t inputPin, float threshold, AnalogEventMode mode_, uint32_t pollInterval_)
Definition: DeviceEvents.h:62
void readingAvailable()
Definition: DeviceEvents.h:143
uint32_t timeOfNextCheck() override
Definition: DeviceEvents.h:107
AnalogEventMode
Definition: DeviceEvents.h:35
@ ANALOGIN_BELOW
Definition: DeviceEvents.h:39
@ ANALOGIN_EXCEEDS
Definition: DeviceEvents.h:37
@ ANALOGIN_CHANGE
Definition: DeviceEvents.h:41