8template <
class Derived, u
int8_t NumRows, u
int8_t NumCols>
11 : rowPins(rowPins), colPins(colPins) {
15template <
class Derived, u
int8_t NumRows, u
int8_t NumCols>
17 unsigned long now = millis();
20 if (now - prevRefresh < debounceTime)
23 for (
size_t row = 0; row < NumRows; row++) {
25#if !defined(__AVR__) && defined(ARDUINO)
28 for (
size_t col = 0; col < NumCols; col++) {
30 if (state != getPrevState(col, row)) {
33 CRTP(Derived).onButtonChanged(row, col, state);
34 setPrevState(col, row, state);
42template <
class Derived, u
int8_t NumRows, u
int8_t NumCols>
46 for (
const pin_t &colPin : colPins)
49 for (
const pin_t &rowPin : rowPins)
53template <
class Derived, u
int8_t NumRows, u
int8_t NumCols>
58 return col * NumRows + row;
61template <
class Derived, u
int8_t NumRows, u
int8_t NumCols>
67template <
class Derived, u
int8_t NumRows, u
int8_t NumCols>
70 return 1 << (bits & 7);
73template <
class Derived, u
int8_t NumRows, u
int8_t NumCols>
76 uint8_t bits = positionToBits(col, row);
77 return !!(prevStates[bitsToIndex(bits)] & bitsToBitmask(bits));
80template <
class Derived, u
int8_t NumRows, u
int8_t NumCols>
84 uint8_t bits = positionToBits(col, row);
86 prevStates[bitsToIndex(bits)] |= bitsToBitmask(bits);
88 prevStates[bitsToIndex(bits)] &= ~bitsToBitmask(bits);
constexpr PinMode_t INPUT
constexpr PinMode_t INPUT_PULLUP
constexpr PinMode_t OUTPUT
#define CRTP(Derived)
Helper for the Curiously Recurring Template Pattern.
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
#define BEGIN_AH_NAMESPACE
constexpr unsigned long SELECT_LINE_DELAY
The time in microseconds to wait for lines of multiplexers and scanning matrices to settle before rea...
void pinMode(pin_t pin, PinMode_t mode)
An ExtIO version of the Arduino function.
PinStatus_t digitalRead(pin_t pin)
An ExtIO version of the Arduino function.