#include "Reader.h" Reader::Reader(bool inverted) { this->inverted = inverted; } bool Reader::On() { bool state = bouncer.rose(); if (inverted) state = bouncer.fell(); return state; } uint8_t Reader::getMode(bool pullup) { if (pullup) return INPUT_PULLUP; return INPUT; } DirectReader::DirectReader(uint8_t pin, bool inverted) : Reader(inverted) { uint8_t mode = getMode(inverted); this->bouncer.attach(pin); } bool DirectReader::Update() { return bouncer.update(); } MuxReader::MuxReader(uint8_t channel, Mux* mux, bool inverted) : Reader(inverted) { uint8_t mode = getMode(inverted); this->bouncer.attach(mux->signalPin().pin, mode); this->channel = channel; } bool MuxReader::Update() { mux->channel(channel); return bouncer.update(); } 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() { matrix->Activate(col); bool changed = bouncer.update(); return changed; }