For uVGAII WebBrowser
Fork of 4DGL by
TFT_4DGL.h@2:6063b076187b, 2010-09-07 (annotated)
- Committer:
- Kerpower
- Date:
- Tue Sep 07 12:25:42 2010 +0000
- Revision:
- 2:6063b076187b
- Parent:
- 1:4f9c6de0879f
- Child:
- 3:2978d0ac4b79
- Child:
- 9:cc9c742bb1a0
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:4f9c6de0879f | 19 | // @author Stephane Rochon |
Kerpower | 1:4f9c6de0879f | 20 | |
Kerpower | 0:1102d253f057 | 21 | #include "mbed.h" |
Kerpower | 0:1102d253f057 | 22 | |
Kerpower | 1:4f9c6de0879f | 23 | // Debug Verbose on terminal enabled |
Kerpower | 0:1102d253f057 | 24 | #ifndef DEBUGMODE |
Kerpower | 0:1102d253f057 | 25 | #define DEBUGMODE 1 |
Kerpower | 0:1102d253f057 | 26 | #endif |
Kerpower | 0:1102d253f057 | 27 | |
Kerpower | 0:1102d253f057 | 28 | // Common WAIT value in millisecond |
Kerpower | 0:1102d253f057 | 29 | #define TEMPO 5 |
Kerpower | 0:1102d253f057 | 30 | |
Kerpower | 0:1102d253f057 | 31 | // 4DGL Functions values |
Kerpower | 0:1102d253f057 | 32 | #define AUTOBAUD '\x55' |
Kerpower | 0:1102d253f057 | 33 | #define CLS '\x45' |
Kerpower | 0:1102d253f057 | 34 | #define BAUDRATE '\x51' |
Kerpower | 0:1102d253f057 | 35 | #define VERSION '\x56' |
Kerpower | 0:1102d253f057 | 36 | #define BCKGDCOLOR '\x42' |
Kerpower | 0:1102d253f057 | 37 | #define DISPCONTROL '\x59' |
Kerpower | 0:1102d253f057 | 38 | #define SETVOLUME '\x76' |
Kerpower | 0:1102d253f057 | 39 | #define CIRCLE '\x43' |
Kerpower | 0:1102d253f057 | 40 | #define TRIANGLE '\x47' |
Kerpower | 0:1102d253f057 | 41 | #define LINE '\x4C' |
Kerpower | 0:1102d253f057 | 42 | #define RECTANGLE '\x72' |
Kerpower | 0:1102d253f057 | 43 | #define ELLIPSE '\x65' |
Kerpower | 0:1102d253f057 | 44 | #define PIXEL '\x50' |
Kerpower | 0:1102d253f057 | 45 | #define READPIXEL '\x52' |
Kerpower | 0:1102d253f057 | 46 | #define SCREENCOPY '\x63' |
Kerpower | 0:1102d253f057 | 47 | #define PENSIZE '\x70' |
Kerpower | 0:1102d253f057 | 48 | #define SETFONT '\x46' |
Kerpower | 0:1102d253f057 | 49 | #define TEXTMODE '\x4F' |
Kerpower | 0:1102d253f057 | 50 | #define TEXTCHAR '\x54' |
Kerpower | 0:1102d253f057 | 51 | #define GRAPHCHAR '\x74' |
Kerpower | 0:1102d253f057 | 52 | #define TEXTSTRING '\x73' |
Kerpower | 0:1102d253f057 | 53 | #define GRAPHSTRING '\x53' |
Kerpower | 0:1102d253f057 | 54 | #define TEXTBUTTON '\x62' |
Kerpower | 0:1102d253f057 | 55 | #define GETTOUCH '\x6F' |
Kerpower | 0:1102d253f057 | 56 | #define WAITTOUCH '\x77' |
Kerpower | 0:1102d253f057 | 57 | #define SETTOUCH '\x75' |
Kerpower | 0:1102d253f057 | 58 | |
Kerpower | 0:1102d253f057 | 59 | |
Kerpower | 0:1102d253f057 | 60 | // Screen answers |
Kerpower | 0:1102d253f057 | 61 | #define ACK '\x06' |
Kerpower | 0:1102d253f057 | 62 | #define NAK '\x15' |
Kerpower | 0:1102d253f057 | 63 | |
Kerpower | 0:1102d253f057 | 64 | // Screen states |
Kerpower | 0:1102d253f057 | 65 | #define OFF '\x00' |
Kerpower | 0:1102d253f057 | 66 | #define ON '\x01' |
Kerpower | 0:1102d253f057 | 67 | |
Kerpower | 0:1102d253f057 | 68 | // Graphics modes |
Kerpower | 0:1102d253f057 | 69 | #define SOLID '\x00' |
Kerpower | 0:1102d253f057 | 70 | #define WIREFRAME '\x01' |
Kerpower | 0:1102d253f057 | 71 | |
Kerpower | 0:1102d253f057 | 72 | // Text modes |
Kerpower | 0:1102d253f057 | 73 | #define TRANSPARENT '\x00' |
Kerpower | 0:1102d253f057 | 74 | #define OPAQUE '\x01' |
Kerpower | 0:1102d253f057 | 75 | |
Kerpower | 0:1102d253f057 | 76 | // Fonts Sizes |
Kerpower | 0:1102d253f057 | 77 | #define FONT_5X7 '\x00' |
Kerpower | 0:1102d253f057 | 78 | #define FONT_8X8 '\x01' |
Kerpower | 0:1102d253f057 | 79 | #define FONT_8X12 '\x02' |
Kerpower | 0:1102d253f057 | 80 | #define FONT_12X16 '\x03' |
Kerpower | 0:1102d253f057 | 81 | |
Kerpower | 0:1102d253f057 | 82 | // Touch Values |
Kerpower | 0:1102d253f057 | 83 | #define WAIT '\x00' |
Kerpower | 0:1102d253f057 | 84 | #define PRESS '\x01' |
Kerpower | 0:1102d253f057 | 85 | #define RELEASE '\x02' |
Kerpower | 0:1102d253f057 | 86 | #define MOVE '\x03' |
Kerpower | 0:1102d253f057 | 87 | #define STATUS '\x04' |
Kerpower | 0:1102d253f057 | 88 | #define GETPOSITION '\x05' |
Kerpower | 0:1102d253f057 | 89 | |
Kerpower | 0:1102d253f057 | 90 | // Data speed |
Kerpower | 0:1102d253f057 | 91 | #define BAUD_110 '\x00' |
Kerpower | 0:1102d253f057 | 92 | #define BAUD_300 '\x01' |
Kerpower | 0:1102d253f057 | 93 | #define BAUD_600 '\x02' |
Kerpower | 0:1102d253f057 | 94 | #define BAUD_1200 '\x03' |
Kerpower | 0:1102d253f057 | 95 | #define BAUD_2400 '\x04' |
Kerpower | 0:1102d253f057 | 96 | #define BAUD_4800 '\x05' |
Kerpower | 0:1102d253f057 | 97 | #define BAUD_9600 '\x06' |
Kerpower | 0:1102d253f057 | 98 | #define BAUD_14400 '\x07' |
Kerpower | 0:1102d253f057 | 99 | #define BAUD_19200 '\x09' |
Kerpower | 0:1102d253f057 | 100 | #define BAUD_31250 '\x09' |
Kerpower | 0:1102d253f057 | 101 | #define BAUD_38400 '\x0A' |
Kerpower | 0:1102d253f057 | 102 | #define BAUD_56000 '\x0B' |
Kerpower | 0:1102d253f057 | 103 | #define BAUD_57600 '\x0C' |
Kerpower | 0:1102d253f057 | 104 | #define BAUD_115200 '\x0D' |
Kerpower | 0:1102d253f057 | 105 | #define BAUD_128000 '\x0E' |
Kerpower | 0:1102d253f057 | 106 | #define BAUD_256000 '\x0F' |
Kerpower | 0:1102d253f057 | 107 | |
Kerpower | 0:1102d253f057 | 108 | // Defined Colors |
Kerpower | 0:1102d253f057 | 109 | #define WHITE 0xFFFFFF |
Kerpower | 0:1102d253f057 | 110 | #define BLACK 0x000000 |
Kerpower | 0:1102d253f057 | 111 | #define RED 0xFF0000 |
Kerpower | 0:1102d253f057 | 112 | #define GREEN 0x00FF00 |
Kerpower | 0:1102d253f057 | 113 | #define BLUE 0x0000FF |
Kerpower | 0:1102d253f057 | 114 | #define LGREY 0xBFBFBF |
Kerpower | 0:1102d253f057 | 115 | #define DGREY 0x5F5F5F |
Kerpower | 0:1102d253f057 | 116 | |
Kerpower | 0:1102d253f057 | 117 | // Mode data |
Kerpower | 0:1102d253f057 | 118 | #define BACKLIGHT '\x00' |
Kerpower | 0:1102d253f057 | 119 | #define DISPLAY '\x01' |
Kerpower | 0:1102d253f057 | 120 | #define CONTRAST '\x02' |
Kerpower | 0:1102d253f057 | 121 | #define POWER '\x03' |
Kerpower | 0:1102d253f057 | 122 | #define ORIENTATION '\x04' |
Kerpower | 0:1102d253f057 | 123 | #define TOUCH_CTRL '\x05' |
Kerpower | 0:1102d253f057 | 124 | #define IMAGE_FORMAT '\x06' |
Kerpower | 0:1102d253f057 | 125 | #define PROTECT_FAT '\x08' |
Kerpower | 0:1102d253f057 | 126 | |
Kerpower | 0:1102d253f057 | 127 | // change this to your specific screen (newer versions) if needed |
Kerpower | 0:1102d253f057 | 128 | // Startup orientation is PORTRAIT so SIZE_X must be lesser than SIZE_Y |
Kerpower | 0:1102d253f057 | 129 | #define SIZE_X 240 |
Kerpower | 0:1102d253f057 | 130 | #define SIZE_Y 320 |
Kerpower | 0:1102d253f057 | 131 | |
Kerpower | 0:1102d253f057 | 132 | #define IS_LANDSCAPE 0 |
Kerpower | 0:1102d253f057 | 133 | #define IS_PORTRAIT 1 |
Kerpower | 0:1102d253f057 | 134 | |
Kerpower | 0:1102d253f057 | 135 | // Screen orientation |
Kerpower | 0:1102d253f057 | 136 | #define LANDSCAPE '\x01' |
Kerpower | 0:1102d253f057 | 137 | #define LANDSCAPE_R '\x02' |
Kerpower | 0:1102d253f057 | 138 | #define PORTRAIT '\x03' |
Kerpower | 0:1102d253f057 | 139 | #define PORTRAIT_R '\x04' |
Kerpower | 0:1102d253f057 | 140 | |
Kerpower | 0:1102d253f057 | 141 | // Parameters |
Kerpower | 0:1102d253f057 | 142 | #define ENABLE '\x00' |
Kerpower | 0:1102d253f057 | 143 | #define DISABLE '\x01' |
Kerpower | 0:1102d253f057 | 144 | #define RESET '\x02' |
Kerpower | 0:1102d253f057 | 145 | |
Kerpower | 0:1102d253f057 | 146 | #define NEW '\x00' |
Kerpower | 0:1102d253f057 | 147 | #define OLD '\x01' |
Kerpower | 0:1102d253f057 | 148 | |
Kerpower | 0:1102d253f057 | 149 | #define DOWN '\x00' |
Kerpower | 0:1102d253f057 | 150 | #define UP '\x01' |
Kerpower | 0:1102d253f057 | 151 | |
Kerpower | 0:1102d253f057 | 152 | #define PROTECT '\x00' |
Kerpower | 0:1102d253f057 | 153 | #define UNPROTECT '\x02' |
Kerpower | 0:1102d253f057 | 154 | |
Kerpower | 0:1102d253f057 | 155 | //************************************************************************** |
Kerpower | 2:6063b076187b | 156 | // \class TFT_4DGL TFT_4DGL.h |
Kerpower | 2:6063b076187b | 157 | // \brief This is the main class. It shoud be used like this : TFT_4GDL myLCD(p9,p10,p11); |
Kerpower | 2:6063b076187b | 158 | |
Kerpower | 0:1102d253f057 | 159 | class TFT_4DGL { |
Kerpower | 0:1102d253f057 | 160 | |
Kerpower | 0:1102d253f057 | 161 | public : |
Kerpower | 0:1102d253f057 | 162 | |
Kerpower | 0:1102d253f057 | 163 | TFT_4DGL(PinName tx, PinName rx, PinName rst); |
Kerpower | 0:1102d253f057 | 164 | |
Kerpower | 0:1102d253f057 | 165 | // General Commands |
Kerpower | 0:1102d253f057 | 166 | void cls(); |
Kerpower | 0:1102d253f057 | 167 | void reset(); |
Kerpower | 0:1102d253f057 | 168 | void autobaud(); |
Kerpower | 0:1102d253f057 | 169 | void baudrate(int); |
Kerpower | 0:1102d253f057 | 170 | void background_color(int); |
Kerpower | 0:1102d253f057 | 171 | void display_control(char, char); |
Kerpower | 0:1102d253f057 | 172 | void set_volume(char); |
Kerpower | 0:1102d253f057 | 173 | |
Kerpower | 0:1102d253f057 | 174 | // Graphics Commands |
Kerpower | 0:1102d253f057 | 175 | void circle(int, int, int, int); |
Kerpower | 0:1102d253f057 | 176 | void triangle(int, int, int, int, int, int, int); |
Kerpower | 0:1102d253f057 | 177 | void line(int, int, int, int, int); |
Kerpower | 0:1102d253f057 | 178 | void rectangle(int, int, int, int, int); |
Kerpower | 0:1102d253f057 | 179 | void ellipse(int, int, int, int, int); |
Kerpower | 0:1102d253f057 | 180 | void pixel(int, int, int); |
Kerpower | 0:1102d253f057 | 181 | int read_pixel(int, int); |
Kerpower | 0:1102d253f057 | 182 | void screen_copy(int, int, int, int, int, int); |
Kerpower | 0:1102d253f057 | 183 | void pen_size(char); |
Kerpower | 0:1102d253f057 | 184 | |
Kerpower | 0:1102d253f057 | 185 | // Texts Commands |
Kerpower | 0:1102d253f057 | 186 | void set_font(char); |
Kerpower | 0:1102d253f057 | 187 | void text_mode(char); |
Kerpower | 0:1102d253f057 | 188 | void text_char(char, char, char, int); |
Kerpower | 0:1102d253f057 | 189 | void graphic_char(char, int, int, int, char, char); |
Kerpower | 0:1102d253f057 | 190 | void text_string(char *, char, char, char, int); |
Kerpower | 0:1102d253f057 | 191 | void graphic_string(char *, int, int, char, int, char, char); |
Kerpower | 0:1102d253f057 | 192 | void text_button(char *, char, int, int, int, char, int, char, char); |
Kerpower | 0:1102d253f057 | 193 | |
Kerpower | 0:1102d253f057 | 194 | void locate(char, char); |
Kerpower | 0:1102d253f057 | 195 | void color(int); |
Kerpower | 0:1102d253f057 | 196 | void putc(char); |
Kerpower | 0:1102d253f057 | 197 | void puts(char *); |
Kerpower | 0:1102d253f057 | 198 | |
Kerpower | 0:1102d253f057 | 199 | // Touch Command |
Kerpower | 0:1102d253f057 | 200 | void touch_mode(char); |
Kerpower | 0:1102d253f057 | 201 | void get_touch(int *, int *); |
Kerpower | 0:1102d253f057 | 202 | void wait_touch(int); |
Kerpower | 0:1102d253f057 | 203 | void set_touch(int, int, int, int); |
Kerpower | 0:1102d253f057 | 204 | int touch_status(void); |
Kerpower | 0:1102d253f057 | 205 | |
Kerpower | 0:1102d253f057 | 206 | // Screen Data |
Kerpower | 0:1102d253f057 | 207 | int type; |
Kerpower | 0:1102d253f057 | 208 | int revision; |
Kerpower | 0:1102d253f057 | 209 | int firmware; |
Kerpower | 0:1102d253f057 | 210 | int reserved1; |
Kerpower | 0:1102d253f057 | 211 | int reserved2; |
Kerpower | 0:1102d253f057 | 212 | |
Kerpower | 0:1102d253f057 | 213 | // Text data |
Kerpower | 0:1102d253f057 | 214 | char current_col; |
Kerpower | 0:1102d253f057 | 215 | char current_row; |
Kerpower | 0:1102d253f057 | 216 | int current_color; |
Kerpower | 0:1102d253f057 | 217 | char current_font; |
Kerpower | 0:1102d253f057 | 218 | char current_orientation; |
Kerpower | 0:1102d253f057 | 219 | char max_col; |
Kerpower | 0:1102d253f057 | 220 | char max_row; |
Kerpower | 0:1102d253f057 | 221 | |
Kerpower | 0:1102d253f057 | 222 | protected : |
Kerpower | 0:1102d253f057 | 223 | |
Kerpower | 0:1102d253f057 | 224 | Serial _cmd; |
Kerpower | 0:1102d253f057 | 225 | DigitalOut _rst; |
Kerpower | 0:1102d253f057 | 226 | |
Kerpower | 0:1102d253f057 | 227 | void freeBUFFER (void); |
Kerpower | 0:1102d253f057 | 228 | void writeBYTE (char); |
Kerpower | 0:1102d253f057 | 229 | int writeCOMMAND(char *, int); |
Kerpower | 0:1102d253f057 | 230 | int readVERSION (char *, int); |
Kerpower | 0:1102d253f057 | 231 | void getTOUCH (char *, int, int *,int *); |
Kerpower | 0:1102d253f057 | 232 | int getSTATUS (char *, int); |
Kerpower | 0:1102d253f057 | 233 | void version (void); |
Kerpower | 0:1102d253f057 | 234 | }; |
Kerpower | 0:1102d253f057 | 235 | |
Kerpower | 0:1102d253f057 | 236 | typedef unsigned char BYTE; |