arduinoprojects

git clone https://git.tarina.org/arduinoprojects
Log | Files | Refs

Key.h (1560B)


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