4#include "../sys/system.h"
36template <
typename BackendType, u
int32_t numPots>
43 deadBand_(1.0 / (1 << 12)),
44 deadBandIdle_(1.0 / (1 << 10)),
74 timeoutCounterMs_[
i] = 0;
87 lastCallSysTime_ =
now;
90 ProcessPot(
i, backend_->GetPotValue(
i),
timeDiff);
101 return timeoutCounterMs_[
potId] < timeout_;
113 return lastValue_[
potId];
133 if(timeoutCounterMs_[
id] < timeout_)
137 float delta = lastValue_[
id] - value;
138 if((
delta > deadBand_) || (
delta < -deadBand_))
140 lastValue_[
id] = value;
142 timeoutCounterMs_[
id] = 0;
147 timeoutCounterMs_[id] += timeDiffMs;
149 if(timeoutCounterMs_[
id] == timeout_)
160 float delta = lastValue_[id] - value;
161 if((delta > deadBandIdle_) || (delta < -deadBandIdle_))
163 lastValue_[id] = value;
166 timeoutCounterMs_[id] = 0;
174 UiEventQueue* queue_;
175 BackendType* backend_;
179 float lastValue_[numPots];
180 uint16_t timeoutCounterMs_[numPots];
181 uint32_t lastCallSysTime_;
Definition leddriver.h:33
A potentiometer monitor that generates events in a UiEventQueue.
Definition PotMonitor.h:38
bool IsMoving(uint16_t potId) const
Definition PotMonitor.h:96
void Init(UiEventQueue &queueToAddEventsTo, BackendType &backend, uint16_t idleTimeoutMs=500, float deadBandIdle=1.0/(1<< 10), float deadBand=1.0/(1<< 12))
Definition PotMonitor.h:59
void Process()
Definition PotMonitor.h:83
float GetCurrentPotValue(uint16_t potId) const
Definition PotMonitor.h:108
PotMonitor()
Definition PotMonitor.h:40
BackendType & GetBackend()
Definition PotMonitor.h:117
uint16_t GetNumPotsMonitored() const
Definition PotMonitor.h:120
A queue that holds user input events in the UI system.
Definition UiEventQueue.h:18
void AddPotMoved(uint16_t potId, float newPosition)
Definition UiEventQueue.h:168
void AddPotActivityChanged(uint16_t potId, bool isActive)
Definition UiEventQueue.h:179
Hardware defines and helpers for daisy field platform.
Definition index.h:2