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

Public Member Functions | |
| EMACurrentSampler (const uint8_t pin, const float vSupply, const float vRef, const float iOffset, const uint16_t periodMs, const float alpha) | |
| virtual float | averageAmps () |
| Get the mean value in the sample set. | |
| virtual float | lastAmps () |
| 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 | |
| float | _vSupply |
| float | _vRef |
| float | _iOffset |
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 current sampler.
Sampler a current, EMA method.
Definition at line 10 of file EMACurrentSampler.h.
| EMACurrentSampler::EMACurrentSampler | ( | const uint8_t | pin, |
| const float | vSupply, | ||
| const float | vRef, | ||
| const float | iOffset, | ||
| 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 EMACurrentSampler.cpp.
1.8.15