Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rpihw::keypad::matrix Class Reference

Matrix keypad controller. More...

#include <matrix.hpp>

+ Inheritance diagram for rpihw::keypad::matrix:

Public Member Functions

 matrix (std::initializer_list< uint8_t > cols, std::initializer_list< uint8_t > rows)
 Constructor method. More...
 
 matrix (std::initializer_list< uint8_t > cols, std::initializer_list< uint8_t > rows, const std::vector< uint8_t > &keymap)
 Constructor method. More...
 
virtual ~matrix ()
 Destructor method.
 
- Public Member Functions inherited from rpihw::keypad::base
 base (size_t total, std::initializer_list< uint8_t > pins)
 Constructor method. More...
 
 base (size_t total, std::initializer_list< uint8_t > pins, const std::vector< uint8_t > &keymap)
 Constructor method. More...
 
 base (size_t total, const std::vector< uint8_t > &pins)
 Constructor method. More...
 
 base (size_t total, const std::vector< uint8_t > &pins, const std::vector< uint8_t > &keymap)
 Constructor method. More...
 
virtual ~base ()
 Destructor method.
 
virtual void setKeymap (const std::vector< uint8_t > &keymap)
 Sets the keymap. More...
 
virtual void addEventListener (T_EventListener listener)
 Sets the keypad event listener. More...
 
virtual void setRefreshRate (float frequency)
 Sets the frequency with which buttons are read. More...
 
virtual float getRefreshRate () const
 Returns the frequency with which buttons are read.
 
virtual bool state (size_t index) const
 Returns a button state. More...
 
virtual bool pressed (size_t index) const
 Checks if a button is pressed. More...
 
virtual bool released (size_t index) const
 Checks if a button is released. More...
 
virtual const std::vector< bool > & state () const
 Returns the list of button states.
 
virtual bool keyState (uint8_t key) const
 Returns a key state. More...
 
virtual bool keyPressed (uint8_t key) const
 Checks if a key is pressed. More...
 
virtual bool keyReleased (uint8_t key) const
 Checks if a key is released. More...
 
virtual std::vector< uint8_t > keyState () const
 Returns the list of pressed keys.
 
virtual size_t numOfKeys () const
 Returns the number of keys.
 

Protected Member Functions

virtual void update ()
 Updates the state of buttons.
 

Protected Attributes

iface::outputm_output
 Columns output interface.
 
- Protected Attributes inherited from rpihw::keypad::base
size_t m_nkeys
 Number of the keys.
 
iface::inputm_input
 Buttons input interface.
 
T_Keymap m_keymap
 The keymap vector.
 
std::vector< bool > m_keystate
 Button states (0 = up, 1 = down).
 
std::vector< bool > m_pressed
 Pressed buttons (0 = none, 1 = pressed).
 
std::vector< bool > m_released
 Pressed buttons (0 = none, 1 = released).
 
float m_frequency
 The refresh rate.
 
std::thread * m_thread
 Updating thread.
 
std::mutex * m_mutex
 Mutex of the updating thread.
 
T_EventListener m_event_listener
 The keypad event listener.
 

Additional Inherited Members

- Public Types inherited from rpihw::keypad::base
typedef std::map< uint8_t,
uint8_t > 
T_Keymap
 The keymap type.
 

Detailed Description

Matrix keypad controller.

Examples:
keypad/12keys0.cpp, keypad/12keys1.cpp, keypad/16keys0.cpp, keypad/16keys1.cpp, and keypad/16keys2.cpp.

Definition at line 50 of file matrix.hpp.

Constructor & Destructor Documentation

rpihw::keypad::matrix::matrix ( std::initializer_list< uint8_t >  cols,
std::initializer_list< uint8_t >  rows 
)

Constructor method.

Parameters
[in]colsSequence of uint8_t containing the column GPIOs.
[in]rowsSequence of uint8_t containing the rows GPIOs.
rpihw::keypad::matrix::matrix ( std::initializer_list< uint8_t >  cols,
std::initializer_list< uint8_t >  rows,
const std::vector< uint8_t > &  keymap 
)

Constructor method.

Parameters
[in]colsSequence of uint8_t containing the column GPIOs.
[in]rowsSequence of uint8_t containing the rows GPIOs.
[in]keymapThe keymap vector.

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