Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
AbstractSampler.h
1 #pragma once
2 
3 #include <stdint.h>
4 
5 
13 public:
19  AbstractSampler(const uint8_t pin, const uint16_t periodMs) :
20  _pin(pin),
21  _periodMs(periodMs) {;}
22 
24  virtual ~AbstractSampler() {;};
25 
28  virtual void begin() {;}
29 
31  virtual void update() = 0;
32 
34  uint8_t pin() { return _pin; }
35 
37  virtual float average() = 0;
38 
40  virtual int16_t last() = 0;
41 
42 protected:
43  const uint8_t _pin;
44  const uint16_t _periodMs;
45 
46 };
47 
AbstractSampler(const uint8_t pin, const uint16_t periodMs)
virtual void update()=0
Update - must be implemented in derived classes.
virtual void begin()
const uint8_t _pin
pin to read data from
virtual ~AbstractSampler()
Destructor.
const uint16_t _periodMs
minimum ms
virtual float average()=0
Implement (and document!) in derived classes.
uint8_t pin()
Accessor for the pin which is geting read from.
virtual int16_t last()=0
Get the most recent sample - derived classes must implement.
Base class for analog pin sampling classes.