uVGA III library

Dependents:   CDUFinal CDU_Mbed_21 CDU_Mbed_26 CDU_Mbed_30

Fork of 4DGL by Adam Green

Committer:
AdamGreen
Date:
Tue Jul 05 11:45:02 2011 +0000
Revision:
0:d6e186427f3e
Fixed a few minor issues in 4DGL library

Moved pc serial port object used for debug output into 4DGL object itself. Previously it was a global object but its constructor wasnt getting run before the global constructor for the 4DGL object itself which led to an assert in the serial code.

I also fixed a few potential buffer overruns that I saw in the code as well.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AdamGreen 0:d6e186427f3e 1 //
AdamGreen 0:d6e186427f3e 2 // TFT_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 //
AdamGreen 0:d6e186427f3e 6 // TFT_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 //
AdamGreen 0:d6e186427f3e 11 // TFT_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
AdamGreen 0:d6e186427f3e 17 // along with TFT_4DGL. If not, see <http://www.gnu.org/licenses/>.
AdamGreen 0:d6e186427f3e 18
AdamGreen 0:d6e186427f3e 19 #include "mbed.h"
AdamGreen 0:d6e186427f3e 20 #include "TFT_4DGL.h"
AdamGreen 0:d6e186427f3e 21
AdamGreen 0:d6e186427f3e 22 //******************************************************************************************************
AdamGreen 0:d6e186427f3e 23 void TFT_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 //******************************************************************************************************
AdamGreen 0:d6e186427f3e 34 void TFT_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 //******************************************************************************************************
AdamGreen 0:d6e186427f3e 45 int TFT_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 //******************************************************************************************************
AdamGreen 0:d6e186427f3e 57 void TFT_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 //******************************************************************************************************
AdamGreen 0:d6e186427f3e 70 void TFT_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 }