Code to interface mbed to a Nokia 3310 LCD using the Nokia 3310 LCD shield from nuelectronics. Includes joystick interface and demo.
Joystick.h
00001 /* 00002 * N3310LCD. A program to interface mbed with the nuelectronics 00003 * Nokia 3310 LCD shield from www.nuelectronics.com. Ported from 00004 * the nuelectronics Arduino code. 00005 * 00006 * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk> 00007 * 00008 * This file is part of N3310LCD. 00009 * 00010 * N3310LCD is free software: you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation, either version 3 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * N3310LCD is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with N3310LCD. If not, see <http://www.gnu.org/licenses/>. 00022 */ 00023 00024 #ifndef SNATCH59_JOYSTICK_H 00025 #define SNATCH59_JOYSTICK_H 00026 00027 #define NUM_KEYS 5 00028 00029 enum eJoystickKey {LEFT_KEY, CENTER_KEY, DOWN_KEY, UP_KEY, RIGHT_KEY}; 00030 00031 class Joystick 00032 { 00033 public: 00034 Joystick(PinName jstick); 00035 00036 int getKeyState(int i); 00037 void resetKeyState(int i); 00038 void updateADCKey(); // call this to initiate joystick read 00039 00040 private: 00041 // data 00042 int buttonCount[NUM_KEYS]; // debounce counters 00043 int buttonStatus[NUM_KEYS]; // button status - pressed/released 00044 int buttonFlag[NUM_KEYS]; // button on flags for user program 00045 00046 static const int adcKeyVal[NUM_KEYS]; 00047 00048 // I/O 00049 AnalogIn joystick; 00050 00051 // functions 00052 int getKey(int input); 00053 }; 00054 00055 #endif
Generated on Thu Jul 14 2022 15:11:34 by 1.7.2