Archived
1
0

move Row::process() to RowBase

This commit is contained in:
wolfv6 2016-06-09 21:11:18 -06:00
parent 1b091ecde5
commit 2b856afa26
6 changed files with 37 additions and 29 deletions

View File

@ -1,4 +1,20 @@
#include "RowBase.h" #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
uint8_t rowState; //1 means pressed, 0 means released
uint16_t rowEnd; //1 bit marks positioned after last key of row
uint8_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. /* wait() delay's scan to give switches time to debounce.
This version of wait() is very simple. More sophisticated versions can override this one. This version of wait() is very simple. More sophisticated versions can override this one.

View File

@ -23,6 +23,8 @@ class RowBase
void pressRelease(const uint16_t rowEnd, const uint8_t debouncedChanged); void pressRelease(const uint16_t rowEnd, const uint8_t debouncedChanged);
public: public:
RowBase(Key *const ptrsKeys[]) : ptrsKeys(ptrsKeys), debounced(0) { } RowBase(Key *const ptrsKeys[]) : ptrsKeys(ptrsKeys), debounced(0) { }
virtual void process()=0; virtual void process();
virtual uint8_t scan(uint16_t& rowEnd)=0;
virtual uint8_t debounce(const uint8_t rowState, uint8_t& debounced)=0;
}; };
#endif #endif

View File

@ -1,17 +1,11 @@
#include "Row_IOE.h" #include "Row_IOE.h"
/* uint8_t Row_IOE::scan(uint16_t& rowEnd)
process() scans the row and calls any newly pressed or released keys.
*/
void Row_IOE::process()
{ {
//these variables are all bitwise, one bit per key return scanner.scan(rowEnd);
uint8_t rowState; //1 means pressed, 0 means released }
uint16_t rowEnd; //1 bit marks positioned after last key of row
uint8_t debouncedChanged; //1 means debounced changed uint8_t Row_IOE::debounce(const uint8_t rowState, uint8_t& debounced)
{
wait(); return debouncer.debounce(rowState, debounced);
rowState = scanner.scan(rowEnd);
debouncedChanged = debouncer.debounce(rowState, debounced);
pressRelease(rowEnd, debouncedChanged);
} }

View File

@ -23,6 +23,7 @@ class Row_IOE : public RowBase
Row_IOE( RowPort& refRowPort, const uint8_t strobePin, Row_IOE( RowPort& refRowPort, const uint8_t strobePin,
ColPort& refColPort, Key *const ptrsKeys[]) ColPort& refColPort, Key *const ptrsKeys[])
: RowBase(ptrsKeys), scanner(refRowPort, strobePin, refColPort) { } : RowBase(ptrsKeys), scanner(refRowPort, strobePin, refColPort) { }
virtual void process(); uint8_t scan(uint16_t& rowEnd);
uint8_t debounce(const uint8_t rowState, uint8_t& debounced);
}; };
#endif #endif

View File

@ -1,17 +1,11 @@
#include "Row_uC.h" #include "Row_uC.h"
/* uint8_t Row_uC::scan(uint16_t& rowEnd)
process() scans the row and calls any newly pressed or released keys.
*/
void Row_uC::process()
{ {
//these variables are all bitwise, one bit per key return scanner.scan(rowEnd);
uint8_t rowState; //1 means pressed, 0 means released }
uint16_t rowEnd; //1 bit marks positioned after last key of row
uint8_t debouncedChanged; //1 means debounced changed uint8_t Row_uC::debounce(const uint8_t rowState, uint8_t& debounced)
{
wait(); return debouncer.debounce(rowState, debounced);
rowState = scanner.scan(rowEnd);
debouncedChanged = debouncer.debounce(rowState, debounced);
pressRelease(rowEnd, debouncedChanged);
} }

View File

@ -22,6 +22,7 @@ class Row_uC : public RowBase
Row_uC(const uint8_t strobePin, const uint8_t readPins[], const uint8_t READ_PIN_COUNT, Row_uC(const uint8_t strobePin, const uint8_t readPins[], const uint8_t READ_PIN_COUNT,
Key *const ptrsKeys[]) Key *const ptrsKeys[])
: RowBase(ptrsKeys), scanner(strobePin, readPins, READ_PIN_COUNT) { } : RowBase(ptrsKeys), scanner(strobePin, readPins, READ_PIN_COUNT) { }
virtual void process(); uint8_t scan(uint16_t& rowEnd);
uint8_t debounce(const uint8_t rowState, uint8_t& debounced);
}; };
#endif #endif