Class daisy::PotMonitor¶
template <typename BackendType, uint32_t numPots>
ClassList > daisy > PotMonitor
A potentiometer monitor that generates events in a UiEventQueue .More...
#include <PotMonitor.h>
Public Functions¶
Type | Name |
---|---|
BackendType & | GetBackend () |
float | GetCurrentPotValue (uint16_t potId) const |
uint16_t | GetNumPotsMonitored () const |
void | Init (UiEventQueue & queueToAddEventsTo, BackendType & backend, uint16_t idleTimeoutMs=500, float deadBandIdle=1.0/(1<< 10), float deadBand=1.0/(1<< 12)) |
bool | IsMoving (uint16_t potId) const |
PotMonitor () |
|
void | Process () |
Detailed Description¶
Author:
jelliesen
This class monitors a number of potentiometers and detects pot movements. When a movement is detected, an event is added to a UiEventQueue. Pots can be either "idle" or "moving" in which case different dead bands are applied to them. The current state and value of a pot can be requested at any time.
This class can monitor an arbitrary number of potentiometers, as configured by its template argument numPots
. Each of the pots is identified by an ID number from 0 .. numPots - 1
. This number will also be used when events are posted to the UiEventQueue. It's suggested to define an enum in your project like this: In different projects, diffent ways of reading the potentiometer positions will be used. That's why this class uses a generic backend that you'll have to write. The BackendType class will provide the source data for each potentiometer. An instance of this backend must be supplied via the constructor. It must implement the following public function via which the PotMonitor will request the current value of the potentiometer in the range 0 .. 1
:
Template parameters:
BackendType
The class type of the backend that will supply pot values.numPots
The number of pots to monitor.
Public Functions Documentation¶
function GetBackend¶
Returns the BackendType that is used by the monitor.
function GetCurrentPotValue¶
For a given potentiometer, this will return the last value that was posted to the UiEventQueue.
Parameters:
potId
The unique ID of the potentiometer (< numPots)
function GetNumPotsMonitored¶
Returns the number of pots that are monitored by this class.
function Init¶
inline void daisy::PotMonitor::Init (
UiEventQueue & queueToAddEventsTo,
BackendType & backend,
uint16_t idleTimeoutMs=500,
float deadBandIdle=1.0/(1<< 10),
float deadBand=1.0/(1<< 12)
)
Initialises the PotMonitor.
Parameters:
queueToAddEventsTo
The UiEventQueue to which events should be posted.backend
The backend that supplies the current value of each potentiometer.idleTimeoutMs
When the pot is currently moving, but no event is generated over "idleTimeoutMs", the pot enters the idle state.deadBandIdle
The dead band that must be exceeded before a movement is detected when the pot is currently idle.deadBand
The dead band that must be exceeded before a movement is detected when the pot is currently moving.
function IsMoving¶
Returns true, if the requested pot is currently being moved.
Parameters:
potId
The unique ID of the potentiometer (< numPots)
function PotMonitor [½]¶
function Process¶
Checks the value of each pot and generates messages for the UIEventQueue. Call this at regular intervals, ideally from your main() idle loop.
The documentation for this class was generated from the following file external-docs/libDaisy/src/ui/PotMonitor.h