KeyboardManager: a class to manage the polling of a switch-matrix keyboard
KeyboardMonitor Class Reference
A class that polls the state of a switch-matrix keyboard. More...
#include <KeyboardMonitor.h>
Inherits kbd_mgr::KeyboardStateEventServer.
Public Member Functions | |
KeyboardMonitor (PortName inPort, std::size_t numKeysPerRow, std::size_t inLowestBit, const OutPinsSet &outPins) | |
void | start (float pollingPeriod=0.001) |
Starts the polling of the keyboard state. | |
void | stop () |
Disables the polling of the keyboard state. | |
void | attach (FunctionKeyboardStateHandler::HandlerFunction fn) |
Attaches the monitor to a function. | |
template<class T > | |
void | attach (T *obj, typename MemberKeyboardStateHandler< T >::MemberFunction fn) |
Attaches the monitor to a method of an object. |
Detailed Description
A class that polls the state of a switch-matrix keyboard.
For efficiency reasons, this class uses contiguous bits in a GPIO ports for reading the state of the keys in a row. Key rows are activated one by one using a set of digital outputs. When a full keyboard scan has been done, it is provided to the registered handler.
Definition at line 18 of file KeyboardMonitor.h.
Constructor & Destructor Documentation
KeyboardMonitor | ( | PortName | inPort, |
std::size_t | numKeysPerRow, | ||
std::size_t | inLowestBit, | ||
const OutPinsSet & | outPins | ||
) |
- Parameters:
-
inPort Port to be used for reading the key state. numKeysPerRow Number of keys in a row (N) inLowestBit Index of the lowest bit of inPort (using inLowestBit to inLowestBit+N). outPins Pins to be used for powering each key row.
Definition at line 5 of file KeyboardMonitor.cpp.
Member Function Documentation
void attach | ( | FunctionKeyboardStateHandler::HandlerFunction | fn ) | [inherited] |
Attaches the monitor to a function.
- Parameters:
-
fn Event handler called to report keyboard state change.
Definition at line 18 of file KeyboardStateEventServer.h.
void attach | ( | T * | obj, |
typename MemberKeyboardStateHandler< T >::MemberFunction | fn | ||
) | [inherited] |
Attaches the monitor to a method of an object.
- Parameters:
-
obj Event handler object fn Event handler method called to report keyboard state after each complete scan.
Definition at line 28 of file KeyboardStateEventServer.h.
void start | ( | float | pollingPeriod = 0.001 ) |
Starts the polling of the keyboard state.
Definition at line 16 of file KeyboardMonitor.cpp.
void stop | ( | ) |
Disables the polling of the keyboard state.
Definition at line 35 of file KeyboardMonitor.cpp.
Generated on Thu Jul 14 2022 19:25:04 by 1.7.2