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
AbstractSampler Class Referenceabstract

Base class for analog pin sampling classes. More...

#include <AbstractSampler.h>

Inheritance diagram for AbstractSampler:
Inheritance graph

Public Member Functions

 AbstractSampler (const uint8_t pin, const uint16_t periodMs)
 
virtual ~AbstractSampler ()
 Destructor.
 
virtual void begin ()
 
virtual void update ()=0
 Update - must be implemented in derived classes.
 
uint8_t pin ()
 Accessor for the pin which is geting read from.
 
virtual float average ()=0
 Implement (and document!) in derived classes.
 
virtual int16_t last ()=0
 Get the most recent sample - derived classes must implement.
 

Protected Attributes

const uint8_t _pin
 pin to read data from
 
const uint16_t _periodMs
 minimum ms
 

Detailed Description

Base class for analog pin sampling classes.

All samplers can calulate an averge value. The exact method of calculation and type of average may vary depending on the derived class - see derived class documentation for details.

Definition at line 12 of file AbstractSampler.h.

Constructor & Destructor Documentation

◆ AbstractSampler()

AbstractSampler::AbstractSampler ( const uint8_t  pin,
const uint16_t  periodMs 
)
inline

Constructor

Parameters
pinthe analog reading pin to read data from
periodMstime between samples (set to 0 to sample ever time update() is called)

Definition at line 19 of file AbstractSampler.h.

Member Function Documentation

◆ begin()

virtual void AbstractSampler::begin ( )
inlinevirtual

Initialization Optionally implement in derived classes

Reimplemented in EMASampler, and BufferedSampler.

Definition at line 28 of file AbstractSampler.h.


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