KeyboardManager: a class to manage the polling of a switch-matrix keyboard
Diff: kbd_mgr/KeyboardManager.h
- Revision:
- 3:1310c57aca77
- Parent:
- 2:eb4cc53ff33d
--- a/kbd_mgr/KeyboardManager.h Sun Jan 23 23:15:36 2011 +0000 +++ b/kbd_mgr/KeyboardManager.h Thu Feb 03 22:01:57 2011 +0000 @@ -1,52 +1,5 @@ -#ifndef KEYBOARD_MANAGER_HPP_ -#define KEYBOARD_MANAGER_HPP_ - -#include "kbd_mgr/KeyPressEventHandler.h" - -#include "mbed.h" -#include <memory> -#include <vector> - -namespace kbd_mgr { - -/** - * @brief A class that polls the state of a NxM 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. - * Each time a key press or a key release is detected, the specified event handler is invoked. - * As the managed switch matrix is not protected against cross-overs, multiple key presses are - * ignored (only the state changes of the first key pressed are reported). - */ -class KeyboardManager { -public: - typedef std::vector<PinName> OutPinsSet; - - /** - * @param inPort Port to be used for reading the key state. - * @param numKeysPerRow Number of keys in a row (N) - * @param inLowestBit Index of the lowest bit of inPort (using inLowestBit to inLowestBit+N). - * @param outPins Pins to be used for powering each key row. - * @param handler Event handler called to report key presses and releases. - */ - KeyboardManager(PortName inPort, std::size_t numKeysPerRow, int inLowestBit, - const OutPinsSet &outPins, KeyPressEventHandler *handler); - - /** - * @brief Enables the polling of the keyboard state. - * @param pollingPeriod Frequency of the polling ticker (1kHz by default, min 20 microsec). - */ - void start(float pollingPeriod = 1e-3); - - /** - * @brief Disables the polling of the keyboard state. - */ - void stop(); - -private: - struct Impl; // opaque structure hiding implementation details - std::auto_ptr<Impl> pimpl; -}; - -} // kbd_mgr - -#endif // KEYBOARD_MANAGER_HPP_ +#include "kbd_mgr/KeyboardMonitor.h" +#include "kbd_mgr/KeyboardStateChangeMonitor.h" +#include "kbd_mgr/SingleKeyPressMonitor.h" +#include "kbd_mgr/LongKeyPressMonitor.h" +#include "kbd_mgr/KeyMapper.h"