33 #if defined(ARDUINO) && ARDUINO >= 100
66 static const uint8_t DEBOUNCED_STATE = 0b00000001;
67 static const uint8_t UNSTABLE_STATE = 0b00000010;
68 static const uint8_t CHANGED_STATE = 0b00000100;
71 inline void changeState();
72 inline void setStateFlag(
const uint8_t flag) {state |= flag;}
73 inline void unsetStateFlag(
const uint8_t flag) {state &= ~flag;}
74 inline void toggleStateFlag(
const uint8_t flag) {state ^= flag;}
75 inline bool getStateFlag(
const uint8_t flag) {
return((state & flag) != 0);}
92 void interval(uint16_t interval_millis);
129 bool changed( ) {
return getStateFlag(CHANGED_STATE); }
152 virtual bool readCurrentState() =0;
153 unsigned long previous_millis;
154 uint16_t interval_millis;
156 unsigned long stateChangeLastTime;
157 unsigned long durationOfPreviousState;
227 virtual bool readCurrentState() {
return digitalRead(
pin); }
228 virtual void setPinMode(
int pin,
int mode) {
229 #if defined(ARDUINO_ARCH_STM32F1)
230 pinMode(
pin, (WiringPinMode)mode);
248 bool stateForPressed = 1;
270 stateForPressed = state;
277 return stateForPressed;
bool fell()
Returns true if pin signal transitions from high to low.
Definition: Bounce2.cpp:128
void interval(uint16_t interval_millis)
Sets the debounce interval in milliseconds.
Definition: Bounce2.cpp:14
bool read()
Returns the pin's state (HIGH or LOW).
Definition: Bounce2.cpp:118
Bounce()
Create an instance of the Bounce class.
Definition: Bounce2.cpp:138
bool changed()
Returns true if the state changed on last update.
Definition: Bounce2.h:129
unsigned long duration()
Returns the duration in milliseconds of the current state.
Definition: Bounce2.cpp:107
bool rose()
Returns true if pin signal transitions from low to high.
Definition: Bounce2.cpp:123
uint8_t pin
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:225
bool risingEdge()
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:212
bool update()
Updates the pin's state.
Definition: Bounce2.cpp:32
unsigned long previousDuration()
Returns the duration in milliseconds of the previous state.
Definition: Bounce2.cpp:103
The Debouncer:Bounce class. Links the Deboucing class to a hardware pin.
Definition: Bounce2.h:166
The Debouce class. Just the deboucing code separated from all harware.
Definition: Bounce2.h:62
bool fallingEdge()
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:216
void attach(int pin, int mode)
Attach to a pin and sets that pin's mode (INPUT, INPUT_PULLUP or OUTPUT).
Definition: Bounce2.cpp:149
The Debouncer:Bounce:Button class. The Button class matches an electrical state to a physical action.
Definition: Bounce2.h:243
Debouncer()
Create an instance of the Debounce class.
Definition: Bounce2.cpp:10