Rework example code, fix bugs and get to compiling state. Also introduce missing logic for the Matrix code to keep track of what column is active.

This commit is contained in:
Anna Rose Wiggins 2021-11-22 20:10:08 +00:00
parent 8ebc1a5523
commit 690afdbce5
18 changed files with 194 additions and 26 deletions

View file

@ -4,9 +4,13 @@
#ifndef _READER_H_
#define _READER_H_
#include "Matrix.h"
#include <Arduino.h>
#include <Bounce2.h>
#include <Mux.h>
using namespace admux;
// The abstract base class - a very simple interface
class Reader {
public:
@ -24,7 +28,7 @@ class Reader {
// A standard reader; the button is connected directly to a switch
class DirectReader {
class DirectReader : public Reader {
public:
DirectReader(uint8_t pin, bool inverted = true);
bool Update();
@ -33,27 +37,29 @@ class DirectReader {
// The button is connected to a Multiplexer channel
class MuxReader {
class MuxReader : public Reader {
public:
MuxReader(uint8_t channel, Mux* mux, bool inverted = true);
bool Update();
bool On();
protected:
uint8_t channel;
Mux * mux;
};
// The button is connected via a scan matrix
// "row" should always be the input, with "col" the selecter.
class MatrixReader {
class MatrixReader : public Reader {
public:
MatrixReader(uint8_t row, uint8_t col, bool inverted = true);
MatrixReader(uint8_t row, uint8_t col, Matrix* matrix, bool inverted = true);
bool Update();
bool On();
protected:
uint8_t col;
Matrix* matrix;
};
#endif