Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
Public Member Functions | Protected Attributes | List of all members
EMACurrentSampler Class Reference

Exponential Moving Average current sampler. More...

#include <EMACurrentSampler.h>

Inheritance diagram for EMACurrentSampler:
Inheritance graph

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
 

Detailed Description

Exponential Moving Average current sampler.

Sampler a current, EMA method.

Definition at line 10 of file EMACurrentSampler.h.

Constructor & Destructor Documentation

◆ EMACurrentSampler()

EMACurrentSampler::EMACurrentSampler ( const uint8_t  pin,
const float  vSupply,
const float  vRef,
const float  iOffset,
const uint16_t  periodMs,
const float  alpha 
)

Constructor

Parameters
pinthe analog input pin to read samples from
periodMsthe number of milliseconds between samples. If update() is called before periodMs has passed since the last update(), no sample will be taken.
samplesthe 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.


The documentation for this class was generated from the following files: