|
Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
|
Exponential Moving Average Voltage Divider based voltage sampler. More...
#include <EMAVDivSampler.h>

Public Member Functions | |
| EMAVDivSampler (const uint8_t pin, const uint16_t r1KOhm, const uint16_t r2KOhm, const float vRef, const uint16_t periodMs, const float alpha) | |
| virtual float | averageVolts () |
| Get the mean value in the sample set. | |
| virtual float | lastVolts () |
| Get the most recent voltage value. | |
Public Member Functions inherited from EMASampler | |
| EMASampler (const uint8_t pin, const uint16_t periodMs=10, const float alpha=0.5) | |
| ~EMASampler () | |
| virtual void | begin () |
| virtual void | update () |
| virtual float | average () |
| virtual int16_t | last () |
Public Member Functions inherited from AbstractSampler | |
| AbstractSampler (const uint8_t pin, const uint16_t periodMs) | |
| virtual | ~AbstractSampler () |
| Destructor. | |
| uint8_t | pin () |
| Accessor for the pin which is geting read from. | |
Protected Attributes | |
| uint16_t | _r1KOhm |
| uint16_t | _r2KOhm |
| float | _vRef |
Protected Attributes inherited from EMASampler | |
| float | _alpha |
| alpha value used in EMA calculation | |
| uint32_t | _lastUpdated |
| when last sample taken | |
| float | _movingAverage |
| most recently calculated mean value | |
| int16_t | _lastSample |
| keep the most recent sample | |
Protected Attributes inherited from AbstractSampler | |
| const uint8_t | _pin |
| pin to read data from | |
| const uint16_t | _periodMs |
| minimum ms | |
Exponential Moving Average Voltage Divider based voltage sampler.
Sampler a voltage using a voltage divider, EMA method.
Definition at line 10 of file EMAVDivSampler.h.
| EMAVDivSampler::EMAVDivSampler | ( | const uint8_t | pin, |
| const uint16_t | r1KOhm, | ||
| const uint16_t | r2KOhm, | ||
| const float | vRef, | ||
| const uint16_t | periodMs, | ||
| const float | alpha | ||
| ) |
Constructor
| pin | the analog input pin to read samples from |
| periodMs | the number of milliseconds between samples. If update() is called before periodMs has passed since the last update(), no sample will be taken. |
| samples | the number of samples to keep in the ring buffer used to calculate average(), minimum() and maximum(). |
Note: this class dynamically allocated memory for the ring buffer.
Definition at line 4 of file EMAVDivSampler.cpp.
1.8.15