|
|
@@ -7,14 +7,14 @@ void RowBase::process(const bool activeHigh) |
|
|
|
//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 newDebounced; //1 means pressed, 0 means released |
|
|
|
uint8_t debounced; //1 means pressed, 0 means released |
|
|
|
uint8_t isFallingEdge; //1 means falling edge |
|
|
|
uint8_t isRisingEdge; //1 means rising edge |
|
|
|
|
|
|
|
scan(activeHigh); //save column-port-pin values to portState |
|
|
|
rowState = getRowState(rowEnd, activeHigh); |
|
|
|
newDebounced = debounce(rowState); |
|
|
|
detectEdge(newDebounced, isFallingEdge, isRisingEdge); |
|
|
|
debounced = debounce(rowState); |
|
|
|
detectEdge(debounced, isFallingEdge, isRisingEdge); |
|
|
|
pressRelease(rowEnd, isFallingEdge, isRisingEdge); |
|
|
|
} |
|
|
|
|
|
|
@@ -98,18 +98,18 @@ uint8_t RowBase::getRowState(uint16_t& rowEnd, const bool activeHigh) |
|
|
|
Computes isFallingEdge and isRisingEdge. |
|
|
|
All 3 parameters are bitwise. |
|
|
|
*/ |
|
|
|
void RowBase::detectEdge(uint8_t newDebounced, uint8_t& isFallingEdge, uint8_t& isRisingEdge) |
|
|
|
void RowBase::detectEdge(uint8_t debounced, uint8_t& isFallingEdge, uint8_t& isRisingEdge) |
|
|
|
{ |
|
|
|
uint8_t debouncedChanged; //bitwise |
|
|
|
|
|
|
|
debouncedChanged = newDebounced xor debounced; |
|
|
|
debounced = newDebounced; |
|
|
|
debouncedChanged = debounced xor previousDebounced; |
|
|
|
previousDebounced = debounced; |
|
|
|
|
|
|
|
//bit=1 if last debounced changed from 1 to 0, else bit=0 |
|
|
|
isFallingEdge = debouncedChanged & ~debounced; |
|
|
|
isFallingEdge = debouncedChanged & ~previousDebounced; |
|
|
|
|
|
|
|
//bit=1 if last debounced changed from 0 to 1, else bit=0 |
|
|
|
isRisingEdge = debouncedChanged & debounced; |
|
|
|
isRisingEdge = debouncedChanged & previousDebounced; |
|
|
|
} |
|
|
|
|
|
|
|
/* |