RTLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Button Class Reference

HAL implementation for buttons. More...

#include <button.h>

Classes

struct  Config
 Configuration for button. More...
 

Public Member Functions

 Button (const Config &config)
 Default constructor for Button. More...
 
 ~Button ()=default
 Default trivial destructor. More...
 
 Button (Button &&other) noexcept=default
 Move constructor for Button. More...
 
Buttonoperator= (Button &&other) noexcept=default
 Move assignment operator for Button. More...
 
 Button (const Button &)=delete
 Copy constructor for Button. More...
 
Buttonoperator= (const Button &)=delete
 Copy assignment operator for Button. More...
 
bool Read ()
 Reads the state of the button. More...
 

Protected Member Functions

CORE_NS::GPIO * GetGpio ()
 

Detailed Description

HAL implementation for buttons.

This abstraction layer provides standard state-reading for onboard buttons. One button object is designed to manage one button on the mainboard.

Constructor & Destructor Documentation

Button::Button ( const Config config)
explicit

Default constructor for Button.

Parameters
configButton configuration
Button::~Button ( )
default

Default trivial destructor.

Button::Button ( Button &&  other)
defaultnoexcept

Move constructor for Button.

Parameters
otherButton object to move from
Button::Button ( const Button )
delete

Copy constructor for Button.

This constructor is deleted because there should only be one object managing each button, similar to std::unique_ptr.

Member Function Documentation

CORE_NS::GPIO* Button::GetGpio ( )
inlineprotected
Returns
GPIO object which manages the pin of the button
Button& Button::operator= ( Button &&  other)
defaultnoexcept

Move assignment operator for Button.

Parameters
otherButton object to move from
Returns
Reference to the moved Button.
Button& Button::operator= ( const Button )
delete

Copy assignment operator for Button.

This constructor is deleted because there should only be one object managing each button, similar to std::unique_ptr.

bool Button::Read ( )

Reads the state of the button.

Note
Button will always be in low state at idle after constructor is calButton. If it isn't, your Button::Config::pullup may be incorrect; Set it to another value or consult a hardware senior if that is the case.
Returns
true if button is pressed, false otherwise.

The documentation for this class was generated from the following files: