From 84fc616916a181204fce4f0f36db4cf5355d1479 Mon Sep 17 00:00:00 2001 From: wolfv6 Date: Thu, 2 Jun 2016 15:51:42 -0600 Subject: [PATCH] swap places of debounced and previousDebounced --- src/Row.cpp | 5 +++-- src/RowBase.cpp | 4 ++-- src/RowBase.h | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Row.cpp b/src/Row.cpp index 8a8b82c..a348859 100644 --- a/src/Row.cpp +++ b/src/Row.cpp @@ -39,7 +39,7 @@ Returns bitwise debouncedChanged. uint8_t Row::debounce(const uint8_t rowState) { - uint8_t debounced; //bitwise, 1 means pressed, 0 means released + uint8_t previousDebounced; //bitwise, one bit per key uint8_t debouncedChanged; //bitwise, 1 means debounced changed uint8_t all_1 = ~0; //bitwise uint8_t all_0 = 0; //bitwise @@ -57,6 +57,8 @@ uint8_t Row::debounce(const uint8_t rowState) all_0 |= samples[j]; //0 if all samples are 0 } + previousDebounced = debounced; + // update newDebounce if all the samples agree with one another // if all samples=1 then debounced=1 // elseif all samples=0 then debounced=0 @@ -64,6 +66,5 @@ uint8_t Row::debounce(const uint8_t rowState) debounced = all_1 | (all_0 & previousDebounced); debouncedChanged = debounced xor previousDebounced; - previousDebounced = debounced; return debouncedChanged; } diff --git a/src/RowBase.cpp b/src/RowBase.cpp index a2b26dc..7d708ee 100644 --- a/src/RowBase.cpp +++ b/src/RowBase.cpp @@ -140,10 +140,10 @@ void RowBase::pressRelease(const uint16_t rowEnd, const uint8_t debouncedChanged uint8_t col; //index for ptrsKeys[col] array //bit=1 if last debounced changed from 1 to 0, else bit=0 - isFallingEdge = debouncedChanged & ~previousDebounced; + isFallingEdge = debouncedChanged & ~debounced; //bit=1 if last debounced changed from 0 to 1, else bit=0 - isRisingEdge = debouncedChanged & previousDebounced; + isRisingEdge = debouncedChanged & debounced; for (rowMask=1, col=0; rowMask