Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
EMAVDivSampler.cpp
1 #include "EMAVDivSampler.h"
2 #include "VIPCalculation.h"
3 
4 EMAVDivSampler::EMAVDivSampler(const uint8_t pin,
5  const uint16_t r1KOhm,
6  const uint16_t r2KOhm,
7  const float vRef,
8  const uint16_t periodMs,
9  const float alpha) :
10  EMASampler(pin, periodMs, alpha),
11  _r1KOhm(r1KOhm),
12  _r2KOhm(r2KOhm),
13  _vRef(vRef)
14 {
15 }
16 
18 {
19  return vDivVolts(average(), _r1KOhm, _r2KOhm, _vRef);
20 }
21 
23 {
24  return vDivVolts(last(), _r1KOhm, _r2KOhm, _vRef);
25 }
26 
27 
virtual float average()
Definition: EMASampler.h:63
virtual float averageVolts()
Get the mean value in the sample set.
Exponential Moving Average (EMA) analog pin sampler.
Definition: EMASampler.h:28
EMAVDivSampler(const uint8_t pin, const uint16_t r1KOhm, const uint16_t r2KOhm, const float vRef, const uint16_t periodMs, const float alpha)
virtual int16_t last()
Definition: EMASampler.h:67
virtual float lastVolts()
Get the most recent voltage value.