Kamil Ondrousek
/
Brusselator
Brusselator chemical oscillator
Diff: TFT_4DGL.h
- Revision:
- 0:7db0029f15d6
diff -r 000000000000 -r 7db0029f15d6 TFT_4DGL.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT_4DGL.h Fri Dec 31 16:54:57 2010 +0000 @@ -0,0 +1,249 @@ +// +// TFT_4DGL is a class to drive 4D Systems TFT touch screens +// +// Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr> +// +// TFT_4DGL is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// TFT_4DGL is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with TFT_4DGL. If not, see <http://www.gnu.org/licenses/>. + +#include "mbed.h" + +#ifndef DEBUGMODE +//#define DEBUGMODE 1 +#endif + +// Common WAIT value in millisecond +#define TEMPO 1 + +// 4DGL Functions values +#define AUTOBAUD '\x55' +#define CLS '\x45' +#define BAUDRATE '\x51' +#define VERSION '\x56' +#define BCKGDCOLOR '\x42' +#define DISPCONTROL '\x59' +#define SETVOLUME '\x76' +#define CIRCLE '\x43' +#define TRIANGLE '\x47' +#define LINE '\x4C' +#define RECTANGLE '\x72' +#define ELLIPSE '\x65' +#define PIXEL '\x50' +#define READPIXEL '\x52' +#define SCREENCOPY '\x63' +#define PENSIZE '\x70' +#define SETFONT '\x46' +#define TEXTMODE '\x4F' +#define TEXTCHAR '\x54' +#define GRAPHCHAR '\x74' +#define TEXTSTRING '\x73' +#define GRAPHSTRING '\x53' +#define TEXTBUTTON '\x62' +#define GETTOUCH '\x6F' +#define WAITTOUCH '\x77' +#define SETTOUCH '\x75' + + +// Screen answers +#define ACK '\x06' +#define NAK '\x15' + +// Screen states +#define OFF '\x00' +#define ON '\x01' + +// Graphics modes +#define SOLID '\x00' +#define WIREFRAME '\x01' + +// Text modes +#define TRANSPARENT '\x00' +#define OPAQUE '\x01' + +// Fonts Sizes +#define FONT_5X7 '\x00' +#define FONT_8X8 '\x01' +#define FONT_8X12 '\x02' +#define FONT_12X16 '\x03' + +// Touch Values +#define WAIT '\x00' +#define PRESS '\x01' +#define RELEASE '\x02' +#define MOVE '\x03' +#define STATUS '\x04' +#define GETPOSITION '\x05' + +// Data speed +#define BAUD_110 '\x00' +#define BAUD_300 '\x01' +#define BAUD_600 '\x02' +#define BAUD_1200 '\x03' +#define BAUD_2400 '\x04' +#define BAUD_4800 '\x05' +#define BAUD_9600 '\x06' +#define BAUD_14400 '\x07' +#define BAUD_19200 '\x09' +#define BAUD_31250 '\x09' +#define BAUD_38400 '\x0A' +#define BAUD_56000 '\x0B' +#define BAUD_57600 '\x0C' +#define BAUD_115200 '\x0D' +#define BAUD_128000 '\x0E' +#define BAUD_256000 '\x0F' + +// Defined Colors +#define WHITE 0xFFFFFF +#define BLACK 0x000000 +//#define RED 0xFF0000 +#define GREEN 0x00FF00 +//#define BLUE 0x0000FF +#define LGREY 0xBFBFBF +#define DGREY 0x5F5F5F + +#define BLACK 0x000000 // Black 1 +#define CYAN 0x00ffff // Cyan 2 +#define RED 0xff0000 // Red 3 +#define DGREEN 0x00923f // Dark green 4 +#define ORANGE 0xffb400 // Orange 5 +#define GREY 0x969696 // Grey 6 +#define PINK 0xeea8a8 // Pink 7 +#define BROWN 0x996633 // Brown 8 +#define LGREEN 0x80ff80 // Light green 9 +#define BLUE 0x0000ff // Blue 10 +#define MAGENTA 0xff00ff // Magenta 11 +#define YELLOW 0xdddd00 // Yellow 12 + +// Mode data +#define BACKLIGHT '\x00' +#define DISPLAY '\x01' +#define CONTRAST '\x02' +#define POWER '\x03' +#define ORIENTATION '\x04' +#define TOUCH_CTRL '\x05' +#define IMAGE_FORMAT '\x06' +#define PROTECT_FAT '\x08' + +// change this to your specific screen (newer versions) if needed +// Startup orientation is PORTRAIT so SIZE_X must be lesser than SIZE_Y +#define SIZE_X 240 +#define SIZE_Y 320 + +#define IS_LANDSCAPE 0 +#define IS_PORTRAIT 1 + +// Screen orientation +#define LANDSCAPE '\x01' +#define LANDSCAPE_R '\x02' +#define PORTRAIT '\x03' +#define PORTRAIT_R '\x04' + +// Parameters +#define ENABLE '\x00' +#define DISABLE '\x01' +#define RESET '\x02' + +#define NEW '\x00' +#define OLD '\x01' + +#define DOWN '\x00' +#define UP '\x01' + +#define PROTECT '\x00' +#define UNPROTECT '\x02' + +//************************************************************************** +class TFT_4DGL { + +public : + + TFT_4DGL(PinName tx, PinName rx, PinName rst); + +// General Commands + void cls(); + void reset(); + void autobaud(); + void baudrate(long); + void background_color(int); + void display_control(char, char); + void set_volume(char); + +// Graphics Commands + void circle(int, int, int, int); + void triangle(int, int, int, int, int, int, int); + void line(int, int, int, int, int); + void rectangle(int, int, int, int, int); + void ellipse(int, int, int, int, int); + void pixel(int, int, int); + int read_pixel(int, int); + void screen_copy(int, int, int, int, int, int); + void pen_size(char); + void SD_Card_Wav(char[]); + void Set_Volume(char); + void uSD_FAT_Image(char[], int, int, long); + void uSD_Image(int, int, long); + void uSD_Video(int, int, long); + +// Texts Commands + void set_font(char); + void text_mode(char); + void text_char(char, char, char, int); + void graphic_char(char, int, int, int, char, char); + void text_string(char *, char, char, char, int); + void graphic_string(char *, int, int, char, int, char, char); + void text_button(char *, char, int, int, int, char, int, char, char); + + void locate(char, char); + void color(int); + void putc(char); + void puts(char *); + +// Touch Command + void touch_mode(char); + void get_touch(int *, int *); + void wait_touch(int); + void set_touch(int, int, int, int); + int touch_status(void); + void Pause_Until_Touch(int *, int *); + +// Screen Data + int type; + int revision; + int firmware; + int reserved1; + int reserved2; + +// Text data + char current_col; + char current_row; + int current_color; + char current_font; + char current_orientation; + char max_col; + char max_row; + +protected : + + Serial _cmd; + DigitalOut _rst; + + void freeBUFFER (void); + void writeBYTE (char); + int writeCOMMAND(char *, int); + int readVERSION (char *, int); + void getTOUCH (char *, int, int *,int *); + int getSTATUS (char *, int); + void version (void); +}; + +typedef unsigned char BYTE; \ No newline at end of file