38 #if defined(ARDUINO) && ARDUINO >= 100 71 static const uint8_t DEBOUNCED_STATE = 0b00000001;
72 static const uint8_t UNSTABLE_STATE = 0b00000010;
73 static const uint8_t CHANGED_STATE = 0b00000100;
76 inline void changeState();
77 inline void setStateFlag(
const uint8_t flag) {state |= flag;}
78 inline void unsetStateFlag(
const uint8_t flag) {state &= ~flag;}
79 inline void toggleStateFlag(
const uint8_t flag) {state ^= flag;}
80 inline bool getStateFlag(
const uint8_t flag) {
return((state & flag) != 0);}
97 void interval(uint16_t interval_millis);
134 bool changed( ) {
return getStateFlag(CHANGED_STATE); }
157 virtual bool readCurrentState() =0;
158 unsigned long previous_millis;
159 uint16_t interval_millis;
161 unsigned long stateChangeLastTime;
162 unsigned long durationOfPreviousState;
198 void attach(
int pin,
int mode);
203 void attach(
int pin);
205 Bounce(uint8_t pin,
unsigned long interval_millis ) :
Bounce() {
232 virtual bool readCurrentState() {
return digitalRead(pin); }
233 virtual void setPinMode(
int pin,
int mode) {
234 #if defined(ARDUINO_ARCH_STM32F1) 235 pinMode(pin, (WiringPinMode)mode);
250 bool stateForPressed = 1;
272 stateForPressed = state;
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:171
void interval(uint16_t interval_millis)
Sets the debounce interval in milliseconds.
Definition: Bounce2.cpp:14
bool fell()
Returns true if pin signal transitions from high to low.
Definition: Bounce2.cpp:128
bool read()
Returns the pin's state (HIGH or LOW).
Definition: Bounce2.cpp:118
-
-
The Debouce class. Just the deboucing code separated from all harware.
Definition: Bounce2.h:77
+
+
The Debouce class. Just the deboucing code separated from all harware.
Definition: Bounce2.h:67
Debouncer()
Create an instance of the Debounce class.
Definition: Bounce2.cpp:10
-
bool fallingEdge()
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:231
-
uint8_t pin
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:240
+
bool fallingEdge()
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:221
+
uint8_t pin
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:230
unsigned long duration()
Returns the duration in milliseconds of the current state.
Definition: Bounce2.cpp:107
-
bool changed()
Returns true if the state changed on last update.
Definition: Bounce2.h:144
+
bool changed()
Returns true if the state changed on last update.
Definition: Bounce2.h:134
bool rose()
Returns true if pin signal transitions from low to high.
Definition: Bounce2.cpp:123
-
bool risingEdge()
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:227
-
-
+
bool risingEdge()
Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...
Definition: Bounce2.h:217
+
+
bool update()
Updates the pin's state.
Definition: Bounce2.cpp:32
-
+