diff -r 5b1e0b384d31 -r 86f099bda525 lib/keypad/Keypad.cpp --- a/lib/keypad/Keypad.cpp Sun Aug 30 22:53:15 2020 +0200 +++ b/lib/keypad/Keypad.cpp Thu Oct 15 01:11:03 2020 +0200 @@ -2,9 +2,12 @@ #include "Keypad.h" -Keypad::Keypad(uint8_t nRows, DigitalIn rows[], - uint8_t nColumns, DigitalOut cols[], - int debounce_ms): +Keypad::Keypad( + uint8_t nRows, + DigitalIn rows[], + uint8_t nColumns, + DigitalOut cols[], + int debounce_ms): _rows(), _columns(), _debounce(debounce_ms), @@ -13,12 +16,14 @@ _ncols(nColumns) { printf("Setup Keypad: %dx%d\r\n", nColumns, nRows); - for(uint8_t c=0; c 0) - { - _keys[row + _nrows*col]--; - if ((_keys[row + _nrows*col] == 0) && _kr_callback) - _kr_callback.call(row, col); - } - } + if (_keys[row + _nrows*col] < 2) + { + _keys[row + _nrows*col]++; + if ((_keys[row + _nrows*col] == 2) && _kp_callback) + _kp_callback.call(row, col); + } + } + else + { + if (_keys[row + _nrows*col] > 0) + { + _keys[row + _nrows*col]--; + if ((_keys[row + _nrows*col] == 0) && _kr_callback) + _kr_callback.call(row, col); + } + } } _columns[col].write(0); col = (col+1) % _ncols; @@ -68,7 +75,7 @@ } void Keypad::attach(const keyevent_callback_t& kp_callback, - const keyevent_callback_t& kr_callback) + const keyevent_callback_t& kr_callback) { _kp_callback = kp_callback; _kr_callback = kr_callback;