class library for a TS Keypad and retrieving multiple keys, then press enter and the values are stored and the keypad disappears.

Committer:
Armand
Date:
Wed Jun 07 08:45:35 2017 +0000
Revision:
0:b3fd90f94e58
Child:
1:483300d6debd
class library for a TS Keypad and retrieving multiple keys, then press enter and the values are stored and the keypad disappears.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Armand 0:b3fd90f94e58 1 /* F7 TS Keypad Multi Key Library v1.0
Armand 0:b3fd90f94e58 2 * Copyright (c) 2017 Armand Coetzer
Armand 0:b3fd90f94e58 3 * s213293048@nmmu.ac.za
Armand 0:b3fd90f94e58 4 *
Armand 0:b3fd90f94e58 5 *
Armand 0:b3fd90f94e58 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
Armand 0:b3fd90f94e58 7 * of this software and associated documentation files (the "Software"), to deal
Armand 0:b3fd90f94e58 8 * in the Software without restriction, including without limitation the rights
Armand 0:b3fd90f94e58 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Armand 0:b3fd90f94e58 10 * copies of the Software, and to permit persons to whom the Software is
Armand 0:b3fd90f94e58 11 * furnished to do so, subject to the following conditions:
Armand 0:b3fd90f94e58 12 *
Armand 0:b3fd90f94e58 13 * The above copyright notice and this permission notice shall be included in
Armand 0:b3fd90f94e58 14 * all copies or substantial portions of the Software.
Armand 0:b3fd90f94e58 15 *
Armand 0:b3fd90f94e58 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Armand 0:b3fd90f94e58 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Armand 0:b3fd90f94e58 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Armand 0:b3fd90f94e58 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Armand 0:b3fd90f94e58 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Armand 0:b3fd90f94e58 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Armand 0:b3fd90f94e58 22 * THE SOFTWARE.
Armand 0:b3fd90f94e58 23 */
Armand 0:b3fd90f94e58 24
Armand 0:b3fd90f94e58 25 #ifndef F7_TSKeypad_MultiKey_H
Armand 0:b3fd90f94e58 26 #define F7_TSKeypad_MultiKey_H
Armand 0:b3fd90f94e58 27
Armand 0:b3fd90f94e58 28 #include "mbed.h"
Armand 0:b3fd90f94e58 29 #include "LCD_DISCO_F746NG.h"
Armand 0:b3fd90f94e58 30 #include "TS_DISCO_F746NG.h"
Armand 0:b3fd90f94e58 31
Armand 0:b3fd90f94e58 32 /** Class library for a TS Keypad and retrieving multiple keys, then press enter and the values are stored and the keypad disappears.
Armand 0:b3fd90f94e58 33 *
Armand 0:b3fd90f94e58 34 * Example:
Armand 0:b3fd90f94e58 35 * @code
Armand 0:b3fd90f94e58 36 *#include "mbed.h"
Armand 0:b3fd90f94e58 37 *#include "F7_TSKeypad_MultiKey.h"
Armand 0:b3fd90f94e58 38
Armand 0:b3fd90f94e58 39 *F7_TSKeypad_MultiKey keypad;
Armand 0:b3fd90f94e58 40 *LCD_DISCO_F746NG lcd;
Armand 0:b3fd90f94e58 41 *
Armand 0:b3fd90f94e58 42 *uint8_t text1[30];
Armand 0:b3fd90f94e58 43 *char s[100];
Armand 0:b3fd90f94e58 44 *
Armand 0:b3fd90f94e58 45 *int main()
Armand 0:b3fd90f94e58 46 *{
Armand 0:b3fd90f94e58 47 * lcd.SetFont(&Font12);
Armand 0:b3fd90f94e58 48 * lcd.Clear(LCD_COLOR_BLUE);
Armand 0:b3fd90f94e58 49 * lcd.SetBackColor(LCD_COLOR_BLUE);
Armand 0:b3fd90f94e58 50 * lcd.SetTextColor(LCD_COLOR_WHITE);
Armand 0:b3fd90f94e58 51 *
Armand 0:b3fd90f94e58 52 * while(1)
Armand 0:b3fd90f94e58 53 * {
Armand 0:b3fd90f94e58 54 * keypad.getkeys(s, 170, 20, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P');
Armand 0:b3fd90f94e58 55 *
Armand 0:b3fd90f94e58 56 * sprintf((char*)text1, "%s", s);
Armand 0:b3fd90f94e58 57 * lcd.DisplayStringAt(0, LINE(5), (uint8_t *)&text1, LEFT_MODE);
Armand 0:b3fd90f94e58 58 *
Armand 0:b3fd90f94e58 59 * wait(1);
Armand 0:b3fd90f94e58 60 * }
Armand 0:b3fd90f94e58 61 *}
Armand 0:b3fd90f94e58 62 * @endcode
Armand 0:b3fd90f94e58 63 */
Armand 0:b3fd90f94e58 64
Armand 0:b3fd90f94e58 65 class F7_TSKeypad_MultiKey
Armand 0:b3fd90f94e58 66 {
Armand 0:b3fd90f94e58 67
Armand 0:b3fd90f94e58 68 public:
Armand 0:b3fd90f94e58 69 /** Constructor.
Armand 0:b3fd90f94e58 70 */
Armand 0:b3fd90f94e58 71 F7_TSKeypad_MultiKey();
Armand 0:b3fd90f94e58 72
Armand 0:b3fd90f94e58 73 /** Retrieves the keys selected as a string.
Armand 0:b3fd90f94e58 74 * @param str[] - stores the keys selected in this array.
Armand 0:b3fd90f94e58 75 * @param startx - to set x start pos of the keypad.
Armand 0:b3fd90f94e58 76 * @param starty - to set y start pos of the keypad.
Armand 0:b3fd90f94e58 77 * @param char1 - char16 to change the keys of the keypad.
Armand 0:b3fd90f94e58 78 * @retval None.
Armand 0:b3fd90f94e58 79 */
Armand 0:b3fd90f94e58 80 void getkeys(char str[], uint8_t startx, uint8_t starty,char char1, char char2, char char3, char char4, char char5, char char6, char char7, char char8, char char9, char char10, char char11, char char12, char char13, char char14, char char15, char char16);
Armand 0:b3fd90f94e58 81
Armand 0:b3fd90f94e58 82 private:
Armand 0:b3fd90f94e58 83
Armand 0:b3fd90f94e58 84 void Detect_isr();
Armand 0:b3fd90f94e58 85 void DrawKeypad(uint8_t startpointx, uint8_t startpointy,char char1, char char2, char char3, char char4, char char5, char char6, char char7, char char8, char char9, char char10, char char11, char char12, char char13, char char14, char char15, char char16);
Armand 0:b3fd90f94e58 86
Armand 0:b3fd90f94e58 87 Ticker ticker;
Armand 0:b3fd90f94e58 88 sFONT *FontSize;
Armand 0:b3fd90f94e58 89 LCD_DISCO_F746NG lcd;
Armand 0:b3fd90f94e58 90 TS_DISCO_F746NG ts;
Armand 0:b3fd90f94e58 91 TS_StateTypeDef TS_State;
Armand 0:b3fd90f94e58 92
Armand 0:b3fd90f94e58 93 uint8_t state, btnsize;
Armand 0:b3fd90f94e58 94 int OK;
Armand 0:b3fd90f94e58 95 uint32_t Bckclr, Txtclr;
Armand 0:b3fd90f94e58 96 uint8_t correcttouch, button;
Armand 0:b3fd90f94e58 97 uint16_t frstprsx, frstprsy;
Armand 0:b3fd90f94e58 98 char keypressed;
Armand 0:b3fd90f94e58 99 int a, b, recv;
Armand 0:b3fd90f94e58 100 int keypad;
Armand 0:b3fd90f94e58 101 int keypadstartX[4][4];
Armand 0:b3fd90f94e58 102 int keypadstartY[4][4];
Armand 0:b3fd90f94e58 103 int keypadendX[4][4];
Armand 0:b3fd90f94e58 104 int keypadendY[4][4];
Armand 0:b3fd90f94e58 105 uint8_t status;
Armand 0:b3fd90f94e58 106 int m, textx, Enter;
Armand 0:b3fd90f94e58 107 };
Armand 0:b3fd90f94e58 108
Armand 0:b3fd90f94e58 109 #endif