lib/keypad/Keypad.h

changeset 24
b43536c064f6
child 26
86f099bda525
equal deleted inserted replaced
23:daf26b083899 24:b43536c064f6
1
2 #ifndef KEYPAD_H
3 #define KEYPAD_H
4
5 #include "mbed.h"
6 #include "rtos.h"
7 #include <vector>
8
9
10
11 typedef Callback<void(uint8_t, uint8_t)> keyevent_callback_t;
12
13 class Keypad {
14 public:
15 Keypad(uint8_t nRows, DigitalIn rows[],
16 uint8_t nColumns, DigitalOut cols[],
17 int debounce_ms=20);
18
19 /** Destructor
20 */
21 ~Keypad();
22
23 void attach(const keyevent_callback_t& kp_callback=NULL,
24 const keyevent_callback_t& kr_callback=NULL);
25
26 void start(void);
27 void stop(void);
28
29
30 protected:
31 std::vector<DigitalIn> _rows;
32 std::vector<DigitalOut> _columns;
33 int _debounce; // miliseconds
34
35 void _kp();
36 void _kr();
37 void _keyPressed(int row);
38 void _keyReleased(int row);
39 void run();
40
41 private:
42 keyevent_callback_t _kp_callback;
43 keyevent_callback_t _kr_callback;
44 bool _started;
45 Thread _loop;
46 //tloop.start(&loop);
47 uint8_t _nrows;
48 uint8_t _ncols;
49 uint8_t *_keys;
50 };
51
52
53 #endif // KEYPAD_H

mercurial