1#ifndef FoltmanDebounceAdapter_h
2#define FoltmanDebounceAdapter_h
5#include "DebounceAdapter.h"
19 lastChangeMs = millis();
20 nextState = lastState = pinAdapter->
read();
24 bool newState = pinAdapter->
read();
25 if (nextState == lastState) {
27 if (newState != nextState) {
30 lastChangeMs = millis();
34 if (newState != nextState) {
36 nextState = lastState;
37 lastChangeMs = millis();
38 }
else if (millis() - lastChangeMs >= debounceInterval) {
47 uint32_t lastChangeMs;
48 bool lastState, nextState;
This is the interface/base class for debounce adapters.
Definition: DebounceAdapter.h:11
void begin()
Initialise the debouncer and pin adapter. Must be safe for repeated calls (Idempotent)
Definition: DebounceAdapter.h:27
This is the default InputEvents debouncer. Many thanks to @kfoltman.
Definition: FoltmanDebounceAdapter.h:11
bool read() override
Return the debounced state of the pin adapter.
Definition: FoltmanDebounceAdapter.h:23
void begin()
Initialise the debouncer and pin adapter. Must be safe for repeated calls (Idempotent)
Definition: FoltmanDebounceAdapter.h:17
The interface specification for button, encoder button and switch pins.
Definition: PinAdapter.h:8
virtual bool read()=0
Read the current state of the pin.