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

Dependents:   KeyboardTest

Committer:
osmeest
Date:
Sun Jan 23 23:15:36 2011 +0000
Revision:
2:eb4cc53ff33d
Child:
3:1310c57aca77
Thorough split of the code to have one responsibility per class. Generalisation of the keyboard layout (not limited to 4x4 anymore). Introduction of the kbd_mgr namespace (also apparent in header filenames).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
osmeest 2:eb4cc53ff33d 1 #ifndef KEYBOARD_STATE_CHANGE_MONITOR_H_
osmeest 2:eb4cc53ff33d 2 #define KEYBOARD_STATE_CHANGE_MONITOR_H_
osmeest 2:eb4cc53ff33d 3
osmeest 2:eb4cc53ff33d 4 #include "kbd_mgr/KeyboardState.h"
osmeest 2:eb4cc53ff33d 5 #include "kbd_mgr/KeyboardStateHandler.h"
osmeest 2:eb4cc53ff33d 6
osmeest 2:eb4cc53ff33d 7 namespace kbd_mgr {
osmeest 2:eb4cc53ff33d 8
osmeest 2:eb4cc53ff33d 9 /**
osmeest 2:eb4cc53ff33d 10 * @brief Interface used by the KeyboardStateChangeMonitor to report state changes.
osmeest 2:eb4cc53ff33d 11 */
osmeest 2:eb4cc53ff33d 12 class KeyboardStateChangeHandler : public KeyboardStateHandler { };
osmeest 2:eb4cc53ff33d 13
osmeest 2:eb4cc53ff33d 14 /**
osmeest 2:eb4cc53ff33d 15 * @brief A keyboard state handler that reports only state changes.
osmeest 2:eb4cc53ff33d 16 */
osmeest 2:eb4cc53ff33d 17 class KeyboardStateChangeMonitor : public KeyboardStateHandler {
osmeest 2:eb4cc53ff33d 18 public:
osmeest 2:eb4cc53ff33d 19 KeyboardStateChangeMonitor(KeyboardStateChangeHandler *handler) : handler(handler), lastState() { }
osmeest 2:eb4cc53ff33d 20
osmeest 2:eb4cc53ff33d 21 virtual void operator()(const KeyboardState &newState);
osmeest 2:eb4cc53ff33d 22
osmeest 2:eb4cc53ff33d 23 private:
osmeest 2:eb4cc53ff33d 24 KeyboardStateChangeHandler *handler;
osmeest 2:eb4cc53ff33d 25 KeyboardState lastState;
osmeest 2:eb4cc53ff33d 26 };
osmeest 2:eb4cc53ff33d 27
osmeest 2:eb4cc53ff33d 28 } // kbd_mgr
osmeest 2:eb4cc53ff33d 29
osmeest 2:eb4cc53ff33d 30 #endif // KEYBOARD_STATE_CHANGE_MONITOR_H_