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