Code to interface mbed to a Nokia 3310 LCD using the Nokia 3310 LCD shield from nuelectronics. Includes joystick interface and demo.

Dependencies:   mbed

Committer:
snatch59
Date:
Mon Dec 07 17:24:52 2009 +0000
Revision:
0:36fb749b83c7

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
snatch59 0:36fb749b83c7 1 /*
snatch59 0:36fb749b83c7 2 * N3310LCD. A program to interface mbed with the nuelectronics
snatch59 0:36fb749b83c7 3 * Nokia 3310 LCD shield from www.nuelectronics.com. Ported from
snatch59 0:36fb749b83c7 4 * the nuelectronics Arduino code.
snatch59 0:36fb749b83c7 5 *
snatch59 0:36fb749b83c7 6 * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk>
snatch59 0:36fb749b83c7 7 *
snatch59 0:36fb749b83c7 8 * This file is part of N3310LCD.
snatch59 0:36fb749b83c7 9 *
snatch59 0:36fb749b83c7 10 * N3310LCD is free software: you can redistribute it and/or modify
snatch59 0:36fb749b83c7 11 * it under the terms of the GNU General Public License as published by
snatch59 0:36fb749b83c7 12 * the Free Software Foundation, either version 3 of the License, or
snatch59 0:36fb749b83c7 13 * (at your option) any later version.
snatch59 0:36fb749b83c7 14 *
snatch59 0:36fb749b83c7 15 * N3310LCD is distributed in the hope that it will be useful,
snatch59 0:36fb749b83c7 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
snatch59 0:36fb749b83c7 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
snatch59 0:36fb749b83c7 18 * GNU General Public License for more details.
snatch59 0:36fb749b83c7 19 *
snatch59 0:36fb749b83c7 20 * You should have received a copy of the GNU General Public License
snatch59 0:36fb749b83c7 21 * along with N3310LCD. If not, see <http://www.gnu.org/licenses/>.
snatch59 0:36fb749b83c7 22 */
snatch59 0:36fb749b83c7 23
snatch59 0:36fb749b83c7 24 #ifndef SNATCH59_JOYSTICK_H
snatch59 0:36fb749b83c7 25 #define SNATCH59_JOYSTICK_H
snatch59 0:36fb749b83c7 26
snatch59 0:36fb749b83c7 27 #define NUM_KEYS 5
snatch59 0:36fb749b83c7 28
snatch59 0:36fb749b83c7 29 enum eJoystickKey {LEFT_KEY, CENTER_KEY, DOWN_KEY, UP_KEY, RIGHT_KEY};
snatch59 0:36fb749b83c7 30
snatch59 0:36fb749b83c7 31 class Joystick
snatch59 0:36fb749b83c7 32 {
snatch59 0:36fb749b83c7 33 public:
snatch59 0:36fb749b83c7 34 Joystick(PinName jstick);
snatch59 0:36fb749b83c7 35
snatch59 0:36fb749b83c7 36 int getKeyState(int i);
snatch59 0:36fb749b83c7 37 void resetKeyState(int i);
snatch59 0:36fb749b83c7 38 void updateADCKey(); // call this to initiate joystick read
snatch59 0:36fb749b83c7 39
snatch59 0:36fb749b83c7 40 private:
snatch59 0:36fb749b83c7 41 // data
snatch59 0:36fb749b83c7 42 int buttonCount[NUM_KEYS]; // debounce counters
snatch59 0:36fb749b83c7 43 int buttonStatus[NUM_KEYS]; // button status - pressed/released
snatch59 0:36fb749b83c7 44 int buttonFlag[NUM_KEYS]; // button on flags for user program
snatch59 0:36fb749b83c7 45
snatch59 0:36fb749b83c7 46 static const int adcKeyVal[NUM_KEYS];
snatch59 0:36fb749b83c7 47
snatch59 0:36fb749b83c7 48 // I/O
snatch59 0:36fb749b83c7 49 AnalogIn joystick;
snatch59 0:36fb749b83c7 50
snatch59 0:36fb749b83c7 51 // functions
snatch59 0:36fb749b83c7 52 int getKey(int input);
snatch59 0:36fb749b83c7 53 };
snatch59 0:36fb749b83c7 54
snatch59 0:36fb749b83c7 55 #endif