uVGA II for display using vga

Dependents:   4DGL

Committer:
pprasad7
Date:
Thu Oct 11 20:12:02 2012 +0000
Revision:
0:6741e7724181
hangman

Who changed what in which revision?

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