4x4 matrix keypad
Fork of Keypad by
Diff: Keypad.h
- Revision:
- 3:82aae98732cd
- Parent:
- 2:a3545b56bdd7
--- a/Keypad.h Thu Dec 21 22:46:19 2017 +0000 +++ b/Keypad.h Thu May 17 18:41:09 2018 +0000 @@ -7,6 +7,9 @@ * http://mbed.org/users/kenjiArai/ * Created: September 27th, 2017 * Revised: December 22nd, 2017 + * + * 4x4 Fork: Henri Clarke + * May 17th, 2018 */ #ifndef KEYPAD_H @@ -22,12 +25,12 @@ * #include "Keypad.h" * * // every 2ms runs 6uS for key detection(CPU occupancy is 0.3%/Nucleo-F446RE) - * // output port X Y Z - * // Input A * 0 # - * // Input B 7 8 9 - * // Input C 4 5 6 - * // Input D 1 2 3 - * // X Y Z A B C D OUT(XYZ), IN(ABCD) + * // output port W X Y Z + * // Input A * 0 # (D) + * // Input B 7 8 9 (C) + * // Input C 4 5 6 (B) + * // Input D 1 2 3 (A) + * // W X Y Z A B C D OUT(WXYZ), IN(ABCD) * Keypad key(D10, D9, D8, D7, D6, D5, D4); * * // define key number at main routine @@ -47,11 +50,11 @@ class Keypad { public: - /** 4x3 keypad interface: + /** 4x4 keypad interface: * @param key input port A,B,C,D - * @param key output(scan) port X,Y,Z + * @param key output(scan) port W,X,Y,Z */ - Keypad(PinName kx, PinName ky, PinName kz, + Keypad(PinName kw, PinName kx, PinName ky, PinName kz, PinName ka, PinName kb, PinName kc, PinName kd); /** Read key data into buffer @@ -62,13 +65,13 @@ protected: DigitalIn *k_in[4]; - DigitalOut *k_out[3]; + DigitalOut *k_out[4]; Ticker tk; // key control enum State {Off_state, Off_to_on_transient, On_state, On_to_off_transient}; - volatile State key_state[3][4]; - volatile int8_t key_transent_cntr[3][4]; + volatile State key_state[4][4]; + volatile int8_t key_transent_cntr[4][4]; void key_scan(void); // buffer control