Class library for a touchscreen-based keypad for the LCD display present on the DISCO_F429ZI board.
Dependents: WIRE-BANDING_FT810 WIRE-BANDING_copy
KEYPAD_DISCO_F429ZI.h@1:1db4c6c394bb, 2016-05-08 (annotated)
- Committer:
- grantphillips
- Date:
- Sun May 08 18:42:07 2016 +0000
- Revision:
- 1:1db4c6c394bb
- Parent:
- 0:8cc22acc00d2
- Child:
- 2:51f454b7c9ab
v1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
grantphillips | 0:8cc22acc00d2 | 1 | /* KEYPAD_DISCO_F429ZI Library v1.0 |
grantphillips | 0:8cc22acc00d2 | 2 | * Copyright (c) 2016 Grant Phillips |
grantphillips | 0:8cc22acc00d2 | 3 | * grant.phillips@nmmu.ac.za |
grantphillips | 0:8cc22acc00d2 | 4 | * |
grantphillips | 0:8cc22acc00d2 | 5 | * |
grantphillips | 0:8cc22acc00d2 | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
grantphillips | 0:8cc22acc00d2 | 7 | * of this software and associated documentation files (the "Software"), to deal |
grantphillips | 0:8cc22acc00d2 | 8 | * in the Software without restriction, including without limitation the rights |
grantphillips | 0:8cc22acc00d2 | 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
grantphillips | 0:8cc22acc00d2 | 10 | * copies of the Software, and to permit persons to whom the Software is |
grantphillips | 0:8cc22acc00d2 | 11 | * furnished to do so, subject to the following conditions: |
grantphillips | 0:8cc22acc00d2 | 12 | * |
grantphillips | 0:8cc22acc00d2 | 13 | * The above copyright notice and this permission notice shall be included in |
grantphillips | 0:8cc22acc00d2 | 14 | * all copies or substantial portions of the Software. |
grantphillips | 0:8cc22acc00d2 | 15 | * |
grantphillips | 0:8cc22acc00d2 | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
grantphillips | 0:8cc22acc00d2 | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
grantphillips | 0:8cc22acc00d2 | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
grantphillips | 0:8cc22acc00d2 | 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
grantphillips | 0:8cc22acc00d2 | 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
grantphillips | 0:8cc22acc00d2 | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
grantphillips | 0:8cc22acc00d2 | 22 | * THE SOFTWARE. |
grantphillips | 0:8cc22acc00d2 | 23 | */ |
grantphillips | 0:8cc22acc00d2 | 24 | |
grantphillips | 0:8cc22acc00d2 | 25 | #ifndef KEYPAD_DISCO_F429ZI_H |
grantphillips | 0:8cc22acc00d2 | 26 | #define KEYPAD_DISCO_F429ZI_H |
grantphillips | 0:8cc22acc00d2 | 27 | |
grantphillips | 0:8cc22acc00d2 | 28 | #include "mbed.h" |
grantphillips | 0:8cc22acc00d2 | 29 | #include "TS_DISCO_F429ZI.h" |
grantphillips | 0:8cc22acc00d2 | 30 | #include "LCD_DISCO_F429ZI.h" |
grantphillips | 0:8cc22acc00d2 | 31 | |
grantphillips | 0:8cc22acc00d2 | 32 | /** Class library for a touchscreen-based keypad for the LCD display present on the DISCO_F429ZI board. |
grantphillips | 0:8cc22acc00d2 | 33 | * |
grantphillips | 0:8cc22acc00d2 | 34 | * Example: |
grantphillips | 0:8cc22acc00d2 | 35 | * @code |
grantphillips | 0:8cc22acc00d2 | 36 | * #include "mbed.h" |
grantphillips | 0:8cc22acc00d2 | 37 | * #include "HCSR04.h" |
grantphillips | 0:8cc22acc00d2 | 38 | * |
grantphillips | 0:8cc22acc00d2 | 39 | * HCSR04 distance(PB_8, PA_1); |
grantphillips | 0:8cc22acc00d2 | 40 | * |
grantphillips | 0:8cc22acc00d2 | 41 | * int main() { |
grantphillips | 0:8cc22acc00d2 | 42 | * while(1){ |
grantphillips | 0:8cc22acc00d2 | 43 | * SWO.printf("Distance = %d (us) %f (cm)\n", distance.read_us(), distance.read_cm()); |
grantphillips | 0:8cc22acc00d2 | 44 | * } |
grantphillips | 0:8cc22acc00d2 | 45 | * } |
grantphillips | 0:8cc22acc00d2 | 46 | * @endcode |
grantphillips | 0:8cc22acc00d2 | 47 | */ |
grantphillips | 0:8cc22acc00d2 | 48 | |
grantphillips | 0:8cc22acc00d2 | 49 | class KEYPAD_DISCO_F429ZI { |
grantphillips | 0:8cc22acc00d2 | 50 | public: |
grantphillips | 0:8cc22acc00d2 | 51 | /** Create a KEYPAD_DISCO_F429ZI object. |
grantphillips | 0:8cc22acc00d2 | 52 | */ |
grantphillips | 0:8cc22acc00d2 | 53 | KEYPAD_DISCO_F429ZI(); |
grantphillips | 0:8cc22acc00d2 | 54 | |
grantphillips | 1:1db4c6c394bb | 55 | /** Draws the keys for the keypad and the Message Box and Output Box areas if enabled. |
grantphillips | 1:1db4c6c394bb | 56 | * @param |
grantphillips | 1:1db4c6c394bb | 57 | * MessageBoxEnable Enable (=1) or disable(=0 the drawing of a Message Box area on the keypad screen. |
grantphillips | 1:1db4c6c394bb | 58 | * @param |
grantphillips | 1:1db4c6c394bb | 59 | * OutBoxEnable Enable (=1) or disable(=0 the drawing of a Output Box area on the keypad screen. |
grantphillips | 0:8cc22acc00d2 | 60 | */ |
grantphillips | 0:8cc22acc00d2 | 61 | void Show(int MessageBoxEnable, int OutBoxEnable); |
grantphillips | 0:8cc22acc00d2 | 62 | |
grantphillips | 0:8cc22acc00d2 | 63 | /** Return the current key pressed on the keypad. |
grantphillips | 0:8cc22acc00d2 | 64 | * @param |
grantphillips | 0:8cc22acc00d2 | 65 | * None |
grantphillips | 0:8cc22acc00d2 | 66 | * @return |
grantphillips | 0:8cc22acc00d2 | 67 | * ASCII character of the key pressed. Will be NULL ('/0') if no key is pressed. |
grantphillips | 0:8cc22acc00d2 | 68 | */ |
grantphillips | 0:8cc22acc00d2 | 69 | char ReadKey(); |
grantphillips | 0:8cc22acc00d2 | 70 | |
grantphillips | 0:8cc22acc00d2 | 71 | |
grantphillips | 0:8cc22acc00d2 | 72 | private: |
grantphillips | 0:8cc22acc00d2 | 73 | LCD_DISCO_F429ZI lcd; |
grantphillips | 0:8cc22acc00d2 | 74 | TS_DISCO_F429ZI ts; |
grantphillips | 0:8cc22acc00d2 | 75 | uint16_t LastkeyX, LastkeyY; |
grantphillips | 0:8cc22acc00d2 | 76 | uint8_t LastKey; |
grantphillips | 0:8cc22acc00d2 | 77 | uint8_t ReadKeyState; |
grantphillips | 0:8cc22acc00d2 | 78 | uint16_t KeysTopY; |
grantphillips | 0:8cc22acc00d2 | 79 | uint8_t row, col; |
grantphillips | 0:8cc22acc00d2 | 80 | uint8_t Keys[4][4]; |
grantphillips | 0:8cc22acc00d2 | 81 | |
grantphillips | 0:8cc22acc00d2 | 82 | uint32_t MsgBColor, MsgFColor; |
grantphillips | 0:8cc22acc00d2 | 83 | uint32_t OutBColor, OutFColor; |
grantphillips | 0:8cc22acc00d2 | 84 | uint32_t KeyBColor, KeyFColor, KeyPressColor; |
grantphillips | 0:8cc22acc00d2 | 85 | uint32_t BackColor; |
grantphillips | 0:8cc22acc00d2 | 86 | |
grantphillips | 0:8cc22acc00d2 | 87 | int MessageBoxEnabledFlag, OutBoxEnabledFlag; |
grantphillips | 0:8cc22acc00d2 | 88 | |
grantphillips | 0:8cc22acc00d2 | 89 | }; |
grantphillips | 0:8cc22acc00d2 | 90 | |
grantphillips | 0:8cc22acc00d2 | 91 | #endif |