Dependents:   Telecommande_prologue

Committer:
projetremote
Date:
Tue May 03 13:36:08 2011 +0000
Revision:
0:277186c9dd25

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
projetremote 0:277186c9dd25 1 //
projetremote 0:277186c9dd25 2 // TFT_4DGL is a class to drive 4D Systems TFT touch screens
projetremote 0:277186c9dd25 3 //
projetremote 0:277186c9dd25 4 // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr>
projetremote 0:277186c9dd25 5 //
projetremote 0:277186c9dd25 6 // TFT_4DGL is free software: you can redistribute it and/or modify
projetremote 0:277186c9dd25 7 // it under the terms of the GNU General Public License as published by
projetremote 0:277186c9dd25 8 // the Free Software Foundation, either version 3 of the License, or
projetremote 0:277186c9dd25 9 // (at your option) any later version.
projetremote 0:277186c9dd25 10 //
projetremote 0:277186c9dd25 11 // TFT_4DGL is distributed in the hope that it will be useful,
projetremote 0:277186c9dd25 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
projetremote 0:277186c9dd25 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
projetremote 0:277186c9dd25 14 // GNU General Public License for more details.
projetremote 0:277186c9dd25 15 //
projetremote 0:277186c9dd25 16 // You should have received a copy of the GNU General Public License
projetremote 0:277186c9dd25 17 // along with TFT_4DGL. If not, see <http://www.gnu.org/licenses/>.
projetremote 0:277186c9dd25 18
projetremote 0:277186c9dd25 19 #include "mbed.h"
projetremote 0:277186c9dd25 20 #include "TFT_4DGL.h"
projetremote 0:277186c9dd25 21
projetremote 0:277186c9dd25 22 //******************************************************************************************************
projetremote 0:277186c9dd25 23 void TFT_4DGL :: touch_mode(char mode) { // Send touch mode (WAIT, PRESS, RELEASE or MOVE)
projetremote 0:277186c9dd25 24
projetremote 0:277186c9dd25 25 char command[2]= "";
projetremote 0:277186c9dd25 26
projetremote 0:277186c9dd25 27 command[0] = GETTOUCH;
projetremote 0:277186c9dd25 28 command[1] = mode;
projetremote 0:277186c9dd25 29
projetremote 0:277186c9dd25 30 writeCOMMAND(command, 2);
projetremote 0:277186c9dd25 31 }
projetremote 0:277186c9dd25 32
projetremote 0:277186c9dd25 33 //******************************************************************************************************
projetremote 0:277186c9dd25 34 void TFT_4DGL :: get_touch(int *x, int *y) { // Get the touch coordinates
projetremote 0:277186c9dd25 35
projetremote 0:277186c9dd25 36 char command[2] = "";
projetremote 0:277186c9dd25 37
projetremote 0:277186c9dd25 38 command[0] = GETTOUCH;
projetremote 0:277186c9dd25 39 command[1] = GETPOSITION;
projetremote 0:277186c9dd25 40
projetremote 0:277186c9dd25 41 getTOUCH(command, 2, x, y);
projetremote 0:277186c9dd25 42 }
projetremote 0:277186c9dd25 43
projetremote 0:277186c9dd25 44 //******************************************************************************************************
projetremote 0:277186c9dd25 45 int TFT_4DGL :: touch_status(void) { // Get the touch screen status
projetremote 0:277186c9dd25 46
projetremote 0:277186c9dd25 47 char command[2] = "";
projetremote 0:277186c9dd25 48
projetremote 0:277186c9dd25 49 command[0] = GETTOUCH;
projetremote 0:277186c9dd25 50 command[1] = STATUS;
projetremote 0:277186c9dd25 51
projetremote 0:277186c9dd25 52 return getSTATUS(command, 2);
projetremote 0:277186c9dd25 53 }
projetremote 0:277186c9dd25 54
projetremote 0:277186c9dd25 55
projetremote 0:277186c9dd25 56 //******************************************************************************************************
projetremote 0:277186c9dd25 57 void TFT_4DGL :: wait_touch(int delay) { // wait until touch within a delay in milliseconds
projetremote 0:277186c9dd25 58
projetremote 0:277186c9dd25 59 char command[3]= "";
projetremote 0:277186c9dd25 60
projetremote 0:277186c9dd25 61 command[0] = WAITTOUCH;
projetremote 0:277186c9dd25 62
projetremote 0:277186c9dd25 63 command[1] = (delay >> 8) & 0xFF;
projetremote 0:277186c9dd25 64 command[2] = delay & 0xFF;
projetremote 0:277186c9dd25 65
projetremote 0:277186c9dd25 66 writeCOMMAND(command, 3);
projetremote 0:277186c9dd25 67 }
projetremote 0:277186c9dd25 68
projetremote 0:277186c9dd25 69 //******************************************************************************************************
projetremote 0:277186c9dd25 70 void TFT_4DGL :: set_touch(int x1, int y1 , int x2, int y2) { // define touch area
projetremote 0:277186c9dd25 71
projetremote 0:277186c9dd25 72 char command[9]= "";
projetremote 0:277186c9dd25 73
projetremote 0:277186c9dd25 74 command[0] = SETTOUCH;
projetremote 0:277186c9dd25 75
projetremote 0:277186c9dd25 76 command[1] = (x1 >> 8) & 0xFF;
projetremote 0:277186c9dd25 77 command[2] = x1 & 0xFF;
projetremote 0:277186c9dd25 78
projetremote 0:277186c9dd25 79 command[3] = (y1 >> 8) & 0xFF;
projetremote 0:277186c9dd25 80 command[4] = y1 & 0xFF;
projetremote 0:277186c9dd25 81
projetremote 0:277186c9dd25 82 command[5] = (x2 >> 8) & 0xFF;
projetremote 0:277186c9dd25 83 command[6] = x2 & 0xFF;
projetremote 0:277186c9dd25 84
projetremote 0:277186c9dd25 85 command[7] = (y2 >> 8) & 0xFF;
projetremote 0:277186c9dd25 86 command[8] = y2 & 0xFF;
projetremote 0:277186c9dd25 87
projetremote 0:277186c9dd25 88 writeCOMMAND(command, 9);
projetremote 0:277186c9dd25 89 }
projetremote 0:277186c9dd25 90
projetremote 0:277186c9dd25 91 void TFT_4DGL :: image_touch( int x, int y, int width, int height, long sector, TFT_4DGL Screen){
projetremote 0:277186c9dd25 92
projetremote 0:277186c9dd25 93 char command[1000]= "";
projetremote 0:277186c9dd25 94
projetremote 0:277186c9dd25 95 command[0] = TEXTBUTTON;
projetremote 0:277186c9dd25 96
projetremote 0:277186c9dd25 97 command[1] = UP;
projetremote 0:277186c9dd25 98
projetremote 0:277186c9dd25 99 command[2] = (x >> 8) & 0xFF;
projetremote 0:277186c9dd25 100 command[3] = x & 0xFF;
projetremote 0:277186c9dd25 101
projetremote 0:277186c9dd25 102 command[4] = (y >> 8) & 0xFF;
projetremote 0:277186c9dd25 103 command[5] = y & 0xFF;
projetremote 0:277186c9dd25 104
projetremote 0:277186c9dd25 105
projetremote 0:277186c9dd25 106 command[6] = TRANSPARENT;
projetremote 0:277186c9dd25 107 command[7] = TRANSPARENT;
projetremote 0:277186c9dd25 108
projetremote 0:277186c9dd25 109 command[8] = TRANSPARENT;
projetremote 0:277186c9dd25 110
projetremote 0:277186c9dd25 111
projetremote 0:277186c9dd25 112 command[9] = TRANSPARENT;
projetremote 0:277186c9dd25 113 command[10] = TRANSPARENT;
projetremote 0:277186c9dd25 114
projetremote 0:277186c9dd25 115 command[11] = width;
projetremote 0:277186c9dd25 116
projetremote 0:277186c9dd25 117 command[12] = height;
projetremote 0:277186c9dd25 118
projetremote 0:277186c9dd25 119 command[13] = NULL;
projetremote 0:277186c9dd25 120
projetremote 0:277186c9dd25 121 Screen.uSD_Image(x, y, sector);
projetremote 0:277186c9dd25 122 writeCOMMAND(command, 14);
projetremote 0:277186c9dd25 123 }