Rucklidge chaotic attractor

Files at this revision

API Documentation at this revision

Comitter:
JLS
Date:
Mon Jan 03 13:57:46 2011 +0000
Commit message:

Changed in this revision

TFT_4DGL.h Show annotated file Show diff for this revision Revisions of this file
TFT_4DGL_Graphics.cpp Show annotated file Show diff for this revision Revisions of this file
TFT_4DGL_Text.cpp Show annotated file Show diff for this revision Revisions of this file
TFT_4DGL_Touch.cpp Show annotated file Show diff for this revision Revisions of this file
TFT_4DGL_main.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 73bfbf91b6e5 TFT_4DGL.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT_4DGL.h	Mon Jan 03 13:57:46 2011 +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
diff -r 000000000000 -r 73bfbf91b6e5 TFT_4DGL_Graphics.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT_4DGL_Graphics.cpp	Mon Jan 03 13:57:46 2011 +0000
@@ -0,0 +1,400 @@
+//
+// 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"
+#include "TFT_4DGL.h"
+
+
+//****************************************************************************************************
+void TFT_4DGL :: circle(int x, int y , int radius, int color) {   // draw a circle in (x,y)
+    char command[9]= "";
+
+    command[0] = CIRCLE;
+
+    command[1] = (x >> 8) & 0xFF;
+    command[2] = x & 0xFF;
+
+    command[3] = (y >> 8) & 0xFF;
+    command[4] = y & 0xFF;
+
+    command[5] = (radius >> 8) & 0xFF;
+    command[6] = radius & 0xFF;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;              // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;              // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;              // get blue on 5 bits
+
+    command[7] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;  // first part of 16 bits color
+    command[8] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    writeCOMMAND(command, 9);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: triangle(int x1, int y1 , int x2, int y2, int x3, int y3, int color) {   // draw a traingle
+    char command[15]= "";
+
+    command[0] = TRIANGLE;
+
+    command[1] = (x1 >> 8) & 0xFF;
+    command[2] = x1 & 0xFF;
+
+    command[3] = (y1 >> 8) & 0xFF;
+    command[4] = y1 & 0xFF;
+
+    command[5] = (x2 >> 8) & 0xFF;
+    command[6] = x2 & 0xFF;
+
+    command[7] = (y2 >> 8) & 0xFF;
+    command[8] = y2 & 0xFF;
+
+    command[9] = (x3 >> 8) & 0xFF;
+    command[10] = x3 & 0xFF;
+
+    command[11] = (y3 >> 8) & 0xFF;
+    command[12] = y3 & 0xFF;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;               // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;               // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;               // get blue on 5 bits
+
+    command[13] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;  // first part of 16 bits color
+    command[14] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    writeCOMMAND(command, 15);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: line(int x1, int y1 , int x2, int y2, int color) {   // draw a line
+    char command[11]= "";
+
+    command[0] = LINE;
+
+    command[1] = (x1 >> 8) & 0xFF;
+    command[2] = x1 & 0xFF;
+
+    command[3] = (y1 >> 8) & 0xFF;
+    command[4] = y1 & 0xFF;
+
+    command[5] = (x2 >> 8) & 0xFF;
+    command[6] = x2 & 0xFF;
+
+    command[7] = (y2 >> 8) & 0xFF;
+    command[8] = y2 & 0xFF;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;               // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;               // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;               // get blue on 5 bits
+
+    command[9] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;   // first part of 16 bits color
+    command[10] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    writeCOMMAND(command, 11);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: rectangle(int x1, int y1 , int x2, int y2, int color) {   // draw a rectangle
+    char command[11]= "";
+
+    command[0] = RECTANGLE;
+
+    command[1] = (x1 >> 8) & 0xFF;
+    command[2] = x1 & 0xFF;
+
+    command[3] = (y1 >> 8) & 0xFF;
+    command[4] = y1 & 0xFF;
+
+    command[5] = (x2 >> 8) & 0xFF;
+    command[6] = x2 & 0xFF;
+
+    command[7] = (y2 >> 8) & 0xFF;
+    command[8] = y2 & 0xFF;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;               // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;               // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;               // get blue on 5 bits
+
+    command[9] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;   // first part of 16 bits color
+    command[10] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    writeCOMMAND(command, 11);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: ellipse(int x, int y , int radius_x, int radius_y, int color) {   // draw an ellipse
+    char command[11]= "";
+
+    command[0] = ELLIPSE;
+
+    command[1] = (x >> 8) & 0xFF;
+    command[2] = x & 0xFF;
+
+    command[3] = (y >> 8) & 0xFF;
+    command[4] = y & 0xFF;
+
+    command[5] = (radius_x >> 8) & 0xFF;
+    command[6] = radius_x & 0xFF;
+
+    command[7] = (radius_y >> 8) & 0xFF;
+    command[8] = radius_y & 0xFF;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;               // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;               // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;               // get blue on 5 bits
+
+    command[9] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;   // first part of 16 bits color
+    command[10] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    writeCOMMAND(command, 11);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: pixel(int x, int y, int color) {   // draw a pixel
+    char command[7]= "";
+
+    command[0] = PIXEL;
+
+    command[1] = (x >> 8) & 0xFF;
+    command[2] = x & 0xFF;
+
+    command[3] = (y >> 8) & 0xFF;
+    command[4] = y & 0xFF;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;              // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;              // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;              // get blue on 5 bits
+
+    command[5] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;  // first part of 16 bits color
+    command[6] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    writeCOMMAND(command, 7);
+}
+
+//******************************************************************************************************
+int TFT_4DGL :: read_pixel(int x, int y) { // read screen info and populate data
+
+    char command[5]= "";
+
+    command[0] = READPIXEL;
+
+    command[1] = (x >> 8) & 0xFF;
+    command[2] = x & 0xFF;
+
+    command[3] = (y >> 8) & 0xFF;
+    command[4] = y & 0xFF;
+
+    int i, temp = 0, color = 0, resp = 0;
+    char response[2] = "";
+
+    freeBUFFER();
+
+    for (i = 0; i < 5; i++) {                   // send all chars to serial port
+        writeBYTE(command[i]);
+    }
+
+    while (!_cmd.readable()) wait_ms(TEMPO);    // wait for screen answer
+
+    while (_cmd.readable()) {
+        temp = _cmd.getc();
+        response[resp++] = (char)temp;
+    }
+
+    color = ((response[0] << 8) + response[1]);
+
+    return color; // WARNING : this is 16bits color, not 24bits... need to be fixed
+}
+
+//******************************************************************************************************
+void TFT_4DGL :: screen_copy(int xs, int ys , int xd, int yd , int width, int height) {
+
+    char command[13]= "";
+
+    command[0] = SCREENCOPY;
+
+    command[1] = (xs >> 8) & 0xFF;
+    command[2] = xs & 0xFF;
+
+    command[3] = (ys >> 8) & 0xFF;
+    command[4] = ys & 0xFF;
+
+    command[5] = (xd >> 8) & 0xFF;
+    command[6] = xd & 0xFF;
+
+    command[7] = (yd >> 8) & 0xFF;
+    command[8] = yd & 0xFF;
+
+    command[9] = (width >> 8) & 0xFF;
+    command[10] = width & 0xFF;
+
+    command[11] = (height >> 8) & 0xFF;
+    command[12] = height & 0xFF;
+
+    writeCOMMAND(command, 13);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: pen_size(char mode) {   // set pen to SOLID or WIREFRAME
+    char command[2]= "";
+
+    command[0] = PENSIZE;
+    command[1] = mode;
+
+    writeCOMMAND(command, 2);
+}
+
+//****************************************************************************************************
+// This plays a .wav file from the FAT partition of an uSD Card
+// Not really recommended as the speaker on the uLCD-32PT is really bad!
+//****************************************************************************************************
+void TFT_4DGL :: SD_Card_Wav(char *Filename) {  
+    char command[21]= "";
+    int Lgt=0;
+
+    command[0] = 0x40;      //ext_cmd
+    command[1] = 0x6C;      //Play Audio
+    command[2] = 0x01;      //Option 0x00=Return at end, 0x01=Return now, 0x02=Stop, 0x03=Pause, 0x04=Resume, 0x05=Loop.        
+    for(int i=0;Filename[i]!=0x00;i++){
+        command[i+3] = Filename[i];
+        Lgt = i;
+    }    
+    command[Lgt+4] = 0x2E;      //.
+    command[Lgt+5] = 0x77;      //w
+    command[Lgt+6] = 0x61;      //a
+    command[Lgt+7] = 0x76;      //v
+    command[Lgt+8] = 0x00;      //terminator
+    
+    writeCOMMAND(command, Lgt+9);
+}
+
+//****************************************************************************************************
+// This sets the volume for the speaker on the uLCD-32PT
+//****************************************************************************************************
+void TFT_4DGL :: Set_Volume(char vol) {  
+    
+    char command[2]= "";   
+    
+    command[0] = 0x76;      //cmd
+    command[1] = vol;       //set volume
+    
+    writeCOMMAND(command, 2);
+}
+
+//****************************************************************************************************
+// This displays an image on the screen that is stored on the FAT partition of an uSD Card
+// Sent Filename, X-pos, Y-pos, Sector Address - Display from the RAW partition is quicker
+//****************************************************************************************************
+void TFT_4DGL :: uSD_FAT_Image(char *Filename, int x, int y, long s) {  
+    char X_MSB, X_LSB, Y_MSB, Y_LSB, S0, S1, S2, S3;
+    char command[25]= "";
+    int Lgt=0;
+    
+    X_LSB = x&0x00FF;
+    X_MSB = (x >> 8); 
+    Y_LSB = y&0x00FF;
+    Y_MSB = (y >> 8);
+    
+    S0 = (s >> 20)&0x000000FF;
+    S1 = (s >> 16)&0x0000FF;
+    S2 = (s >> 8)&0x0000FF; 
+    S3 = s&0x0000FF;;
+    
+    command[0] = '@';         //ext_cmd
+    command[1] = 'm';         //FAT Image    
+    for(int i=0;Filename[i]!=0x00;i++){
+        command[i+2] = Filename[i];
+        Lgt = i;
+    }  
+    command[Lgt+3] = '.';      //.
+    command[Lgt+4] = 'G';      //G
+    command[Lgt+5] = 'C';      //C
+    command[Lgt+6] = 'I';      //I
+    command[Lgt+7] = 0x00;     //Terminator
+    command[Lgt+8] = X_MSB;    //X-Position MSB
+    command[Lgt+9] = X_LSB;    //X-Position LSB
+    command[Lgt+10] = Y_MSB;   //Y-Position MSB
+    command[Lgt+11] = Y_LSB;   //Y-Position LSB
+    command[Lgt+12] = S0;      //Sector Address 4 bytes
+    command[Lgt+13] = S1;      
+    command[Lgt+14] = S2;      
+    command[Lgt+15] = S3;      
+    
+    writeCOMMAND(command, Lgt+16);
+}
+
+//****************************************************************************************************
+// This displays an image on the screen in the NEW FORMAT
+// Sent X-pos, Y-pos, Sector Address - This is the recommended way to display images
+//****************************************************************************************************
+void TFT_4DGL :: uSD_Image(int x, int y, long s) {  
+    char S1, S2, S3;
+    char X_MSB, X_LSB, Y_MSB, Y_LSB;
+    char command[9]= "";
+    
+    X_LSB = x&0x00FF;           //Work out the x position
+    X_MSB = (x >> 8); 
+    Y_LSB = y&0x00FF;           //Work out the y position
+    Y_MSB = (y >> 8);
+    
+    S1 = (s >> 16)&0x0000FF;    //Work out the sector address
+    S2 = (s >> 8)&0x0000FF; 
+    S3 = s&0x0000FF;
+
+    command[0] = 0x40;          //ext_cmd
+    command[1] = 0x49;          //Display image
+    command[2] = X_MSB;         //X position - 2 bytes    
+    command[3] = X_LSB;
+    command[4] = Y_MSB;         //Y position - 2 bytes
+    command[5] = Y_LSB;
+    command[6] = S1;            //Sector address - 3 bytes
+    command[7] = S2;
+    command[8] = S3;
+    
+    writeCOMMAND(command, 9);
+}
+
+//****************************************************************************************************
+// This displays an video on the screen in the NEW FORMAT
+// Sent X-pos, Y-pos, Sector Address - This is the recommended way to display video
+//****************************************************************************************************
+void TFT_4DGL :: uSD_Video(int x, int y, long s) {  
+    char S1, S2, S3;
+    char X_MSB, X_LSB, Y_MSB, Y_LSB;
+    char command[10]= "";
+    
+    X_LSB = x&0x00FF;
+    X_MSB = (x >> 8); 
+    Y_LSB = y&0x00FF;
+    Y_MSB = (y >> 8);
+    
+    S1 = (s >> 16)&0x0000FF;
+    S2 = (s >> 8)&0x0000FF; 
+    S3 = s&0x0000FF;
+
+    command[0] = 0x40;      //ext_cmd
+    command[1] = 0x56;      //Display video
+    command[2] = X_MSB;     //X position - 2 bytes    
+    command[3] = X_LSB;
+    command[4] = Y_MSB;     //Y position - 2 bytes
+    command[5] = Y_LSB;
+    command[6] = 0x00;      //delay between frames   
+    command[7] = S1;        //Sector address - 3 bytes
+    command[8] = S2;
+    command[9] = S3;
+    
+    writeCOMMAND(command, 10);
+}
diff -r 000000000000 -r 73bfbf91b6e5 TFT_4DGL_Text.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT_4DGL_Text.cpp	Mon Jan 03 13:57:46 2011 +0000
@@ -0,0 +1,270 @@
+//
+// 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"
+#include "TFT_4DGL.h"
+
+//****************************************************************************************************
+void TFT_4DGL :: set_font(char mode) {   // set font size
+    char command[2]= "";
+
+    int w, h, fx = 8, fy = 8;
+
+    command[0] = SETFONT;
+    command[1] = mode;
+
+    current_font = mode;
+
+    if (current_orientation == IS_PORTRAIT) {
+        w = SIZE_X;
+        h = SIZE_Y;
+    } else {
+        w = SIZE_Y;
+        h = SIZE_X;
+    }
+
+    switch (mode) {
+        case FONT_5X7 :
+            fx = 6;
+            fy = 8;
+            break;
+        case FONT_8X8 :
+            fx = 8;
+            fy = 8;
+            break;
+        case FONT_8X12 :
+            fx = 8;
+            fy = 12;
+            break;
+        case FONT_12X16 :
+            fx = 12;
+            fy = 16;
+            break;
+    }
+
+    max_col = w / fx;
+    max_row = h / fy;
+
+    writeCOMMAND(command, 2);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: text_mode(char mode) {   // set text mode
+    char command[2]= "";
+
+    command[0] = TEXTMODE;
+    command[1] = mode;
+
+    writeCOMMAND(command, 2);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: text_char(char c, char col, char row, int color) {   // draw a text char
+    char command[6]= "";
+
+    command[0] = TEXTCHAR;
+
+    command[1] = c;
+    command[2] = col;
+    command[3] = row;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;              // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;              // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;              // get blue on 5 bits
+
+    command[4] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;  // first part of 16 bits color
+    command[5] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    writeCOMMAND(command, 8);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: graphic_char(char c, int x, int y, int color, char width, char height) {   // draw a graphic char
+    char command[10]= "";
+
+    command[0] = GRAPHCHAR;
+
+    command[1] = c;
+
+    command[2] = (x >> 8) & 0xFF;
+    command[3] = x & 0xFF;
+
+    command[4] = (y >> 8) & 0xFF;
+    command[5] = y & 0xFF;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;              // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;              // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;              // get blue on 5 bits
+
+    command[6] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;  // first part of 16 bits color
+    command[7] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    command[8] = width;
+
+    command[9] = height;
+
+    writeCOMMAND(command, 10);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: text_string(char *s, char col, char row, char font, int color) {   // draw a text string
+
+    char command[1000]= "";
+    int size = strlen(s);
+    int i = 0;
+
+    command[0] = TEXTSTRING;
+
+    command[1] = col;
+    command[2] = row;
+
+    command[3] = font;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;              // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;              // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;              // get blue on 5 bits
+
+    command[4] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;  // first part of 16 bits color
+    command[5] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    for (i=0; i<size; i++) command[6+i] = s[i];
+
+    command[6+size] = 0;
+
+    writeCOMMAND(command, 7 + size);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: graphic_string(char *s, int x, int y, char font, int color, char width, char height) {   // draw a text string
+
+    char command[1000]= "";
+    int size = strlen(s);
+    int i = 0;
+
+    command[0] = GRAPHSTRING;
+
+    command[1] = (x >> 8) & 0xFF;
+    command[2] = x & 0xFF;
+
+    command[3] = (y >> 8) & 0xFF;
+    command[4] = y & 0xFF;
+
+    command[5] = font;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;              // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;              // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;              // get blue on 5 bits
+
+    command[6] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;  // first part of 16 bits color
+    command[7] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    command[8] = width;
+
+    command[9] = height;
+
+    for (i=0; i<size; i++) command[10+i] = s[i];
+
+    command[10+size] = 0;
+
+    writeCOMMAND(command, 11 + size);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: text_button(char *s, char mode, int x, int y, int button_color, char font, int text_color, char width, char height) {   // draw a text string
+
+    char command[1000]= "";
+    int size = strlen(s);
+    int i = 0, red5, green6, blue5;
+
+    command[0] = TEXTBUTTON;
+
+    command[1] = mode;
+
+    command[2] = (x >> 8) & 0xFF;
+    command[3] = x & 0xFF;
+
+    command[4] = (y >> 8) & 0xFF;
+    command[5] = y & 0xFF;
+
+    red5   = (button_color >> (16 + 3)) & 0x1F;             // get red on 5 bits
+    green6 = (button_color >> (8 + 2))  & 0x3F;             // get green on 6 bits
+    blue5  = (button_color >> (0 + 3))  & 0x1F;             // get blue on 5 bits
+
+    command[6] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;    // first part of 16 bits color
+    command[7] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;    // second part of 16 bits color
+
+    command[8] = font;
+
+    red5   = (text_color >> (16 + 3)) & 0x1F;               // get red on 5 bits
+    green6 = (text_color >> (8 + 2))  & 0x3F;               // get green on 6 bits
+    blue5  = (text_color >> (0 + 3))  & 0x1F;               // get blue on 5 bits
+
+    command[9] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;    // first part of 16 bits color
+    command[10] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;   // second part of 16 bits color
+
+    command[11] = width;
+
+    command[12] = height;
+
+    for (i=0; i<size; i++) command[13+i] = s[i];
+
+    command[13+size] = 0;
+
+    writeCOMMAND(command, 14 + size);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: locate(char col, char row) {   // place text curssor at col, row
+    current_col = col;
+    current_row = row;
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: color(int color) {   // set text color
+    current_color = color;
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: putc(char c) {   // place char at current cursor position
+
+    text_char(c, current_col++, current_row, current_color);
+
+    if (current_col == max_col) {
+        current_col = 0;
+        current_row++;
+    }
+    if (current_row == max_row) {
+        current_row = 0;
+    }
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: puts(char *s) {   // place string at current cursor position
+
+    text_string(s, current_col, current_row, current_font, current_color);
+
+    current_col += strlen(s);
+
+    if (current_col >= max_col) {
+        current_row += current_col / max_col;
+        current_col %= max_col;
+    }
+    if (current_row >= max_row) {
+        current_row %= max_row;
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 73bfbf91b6e5 TFT_4DGL_Touch.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT_4DGL_Touch.cpp	Mon Jan 03 13:57:46 2011 +0000
@@ -0,0 +1,109 @@
+//
+// 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"
+#include "TFT_4DGL.h"
+
+//******************************************************************************************************
+void TFT_4DGL :: touch_mode(char mode) { // Send touch mode (WAIT, PRESS, RELEASE or MOVE)
+
+    char command[2]= "";
+
+    command[0] = GETTOUCH;
+    command[1] = mode;
+
+    writeCOMMAND(command, 2);
+}
+
+//******************************************************************************************************
+void TFT_4DGL :: get_touch(int *x, int *y) { // Get the touch coordinates
+
+    char command[2] = "";
+    
+    command[0] = GETTOUCH;
+    command[1] = GETPOSITION;
+    
+    getTOUCH(command, 2, x, y);
+}
+
+//******************************************************************************************************
+int TFT_4DGL :: touch_status(void) { // Get the touch screen status
+
+    char command[2] = "";
+    
+    command[0] = GETTOUCH;
+    command[1] = STATUS;
+    
+    return getSTATUS(command, 2);
+}
+
+
+//******************************************************************************************************
+void TFT_4DGL :: wait_touch(int delay) { // wait until touch within a delay in milliseconds
+
+    char command[3]= "";
+
+    command[0] = WAITTOUCH;
+
+    command[1] = (delay >> 8) & 0xFF;
+    command[2] = delay & 0xFF;
+
+    writeCOMMAND(command, 3);
+}
+
+//******************************************************************************************************
+void TFT_4DGL :: set_touch(int x1, int y1 , int x2, int y2) { // define touch area
+
+    char command[9]= "";
+
+    command[0] = SETTOUCH;
+
+    command[1] = (x1 >> 8) & 0xFF;
+    command[2] = x1 & 0xFF;
+
+    command[3] = (y1 >> 8) & 0xFF;
+    command[4] = y1 & 0xFF;
+
+    command[5] = (x2 >> 8) & 0xFF;
+    command[6] = x2 & 0xFF;
+
+    command[7] = (y2 >> 8) & 0xFF;
+    command[8] = y2 & 0xFF;
+
+    writeCOMMAND(command, 9);
+}
+
+//******************************************************************************************************
+// There is no way to have the uLCD-32PT trigger an interrupt when touched. 
+// This function polls the screen and waits for a touch to regiester
+//******************************************************************************************************
+void TFT_4DGL :: Pause_Until_Touch(int *x, int *y) { // Actually waits for a TouchScreen release!
+    
+    char TouchStatus = 0;                       //Initalise the TouchStatus as 0 = no touch activity
+    char command[2] = "";
+
+    do{
+        TouchStatus = touch_status();           //Get the touchscreen status
+        wait(0.1);
+    }while (TouchStatus != 2);
+    
+    command[0] = GETTOUCH;
+    command[1] = GETPOSITION;
+    
+    getTOUCH(command, 2, x, y);
+}
\ No newline at end of file
diff -r 000000000000 -r 73bfbf91b6e5 TFT_4DGL_main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT_4DGL_main.cpp	Mon Jan 03 13:57:46 2011 +0000
@@ -0,0 +1,394 @@
+//
+// 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"
+#include "TFT_4DGL.h"
+
+Serial pc(USBTX,USBRX);
+//DigitalOut led1(LED1), led2(LED2);
+
+//******************************************************************************************************
+TFT_4DGL :: TFT_4DGL(PinName tx, PinName rx, PinName rst) : _cmd(tx, rx), _rst(rst) { // Constructor
+
+#if DEBUGMODE
+    pc.baud(115200);
+
+    pc.printf("\n\n\n");
+    pc.printf("********************\n\r");
+    pc.printf("TFT_4DGL CONSTRUCTOR\n\r");
+    pc.printf("********************\n\r");
+#endif
+
+    _rst = 1;    // put RESET pin to high to start TFT screen
+
+    reset();
+    autobaud();         // send autobaud command
+    baudrate(256000);   // set the initial baudrate to 256kbps - fastest supported by uLCD-32PT
+    cls();              // clear screen
+
+    current_col         = 0;            // initial cursor col
+    current_row         = 0;            // initial cursor row
+    current_color       = WHITE;        // initial text color
+    current_orientation = IS_PORTRAIT;  // initial screen orientation
+
+    set_font(FONT_5X7);                 // initial font
+    text_mode(TRANSPARENT);             // initial text mode
+    display_control(0x06,0x00);         // initial Image control new format
+}
+
+//******************************************************************************************************
+void TFT_4DGL :: writeBYTE(char c) { // send a BYTE command to screen
+
+    _cmd.putc(c);
+
+#if DEBUGMODE
+    pc.printf("   Char sent : 0x%02X  ",c);
+    pc.putc(c);
+    pc.printf(" \n\r");
+#endif
+
+}
+
+//******************************************************************************************************
+void TFT_4DGL :: freeBUFFER(void) {       // Clear serial buffer before writing command
+
+    while (_cmd.readable()) _cmd.getc();  // clear buffer garbage
+}
+
+//******************************************************************************************************
+int TFT_4DGL :: writeCOMMAND(char *command, int number) { // send several BYTES making a command and return an answer
+
+#if DEBUGMODE
+    pc.printf("\n\r");
+    pc.printf("New COMMAND : 0x%02X\n\r", command[0]);
+#endif
+    int i, resp = 0;
+    freeBUFFER();
+
+    for (i = 0; i < number; i++) writeBYTE(command[i]); // send command to serial port
+
+    while (!_cmd.readable()) wait_ms(TEMPO);            // wait for screen answer    
+    if (_cmd.readable()) resp = _cmd.getc();            // read response if any
+    switch (resp) {
+        case ACK :                                      // if OK return   1
+            resp =  1;
+            break;
+        case NAK :                                      // if NOK return -1
+            resp = -1;  
+            break;
+        default :
+            resp =  0;                                  // else return   0
+            break;
+    }
+#if DEBUGMODE
+    pc.printf("   Answer received : %d\n\r",resp);
+#endif
+
+    return resp;
+}
+
+//**************************************************************************
+void TFT_4DGL :: reset() {  // Reset Screen
+
+    _rst = 0;               // put RESET pin to low
+    wait_ms(TEMPO);         // wait a few milliseconds for command reception
+    _rst = 1;               // put RESET back to high
+    wait(3);                // wait 3s for screen to restart
+
+    freeBUFFER();           // clean buffer from possible garbage
+}
+
+//**************************************************************************
+void TFT_4DGL :: autobaud() { // send AutoBaud command (9600)
+    char command[1] = "";
+    command[0] = AUTOBAUD;
+    writeCOMMAND(command, 1);
+}
+
+//**************************************************************************
+void TFT_4DGL :: cls() {  // clear screen
+    char command[1] = "";
+    command[0] = CLS;
+    writeCOMMAND(command, 1);
+}
+
+//**************************************************************************
+void TFT_4DGL :: version() {  // get API version
+    char command[2] = "";
+    command[0] = VERSION;
+    command[1] = OFF;
+    readVERSION(command, 2);
+}
+
+//**************************************************************************
+void TFT_4DGL :: baudrate(long speed) {  // set screen baud rate
+    char command[2]= "";
+    command[0] = BAUDRATE;
+    switch (speed) {
+        case  110 :
+            command[1] = BAUD_110;
+            break;
+        case  300 :
+            command[1] = BAUD_300;
+            break;
+        case  600 :
+            command[1] = BAUD_600;
+            break;
+        case 1200 :
+            command[1] = BAUD_1200;
+            break;
+        case 2400 :
+            command[1] = BAUD_2400;
+            break;
+        case 4800 :
+            command[1] = BAUD_4800;
+            break;
+        case 9600 :
+            command[1] = BAUD_9600;
+            break;
+        case 14400 :
+            command[1] = BAUD_14400;
+            break;
+        case 19200 :
+            command[1] = BAUD_19200;
+            break;
+        case 31250 :
+            command[1] = BAUD_31250;
+            break;
+        case 38400 :
+            command[1] = BAUD_38400;
+            break;
+        case 56000 :
+            command[1] = BAUD_56000;
+            break;
+        case 57600 :
+            command[1] = BAUD_57600;
+            break;
+        case 115200 :
+            command[1] = BAUD_115200;
+            break;
+        case 128000 :
+            command[1] = BAUD_128000;
+            break;
+        case 256000 :
+            command[1] = BAUD_256000;
+            break;
+        default   :
+            command[1] = BAUD_9600;
+            speed = 9600;
+            break;
+    }
+    
+#if DEBUGMODE
+    pc.printf("\n\r");
+    pc.printf("New COMMAND : 0x%02X\n\r", command[0]);
+#endif
+
+    int i, resp = 0;
+    freeBUFFER();
+    
+    if(speed==256000)
+        speed=281000;       //If baud rate is 256K comm at 281k - as instructed by 4DGL
+        
+    for (i = 0; i <2; i++) writeBYTE(command[i]);      // send command to serial port
+    _cmd.baud(speed);                                  // set mbed to same speed
+
+    while (!_cmd.readable()) wait_ms(TEMPO);           // wait for screen answer
+
+    if (_cmd.readable()) resp = _cmd.getc();           // read response if any
+    switch (resp) {
+        case ACK :                                     // if OK return   1
+            resp =  1;
+            break;
+        case NAK :                                     // if NOK return -1
+            resp = -1;
+            break;
+        default :
+            resp =  0;                                 // else return   0
+            break;
+    }
+#if DEBUGMODE
+    pc.printf("   Baudrate reply received : %d\n\r",resp);
+#endif
+}
+
+//******************************************************************************************************
+int TFT_4DGL :: readVERSION(char *command, int number) { // read screen info and populate data
+
+    int i, temp = 0, resp = 0;
+    char response[5] = "";
+
+    freeBUFFER();
+
+    for (i = 0; i < number; i++) writeBYTE(command[i]);    // send all chars to serial port
+
+    while (!_cmd.readable()) wait_ms(TEMPO);               // wait for screen answer
+
+    while (_cmd.readable()) {
+        temp = _cmd.getc();
+        response[resp++] = (char)temp;
+    }
+    switch (resp) {
+        case 5 :                                           // if OK populate data and return 1
+            type      = response[0];
+            revision  = response[1];
+            firmware  = response[2];
+            reserved1 = response[3];
+            reserved2 = response[4];
+            resp      = 1;
+            break;
+        default :
+            resp =  0;                                     // else return 0
+            break;
+    }
+    return resp;
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: background_color(int color) {            // set screen background color
+    char command[3]= "";                                  // input color is in 24bits like 0xRRGGBB
+
+    command[0] = BCKGDCOLOR;
+
+    int red5   = (color >> (16 + 3)) & 0x1F;              // get red on 5 bits
+    int green6 = (color >> (8 + 2))  & 0x3F;              // get green on 6 bits
+    int blue5  = (color >> (0 + 3))  & 0x1F;              // get blue on 5 bits
+
+    command[1] = ((red5 << 3)   + (green6 >> 3)) & 0xFF;  // first part of 16 bits color
+    command[2] = ((green6 << 5) + (blue5 >>  0)) & 0xFF;  // second part of 16 bits color
+
+    writeCOMMAND(command, 3);
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: display_control(char mode, char value) {   // set screen mode to value
+    char command[3]= "";
+
+    command[0] = DISPCONTROL;
+    command[1] = mode;
+    command[2] = value;
+
+    if (mode ==  ORIENTATION) {
+        switch (value) {
+            case LANDSCAPE :
+                current_orientation = IS_LANDSCAPE;
+                break;
+            case LANDSCAPE_R :
+                current_orientation = IS_LANDSCAPE;
+                break;
+            case PORTRAIT :
+                current_orientation = IS_PORTRAIT;
+                break;
+            case PORTRAIT_R :
+                current_orientation = IS_PORTRAIT;
+                break;
+        }
+        set_font(current_font);
+    }
+    writeCOMMAND(command, 3);
+
+}
+
+//****************************************************************************************************
+void TFT_4DGL :: set_volume(char value) {   // set sound volume to value
+    char command[2]= "";
+
+    command[0] = SETVOLUME;
+    command[1] = value;
+
+    writeCOMMAND(command, 2);
+}
+
+
+//******************************************************************************************************
+void TFT_4DGL :: getTOUCH(char *command, int number, int *x, int *y) { // read screen info and populate data
+
+#if DEBUGMODE
+    pc.printf("\n\r");
+    pc.printf("New COMMAND : 0x%02X\n\r", command[0]);
+#endif
+    int i, temp = 0, resp = 0;
+    char response[5] = "";
+
+    freeBUFFER();
+
+    for (i = 0; i < number; i++) writeBYTE(command[i]);    // send all chars to serial port
+
+    while (!_cmd.readable()) wait_ms(TEMPO);               // wait for screen answer
+
+    while (_cmd.readable()) {
+        temp = _cmd.getc();
+        response[resp++] = (char)temp;
+    }
+
+#if DEBUGMODE
+    pc.printf("   Answer received %d : 0x%02X 0x%02X 0x%02X 0x%02X\n\r", resp, response[0], response[1], response[2], response[3]);
+#endif
+
+    switch (resp) {
+        case 4 :                                                              // if OK populate data
+            *x = ((response[0]<<8)+ response[1]) * (response[0] != 0xFF);
+            *y = ((response[2]<<8)+ response[3]) * (response[2] != 0xFF);
+            break;
+        default :
+            *x = -1;
+            *y = -1;
+            break;
+    }
+
+#if DEBUGMODE
+    pc.printf("   X,Y : %03d,%03d\n\r", *x, *y);
+#endif
+}
+
+//******************************************************************************************************
+int TFT_4DGL :: getSTATUS(char *command, int number) { // read screen info and populate data
+
+#if DEBUGMODE
+    pc.printf("\n\r");
+    pc.printf("New COMMAND : 0x%02X\n\r", command[0]);
+#endif
+
+    int i, temp = 0, resp = 0;
+    char response[5] = "";
+
+    freeBUFFER();
+
+    for (i = 0; i < number; i++) writeBYTE(command[i]);    // send all chars to serial port
+
+    while (!_cmd.readable()) wait_ms(TEMPO);    // wait for screen answer
+
+    while (_cmd.readable()) {
+        temp = _cmd.getc();
+        response[resp++] = (char)temp;
+    }
+    switch (resp) {
+        case 4 :
+            resp = (int)response[1];            // if OK populate data
+            break;
+        default :
+            resp =  -1;                         // else return   0
+            break;
+    }
+    
+#if DEBUGMODE
+    pc.printf("   Answer received : %d\n\r", resp);
+#endif
+
+    return resp;
+}
\ No newline at end of file
diff -r 000000000000 -r 73bfbf91b6e5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jan 03 13:57:46 2011 +0000
@@ -0,0 +1,39 @@
+#include "TFT_4DGL.h"
+
+TFT_4DGL lcd(p9,p10,p11);
+
+int main() {
+
+    double x1,y1,z1,x,y,z,t,dt;
+    int   xp,yp;
+   
+    float k = 2;
+    float a = 6.7;
+
+    x1 = 1;
+    y1 = 0;
+    z1 = 4.5;
+    
+    dt = 0.01;
+
+    while(1)
+    
+    {
+    
+        x = x1+(-k*x1+a*y1-y1*z1)*dt;
+        y = y1+(x1)*dt;
+        z = z1+(-z+pow(y1,2))*dt;
+        t = t+dt;
+
+        xp = 160+(int)floor(14*x);
+        yp = 120+(int)floor(19*y);
+
+        lcd.pixel(yp,xp,WHITE);
+      
+        x1 = x;
+        y1 = y;
+        z1 = z;
+
+    }
+ 
+}
\ No newline at end of file
diff -r 000000000000 -r 73bfbf91b6e5 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jan 03 13:57:46 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e