KeyboardManager: a class to manage the polling of a switch-matrix keyboard

Dependents:   KeyboardTest

Embed: (wiki syntax)

« Back to documentation index

KeyboardMonitor Class Reference

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:
inPortPort to be used for reading the key state.
numKeysPerRowNumber of keys in a row (N)
inLowestBitIndex of the lowest bit of inPort (using inLowestBit to inLowestBit+N).
outPinsPins 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:
fnEvent 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:
objEvent handler object
fnEvent 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.