flip tile
Fork of 4DGL-uLCD-SE by
uLCD_4DGL_Touch.cpp@1:8b656995301f, 2013-11-11 (annotated)
- Committer:
- 4180_1
- Date:
- Mon Nov 11 01:22:41 2013 +0000
- Revision:
- 1:8b656995301f
- Parent:
- TFT_4DGL_Touch.cpp@0:d6e186427f3e
- Child:
- 6:b759b69cbaf9
ver 1.0 uLCD144-G2 demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AdamGreen | 0:d6e186427f3e | 1 | // |
4180_1 | 1:8b656995301f | 2 | // uLCD_4DGL is a class to drive 4D Systems TFT touch screens |
AdamGreen | 0:d6e186427f3e | 3 | // |
AdamGreen | 0:d6e186427f3e | 4 | // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr> |
AdamGreen | 0:d6e186427f3e | 5 | // |
4180_1 | 1:8b656995301f | 6 | // uLCD_4DGL is free software: you can redistribute it and/or modify |
AdamGreen | 0:d6e186427f3e | 7 | // it under the terms of the GNU General Public License as published by |
AdamGreen | 0:d6e186427f3e | 8 | // the Free Software Foundation, either version 3 of the License, or |
AdamGreen | 0:d6e186427f3e | 9 | // (at your option) any later version. |
AdamGreen | 0:d6e186427f3e | 10 | // |
4180_1 | 1:8b656995301f | 11 | // uLCD_4DGL is distributed in the hope that it will be useful, |
AdamGreen | 0:d6e186427f3e | 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
AdamGreen | 0:d6e186427f3e | 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
AdamGreen | 0:d6e186427f3e | 14 | // GNU General Public License for more details. |
AdamGreen | 0:d6e186427f3e | 15 | // |
AdamGreen | 0:d6e186427f3e | 16 | // You should have received a copy of the GNU General Public License |
4180_1 | 1:8b656995301f | 17 | // along with uLCD_4DGL. If not, see <http://www.gnu.org/licenses/>. |
AdamGreen | 0:d6e186427f3e | 18 | |
AdamGreen | 0:d6e186427f3e | 19 | #include "mbed.h" |
4180_1 | 1:8b656995301f | 20 | #include "uLCD_4DGL.h" |
AdamGreen | 0:d6e186427f3e | 21 | |
AdamGreen | 0:d6e186427f3e | 22 | //****************************************************************************************************** |
4180_1 | 1:8b656995301f | 23 | void uLCD_4DGL :: touch_mode(char mode) { // Send touch mode (WAIT, PRESS, RELEASE or MOVE) |
AdamGreen | 0:d6e186427f3e | 24 | |
AdamGreen | 0:d6e186427f3e | 25 | char command[2]= ""; |
AdamGreen | 0:d6e186427f3e | 26 | |
AdamGreen | 0:d6e186427f3e | 27 | command[0] = GETTOUCH; |
AdamGreen | 0:d6e186427f3e | 28 | command[1] = mode; |
AdamGreen | 0:d6e186427f3e | 29 | |
AdamGreen | 0:d6e186427f3e | 30 | writeCOMMAND(command, 2); |
AdamGreen | 0:d6e186427f3e | 31 | } |
AdamGreen | 0:d6e186427f3e | 32 | |
AdamGreen | 0:d6e186427f3e | 33 | //****************************************************************************************************** |
4180_1 | 1:8b656995301f | 34 | void uLCD_4DGL :: get_touch(int *x, int *y) { // Get the touch coordinates |
AdamGreen | 0:d6e186427f3e | 35 | |
AdamGreen | 0:d6e186427f3e | 36 | char command[2] = ""; |
AdamGreen | 0:d6e186427f3e | 37 | |
AdamGreen | 0:d6e186427f3e | 38 | command[0] = GETTOUCH; |
AdamGreen | 0:d6e186427f3e | 39 | command[1] = GETPOSITION; |
AdamGreen | 0:d6e186427f3e | 40 | |
AdamGreen | 0:d6e186427f3e | 41 | getTOUCH(command, 2, x, y); |
AdamGreen | 0:d6e186427f3e | 42 | } |
AdamGreen | 0:d6e186427f3e | 43 | |
AdamGreen | 0:d6e186427f3e | 44 | //****************************************************************************************************** |
4180_1 | 1:8b656995301f | 45 | int uLCD_4DGL :: touch_status(void) { // Get the touch screen status |
AdamGreen | 0:d6e186427f3e | 46 | |
AdamGreen | 0:d6e186427f3e | 47 | char command[2] = ""; |
AdamGreen | 0:d6e186427f3e | 48 | |
AdamGreen | 0:d6e186427f3e | 49 | command[0] = GETTOUCH; |
AdamGreen | 0:d6e186427f3e | 50 | command[1] = STATUS; |
AdamGreen | 0:d6e186427f3e | 51 | |
AdamGreen | 0:d6e186427f3e | 52 | return getSTATUS(command, 2); |
AdamGreen | 0:d6e186427f3e | 53 | } |
AdamGreen | 0:d6e186427f3e | 54 | |
AdamGreen | 0:d6e186427f3e | 55 | |
AdamGreen | 0:d6e186427f3e | 56 | //****************************************************************************************************** |
4180_1 | 1:8b656995301f | 57 | void uLCD_4DGL :: wait_touch(int delay) { // wait until touch within a delay in milliseconds |
AdamGreen | 0:d6e186427f3e | 58 | |
AdamGreen | 0:d6e186427f3e | 59 | char command[3]= ""; |
AdamGreen | 0:d6e186427f3e | 60 | |
AdamGreen | 0:d6e186427f3e | 61 | command[0] = WAITTOUCH; |
AdamGreen | 0:d6e186427f3e | 62 | |
AdamGreen | 0:d6e186427f3e | 63 | command[1] = (delay >> 8) & 0xFF; |
AdamGreen | 0:d6e186427f3e | 64 | command[2] = delay & 0xFF; |
AdamGreen | 0:d6e186427f3e | 65 | |
AdamGreen | 0:d6e186427f3e | 66 | writeCOMMAND(command, 3); |
AdamGreen | 0:d6e186427f3e | 67 | } |
AdamGreen | 0:d6e186427f3e | 68 | |
AdamGreen | 0:d6e186427f3e | 69 | //****************************************************************************************************** |
4180_1 | 1:8b656995301f | 70 | void uLCD_4DGL :: set_touch(int x1, int y1 , int x2, int y2) { // define touch area |
AdamGreen | 0:d6e186427f3e | 71 | |
AdamGreen | 0:d6e186427f3e | 72 | char command[9]= ""; |
AdamGreen | 0:d6e186427f3e | 73 | |
AdamGreen | 0:d6e186427f3e | 74 | command[0] = SETTOUCH; |
AdamGreen | 0:d6e186427f3e | 75 | |
AdamGreen | 0:d6e186427f3e | 76 | command[1] = (x1 >> 8) & 0xFF; |
AdamGreen | 0:d6e186427f3e | 77 | command[2] = x1 & 0xFF; |
AdamGreen | 0:d6e186427f3e | 78 | |
AdamGreen | 0:d6e186427f3e | 79 | command[3] = (y1 >> 8) & 0xFF; |
AdamGreen | 0:d6e186427f3e | 80 | command[4] = y1 & 0xFF; |
AdamGreen | 0:d6e186427f3e | 81 | |
AdamGreen | 0:d6e186427f3e | 82 | command[5] = (x2 >> 8) & 0xFF; |
AdamGreen | 0:d6e186427f3e | 83 | command[6] = x2 & 0xFF; |
AdamGreen | 0:d6e186427f3e | 84 | |
AdamGreen | 0:d6e186427f3e | 85 | command[7] = (y2 >> 8) & 0xFF; |
AdamGreen | 0:d6e186427f3e | 86 | command[8] = y2 & 0xFF; |
AdamGreen | 0:d6e186427f3e | 87 | |
AdamGreen | 0:d6e186427f3e | 88 | writeCOMMAND(command, 9); |
AdamGreen | 0:d6e186427f3e | 89 | } |