Anuj Patel
/
uVGAII_with_printf
Wrappper for VGAII demo by Jim Hamblem that includes a printf function that can print infinitely.
Embed:
(wiki syntax)
Show/hide line numbers
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 // 00006 // TFT_4DGL is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation, either version 3 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // TFT_4DGL is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with TFT_4DGL. If not, see <http://www.gnu.org/licenses/>. 00018 00019 // @author Stephane Rochon 00020 00021 #include "mbed.h" 00022 #include <stdarg.h> 00023 #include <stdio.h> 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 Example: 00161 * @code 00162 * // Display a white circle on the screen 00163 * #include "mbed.h" 00164 * #include " TFT_4DGL.h" 00165 * 00166 * TFT_4GDL myLCD(p9,p10,p11); 00167 * 00168 * int main() { 00169 * myLCD.circle(120, 160, 80, WHITE); 00170 * } 00171 * @endcode 00172 */ 00173 00174 class TFT_4DGL { 00175 00176 public : 00177 00178 TFT_4DGL(PinName tx, PinName rx, PinName rst); 00179 00180 // General Commands ******************************************************************************* 00181 00182 /** Clear the entire screen using the current background colour */ 00183 void cls(); 00184 00185 /** Reset screen */ 00186 void reset(); 00187 00188 /** Launch Autobaud for serial communication. This function is automatically called at startup */ 00189 void autobaud(); 00190 /** Set serial Baud rate (both sides : screen and mbed) 00191 * @param Speed Correct BAUD value (see TFT_4DGL.h) 00192 */ 00193 void baudrate(int speed); 00194 00195 /** Set background colour to the specified value 00196 * @param color in HEX RGB like 0xFF00FF 00197 */ 00198 void background_color(int color); 00199 00200 /** Set screen display mode to specific values 00201 * @param mode See 4DGL documentation 00202 * @param value See 4DGL documentation 00203 */ 00204 void display_control(char mode, char value); 00205 00206 /** Set internal speaker to specified value 00207 * @param value Correct range is 8 - 127 00208 */ 00209 void set_volume(char value); 00210 00211 // Graphics Commands ******************************************************************************* 00212 00213 /** Draw a circle centered at x,y with a radius and a colour. It uses Pen Size stored value to draw a solid or wireframe circle 00214 * @param x Horizontal position of the circle centre 00215 * @param y Vertical position of the circle centre 00216 * @param radius Radius of the circle 00217 * @param color Circle color in HEX RGB like 0xFF00FF 00218 */ 00219 void circle(int x , int y , int radius, int color); 00220 00221 void triangle(int, int, int, int, int, int, int); 00222 void line(int, int, int, int, int); 00223 void rectangle(int, int, int, int, int); 00224 void ellipse(int, int, int, int, int); 00225 void pixel(int, int, int); 00226 int read_pixel(int, int); 00227 void screen_copy(int, int, int, int, int, int); 00228 void pen_size(char); 00229 00230 // Texts Commands 00231 void set_font(char); 00232 void text_mode(char); 00233 void text_char(char, char, char, int); 00234 void graphic_char(char, int, int, int, char, char); 00235 void text_string(char *, char, char, char, int); 00236 void graphic_string(char *, int, int, char, int, char, char); 00237 void text_button(char *, char, int, int, int, char, int, char, char); 00238 00239 00240 void locate(char, char); 00241 void color(int); 00242 void putc(char); 00243 void puts(char *); 00244 00245 // Touch Command 00246 void touch_mode(char); 00247 void get_touch(int *, int *); 00248 void wait_touch(int); 00249 void set_touch(int, int, int, int); 00250 int touch_status(void); 00251 00252 // Screen Data 00253 int type; 00254 int revision; 00255 int firmware; 00256 int reserved1; 00257 int reserved2; 00258 00259 // Text data 00260 char current_col; 00261 char current_row; 00262 int current_color; 00263 char current_font; 00264 char current_orientation; 00265 char max_col; 00266 char max_row; 00267 00268 protected : 00269 00270 Serial _cmd; 00271 DigitalOut _rst; 00272 00273 void freeBUFFER (void); 00274 void writeBYTE (char); 00275 int writeCOMMAND(char *, int); 00276 int readVERSION (char *, int); 00277 void getTOUCH (char *, int, int *,int *); 00278 int getSTATUS (char *, int); 00279 void version (void); 00280 #if DEBUGMODE 00281 Serial pc; 00282 #endif // DEBUGMODE 00283 }; 00284 00285 typedef unsigned char BYTE;
Generated on Fri Jul 15 2022 06:03:34 by 1.7.2