This is a library for 4DGL screens from 4D Systems in Autralia (http://www.4dsystems.com.au). Most graphic, touch and text functions are supported

Dependents:   Conways_Game_Life uVGAII_demo 4DGLtest_CalSol uVGA_4180

Committer:
Kerpower
Date:
Sun Oct 17 10:26:10 2010 +0000
Revision:
8:b95348b8030e
Parent:
0:1102d253f057
9

Who changed what in which revision?

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