// "Readers" represent different methods for reading the state of a pin. // They also include debouncing logic using the Bounce2 library, when appropriate. #ifndef _READER_H_ #define _READER_H_ #include <Bounce2.h> #include <Mux.h> // The abstract base class - a very simple interface class Reader { public: Reader(bool inverted); virtual bool Update() = 0; // should return true if the state of the pin has changed bool On(); protected: uint8_t getMode(bool pullup); Bounce bouncer; bool inverted; }; // A standard reader; the button is connected directly to a switch class DirectReader { public: DirectReader(uint8_t pin, bool inverted = true); bool Update(); bool On(); }; // The button is connected to a Multiplexer channel class MuxReader { public: MuxReader(uint8_t channel, Mux* mux, bool inverted = true); bool Update(); bool On(); protected: Mux * mux; }; // The button is connected via a scan matrix // "row" should always be the input, with "col" the selecter. class MatrixReader { public: MatrixReader(uint8_t row, uint8_t col, bool inverted = true); bool Update(); bool On(); protected: uint8_t col; }; #endif