Driver to control buttons (with hardware debounce). This driver considered external pull-ups (or pull-downs) are in use
Dependents: buttons is_released is_pressed button_status ... more
Hotboards_buttons Class Reference
Hotboards_buttons class. More...
#include <Hotboards_buttons.h>
Public Member Functions | |
Hotboards_buttons (PinName pin, bool active=0) | |
Create Hotboards_buttons instance. | |
bool | isPressed (void) |
Tells you if a button has been pressed (only once) | |
bool | isReleased (void) |
Tells you if a button has been Released (only once) | |
bool | status (void) |
Tells you the button state. |
Detailed Description
Hotboards_buttons class.
Used to read mechanical buttons
Example:
#include "Hotboards_buttons.h" Hotboards_buttons btn( 5 ); int main( void ) { for(;;){ if( btn.isPressed( ) ) // do something } }
Definition at line 31 of file Hotboards_buttons.h.
Constructor & Destructor Documentation
Hotboards_buttons | ( | PinName | pin, |
bool | active = 0 |
||
) |
Create Hotboards_buttons instance.
- Parameters:
-
pin pin where the button will be read it active logic level that gives you when the button is pressed
Example:
// instance one button on pin 5 (with pull-ups) Hotboards_buttons btn( 5 ); // instance one button on pin 6 (with pull-downs) Hotboards_buttons btn( 6, 1 );
Definition at line 10 of file Hotboards_buttons.cpp.
Member Function Documentation
bool isPressed | ( | void | ) |
Tells you if a button has been pressed (only once)
- Returns:
- '1' if the buttons has been pressed
Example:
// instance one button on pin 5 Hotboards_buttons btn( 5 ); if( btn.isPressed( ) ) // do something
Definition at line 19 of file Hotboards_buttons.cpp.
bool isReleased | ( | void | ) |
Tells you if a button has been Released (only once)
- Returns:
- '1' if the buttons has been Released
Example:
// instance one button on pin 5 Hotboards_buttons btn( 5 ); if( btn.isReleased( ) ) // do something
Definition at line 28 of file Hotboards_buttons.cpp.
bool status | ( | void | ) |
Tells you the button state.
- Returns:
- '1' if the buttons is pressed
Example:
// instance one button on pin 5 Hotboards_buttons btn( 5 ); if( btn.istatus( ) ) // button pressed else // button not pressed
Definition at line 37 of file Hotboards_buttons.cpp.
Generated on Mon Jul 18 2022 03:54:34 by 1.7.2