diff --git a/src/RowBase.cpp b/src/RowBase.cpp index 395430a..916c644 100644 --- a/src/RowBase.cpp +++ b/src/RowBase.cpp @@ -1,20 +1,4 @@ #include "RowBase.h" -/* -process() scans the row and calls any newly pressed or released keys. -*/ -void RowBase::process() -{ - //these variables are all bitwise, one bit per key - read_pins_t rowState; //1 means pressed, 0 means released - read_pins_mask_t rowEnd; //1 bit marks positioned after last key of row - read_pins_t debouncedChanged; //1 means debounced changed - - wait(); - rowState = scan(rowEnd); - debouncedChanged = debounce(rowState, debounced); - pressRelease(rowEnd, debouncedChanged); -} - /* wait() delay's scan to give switches time to debounce. This version of wait() is very simple. More sophisticated versions can override this one. diff --git a/src/RowBase.h b/src/RowBase.h index cf75836..5372c7e 100644 --- a/src/RowBase.h +++ b/src/RowBase.h @@ -21,8 +21,6 @@ class RowBase void pressRelease(const read_pins_mask_t rowEnd, const read_pins_t debouncedChanged); public: RowBase(Key *const ptrsKeys[]) : ptrsKeys(ptrsKeys), debounced(0) { } - virtual void process(); - virtual read_pins_t scan(read_pins_mask_t& rowEnd)=0; - virtual read_pins_t debounce(const read_pins_t rowState, read_pins_t& debounced)=0; + virtual void process()=0; }; #endif diff --git a/src/Row_IOE.cpp b/src/Row_IOE.cpp index d8a168b..5a6ab3f 100644 --- a/src/Row_IOE.cpp +++ b/src/Row_IOE.cpp @@ -1,11 +1,14 @@ #include "Row_IOE.h" -read_pins_t Row_IOE::scan(read_pins_mask_t& rowEnd) +void Row_IOE::process() { - return scanner.scan(rowEnd); -} + //these variables are all bitwise, one bit per key + read_pins_t rowState; //1 means pressed, 0 means released + read_pins_mask_t rowEnd; //1 bit marks positioned after last key of row + read_pins_t debouncedChanged; //1 means debounced changed -read_pins_t Row_IOE::debounce(const read_pins_t rowState, read_pins_t& debounced) -{ - return debouncer.debounce(rowState, debounced); + wait(); + rowState = scanner.scan(rowEnd); + debouncedChanged = debouncer.debounce(rowState, debounced); + pressRelease(rowEnd, debouncedChanged); } diff --git a/src/Row_IOE.h b/src/Row_IOE.h index ca147a9..d2e7c85 100644 --- a/src/Row_IOE.h +++ b/src/Row_IOE.h @@ -40,7 +40,6 @@ class Row_IOE : public RowBase Row_IOE( RowPort& refRowPort, const uint8_t strobePin, ColPort& refColPort, Key *const ptrsKeys[]) : RowBase(ptrsKeys), scanner(refRowPort, strobePin, refColPort) { } - read_pins_t scan(read_pins_mask_t& rowEnd); - read_pins_t debounce(const read_pins_t rowState, read_pins_t& debounced); + void process(); }; #endif diff --git a/src/Row_ShiftRegisters.cpp b/src/Row_ShiftRegisters.cpp index 46ad104..2dd5ea2 100644 --- a/src/Row_ShiftRegisters.cpp +++ b/src/Row_ShiftRegisters.cpp @@ -1,16 +1,19 @@ #include "Row_ShiftRegisters.h" +void Row_ShiftRegisters::process() +{ + //these variables are all bitwise, one bit per key + read_pins_t rowState; //1 means pressed, 0 means released + read_pins_mask_t rowEnd; //1 bit marks positioned after last key of row + read_pins_t debouncedChanged; //1 means debounced changed + + wait(); + rowState = scanner.scan(rowEnd); + debouncedChanged = debouncer.debounce(rowState, debounced); + pressRelease(rowEnd, debouncedChanged); +} + void Row_ShiftRegisters::begin() { scanner.begin(); } - -read_pins_t Row_ShiftRegisters::scan(read_pins_mask_t& rowEnd) -{ - return scanner.scan(rowEnd); -} - -read_pins_t Row_ShiftRegisters::debounce(const read_pins_t rowState, read_pins_t& debounced) -{ - return debouncer.debounce(rowState, debounced); -} diff --git a/src/Row_ShiftRegisters.h b/src/Row_ShiftRegisters.h index e2bf572..6c2d144 100644 --- a/src/Row_ShiftRegisters.h +++ b/src/Row_ShiftRegisters.h @@ -34,7 +34,6 @@ class Row_ShiftRegisters : public RowBase Row_ShiftRegisters(const uint8_t STROBE_PIN, Key *const ptrsKeys[], uint8_t KEY_COUNT) : RowBase(ptrsKeys), scanner(STROBE_PIN, KEY_COUNT) { } void begin(); - read_pins_t scan(read_pins_mask_t& rowEnd); - read_pins_t debounce(const read_pins_t rowState, read_pins_t& debounced); + void process(); }; #endif diff --git a/src/Row_uC.cpp b/src/Row_uC.cpp index 9b3dc83..a865c2a 100644 --- a/src/Row_uC.cpp +++ b/src/Row_uC.cpp @@ -1,11 +1,17 @@ #include "Row_uC.h" -read_pins_t Row_uC::scan(read_pins_mask_t& rowEnd) +/* +process() scans the row and calls any newly pressed or released keys. +*/ +void Row_uC::process() { - return scanner.scan(rowEnd); -} + //these variables are all bitwise, one bit per key + read_pins_t rowState; //1 means pressed, 0 means released + read_pins_mask_t rowEnd; //1 bit marks positioned after last key of row + read_pins_t debouncedChanged; //1 means debounced changed -read_pins_t Row_uC::debounce(const read_pins_t rowState, read_pins_t& debounced) -{ - return debouncer.debounce(rowState, debounced); + wait(); + rowState = scanner.scan(rowEnd); + debouncedChanged = debouncer.debounce(rowState, debounced); + pressRelease(rowEnd, debouncedChanged); } diff --git a/src/Row_uC.h b/src/Row_uC.h index 6d267da..3c2f625 100644 --- a/src/Row_uC.h +++ b/src/Row_uC.h @@ -35,7 +35,6 @@ class Row_uC : public RowBase Row_uC(const uint8_t strobePin, const uint8_t readPins[], const uint8_t READ_PIN_COUNT, Key *const ptrsKeys[]) : RowBase(ptrsKeys), scanner(strobePin, readPins, READ_PIN_COUNT) { } - read_pins_t scan(read_pins_mask_t& rowEnd); - read_pins_t debounce(const read_pins_t rowState, read_pins_t& debounced); + void process(); }; #endif