Lorenz limit cycle - 2D nonlinear attractor

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TFT_4DGL.h Source File

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 #include "mbed.h"
00020 
00021 #ifndef DEBUGMODE
00022 //#define DEBUGMODE 1
00023 #endif
00024 
00025 // Common WAIT value in millisecond
00026 #define TEMPO 1
00027 
00028 // 4DGL Functions values
00029 #define AUTOBAUD     '\x55'
00030 #define CLS          '\x45'
00031 #define BAUDRATE     '\x51'
00032 #define VERSION      '\x56'
00033 #define BCKGDCOLOR   '\x42'
00034 #define DISPCONTROL  '\x59'
00035 #define SETVOLUME    '\x76'
00036 #define CIRCLE       '\x43'
00037 #define TRIANGLE     '\x47'
00038 #define LINE         '\x4C'
00039 #define RECTANGLE    '\x72'
00040 #define ELLIPSE      '\x65'
00041 #define PIXEL        '\x50'
00042 #define READPIXEL    '\x52'
00043 #define SCREENCOPY   '\x63'
00044 #define PENSIZE      '\x70'
00045 #define SETFONT      '\x46'
00046 #define TEXTMODE     '\x4F'
00047 #define TEXTCHAR     '\x54'
00048 #define GRAPHCHAR    '\x74'
00049 #define TEXTSTRING   '\x73'
00050 #define GRAPHSTRING  '\x53'
00051 #define TEXTBUTTON   '\x62'
00052 #define GETTOUCH     '\x6F'
00053 #define WAITTOUCH    '\x77'
00054 #define SETTOUCH     '\x75'
00055 
00056 
00057 // Screen answers
00058 #define ACK          '\x06'
00059 #define NAK          '\x15'
00060 
00061 // Screen states
00062 #define OFF          '\x00'
00063 #define ON           '\x01'
00064 
00065 // Graphics modes
00066 #define SOLID        '\x00'
00067 #define WIREFRAME    '\x01'
00068 
00069 // Text modes
00070 #define TRANSPARENT  '\x00'
00071 #define OPAQUE       '\x01'
00072 
00073 // Fonts Sizes
00074 #define FONT_5X7     '\x00'
00075 #define FONT_8X8     '\x01'
00076 #define FONT_8X12    '\x02'
00077 #define FONT_12X16   '\x03'
00078 
00079 // Touch Values
00080 #define WAIT         '\x00'
00081 #define PRESS        '\x01'
00082 #define RELEASE      '\x02'
00083 #define MOVE         '\x03'
00084 #define STATUS       '\x04'
00085 #define GETPOSITION  '\x05'
00086 
00087 // Data speed
00088 #define BAUD_110     '\x00'
00089 #define BAUD_300     '\x01'
00090 #define BAUD_600     '\x02'
00091 #define BAUD_1200    '\x03'
00092 #define BAUD_2400    '\x04'
00093 #define BAUD_4800    '\x05'
00094 #define BAUD_9600    '\x06'
00095 #define BAUD_14400   '\x07'
00096 #define BAUD_19200   '\x09'
00097 #define BAUD_31250   '\x09'
00098 #define BAUD_38400   '\x0A'
00099 #define BAUD_56000   '\x0B'
00100 #define BAUD_57600   '\x0C'
00101 #define BAUD_115200  '\x0D'
00102 #define BAUD_128000  '\x0E'
00103 #define BAUD_256000  '\x0F'
00104 
00105 // Defined Colors
00106 #define WHITE 0xFFFFFF
00107 #define BLACK 0x000000
00108 //#define RED   0xFF0000
00109 #define GREEN 0x00FF00
00110 //#define BLUE  0x0000FF
00111 #define LGREY 0xBFBFBF
00112 #define DGREY 0x5F5F5F
00113 
00114 #define BLACK   0x000000 // Black        1
00115 #define CYAN    0x00ffff // Cyan         2
00116 #define RED     0xff0000 // Red          3
00117 #define DGREEN  0x00923f // Dark green   4
00118 #define ORANGE  0xffb400 // Orange       5
00119 #define GREY    0x969696 // Grey         6
00120 #define PINK    0xeea8a8 // Pink         7
00121 #define BROWN   0x996633 // Brown        8
00122 #define LGREEN  0x80ff80 // Light green  9
00123 #define BLUE    0x0000ff // Blue         10
00124 #define MAGENTA 0xff00ff // Magenta      11
00125 #define YELLOW  0xdddd00 // Yellow       12
00126 
00127 // Mode data
00128 #define BACKLIGHT    '\x00'
00129 #define DISPLAY      '\x01'
00130 #define CONTRAST     '\x02'
00131 #define POWER        '\x03'
00132 #define ORIENTATION  '\x04'
00133 #define TOUCH_CTRL   '\x05'
00134 #define IMAGE_FORMAT '\x06'
00135 #define PROTECT_FAT  '\x08'
00136 
00137 // change this to your specific screen (newer versions) if needed
00138 // Startup orientation is PORTRAIT so SIZE_X must be lesser than SIZE_Y
00139 #define SIZE_X       240
00140 #define SIZE_Y       320
00141 
00142 #define IS_LANDSCAPE 0
00143 #define IS_PORTRAIT  1
00144 
00145 // Screen orientation
00146 #define LANDSCAPE    '\x01'
00147 #define LANDSCAPE_R  '\x02'
00148 #define PORTRAIT     '\x03'
00149 #define PORTRAIT_R   '\x04'
00150 
00151 // Parameters
00152 #define ENABLE       '\x00'
00153 #define DISABLE      '\x01'
00154 #define RESET        '\x02'
00155 
00156 #define NEW          '\x00'
00157 #define OLD          '\x01'
00158 
00159 #define DOWN         '\x00'
00160 #define UP           '\x01'
00161 
00162 #define PROTECT      '\x00'
00163 #define UNPROTECT    '\x02'
00164 
00165 //**************************************************************************
00166 class TFT_4DGL {
00167 
00168 public :
00169 
00170     TFT_4DGL(PinName tx, PinName rx, PinName rst);
00171 
00172 // General Commands
00173     void cls();
00174     void reset();
00175     void autobaud();
00176     void baudrate(long);
00177     void background_color(int);
00178     void display_control(char, char);
00179     void set_volume(char);
00180 
00181 // Graphics Commands
00182     void circle(int, int, int, int);
00183     void triangle(int, int, int, int, int, int, int);
00184     void line(int, int, int, int, int);
00185     void rectangle(int, int, int, int, int);
00186     void ellipse(int, int, int, int, int);
00187     void pixel(int, int, int);
00188     int  read_pixel(int, int);
00189     void screen_copy(int, int, int, int, int, int);
00190     void pen_size(char); 
00191     void SD_Card_Wav(char[]);
00192     void Set_Volume(char);
00193     void uSD_FAT_Image(char[], int, int, long);
00194     void uSD_Image(int, int, long);
00195     void uSD_Video(int, int, long);
00196 
00197 // Texts Commands
00198     void set_font(char);
00199     void text_mode(char);
00200     void text_char(char, char, char, int);
00201     void graphic_char(char, int, int, int, char, char);
00202     void text_string(char *, char, char, char, int);
00203     void graphic_string(char *, int, int, char, int, char, char);
00204     void text_button(char *, char, int, int, int, char, int, char, char);
00205 
00206     void locate(char, char);
00207     void color(int);
00208     void putc(char);
00209     void puts(char *);
00210 
00211 // Touch Command
00212     void touch_mode(char);
00213     void get_touch(int *, int *);
00214     void wait_touch(int);
00215     void set_touch(int, int, int, int);
00216     int  touch_status(void);
00217     void Pause_Until_Touch(int *, int *);
00218 
00219 // Screen Data
00220     int type;
00221     int revision;
00222     int firmware;
00223     int reserved1;
00224     int reserved2;
00225 
00226 // Text data
00227     char current_col;
00228     char current_row;
00229     int  current_color;
00230     char current_font;
00231     char current_orientation;
00232     char max_col;
00233     char max_row;
00234 
00235 protected :
00236 
00237     Serial     _cmd;
00238     DigitalOut _rst;
00239 
00240     void freeBUFFER  (void);
00241     void writeBYTE   (char);
00242     int  writeCOMMAND(char *, int);
00243     int  readVERSION (char *, int);
00244     void getTOUCH    (char *, int, int *,int *);
00245     int  getSTATUS   (char *, int);
00246     void version     (void);
00247 };
00248 
00249 typedef unsigned char BYTE;