2 #include "MutilaDebug.h" 4 #include "BufferedSampler.h" 31 _DBLN(F(
"BufferedSampler::begin"));
45 _DB(F(
"BufferedSampler::update sample="));
65 for (uint8_t i=1; i<
_count; i++) {
virtual int16_t last()
Get the most recent sample value.
uint32_t _lastUpdated
when last sample taken
const uint8_t _pin
pin to read data from
int16_t * _sampleData
ring buffer for data
uint8_t _samples
max number of samples to keep in buffer
const uint16_t _periodMs
minimum ms
uint8_t _count
number of samples in buffer
float _mean
most recently calculated mean value
int16_t _minimum
most recently calculated minimum value
BufferedSampler(const uint8_t pin, const uint16_t periodMs=10, const uint8_t samples=10)
bool _updated
flag to re-calulate avg or not
Base class for analog pin sampling classes.
int16_t _maximum
most recently calculated maximum value
virtual void calculate()
calculate avg, min, max if required
uint8_t _idx
index ptr (ring buffer)