Claes Ekengren / Mbed 2 deprecated Measurement_system

Dependencies:   mbed

Committer:
CE
Date:
Thu Jan 06 19:01:44 2011 +0000
Revision:
0:0732b16d9a92
R1A

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CE 0:0732b16d9a92 1 //
CE 0:0732b16d9a92 2 // TFT_4DGL is a class to drive 4D Systems TFT touch screens
CE 0:0732b16d9a92 3 //
CE 0:0732b16d9a92 4 // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr>
CE 0:0732b16d9a92 5 //
CE 0:0732b16d9a92 6 // TFT_4DGL is free software: you can redistribute it and/or modify
CE 0:0732b16d9a92 7 // it under the terms of the GNU General Public License as published by
CE 0:0732b16d9a92 8 // the Free Software Foundation, either version 3 of the License, or
CE 0:0732b16d9a92 9 // (at your option) any later version.
CE 0:0732b16d9a92 10 //
CE 0:0732b16d9a92 11 // TFT_4DGL is distributed in the hope that it will be useful,
CE 0:0732b16d9a92 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
CE 0:0732b16d9a92 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
CE 0:0732b16d9a92 14 // GNU General Public License for more details.
CE 0:0732b16d9a92 15 //
CE 0:0732b16d9a92 16 // You should have received a copy of the GNU General Public License
CE 0:0732b16d9a92 17 // along with TFT_4DGL. If not, see <http://www.gnu.org/licenses/>.
CE 0:0732b16d9a92 18
CE 0:0732b16d9a92 19 #include "mbed.h"
CE 0:0732b16d9a92 20
CE 0:0732b16d9a92 21 #ifndef DEBUGMODE
CE 0:0732b16d9a92 22 //#define DEBUGMODE 1
CE 0:0732b16d9a92 23 #endif
CE 0:0732b16d9a92 24
CE 0:0732b16d9a92 25 // Common WAIT value in millisecond
CE 0:0732b16d9a92 26 #define TEMPO 1
CE 0:0732b16d9a92 27
CE 0:0732b16d9a92 28 // 4DGL Functions values
CE 0:0732b16d9a92 29 #define AUTOBAUD '\x55'
CE 0:0732b16d9a92 30 #define CLS '\x45'
CE 0:0732b16d9a92 31 #define BAUDRATE '\x51'
CE 0:0732b16d9a92 32 #define VERSION '\x56'
CE 0:0732b16d9a92 33 #define BCKGDCOLOR '\x42'
CE 0:0732b16d9a92 34 #define DISPCONTROL '\x59'
CE 0:0732b16d9a92 35 #define SETVOLUME '\x76'
CE 0:0732b16d9a92 36 #define CIRCLE '\x43'
CE 0:0732b16d9a92 37 #define TRIANGLE '\x47'
CE 0:0732b16d9a92 38 #define LINE '\x4C'
CE 0:0732b16d9a92 39 #define RECTANGLE '\x72'
CE 0:0732b16d9a92 40 #define ELLIPSE '\x65'
CE 0:0732b16d9a92 41 #define PIXEL '\x50'
CE 0:0732b16d9a92 42 #define READPIXEL '\x52'
CE 0:0732b16d9a92 43 #define SCREENCOPY '\x63'
CE 0:0732b16d9a92 44 #define PENSIZE '\x70'
CE 0:0732b16d9a92 45 #define SETFONT '\x46'
CE 0:0732b16d9a92 46 #define TEXTMODE '\x4F'
CE 0:0732b16d9a92 47 #define TEXTCHAR '\x54'
CE 0:0732b16d9a92 48 #define GRAPHCHAR '\x74'
CE 0:0732b16d9a92 49 #define TEXTSTRING '\x73'
CE 0:0732b16d9a92 50 #define GRAPHSTRING '\x53'
CE 0:0732b16d9a92 51 #define TEXTBUTTON '\x62'
CE 0:0732b16d9a92 52 #define GETTOUCH '\x6F'
CE 0:0732b16d9a92 53 #define WAITTOUCH '\x77'
CE 0:0732b16d9a92 54 #define SETTOUCH '\x75'
CE 0:0732b16d9a92 55
CE 0:0732b16d9a92 56
CE 0:0732b16d9a92 57 // Screen answers
CE 0:0732b16d9a92 58 #define ACK '\x06'
CE 0:0732b16d9a92 59 #define NAK '\x15'
CE 0:0732b16d9a92 60
CE 0:0732b16d9a92 61 // Screen states
CE 0:0732b16d9a92 62 #define OFF '\x00'
CE 0:0732b16d9a92 63 #define ON '\x01'
CE 0:0732b16d9a92 64
CE 0:0732b16d9a92 65 // Graphics modes
CE 0:0732b16d9a92 66 #define SOLID '\x00'
CE 0:0732b16d9a92 67 #define WIREFRAME '\x01'
CE 0:0732b16d9a92 68
CE 0:0732b16d9a92 69 // Text modes
CE 0:0732b16d9a92 70 #define TRANSPARENT '\x00'
CE 0:0732b16d9a92 71 #define OPAQUE '\x01'
CE 0:0732b16d9a92 72
CE 0:0732b16d9a92 73 // Fonts Sizes
CE 0:0732b16d9a92 74 #define FONT_5X7 '\x00'
CE 0:0732b16d9a92 75 #define FONT_8X8 '\x01'
CE 0:0732b16d9a92 76 #define FONT_8X12 '\x02'
CE 0:0732b16d9a92 77 #define FONT_12X16 '\x03'
CE 0:0732b16d9a92 78
CE 0:0732b16d9a92 79 // Touch Values
CE 0:0732b16d9a92 80 #define WAIT '\x00'
CE 0:0732b16d9a92 81 #define PRESS '\x01'
CE 0:0732b16d9a92 82 #define RELEASE '\x02'
CE 0:0732b16d9a92 83 #define MOVE '\x03'
CE 0:0732b16d9a92 84 #define STATUS '\x04'
CE 0:0732b16d9a92 85 #define GETPOSITION '\x05'
CE 0:0732b16d9a92 86
CE 0:0732b16d9a92 87 // Data speed
CE 0:0732b16d9a92 88 #define BAUD_110 '\x00'
CE 0:0732b16d9a92 89 #define BAUD_300 '\x01'
CE 0:0732b16d9a92 90 #define BAUD_600 '\x02'
CE 0:0732b16d9a92 91 #define BAUD_1200 '\x03'
CE 0:0732b16d9a92 92 #define BAUD_2400 '\x04'
CE 0:0732b16d9a92 93 #define BAUD_4800 '\x05'
CE 0:0732b16d9a92 94 #define BAUD_9600 '\x06'
CE 0:0732b16d9a92 95 #define BAUD_14400 '\x07'
CE 0:0732b16d9a92 96 #define BAUD_19200 '\x09'
CE 0:0732b16d9a92 97 #define BAUD_31250 '\x09'
CE 0:0732b16d9a92 98 #define BAUD_38400 '\x0A'
CE 0:0732b16d9a92 99 #define BAUD_56000 '\x0B'
CE 0:0732b16d9a92 100 #define BAUD_57600 '\x0C'
CE 0:0732b16d9a92 101 #define BAUD_115200 '\x0D'
CE 0:0732b16d9a92 102 #define BAUD_128000 '\x0E'
CE 0:0732b16d9a92 103 #define BAUD_256000 '\x0F'
CE 0:0732b16d9a92 104
CE 0:0732b16d9a92 105 // Defined Colors
CE 0:0732b16d9a92 106 #define WHITE 0xFFFFFF
CE 0:0732b16d9a92 107 #define BLACK 0x000000
CE 0:0732b16d9a92 108 //#define RED 0xFF0000
CE 0:0732b16d9a92 109 #define GREEN 0x00FF00
CE 0:0732b16d9a92 110 //#define BLUE 0x0000FF
CE 0:0732b16d9a92 111 #define LGREY 0xBFBFBF
CE 0:0732b16d9a92 112 #define DGREY 0x5F5F5F
CE 0:0732b16d9a92 113
CE 0:0732b16d9a92 114 #define BLACK 0x000000 // Black 1
CE 0:0732b16d9a92 115 #define CYAN 0x00ffff // Cyan 2
CE 0:0732b16d9a92 116 #define RED 0xff0000 // Red 3
CE 0:0732b16d9a92 117 #define DGREEN 0x00923f // Dark green 4
CE 0:0732b16d9a92 118 #define ORANGE 0xffb400 // Orange 5
CE 0:0732b16d9a92 119 #define GREY 0x969696 // Grey 6
CE 0:0732b16d9a92 120 #define PINK 0xeea8a8 // Pink 7
CE 0:0732b16d9a92 121 #define BROWN 0x996633 // Brown 8
CE 0:0732b16d9a92 122 #define LGREEN 0x80ff80 // Light green 9
CE 0:0732b16d9a92 123 #define BLUE 0x0000ff // Blue 10
CE 0:0732b16d9a92 124 #define MAGENTA 0xff00ff // Magenta 11
CE 0:0732b16d9a92 125 #define YELLOW 0xdddd00 // Yellow 12
CE 0:0732b16d9a92 126
CE 0:0732b16d9a92 127 // Mode data
CE 0:0732b16d9a92 128 #define BACKLIGHT '\x00'
CE 0:0732b16d9a92 129 #define DISPLAY '\x01'
CE 0:0732b16d9a92 130 #define CONTRAST '\x02'
CE 0:0732b16d9a92 131 #define POWER '\x03'
CE 0:0732b16d9a92 132 #define ORIENTATION '\x04'
CE 0:0732b16d9a92 133 #define TOUCH_CTRL '\x05'
CE 0:0732b16d9a92 134 #define IMAGE_FORMAT '\x06'
CE 0:0732b16d9a92 135 #define PROTECT_FAT '\x08'
CE 0:0732b16d9a92 136
CE 0:0732b16d9a92 137 // change this to your specific screen (newer versions) if needed
CE 0:0732b16d9a92 138 // Startup orientation is PORTRAIT so SIZE_X must be lesser than SIZE_Y
CE 0:0732b16d9a92 139 #define SIZE_X 240
CE 0:0732b16d9a92 140 #define SIZE_Y 320
CE 0:0732b16d9a92 141
CE 0:0732b16d9a92 142 #define IS_LANDSCAPE 0
CE 0:0732b16d9a92 143 #define IS_PORTRAIT 1
CE 0:0732b16d9a92 144
CE 0:0732b16d9a92 145 // Screen orientation
CE 0:0732b16d9a92 146 #define LANDSCAPE '\x01'
CE 0:0732b16d9a92 147 #define LANDSCAPE_R '\x02'
CE 0:0732b16d9a92 148 #define PORTRAIT '\x03'
CE 0:0732b16d9a92 149 #define PORTRAIT_R '\x04'
CE 0:0732b16d9a92 150
CE 0:0732b16d9a92 151 // Parameters
CE 0:0732b16d9a92 152 #define ENABLE '\x00'
CE 0:0732b16d9a92 153 #define DISABLE '\x01'
CE 0:0732b16d9a92 154 #define RESET '\x02'
CE 0:0732b16d9a92 155
CE 0:0732b16d9a92 156 #define NEW '\x00'
CE 0:0732b16d9a92 157 #define OLD '\x01'
CE 0:0732b16d9a92 158
CE 0:0732b16d9a92 159 #define DOWN '\x00'
CE 0:0732b16d9a92 160 #define UP '\x01'
CE 0:0732b16d9a92 161
CE 0:0732b16d9a92 162 #define PROTECT '\x00'
CE 0:0732b16d9a92 163 #define UNPROTECT '\x02'
CE 0:0732b16d9a92 164
CE 0:0732b16d9a92 165 //**************************************************************************
CE 0:0732b16d9a92 166 class TFT_4DGL {
CE 0:0732b16d9a92 167
CE 0:0732b16d9a92 168 public :
CE 0:0732b16d9a92 169
CE 0:0732b16d9a92 170 TFT_4DGL(PinName tx, PinName rx, PinName rst);
CE 0:0732b16d9a92 171
CE 0:0732b16d9a92 172 // General Commands
CE 0:0732b16d9a92 173 void cls();
CE 0:0732b16d9a92 174 void reset();
CE 0:0732b16d9a92 175 void autobaud();
CE 0:0732b16d9a92 176 void baudrate(long);
CE 0:0732b16d9a92 177 void background_color(int);
CE 0:0732b16d9a92 178 void display_control(char, char);
CE 0:0732b16d9a92 179 void set_volume(char);
CE 0:0732b16d9a92 180
CE 0:0732b16d9a92 181 // Graphics Commands
CE 0:0732b16d9a92 182 void circle(int, int, int, int);
CE 0:0732b16d9a92 183 void triangle(int, int, int, int, int, int, int);
CE 0:0732b16d9a92 184 void line(int, int, int, int, int);
CE 0:0732b16d9a92 185 void rectangle(int, int, int, int, int);
CE 0:0732b16d9a92 186 void ellipse(int, int, int, int, int);
CE 0:0732b16d9a92 187 void pixel(int, int, int);
CE 0:0732b16d9a92 188 int read_pixel(int, int);
CE 0:0732b16d9a92 189 void screen_copy(int, int, int, int, int, int);
CE 0:0732b16d9a92 190 void pen_size(char);
CE 0:0732b16d9a92 191 void SD_Card_Wav(char[]);
CE 0:0732b16d9a92 192 void Set_Volume(char);
CE 0:0732b16d9a92 193 void uSD_FAT_Image(char[], int, int, long);
CE 0:0732b16d9a92 194 void uSD_Image(int, int, long);
CE 0:0732b16d9a92 195 void uSD_Video(int, int, long);
CE 0:0732b16d9a92 196
CE 0:0732b16d9a92 197 // Texts Commands
CE 0:0732b16d9a92 198 void set_font(char);
CE 0:0732b16d9a92 199 void text_mode(char);
CE 0:0732b16d9a92 200 void text_char(char, char, char, int);
CE 0:0732b16d9a92 201 void graphic_char(char, int, int, int, char, char);
CE 0:0732b16d9a92 202 void text_string(char *, char, char, char, int);
CE 0:0732b16d9a92 203 void graphic_string(char *, int, int, char, int, char, char);
CE 0:0732b16d9a92 204 void text_button(char *, char, int, int, int, char, int, char, char);
CE 0:0732b16d9a92 205
CE 0:0732b16d9a92 206 void locate(char, char);
CE 0:0732b16d9a92 207 void color(int);
CE 0:0732b16d9a92 208 void putc(char);
CE 0:0732b16d9a92 209 void puts(char *);
CE 0:0732b16d9a92 210
CE 0:0732b16d9a92 211 // Touch Command
CE 0:0732b16d9a92 212 void touch_mode(char);
CE 0:0732b16d9a92 213 void get_touch(int *, int *);
CE 0:0732b16d9a92 214 void wait_touch(int);
CE 0:0732b16d9a92 215 void set_touch(int, int, int, int);
CE 0:0732b16d9a92 216 int touch_status(void);
CE 0:0732b16d9a92 217 void Pause_Until_Touch(int *, int *);
CE 0:0732b16d9a92 218
CE 0:0732b16d9a92 219 // Screen Data
CE 0:0732b16d9a92 220 int type;
CE 0:0732b16d9a92 221 int revision;
CE 0:0732b16d9a92 222 int firmware;
CE 0:0732b16d9a92 223 int reserved1;
CE 0:0732b16d9a92 224 int reserved2;
CE 0:0732b16d9a92 225
CE 0:0732b16d9a92 226 // Text data
CE 0:0732b16d9a92 227 char current_col;
CE 0:0732b16d9a92 228 char current_row;
CE 0:0732b16d9a92 229 int current_color;
CE 0:0732b16d9a92 230 char current_font;
CE 0:0732b16d9a92 231 char current_orientation;
CE 0:0732b16d9a92 232 char max_col;
CE 0:0732b16d9a92 233 char max_row;
CE 0:0732b16d9a92 234
CE 0:0732b16d9a92 235 protected :
CE 0:0732b16d9a92 236
CE 0:0732b16d9a92 237 Serial _cmd;
CE 0:0732b16d9a92 238 DigitalOut _rst;
CE 0:0732b16d9a92 239
CE 0:0732b16d9a92 240 void freeBUFFER (void);
CE 0:0732b16d9a92 241 void writeBYTE (char);
CE 0:0732b16d9a92 242 int writeCOMMAND(char *, int);
CE 0:0732b16d9a92 243 int readVERSION (char *, int);
CE 0:0732b16d9a92 244 void getTOUCH (char *, int, int *,int *);
CE 0:0732b16d9a92 245 int getSTATUS (char *, int);
CE 0:0732b16d9a92 246 void version (void);
CE 0:0732b16d9a92 247 };
CE 0:0732b16d9a92 248
CE 0:0732b16d9a92 249 typedef unsigned char BYTE;