Arduino-GPIO
General Purpose Input/Output (GPIO) library for Arduino
Button< PIN, DEBOUNCE > Class Template Reference

#include <Button.h>

Collaboration diagram for Button< PIN, DEBOUNCE >:
Collaboration graph

Public Member Functions

 Button ()
 
bool ischanged ()
 
bool read ()
 
 operator bool ()
 
uint16_t timestamp ()
 

Protected Attributes

GPIO< PIN > m_pin
 
uint16_t m_timestamp
 
bool m_state
 

Detailed Description

template<BOARD::pin_t PIN, uint16_t DEBOUNCE = 50>
class Button< PIN, DEBOUNCE >

Debounced Input Pin template class using GPIO. The internal pullup resistor is used. The button/switch should be connected to ground.

Parameters
[in]PINboard pin for input signal.
[in]DEBOUNCEtime limit (Default 50 ms).

Definition at line 31 of file Button.h.

Constructor & Destructor Documentation

template<BOARD::pin_t PIN, uint16_t DEBOUNCE = 50>
Button< PIN, DEBOUNCE >::Button ( )
inline

Construct debounced input pin instance with given template parameters. Initiate GPIO pins input mode with pullup resistor.

Definition at line 37 of file Button.h.

Member Function Documentation

template<BOARD::pin_t PIN, uint16_t DEBOUNCE = 50>
bool Button< PIN, DEBOUNCE >::ischanged ( )
inline

Return true(1) if a button state change was detected, otherwise false(0). Rising or falling edge is determined by reading the debounced pin state.

Returns
bool.

Definition at line 50 of file Button.h.

template<BOARD::pin_t PIN, uint16_t DEBOUNCE = 50>
Button< PIN, DEBOUNCE >::operator bool ( )
inline

Return debounced pin state. Shorthand for read().

Returns
bool.

Definition at line 76 of file Button.h.

template<BOARD::pin_t PIN, uint16_t DEBOUNCE = 50>
bool Button< PIN, DEBOUNCE >::read ( )
inline

Return debounced pin state.

Returns
state.

Definition at line 67 of file Button.h.

template<BOARD::pin_t PIN, uint16_t DEBOUNCE = 50>
uint16_t Button< PIN, DEBOUNCE >::timestamp ( )
inline

Return debounce timestamp.

Returns
timestamp.

Definition at line 86 of file Button.h.

Member Data Documentation

template<BOARD::pin_t PIN, uint16_t DEBOUNCE = 50>
GPIO<PIN> Button< PIN, DEBOUNCE >::m_pin
protected

Button pin.

Definition at line 93 of file Button.h.

template<BOARD::pin_t PIN, uint16_t DEBOUNCE = 50>
bool Button< PIN, DEBOUNCE >::m_state
protected

Latest pin read; debounced pin state.

Definition at line 99 of file Button.h.

template<BOARD::pin_t PIN, uint16_t DEBOUNCE = 50>
uint16_t Button< PIN, DEBOUNCE >::m_timestamp
protected

Timestamp for latest pin read.

Definition at line 96 of file Button.h.


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