Bounce2
Public Member Functions | Protected Attributes | List of all members
Bounce2::Button Class Reference
Inheritance diagram for Bounce2::Button:
Bounce Debouncer

Public Member Functions

 Button ()
 Create an instance of the Button class. By default, the pressed state is matched to a HIGH electrical level. More...
 
void setPressedState (bool state)
 Set the electrical state (HIGH/LOW) that corresponds to a physical press. By default, the pressed state is matched to a HIGH electrical level. More...
 
bool getPressedState () const
 Get the electrical state (HIGH/LOW) that corresponds to a physical press.
 
bool isPressed () const
 Returns true if the button is currently physically pressed.
 
bool pressed () const
 Returns true if the button was physically pressed

 
bool released () const
 Returns true if the button was physically released

 
- Public Member Functions inherited from Bounce
 Bounce ()
 Create an instance of the Bounce class. More...
 
void attach (int pin, int mode)
 Attach to a pin and sets that pin's mode (INPUT, INPUT_PULLUP or OUTPUT). More...
 
void attach (int pin)
 
 Bounce (uint8_t pin, unsigned long interval_millis)
 
int getPin () const
 Return pin that this Bounce is attached to. More...
 
bool risingEdge () const
 Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce version 1.
 
bool fallingEdge () const
 Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce version 1.
 
- Public Member Functions inherited from Debouncer
 Debouncer ()
 Create an instance of the Debounce class. More...
 
void interval (uint16_t interval_millis)
 Sets the debounce interval in milliseconds. More...
 
bool update ()
 Updates the pin's state. More...
 
bool read () const
 Returns the pin's state (HIGH or LOW). More...
 
bool fell () const
 Returns true if pin signal transitions from high to low.
 
bool rose () const
 Returns true if pin signal transitions from low to high.
 
bool changed () const
 Returns true if the state changed on last update. More...
 
unsigned long currentDuration () const
 Returns the duration in milliseconds of the current state. More...
 
unsigned long previousDuration () const
 Returns the duration in milliseconds of the previous state. More...
 
unsigned long duration ()
 DEPRECATED (i.e. do not use). Renamed currentDuration(). More...
 

Protected Attributes

bool stateForPressed = 1
 
- Protected Attributes inherited from Bounce
uint8_t pin
 Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce version 1.
 
- Protected Attributes inherited from Debouncer
unsigned long previous_millis
 
uint16_t interval_millis
 
uint8_t state
 
unsigned long stateChangeLastTime
 
unsigned long durationOfPreviousState
 

Additional Inherited Members

- Protected Member Functions inherited from Bounce
virtual bool readCurrentState ()
 
virtual void setPinMode (int pin, int mode)
 
- Protected Member Functions inherited from Debouncer
void begin ()
 

Constructor & Destructor Documentation

◆ Button()

Bounce2::Button::Button ( )
inline

Create an instance of the Button class. By default, the pressed state is matched to a HIGH electrical level.

// Create an instance of the Button class.
Button() button;

Member Function Documentation

◆ setPressedState()

void Bounce2::Button::setPressedState ( bool  state)
inline

Set the electrical state (HIGH/LOW) that corresponds to a physical press. By default, the pressed state is matched to a HIGH electrical level.

Parameters
stateThe electrical state (HIGH/LOW) that corresponds to a physical press.

The documentation for this class was generated from the following file:
Bounce2::Button::Button
Button()
Create an instance of the Button class. By default, the pressed state is matched to a HIGH electrical...
Definition: Bounce2.h:290