Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
|
Base class for analog pin sampling classes. More...
#include <AbstractSampler.h>
Public Member Functions | |
AbstractSampler (const uint8_t pin, const uint16_t periodMs) | |
virtual | ~AbstractSampler () |
Destructor. | |
virtual void | begin () |
virtual void | update ()=0 |
Update - must be implemented in derived classes. | |
uint8_t | pin () |
Accessor for the pin which is geting read from. | |
virtual float | average ()=0 |
Implement (and document!) in derived classes. | |
virtual int16_t | last ()=0 |
Get the most recent sample - derived classes must implement. | |
Protected Attributes | |
const uint8_t | _pin |
pin to read data from | |
const uint16_t | _periodMs |
minimum ms | |
Base class for analog pin sampling classes.
All samplers can calulate an averge value. The exact method of calculation and type of average may vary depending on the derived class - see derived class documentation for details.
Definition at line 12 of file AbstractSampler.h.
|
inline |
Constructor
pin | the analog reading pin to read data from |
periodMs | time between samples (set to 0 to sample ever time update() is called) |
Definition at line 19 of file AbstractSampler.h.
|
inlinevirtual |
Initialization Optionally implement in derived classes
Reimplemented in EMASampler, and BufferedSampler.
Definition at line 28 of file AbstractSampler.h.