Sense keypresses from a 4x4 keypad A derivative ot he Hotboard_keypad library

Dependents:   26_Hotboards_MultiKey 26_Hotboards_EventKeypad

Fork of Hotboards_keypad by Hotboards MX

Committer:
icserny
Date:
Mon May 30 09:30:12 2016 +0000
Revision:
3:c88c922efd74
Parent:
0:4ca112f96484
Changes in v1.2:; 1. i < LIST_MAX in for cycle instead of i <= LIST_MAX; 2. Adaptation for KL25z; 3. Use internal pullup in the library;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Hotboards 0:4ca112f96484 1 /*
Hotboards 0:4ca112f96484 2 ||
Hotboards 0:4ca112f96484 3 || @file Key.h
Hotboards 0:4ca112f96484 4 || @version 1.0
Hotboards 0:4ca112f96484 5 || @author Mark Stanley
Hotboards 0:4ca112f96484 6 || @contact mstanley@technologist.com
Hotboards 0:4ca112f96484 7 ||
Hotboards 0:4ca112f96484 8 || @description
Hotboards 0:4ca112f96484 9 || | Key class provides an abstract definition of a key or button
Hotboards 0:4ca112f96484 10 || | and was initially designed to be used in conjunction with a
Hotboards 0:4ca112f96484 11 || | state-machine.
Hotboards 0:4ca112f96484 12 || #
Hotboards 0:4ca112f96484 13 ||
Hotboards 0:4ca112f96484 14 || @license
Hotboards 0:4ca112f96484 15 || | This library is free software; you can redistribute it and/or
Hotboards 0:4ca112f96484 16 || | modify it under the terms of the GNU Lesser General Public
Hotboards 0:4ca112f96484 17 || | License as published by the Free Software Foundation; version
Hotboards 0:4ca112f96484 18 || | 2.1 of the License.
Hotboards 0:4ca112f96484 19 || |
Hotboards 0:4ca112f96484 20 || | This library is distributed in the hope that it will be useful,
Hotboards 0:4ca112f96484 21 || | but WITHOUT ANY WARRANTY; without even the implied warranty of
Hotboards 0:4ca112f96484 22 || | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Hotboards 0:4ca112f96484 23 || | Lesser General Public License for more details.
Hotboards 0:4ca112f96484 24 || |
Hotboards 0:4ca112f96484 25 || | You should have received a copy of the GNU Lesser General Public
Hotboards 0:4ca112f96484 26 || | License along with this library; if not, write to the Free Software
Hotboards 0:4ca112f96484 27 || | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Hotboards 0:4ca112f96484 28 || #
Hotboards 0:4ca112f96484 29 ||
Hotboards 0:4ca112f96484 30 */
Hotboards 0:4ca112f96484 31
Hotboards 0:4ca112f96484 32 #ifndef KEY_H
Hotboards 0:4ca112f96484 33 #define KEY_H
Hotboards 0:4ca112f96484 34
Hotboards 0:4ca112f96484 35 #include "mbed.h"
Hotboards 0:4ca112f96484 36
Hotboards 0:4ca112f96484 37 #define OPEN 0
Hotboards 0:4ca112f96484 38 #define CLOSED 1
Hotboards 0:4ca112f96484 39
Hotboards 0:4ca112f96484 40 typedef unsigned int uint;
Hotboards 0:4ca112f96484 41 typedef enum{ IDLE, PRESSED, HOLD, RELEASED } KeyState;
Hotboards 0:4ca112f96484 42
Hotboards 0:4ca112f96484 43 const char NO_KEY = '\0';
Hotboards 0:4ca112f96484 44
Hotboards 0:4ca112f96484 45 class Key {
Hotboards 0:4ca112f96484 46 public:
Hotboards 0:4ca112f96484 47 // members
Hotboards 0:4ca112f96484 48 char kchar;
Hotboards 0:4ca112f96484 49 int kcode;
Hotboards 0:4ca112f96484 50 KeyState kstate;
Hotboards 0:4ca112f96484 51 bool stateChanged;
Hotboards 0:4ca112f96484 52
Hotboards 0:4ca112f96484 53 // methods
Hotboards 0:4ca112f96484 54 Key();
Hotboards 0:4ca112f96484 55 Key(char userKeyChar);
Hotboards 0:4ca112f96484 56 void key_update(char userKeyChar, KeyState userState, bool userStatus);
Hotboards 0:4ca112f96484 57
Hotboards 0:4ca112f96484 58 private:
Hotboards 0:4ca112f96484 59
Hotboards 0:4ca112f96484 60 };
Hotboards 0:4ca112f96484 61
Hotboards 0:4ca112f96484 62 #endif
Hotboards 0:4ca112f96484 63
Hotboards 0:4ca112f96484 64 /*
Hotboards 0:4ca112f96484 65 || @changelog
Hotboards 0:4ca112f96484 66 || | 1.0 2012-06-04 - Mark Stanley : Initial Release
Hotboards 0:4ca112f96484 67 || #
Hotboards 0:4ca112f96484 68 */