Updated serial prints for debugging

Dependents:   mbedica_on_yehowshua mbedica

Committer:
zrussell3
Date:
Mon Dec 10 17:58:38 2018 +0000
Revision:
6:58c02c38e75f
Parent:
0:de1ab53f3480
Added checks for serial output

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ivygatech 0:de1ab53f3480 1 //
ivygatech 0:de1ab53f3480 2 // uVGAIII is a class to drive 4D Systems TFT touch screens
ivygatech 0:de1ab53f3480 3 //
ivygatech 0:de1ab53f3480 4 // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr>
ivygatech 0:de1ab53f3480 5 //
ivygatech 0:de1ab53f3480 6 // uVGAIII is free software: you can redistribute it and/or modify
ivygatech 0:de1ab53f3480 7 // it under the terms of the GNU General Public License as published by
ivygatech 0:de1ab53f3480 8 // the Free Software Foundation, either version 3 of the License, or
ivygatech 0:de1ab53f3480 9 // (at your option) any later version.
ivygatech 0:de1ab53f3480 10 //
ivygatech 0:de1ab53f3480 11 // uVGAIII is distributed in the hope that it will be useful,
ivygatech 0:de1ab53f3480 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
ivygatech 0:de1ab53f3480 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ivygatech 0:de1ab53f3480 14 // GNU General Public License for more details.
ivygatech 0:de1ab53f3480 15 //
ivygatech 0:de1ab53f3480 16 // You should have received a copy of the GNU General Public License
ivygatech 0:de1ab53f3480 17 // along with uVGAIII. If not, see <http://www.gnu.org/licenses/>.
ivygatech 0:de1ab53f3480 18
ivygatech 0:de1ab53f3480 19 #include "mbed.h"
ivygatech 0:de1ab53f3480 20 #include "uVGAIII.h"
ivygatech 0:de1ab53f3480 21
ivygatech 0:de1ab53f3480 22 //******************************************************************************************************
ivygatech 0:de1ab53f3480 23 int uVGAIII :: touch_status(void) { // Get the touch screen status
ivygatech 0:de1ab53f3480 24 char command[4] = "";
ivygatech 0:de1ab53f3480 25
ivygatech 0:de1ab53f3480 26 command[0] = (TOUCHGET >> 8) & 0xFF;
ivygatech 0:de1ab53f3480 27 command[1] = TOUCHGET & 0xFF;
ivygatech 0:de1ab53f3480 28
ivygatech 0:de1ab53f3480 29 command[2] = (STATUS >> 8) & 0xFF;
ivygatech 0:de1ab53f3480 30 command[3] = STATUS & 0xFF;
ivygatech 0:de1ab53f3480 31
ivygatech 0:de1ab53f3480 32 return getSTATUS(command, 4);
ivygatech 0:de1ab53f3480 33 }
ivygatech 0:de1ab53f3480 34
ivygatech 0:de1ab53f3480 35 //******************************************************************************************************
ivygatech 0:de1ab53f3480 36 void uVGAIII :: touch_get_x(int *x) { // Get X coordinates
ivygatech 0:de1ab53f3480 37 char command[4] = "";
ivygatech 0:de1ab53f3480 38
ivygatech 0:de1ab53f3480 39 command[0] = (TOUCHGET >> 8) & 0xFF;
ivygatech 0:de1ab53f3480 40 command[1] = TOUCHGET & 0xFF;
ivygatech 0:de1ab53f3480 41
ivygatech 0:de1ab53f3480 42 command[2] = 0;
ivygatech 0:de1ab53f3480 43 command[3] = GETXPOSITION;
ivygatech 0:de1ab53f3480 44
ivygatech 0:de1ab53f3480 45 getTOUCH(command, 4, x);
ivygatech 0:de1ab53f3480 46
ivygatech 0:de1ab53f3480 47 #if DEBUGMODE
ivygatech 0:de1ab53f3480 48 pc.printf("Get X coordinates completed.\n");
ivygatech 0:de1ab53f3480 49 #endif
ivygatech 0:de1ab53f3480 50 }
ivygatech 0:de1ab53f3480 51
ivygatech 0:de1ab53f3480 52 //******************************************************************************************************
ivygatech 0:de1ab53f3480 53 void uVGAIII :: touch_get_y(int *y) { // Get Y coordinates
ivygatech 0:de1ab53f3480 54 char command[4] = "";
ivygatech 0:de1ab53f3480 55
ivygatech 0:de1ab53f3480 56 command[0] = (TOUCHGET >> 8) & 0xFF;
ivygatech 0:de1ab53f3480 57 command[1] = TOUCHGET & 0xFF;
ivygatech 0:de1ab53f3480 58
ivygatech 0:de1ab53f3480 59 command[2] = 0;
ivygatech 0:de1ab53f3480 60 command[3] = GETYPOSITION;
ivygatech 0:de1ab53f3480 61
ivygatech 0:de1ab53f3480 62 getTOUCH(command, 4, y);
ivygatech 0:de1ab53f3480 63
ivygatech 0:de1ab53f3480 64 #if DEBUGMODE
ivygatech 0:de1ab53f3480 65 pc.printf("Get Y coordinates completed.\n");
ivygatech 0:de1ab53f3480 66 #endif
ivygatech 0:de1ab53f3480 67 }
ivygatech 0:de1ab53f3480 68
ivygatech 0:de1ab53f3480 69 //******************************************************************************************************
ivygatech 0:de1ab53f3480 70 void uVGAIII :: touch_set(char mode) { // Sets various Touch Screen related parameters
ivygatech 0:de1ab53f3480 71
ivygatech 0:de1ab53f3480 72 char command[4]= "";
ivygatech 0:de1ab53f3480 73
ivygatech 0:de1ab53f3480 74 command[0] = (TOUCHSET >>8) & 0xFF;
ivygatech 0:de1ab53f3480 75 command[1] = TOUCHSET & 0xFF;
ivygatech 0:de1ab53f3480 76
ivygatech 0:de1ab53f3480 77 command[2] = 0;
ivygatech 0:de1ab53f3480 78 command[3] = mode;
ivygatech 0:de1ab53f3480 79
ivygatech 0:de1ab53f3480 80 writeCOMMAND(command, 4, 1);
ivygatech 0:de1ab53f3480 81
ivygatech 0:de1ab53f3480 82 #if DEBUGMODE
ivygatech 0:de1ab53f3480 83 pc.printf("Touch set completed.\n");
ivygatech 0:de1ab53f3480 84 #endif
ivygatech 0:de1ab53f3480 85 }
ivygatech 0:de1ab53f3480 86
ivygatech 0:de1ab53f3480 87 //******************************************************************************************************
ivygatech 0:de1ab53f3480 88 void uVGAIII :: detect_touch_region(int x1, int y1, int x2, int y2) { // Specificies a new touch detect region on the screen
ivygatech 0:de1ab53f3480 89 char command[10] = "";
ivygatech 0:de1ab53f3480 90
ivygatech 0:de1ab53f3480 91 command[0] = (TOUCHDETECT >> 8) & 0xFF;
ivygatech 0:de1ab53f3480 92 command[1] = TOUCHDETECT & 0xFF;
ivygatech 0:de1ab53f3480 93
ivygatech 0:de1ab53f3480 94 command[2] = (x1 >> 8) & 0xFF;
ivygatech 0:de1ab53f3480 95 command[3] = x1 & 0xFF;
ivygatech 0:de1ab53f3480 96
ivygatech 0:de1ab53f3480 97 command[4] = (y1 >> 8) & 0xFF;
ivygatech 0:de1ab53f3480 98 command[5] = y1 & 0xFF;
ivygatech 0:de1ab53f3480 99
ivygatech 0:de1ab53f3480 100 command[6] = (x2 >> 8) & 0xFF;
ivygatech 0:de1ab53f3480 101 command[7] = x2 & 0xFF;
ivygatech 0:de1ab53f3480 102
ivygatech 0:de1ab53f3480 103 command[8] = (y2 >> 8) & 0xFF;
ivygatech 0:de1ab53f3480 104 command[9] = y2 & 0xFF;
ivygatech 0:de1ab53f3480 105
ivygatech 0:de1ab53f3480 106 writeCOMMAND(command, 10, 1);
ivygatech 0:de1ab53f3480 107
ivygatech 0:de1ab53f3480 108 #if DEBUGMODE
ivygatech 0:de1ab53f3480 109 pc.printf("Detect touch region completed.\n");
ivygatech 0:de1ab53f3480 110 #endif
ivygatech 0:de1ab53f3480 111 }