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