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

@ -1,8 +1,5 @@
#include "Reader.h"
#include <Mux.h>
#include <Bounce2.h>
Reader::Reader(bool inverted) {
this->inverted = inverted;
@ -22,7 +19,7 @@ uint8_t Reader::getMode(bool pullup) {
DirectReader::DirectReader(uint8_t pin, bool inverted) : Reader(inverted) {
uint8_t mode = getMode(inverted);
this->bouncer.attach(pin)
this->bouncer.attach(pin);
}
bool DirectReader::Update() {
@ -42,20 +39,16 @@ bool MuxReader::Update() {
}
MatrixReader::MatrixReader(uint8_t row, uint8_t col, bool inverted) : Reader(inverted) {
MatrixReader::MatrixReader(uint8_t row, uint8_t col, Matrix* matrix, bool inverted) : Reader(inverted) {
uint8_t mode = getMode(inverted);
this->bouncer.attach(row, mode);
this->col = col;
this->matrix = matrix;
}
bool MatrixReader::Update() {
digitalWrite(col, LOW);
delayMicroseconds(10);
matrix->Activate(col);
bool changed = bouncer.update();
digitalWrite(col, HIGH);
delayMicroseconds(10);
return changed;
}