Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
TFT_4DGL.h
00001 // 00002 // TFT_4DGL is a class to drive 4D Systems TFT touch screens 00003 // 00004 // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr> 00005 // modified at drawImage() by Kazushi Mukaiyama <i@kazushi.info> 00006 // 00007 // TFT_4DGL is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // TFT_4DGL is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with TFT_4DGL. If not, see <http://www.gnu.org/licenses/>. 00019 00020 // @author Stephane Rochon 00021 00022 #include "mbed.h" 00023 00024 // Debug Verbose on terminal enabled 00025 #ifndef DEBUGMODE 00026 #define DEBUGMODE 1 00027 #endif 00028 00029 // Common WAIT value in millisecond 00030 #define TEMPO 5 00031 00032 // 4DGL Functions values 00033 #define AUTOBAUD '\x55' 00034 #define CLS '\x45' 00035 #define BAUDRATE '\x51' 00036 #define VERSION '\x56' 00037 #define BCKGDCOLOR '\x42' 00038 #define DISPCONTROL '\x59' 00039 #define SETVOLUME '\x76' 00040 #define CIRCLE '\x43' 00041 #define TRIANGLE '\x47' 00042 #define LINE '\x4C' 00043 #define RECTANGLE '\x72' 00044 #define ELLIPSE '\x65' 00045 #define PIXEL '\x50' 00046 #define READPIXEL '\x52' 00047 #define SCREENCOPY '\x63' 00048 #define PENSIZE '\x70' 00049 #define SETFONT '\x46' 00050 #define TEXTMODE '\x4F' 00051 #define TEXTCHAR '\x54' 00052 #define GRAPHCHAR '\x74' 00053 #define TEXTSTRING '\x73' 00054 #define GRAPHSTRING '\x53' 00055 #define TEXTBUTTON '\x62' 00056 #define GETTOUCH '\x6F' 00057 #define WAITTOUCH '\x77' 00058 #define SETTOUCH '\x75' 00059 00060 00061 // Screen answers 00062 #define ACK '\x06' 00063 #define NAK '\x15' 00064 00065 // Screen states 00066 #define OFF '\x00' 00067 #define ON '\x01' 00068 00069 // Graphics modes 00070 #define SOLID '\x00' 00071 #define WIREFRAME '\x01' 00072 00073 // Text modes 00074 #define TRANSPARENT '\x00' 00075 #define OPAQUE '\x01' 00076 00077 // Fonts Sizes 00078 #define FONT_5X7 '\x00' 00079 #define FONT_8X8 '\x01' 00080 #define FONT_8X12 '\x02' 00081 #define FONT_12X16 '\x03' 00082 00083 // Touch Values 00084 #define WAIT '\x00' 00085 #define PRESS '\x01' 00086 #define RELEASE '\x02' 00087 #define MOVE '\x03' 00088 #define STATUS '\x04' 00089 #define GETPOSITION '\x05' 00090 00091 // Data speed 00092 #define BAUD_110 '\x00' 00093 #define BAUD_300 '\x01' 00094 #define BAUD_600 '\x02' 00095 #define BAUD_1200 '\x03' 00096 #define BAUD_2400 '\x04' 00097 #define BAUD_4800 '\x05' 00098 #define BAUD_9600 '\x06' 00099 #define BAUD_14400 '\x07' 00100 #define BAUD_19200 '\x09' 00101 #define BAUD_31250 '\x09' 00102 #define BAUD_38400 '\x0A' 00103 #define BAUD_56000 '\x0B' 00104 #define BAUD_57600 '\x0C' 00105 #define BAUD_115200 '\x0D' 00106 #define BAUD_128000 '\x0E' 00107 #define BAUD_256000 '\x0F' 00108 00109 // Defined Colors 00110 #define WHITE 0xFFFFFF 00111 #define BLACK 0x000000 00112 #define RED 0xFF0000 00113 #define GREEN 0x00FF00 00114 #define BLUE 0x0000FF 00115 #define LGREY 0xBFBFBF 00116 #define DGREY 0x5F5F5F 00117 00118 // Mode data 00119 #define BACKLIGHT '\x00' 00120 #define DISPLAY '\x01' 00121 #define CONTRAST '\x02' 00122 #define POWER '\x03' 00123 #define ORIENTATION '\x04' 00124 #define TOUCH_CTRL '\x05' 00125 #define IMAGE_FORMAT '\x06' 00126 #define PROTECT_FAT '\x08' 00127 00128 // change this to your specific screen (newer versions) if needed 00129 // Startup orientation is PORTRAIT so SIZE_X must be lesser than SIZE_Y 00130 #define SIZE_X 240 00131 #define SIZE_Y 320 00132 00133 #define IS_LANDSCAPE 0 00134 #define IS_PORTRAIT 1 00135 00136 // Screen orientation 00137 #define LANDSCAPE '\x01' 00138 #define LANDSCAPE_R '\x02' 00139 #define PORTRAIT '\x03' 00140 #define PORTRAIT_R '\x04' 00141 00142 // Parameters 00143 #define ENABLE '\x00' 00144 #define DISABLE '\x01' 00145 #define RESET '\x02' 00146 00147 #define NEW '\x00' 00148 #define OLD '\x01' 00149 00150 #define DOWN '\x00' 00151 #define UP '\x01' 00152 00153 #define PROTECT '\x00' 00154 #define UNPROTECT '\x02' 00155 00156 //************************************************************************** 00157 // \class TFT_4DGL TFT_4DGL.h 00158 // \brief This is the main class. It shoud be used like this : TFT_4GDL myLCD(p9,p10,p11); 00159 00160 class TFT_4DGL { 00161 00162 public : 00163 00164 TFT_4DGL(PinName tx, PinName rx, PinName rst); 00165 00166 // General Commands 00167 void cls(); 00168 void reset(); 00169 void autobaud(); 00170 void baudrate(int); 00171 void background_color(int); 00172 void display_control(char, char); 00173 void set_volume(char); 00174 00175 // Graphics Commands 00176 void circle(int, int, int, int); 00177 void triangle(int, int, int, int, int, int, int); 00178 void line(int, int, int, int, int); 00179 void rectangle(int, int, int, int, int); 00180 void ellipse(int, int, int, int, int); 00181 void pixel(int, int, int); 00182 int read_pixel(int, int); 00183 void screen_copy(int, int, int, int, int, int); 00184 void pen_size(char); 00185 void displayImage(char x, char y, char w, char h, int ad); 00186 void displayMovie(char x, char y, char w, char h, int ad, int frames); 00187 00188 // Texts Commands 00189 void set_font(char); 00190 void text_mode(char); 00191 void text_char(char, char, char, int); 00192 void graphic_char(char, int, int, int, char, char); 00193 void text_string(char *, char, char, char, int); 00194 void graphic_string(char *, int, int, char, int, char, char); 00195 void text_button(char *, char, int, int, int, char, int, char, char); 00196 00197 void locate(char, char); 00198 void color(int); 00199 void putc(char); 00200 void puts(char *); 00201 00202 // Touch Command 00203 void touch_mode(char); 00204 void get_touch(int *, int *); 00205 void wait_touch(int); 00206 void set_touch(int, int, int, int); 00207 int touch_status(void); 00208 00209 // Screen Data 00210 int type; 00211 int revision; 00212 int firmware; 00213 int reserved1; 00214 int reserved2; 00215 00216 // Text data 00217 char current_col; 00218 char current_row; 00219 int current_color; 00220 char current_font; 00221 char current_orientation; 00222 char max_col; 00223 char max_row; 00224 00225 protected : 00226 00227 Serial _cmd; 00228 DigitalOut _rst; 00229 00230 void freeBUFFER (void); 00231 void writeBYTE (char); 00232 int writeCOMMAND(char *, int); 00233 int readVERSION (char *, int); 00234 void getTOUCH (char *, int, int *,int *); 00235 int getSTATUS (char *, int); 00236 void version (void); 00237 }; 00238 00239 typedef unsigned char BYTE;
Generated on Tue Jul 12 2022 21:45:01 by
1.7.2