A DTMF sequence editor and player for HAM radio equipment command & control.

Dependencies:   mbed ExtTextLCD

Committer:
osmeest
Date:
Mon Mar 07 22:51:19 2011 +0000
Revision:
0:1324e7d9d471

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
osmeest 0:1324e7d9d471 1 #ifndef KEYBOARD_MONITOR_H_
osmeest 0:1324e7d9d471 2 #define KEYBOARD_MONITOR_H_
osmeest 0:1324e7d9d471 3
osmeest 0:1324e7d9d471 4 #include "kbd_mgr/KeyboardStateEventServer.h"
osmeest 0:1324e7d9d471 5 #include "kbd_mgr/KeyboardState.h"
osmeest 0:1324e7d9d471 6
osmeest 0:1324e7d9d471 7 #include "mbed.h"
osmeest 0:1324e7d9d471 8 #include <vector>
osmeest 0:1324e7d9d471 9
osmeest 0:1324e7d9d471 10 namespace kbd_mgr {
osmeest 0:1324e7d9d471 11
osmeest 0:1324e7d9d471 12 /**
osmeest 0:1324e7d9d471 13 * @brief A class that polls the state of a switch-matrix keyboard.
osmeest 0:1324e7d9d471 14 * For efficiency reasons, this class uses contiguous bits in a GPIO ports for reading the state of the keys in a row.
osmeest 0:1324e7d9d471 15 * Key rows are activated one by one using a set of digital outputs.
osmeest 0:1324e7d9d471 16 * When a full keyboard scan has been done, it is provided to the registered handler.
osmeest 0:1324e7d9d471 17 */
osmeest 0:1324e7d9d471 18 class KeyboardMonitor : public KeyboardStateEventServer {
osmeest 0:1324e7d9d471 19 public:
osmeest 0:1324e7d9d471 20 typedef std::vector<PinName> OutPinsSet;
osmeest 0:1324e7d9d471 21
osmeest 0:1324e7d9d471 22 /**
osmeest 0:1324e7d9d471 23 * @param inPort Port to be used for reading the key state.
osmeest 0:1324e7d9d471 24 * @param numKeysPerRow Number of keys in a row (N)
osmeest 0:1324e7d9d471 25 * @param inLowestBit Index of the lowest bit of inPort (using inLowestBit to inLowestBit+N).
osmeest 0:1324e7d9d471 26 * @param outPins Pins to be used for powering each key row.
osmeest 0:1324e7d9d471 27 */
osmeest 0:1324e7d9d471 28 KeyboardMonitor(PortName inPort, std::size_t numKeysPerRow, std::size_t inLowestBit,
osmeest 0:1324e7d9d471 29 const OutPinsSet &outPins);
osmeest 0:1324e7d9d471 30
osmeest 0:1324e7d9d471 31 ~KeyboardMonitor();
osmeest 0:1324e7d9d471 32
osmeest 0:1324e7d9d471 33 /**
osmeest 0:1324e7d9d471 34 * @brief Starts the polling of the keyboard state.
osmeest 0:1324e7d9d471 35 */
osmeest 0:1324e7d9d471 36 void start(float pollingPeriod = 0.001);
osmeest 0:1324e7d9d471 37
osmeest 0:1324e7d9d471 38 /**
osmeest 0:1324e7d9d471 39 * @brief Disables the polling of the keyboard state.
osmeest 0:1324e7d9d471 40 */
osmeest 0:1324e7d9d471 41 void stop();
osmeest 0:1324e7d9d471 42
osmeest 0:1324e7d9d471 43 private:
osmeest 0:1324e7d9d471 44 void timerHandler();
osmeest 0:1324e7d9d471 45
osmeest 0:1324e7d9d471 46 PortIn in;
osmeest 0:1324e7d9d471 47 int inBitShift;
osmeest 0:1324e7d9d471 48 OutPinsSet outPins;
osmeest 0:1324e7d9d471 49
osmeest 0:1324e7d9d471 50 Ticker ticker;
osmeest 0:1324e7d9d471 51 std::size_t scanRow; /*!< next key row to be scanned */
osmeest 0:1324e7d9d471 52 KeyboardState currentState; /*!< currently being built keyboard state */
osmeest 0:1324e7d9d471 53 };
osmeest 0:1324e7d9d471 54
osmeest 0:1324e7d9d471 55 } // kbd_mgr
osmeest 0:1324e7d9d471 56
osmeest 0:1324e7d9d471 57 #endif // KEYBOARD_MONITOR_H_