Ported Control Serial Display Via Commands. Uses Highest Speed BAUD Rate Possible. You can DRAW,TYPE Create Menus or whatever you like just by communicating with the mbed over serial connection. I did this a while back however Ian Uploaded most of the files i published a while back to his account.

Dependencies:   mbed

Everything should be working. If not start a discussion and i'll help you asap.

Here is some VB.NET code to help you get started playing with the tft screen through serial. This code will create a menu based graphics which you can select the menu on the left of the screen You can create your own in menu graphics and items however you like, and modify the code to make the mbed do anything you like from inside the windows vb.net application, All you will need is 6 buttons on the form.

VB.NET CODE

Imports System.Threading

Public Class Form1
    dim com_port as string =  "COM6" 'CHANGE THIS TO YOUR MBED COM PORT NUMBER
    'Load/Close
    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        SerialPort1.WriteLine("fill,255,255,255")
        SerialPort1.Close()
        Try
            End
        Catch
            Thread.EndThreadAffinity()
        End Try
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        SerialPort1.PortName = com_port
        SerialPort1.Open()
        SerialPort1.WriteLine("fill,255,255,255")
        Thread.Sleep(2000) 'Required
        SerialPort1.WriteLine("rot,3")
        init_menu()
    End Sub

    'Create TFT Graphics
    Public Sub write_text(ByVal msg As String, ByVal x As Integer, ByVal y As Integer, ByVal size As Integer, ByVal rgb As String)
        Dim send_string As String = "text," + msg + "," + x.ToString + "," + y.ToString + "," + size.ToString + "," + rgb
        SerialPort1.WriteLine(send_string)
        Thread.Sleep(40)
    End Sub
    Public Sub create_rect(ByVal sx As Integer, ByVal sy As Integer, ByVal ex As Integer, ByVal ey As Integer, ByVal rgb As String)
        Dim send_string As String = "rect," + sx.ToString + "," + sy.ToString + "," + ex.ToString + "," + ey.ToString + "," + rgb
        SerialPort1.WriteLine(send_string)
        Thread.Sleep(60)
    End Sub
    Public Sub create_fillrect(ByVal sx As Integer, ByVal sy As Integer, ByVal ex As Integer, ByVal ey As Integer, ByVal rgb As String)
        Dim send_string As String = "frect," + sx.ToString + "," + sy.ToString + "," + ex.ToString + "," + ey.ToString + "," + rgb
        SerialPort1.WriteLine(send_string)
        Thread.Sleep(60)
    End Sub
    Public Sub create_line(ByVal sx As Integer, ByVal sy As Integer, ByVal ex As Integer, ByVal ey As Integer, ByVal rgb As String)
        Dim send_string As String = "dline," + sx.ToString + "," + sy.ToString + "," + ex.ToString + "," + ey.ToString + "," + rgb
        SerialPort1.WriteLine(send_string)
        Thread.Sleep(60)
    End Sub
    Public Sub create_circle(ByVal x As Integer, ByVal y As Integer, ByVal size As Integer, ByVal rgb As String)
        Dim send_string As String = "circle," + x.ToString + "," + y.ToString + "," + size.ToString + "," + rgb
        SerialPort1.WriteLine(send_string)
        Thread.Sleep(60)
    End Sub

    'draw main menu UI
    Public Sub init_menu()
        SerialPort1.WriteLine("rot,3")
        write_text("TFT_PANEL", 100, 13, 2, "200,0,0")
        create_line(80, 40, 320, 40, "255,0,0") 'Boarder Horizontal
        create_line(80, 40, 80, 240, "255,0,0") 'Boarder Vertical
        create_fillrect(0, 0, 80, 40, "100,100,100") 'MENU 1
        write_text("Welcome", 12, 17, 1, "0,0,0")
        create_fillrect(0, 40, 80, 40, "100,100,100") 'MENU 2
        write_text("Menu_1", 15, 57, 1, "0,0,0")
        create_fillrect(0, 80, 80, 40, "100,100,100") 'MENU 3
        write_text("Menu_2", 15, 97, 1, "0,0,0")
        create_fillrect(0, 120, 80, 40, "100,100,100") 'MENU 4
        write_text("Menu_3", 15, 137, 1, "0,0,0")
        create_fillrect(0, 160, 80, 40, "100,100,100") 'MENU 5
        write_text("Menu_4", 15, 177, 1, "0,0,0")
        create_fillrect(0, 200, 80, 40, "100,100,100") 'MENU 6
        write_text("Menu_5", 15, 217, 1, "0,0,0")
        'Select Top Menu
        c_menu(0)
    End Sub

    'Unselect previous selected menu tab
    Public Sub unselect()
        If last_selected = 0 Then
            create_fillrect(0, 0, 80, 40, "100,100,100")  'MAIN MENU
            write_text("Welcome", 12, 17, 1, "0,0,0")
        End If
        If last_selected = 1 Then
            create_fillrect(0, 40, 80, 40, "100,100,100") 'MENU 2
            write_text("Menu_1", 15, 57, 1, "0,0,0")
        End If
        If last_selected = 2 Then
            create_fillrect(0, 80, 80, 40, "100,100,100") 'MENU 3
            write_text("Menu_2", 15, 97, 1, "0,0,0")
        End If
        If last_selected = 3 Then
            create_fillrect(0, 120, 80, 40, "100,100,100") 'MENU 4
            write_text("Menu_3", 15, 137, 1, "0,0,0")
        End If
        If last_selected = 4 Then
            create_fillrect(0, 160, 80, 40, "100,100,100") 'MENU 5
            write_text("Menu_4", 15, 177, 1, "0,0,0")
        End If
        If last_selected = 5 Then
            create_fillrect(0, 200, 80, 40, "100,100,100") 'MENU 6
            write_text("Menu_5", 15, 217, 1, "0,0,0")
        End If
    End Sub

    'Select Menu
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        c_menu(0)
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        c_menu(1)
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        c_menu(2)
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        c_menu(3)
    End Sub
    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        c_menu(4)
    End Sub
    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        c_menu(5)
    End Sub

    'SELECT MENU GRAPHICS!
    Dim last_selected As Integer
    Public Sub c_menu(ByVal menu As Integer)
        unselect()
        If menu = 0 Then
            last_selected = 0
            create_rect(0, 0, 80, 40, "255,255,255")
            write_text("Welcome", 12, 17, 1, "255,255,255")
            '/IN MENU GRAPHICS
            create_fillrect(81, 41, 320, 240, "200,200,200")
            Thread.Sleep(850) 'Required
            write_text("Welcome_Panel_Menu", 90, 50, 1, "255,0,0")
            write_text("This_Is_A_Welcome_Panel", 90, 70, 1, "255,0,0")
            write_text("Menus_Can_Be_Opened_On_Left", 90, 80, 1, "255,0,0")
            create_circle(100, 100, 5, "255,0,0")
        End If
        If menu = 1 Then
            last_selected = 1
            create_rect(0, 40, 80, 40, "255,255,255")
            write_text("Menu_1", 15, 57, 1, "255,255,255")
            '/IN MENU GRAPHICS
            create_fillrect(81, 41, 320, 240, "200,200,200")
            Thread.Sleep(850) 'Required
            write_text("Menu_1", 90, 50, 1, "255,0,0")
            write_text("THIS_IS_THE_FIRST_MENU", 90, 70, 1, "255,0,0")
            write_text("There_are_more_menus_ahead...", 90, 80, 1, "255,0,0")
        End If
        If menu = 2 Then
            last_selected = 2
            create_rect(0, 80, 80, 40, "255,255,255") 'MENU 3
            write_text("Menu_2", 15, 97, 1, "255,255,255")
            '/IN MENU GRAPHICS
            create_fillrect(81, 41, 320, 240, "200,200,200")
            Thread.Sleep(850) 'Required
            write_text("Menu_2", 90, 50, 1, "255,0,0")
            write_text("THIS_IS_THE_SECOND_MENU", 90, 70, 1, "255,0,0")
            write_text("There_are_more_menus_ahead...", 90, 80, 1, "255,0,0")
        End If
        If menu = 3 Then
            last_selected = 3
            create_rect(0, 120, 80, 40, "255,255,255") 'MENU 3
            write_text("Menu_3", 15, 137, 1, "255,255,255")
            '/IN MENU GRAPHICS
            create_fillrect(81, 41, 320, 240, "200,200,200")
            Thread.Sleep(850) 'Required
            write_text("Menu_3", 90, 50, 1, "255,0,0")
            write_text("THIS_IS_THE_THIRD_MENU", 90, 70, 1, "255,0,0")
            write_text("There_are_more_menus_ahead...", 90, 80, 1, "255,0,0")
        End If
        If menu = 4 Then
            last_selected = 4
            create_rect(0, 160, 80, 40, "255,255,255") 'MENU 4
            write_text("Menu_4", 15, 177, 1, "255,255,255")
            '/IN MENU GRAPHICS
            create_fillrect(81, 41, 320, 240, "200,200,200")
            Thread.Sleep(850) 'Required
            write_text("Menu_4", 90, 50, 1, "255,0,0")
            write_text("THIS_IS_THE_FOURTH_MENU", 90, 70, 1, "255,0,0")
            write_text("There_are_more_menus_ahead...", 90, 80, 1, "255,0,0")
        End If
        If menu = 5 Then
            last_selected = 5
            create_rect(0, 200, 80, 40, "255,255,255") 'MENU 5
            write_text("Menu_5", 15, 217, 1, "255,255,255")
            '/IN MENU GRAPHICS
            create_fillrect(81, 41, 320, 240, "200,200,200")
            Thread.Sleep(850) 'Required
            write_text("Menu_5", 90, 50, 1, "255,0,0")
            write_text("THIS_IS_THE_FIFTH_MENU", 90, 70, 1, "255,0,0")
            write_text("There_are_NO_menus_ahead...", 90, 80, 1, "255,0,0")
        End If
    End Sub
End Class

Files at this revision

API Documentation at this revision

Comitter:
Elitism
Date:
Thu Aug 28 17:29:23 2014 +0000
Child:
1:993a4757891d
Commit message:
Serial Control of ILI9340C TFT Display.

Changed in this revision

ILI9340_Driver.cpp Show annotated file Show diff for this revision Revisions of this file
ILI9340_Driver.h Show annotated file Show diff for this revision Revisions of this file
SimpleFont.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ILI9340_Driver.cpp	Thu Aug 28 17:29:23 2014 +0000
@@ -0,0 +1,507 @@
+/* ILI9340C
+For use with Arduino Lib Ported for mbed */
+
+#include "mbed.h"
+#include "ILI9340_Driver.h"
+#include "SimpleFont.cpp"
+
+// Constructor, assigns the pins to the SPI object, set orientation, and sets screen dims.
+ILI9340_Display::ILI9340_Display(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName dc)
+    : spi(mosi, miso, sclk), cs(cs), rst(rst), dc(dc)
+{
+    _height = _TFTHEIGHT;
+    _width = _TFTWIDTH;
+    orientation = 0;
+}
+
+// Command writing code
+void ILI9340_Display::WriteCommand(uint8_t command)
+{
+    dc = 0;
+    cs = 0;
+    spi.write(command);
+    cs = 1;
+}
+
+// Data writing code
+void ILI9340_Display::WriteData(uint8_t data)
+{
+    cs = 0;
+    dc = 1;
+    spi.write(data);
+    cs = 1;
+}
+
+
+// Initilise the display
+void ILI9340_Display::DispInit(void)
+{
+    //CtrlOutput();
+
+    rst = 0;
+
+    // Setup the spi for 8 bit data, high steady state clock,
+    // second edge capture, with a 1MHz clock rate
+    //spi.format(8,3);
+    spi.frequency(24000000); // actually seems to work up to about 20Mhz... way better than the 8mhz as std.
+
+    // Toggle rst to reset
+    rst = 1;
+    wait(0.005);
+    rst = 0;
+    wait(0.020);
+    rst = 1;
+    wait(0.150);
+
+    WriteCommand(0xEF);
+    WriteData(0x03);
+    WriteData(0x80);
+    WriteData(0x02);
+
+    WriteCommand(0xCF);
+    WriteData(0x00);
+    WriteData(0xC1);
+    WriteData(0x30);
+
+    WriteCommand(0xED);
+    WriteData(0x64);
+    WriteData(0x03);
+    WriteData(0x12);
+    WriteData(0x81);
+
+    WriteCommand(0xE8);
+    WriteData(0x85);
+    WriteData(0x00);
+    WriteData(0x78);
+
+    WriteCommand(0xCB);
+    WriteData(0x39);
+    WriteData(0x2C);
+    WriteData(0x00);
+    WriteData(0x34);
+    WriteData(0x02);
+
+    WriteCommand(0xF7);
+    WriteData(0x20);
+
+    WriteCommand(0xEA);
+    WriteData(0x00);
+    WriteData(0x00);
+
+    WriteCommand(ILI9340_PWCTR1);    //Power control
+    WriteData(0x23);   //VRH[5:0]
+
+    WriteCommand(ILI9340_PWCTR2);    //Power control
+    WriteData(0x10);   //SAP[2:0];BT[3:0]
+
+    WriteCommand(ILI9340_VMCTR1);    //VCM control
+    WriteData(0x3e); //�Աȶȵ���
+    WriteData(0x28);
+
+    WriteCommand(ILI9340_VMCTR2);    //VCM control2
+    WriteData(0x86);  //--
+
+    WriteCommand(ILI9340_MADCTL);    // Memory Access Control
+    WriteData(ILI9340_MADCTL_MX | ILI9340_MADCTL_BGR);
+
+    WriteCommand(ILI9340_PIXFMT);
+    WriteData(0x55);
+
+    WriteCommand(ILI9340_FRMCTR1);
+    WriteData(0x00);
+    WriteData(0x18);
+
+    WriteCommand(ILI9340_DFUNCTR);    // Display Function Control
+    WriteData(0x08);
+    WriteData(0x82);
+    WriteData(0x27);
+
+    WriteCommand(0xF2);    // 3Gamma Function Disable
+    WriteData(0x00);
+
+    WriteCommand(ILI9340_GAMMASET);    //Gamma curve selected
+    WriteData(0x01);
+
+    WriteCommand(ILI9340_GMCTRP1);    //Set Gamma
+    WriteData(0x0F);
+    WriteData(0x31);
+    WriteData(0x2B);
+    WriteData(0x0C);
+    WriteData(0x0E);
+    WriteData(0x08);
+    WriteData(0x4E);
+    WriteData(0xF1);
+    WriteData(0x37);
+    WriteData(0x07);
+    WriteData(0x10);
+    WriteData(0x03);
+    WriteData(0x0E);
+    WriteData(0x09);
+    WriteData(0x00);
+
+    WriteCommand(ILI9340_GMCTRN1);    //Set Gamma
+    WriteData(0x00);
+    WriteData(0x0E);
+    WriteData(0x14);
+    WriteData(0x03);
+    WriteData(0x11);
+    WriteData(0x07);
+    WriteData(0x31);
+    WriteData(0xC1);
+    WriteData(0x48);
+    WriteData(0x08);
+    WriteData(0x0F);
+    WriteData(0x0C);
+    WriteData(0x31);
+    WriteData(0x36);
+    WriteData(0x0F);
+
+    WriteCommand(ILI9340_SLPOUT);    //Exit Sleep
+    wait(0.120);
+    WriteCommand(ILI9340_DISPON);    //Display on
+
+}
+
+
+// Sets the rotation of the display
+void ILI9340_Display::SetRotation(uint8_t m)
+{
+
+    WriteCommand(ILI9340_MADCTL);
+    orientation = m % 4; // can't be higher than 3
+
+    switch (orientation) {
+        case 0:
+            WriteData(ILI9340_MADCTL_MX | ILI9340_MADCTL_BGR);
+            _width  = _TFTWIDTH;
+            _height = _TFTHEIGHT;
+            break;
+        case 1:
+            WriteData(ILI9340_MADCTL_MV | ILI9340_MADCTL_BGR);
+            _width  = _TFTHEIGHT;
+            _height = _TFTWIDTH;
+            break;
+        case 2:
+            WriteData(ILI9340_MADCTL_MY | ILI9340_MADCTL_BGR);
+            _width  = _TFTWIDTH;
+            _height = _TFTHEIGHT;
+            break;
+        case 3:
+            WriteData(ILI9340_MADCTL_MV | ILI9340_MADCTL_MY | ILI9340_MADCTL_MX | ILI9340_MADCTL_BGR);
+            _width  = _TFTHEIGHT;
+            _height = _TFTWIDTH;
+            break;
+    }
+}
+
+// Invert the colours of the display in hardware
+void ILI9340_Display::InvertDisplay(bool i)
+{
+    WriteCommand(i ? ILI9340_INVON : ILI9340_INVOFF);
+}
+
+// Set address window for writing data to.
+void ILI9340_Display::SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
+{
+    WriteCommand(ILI9340_CASET); // Column addr set
+    WriteData(x0 >> 8);
+    WriteData(x0 & 0xFF);     // XSTART
+    WriteData(x1 >> 8);
+    WriteData(x1 & 0xFF);     // XEND
+    WriteCommand(ILI9340_PASET); // Row addr set
+    WriteData(y0>>8);
+    WriteData(y0);     // YSTART
+    WriteData(y1>>8);
+    WriteData(y1);     // YEND
+
+    WriteCommand(ILI9340_RAMWR); // write to RAM
+}
+
+// To draw the humble pixel
+void ILI9340_Display::DrawPixel(uint16_t x, uint16_t y, uint16_t colour)
+{
+    if((x < 1) ||(x >= _width) || (y < 1) || (y >= _height)) return;
+
+    SetAddrWindow(x,y,x+1,y+1);
+
+    dc = 1;
+    cs = 0;
+
+    spi.write(colour >> 8);
+    spi.write(colour);
+
+    cs = 1;
+}
+
+// Fill the screen with a colour
+void ILI9340_Display::FillScreen(uint16_t colour)
+{
+    SetAddrWindow(0,0,_width,_height);
+
+    dc = 1;
+    cs = 0;
+
+    unsigned int total = _width * _height;
+    unsigned int position = 0;
+
+    while (position < total) {
+        spi.write(colour >> 8);
+        spi.write(colour);
+        position++;
+    }
+    cs = 1;
+}
+
+// Draws a vertical line fast
+void ILI9340_Display::DrawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t colour)
+{
+    // Rudimentary clipping
+    if((x >= _width) || (y >= _height)) return;
+    if((y+h-1) >= _height)
+        h = _height-y;
+
+    SetAddrWindow(x, y, x, y+h-1);
+
+    uint8_t hi = colour >> 8, lo = colour;
+    dc = 1;
+    cs = 0;
+
+    while (h--) {
+        spi.write(hi);
+        spi.write(lo);
+    }
+    cs = 1;
+}
+
+// Draws a horizontal line fast
+void ILI9340_Display::DrawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t colour)
+{
+
+    // Rudimentary clipping
+    if((x >= _width) || (y >= _height)) return;
+    if((x+w-1) >= _height)  w = _width-x;
+    SetAddrWindow(x, y, x+w-1, y);
+
+    uint8_t hi = colour >> 8, lo = colour;
+    dc = 1;
+    cs = 0;
+    while (w--) {
+        spi.write(hi);
+        spi.write(lo);
+    }
+    cs = 1;
+}
+
+// Draws a filled rectangle
+void ILI9340_Display::FillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t colour)
+{
+
+    // rudimentary clipping (drawChar w/big text requires this)
+    if((x >= _width) || (y >= _height)) return;
+    if((x + w - 1) >= _width)  w = _width  - x;
+    if((y + h - 1) >= _height) h = _height - y;
+
+    SetAddrWindow(x, y, x+w-1, y+h-1);
+
+    uint8_t hi = colour >> 8, lo = colour;
+
+    dc = 1;
+    cs = 0;
+
+    for(y=h; y>0; y--) {
+        for(x=w; x>0; x--) {
+            spi.write(hi);
+            spi.write(lo);
+        }
+    }
+    cs = 1;
+}
+
+// Draw an unfilled rectangle
+void ILI9340_Display::DrawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
+{
+    DrawFastHLine(x, y, w, color);
+    DrawFastHLine(x, y+h-1, w, color);
+    DrawFastVLine(x, y, h, color);
+    DrawFastVLine(x+w-1, y, h, color);
+}
+
+// draw an unfilled circle
+void ILI9340_Display::DrawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t colour)
+{
+    int16_t f = 1 - r;
+    int16_t ddF_x = 1;
+    int16_t ddF_y = -2 * r;
+    int16_t x = 0;
+    int16_t y = r;
+
+    DrawPixel(x0  , y0+r, colour);
+    DrawPixel(x0  , y0-r, colour);
+    DrawPixel(x0+r, y0  , colour);
+    DrawPixel(x0-r, y0  , colour);
+
+    while (x<y) {
+        if (f >= 0) {
+            y--;
+            ddF_y += 2;
+            f += ddF_y;
+        }
+        x++;
+        ddF_x += 2;
+        f += ddF_x;
+
+        DrawPixel(x0 + x, y0 + y, colour);
+        DrawPixel(x0 - x, y0 + y, colour);
+        DrawPixel(x0 + x, y0 - y, colour);
+        DrawPixel(x0 - x, y0 - y, colour);
+        DrawPixel(x0 + y, y0 + x, colour);
+        DrawPixel(x0 - y, y0 + x, colour);
+        DrawPixel(x0 + y, y0 - x, colour);
+        DrawPixel(x0 - y, y0 - x, colour);
+    }
+}
+
+// Pass 8-bit (each) R,G,B, get back 16-bit packed color
+uint16_t ILI9340_Display::Colour565(uint8_t r, uint8_t g, uint8_t b)
+{
+    return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
+}
+
+// Writes an ascii character to the display
+void ILI9340_Display::DrawAscii(unsigned char ascii, uint16_t x, uint16_t y, uint16_t size, uint16_t colour)
+{
+    SetAddrWindow(x, y, x+size, y+size);
+
+    if( (ascii < 0x20) || (ascii > 0x7e) ) {    //check for valid ASCII char
+        ascii = '?';                            //char not supported
+    }
+    for(unsigned char i=0; i<8; i++) {
+        unsigned char temp = simpleFont[ascii - 0x20][i];
+        for(unsigned char f=0; f<8; f++) {
+            if( (temp>>f) & 0x01 ) {
+                switch(orientation) {
+                    case '0':
+                        FillRect(x+f*size, y-i*size, size, size, colour);
+                        break;
+                    case '1':
+                        FillRect(x-i*size, x-f*size, size, size, colour);
+                        break;
+                    case '2':
+                        FillRect(x-f*size, y+i*size, size, size, colour);
+                        break;
+                    case '3':
+                    default:
+                        FillRect(x+i*size, y+f*size, size, size, colour);
+                }
+            }
+        }
+    }
+}
+
+// Writes a character array to the display
+void ILI9340_Display::DrawString(char *string, uint16_t x, uint16_t y, uint8_t size, uint16_t colour)
+{
+    while(*string) {
+        DrawAscii(*string, x, y, size, colour);
+        *string++;
+        switch(orientation) {
+            case '0':
+                if(y > 0) y-=8*size;              //Change position to next char
+                break;
+            case '1':
+                if(x > 0) x-=8*size;
+                break;
+            case '2':
+                if(y < _height) y+=8*size;
+                break;
+            case '3':
+            default:
+                if(x < _width) x+=8*size;
+        }
+    }
+}
+
+// Converts integers into a character array
+void ILI9340_Display::IntToChars (char* buffer, int value, uint8_t spaceonbuffer, uint8_t countbase, uint16_t x, uint16_t y, uint8_t size, uint16_t colour)
+{
+    int workvalue = value;
+    int i;
+    int valuetowrite;
+    int  end_i = 0;
+
+    if (value < 0) {
+        workvalue = -value;
+        end_i = 1;
+        buffer[0] = '-';
+    }
+
+    for (i = spaceonbuffer - 1; i >= end_i; i--) {
+        valuetowrite = (workvalue % countbase);
+        if (workvalue == 0) {
+            if (i == (spaceonbuffer - 1)) {
+                buffer[i] = 48;                        // ASCII 0
+            } else {
+                buffer[i] = 32;                        // ASCII SPACE
+            }
+        } else {
+            if (valuetowrite > 9) {
+                buffer[i] = valuetowrite + 55;        // ASCII A-Z
+            } else {
+                buffer[i] = valuetowrite + 48;        // ASCII of that character
+            }
+        };
+        workvalue = (workvalue - valuetowrite) / countbase;
+    }
+
+    DrawString(buffer, x, y, size, colour);
+}
+
+// Functional code to swap data contents of 16bit registers
+void ILI9340_Display::Swap(int16_t *a, int16_t *b)
+{
+
+    int16_t x = *a;
+    *a = *b;
+    *b = x;
+}
+
+// Draws a line with any length and orientation
+void ILI9340_Display::DrawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour)
+{
+    int16_t steep = abs(y1 - y0) > abs(x1 - x0);
+    if (steep) {
+        Swap(&x0, &y0);
+        Swap(&x1, &y1);
+    }
+
+    if (x0 > x1) {
+        Swap(&x0, &x1);
+        Swap(&y0, &y1);
+    }
+
+    int16_t dx, dy;
+    dx = x1 - x0;
+    dy = abs(y1 - y0);
+
+    int16_t err = dx / 2;
+    int16_t ystep;
+
+    if (y0 < y1) {
+        ystep = 1;
+    } else {
+        ystep = -1;
+    }
+
+    for (; x0<=x1; x0++) {
+        if (steep) {
+            DrawPixel(y0, x0, colour);
+        } else {
+            DrawPixel(x0, y0, colour);
+        }
+        err -= dy;
+        if (err < 0) {
+            y0 += ystep;
+            err += dx;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ILI9340_Driver.h	Thu Aug 28 17:29:23 2014 +0000
@@ -0,0 +1,139 @@
+/* PORTED FROM ARDUINO ADAFRUIT TO MBED */
+
+
+
+#include "mbed.h"
+
+#ifndef ILI9340_DRIVER_h
+#define ILI9340_DRIVER_h
+
+
+#define _TFTWIDTH  240
+#define _TFTHEIGHT 320
+
+#define ILI9340_NOP     0x00
+#define ILI9340_SWRESET 0x01
+#define ILI9340_RDDID   0x04
+#define ILI9340_RDDST   0x09
+
+#define ILI9340_SLPIN   0x10
+#define ILI9340_SLPOUT  0x11
+#define ILI9340_PTLON   0x12
+#define ILI9340_NORON   0x13
+
+#define ILI9340_RDMODE  0x0A
+#define ILI9340_RDMADCTL  0x0B
+#define ILI9340_RDPIXFMT  0x0C
+#define ILI9340_RDIMGFMT  0x0A
+#define ILI9340_RDSELFDIAG  0x0F
+
+#define ILI9340_INVOFF  0x20
+#define ILI9340_INVON   0x21
+#define ILI9340_GAMMASET 0x26
+#define ILI9340_DISPOFF 0x28
+#define ILI9340_DISPON  0x29
+
+#define ILI9340_CASET   0x2A
+#define ILI9340_PASET   0x2B
+#define ILI9340_RAMWR   0x2C
+#define ILI9340_RAMRD   0x2E
+
+#define ILI9340_PTLAR   0x30
+#define ILI9340_MADCTL  0x36
+
+
+#define ILI9340_MADCTL_MY  0x80
+#define ILI9340_MADCTL_MX  0x40
+#define ILI9340_MADCTL_MV  0x20
+#define ILI9340_MADCTL_ML  0x10
+#define ILI9340_MADCTL_RGB 0x00
+#define ILI9340_MADCTL_BGR 0x08
+#define ILI9340_MADCTL_MH  0x04
+
+#define ILI9340_PIXFMT  0x3A
+
+#define ILI9340_FRMCTR1 0xB1
+#define ILI9340_FRMCTR2 0xB2
+#define ILI9340_FRMCTR3 0xB3
+#define ILI9340_INVCTR  0xB4
+#define ILI9340_DFUNCTR 0xB6
+
+#define ILI9340_PWCTR1  0xC0
+#define ILI9340_PWCTR2  0xC1
+#define ILI9340_PWCTR3  0xC2
+#define ILI9340_PWCTR4  0xC3
+#define ILI9340_PWCTR5  0xC4
+#define ILI9340_VMCTR1  0xC5
+#define ILI9340_VMCTR2  0xC7
+
+#define ILI9340_RDID1   0xDA
+#define ILI9340_RDID2   0xDB
+#define ILI9340_RDID3   0xDC
+#define ILI9340_RDID4   0xDD
+
+#define ILI9340_GMCTRP1 0xE0
+#define ILI9340_GMCTRN1 0xE1
+/*
+#define ILI9340_PWCTR6  0xFC
+
+*/
+
+// Color definitions
+#define ILI9340_BLACK   0x0000
+#define ILI9340_BLUE    0x001F
+#define ILI9340_RED     0xF800
+#define ILI9340_GREEN   0x07E0
+#define ILI9340_CYAN    0x07FF
+#define ILI9340_MAGENTA 0xF81F
+#define ILI9340_YELLOW  0xFFE0  
+#define ILI9340_WHITE   0xFFFF
+
+
+
+class ILI9340_Display {
+    
+    public:
+    
+    uint16_t _height;
+    uint16_t _width;
+    
+    ILI9340_Display(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName dc);
+    
+    void DispInit();
+    void WriteCommand(uint8_t);
+    void WriteData(uint8_t);
+    void SetRotation(uint8_t);
+    void InvertDisplay(bool);
+    void SetAddrWindow(uint16_t, uint16_t, uint16_t, uint16_t);
+    
+    void DrawPixel(uint16_t, uint16_t, uint16_t);
+    void FillScreen(uint16_t);
+    void DrawFastVLine(int16_t, int16_t, int16_t, uint16_t);
+    void DrawFastHLine(int16_t, int16_t, int16_t, uint16_t);
+    void FillRect(int16_t, int16_t, int16_t, int16_t, uint16_t);
+    void DrawRect(int16_t, int16_t, int16_t, int16_t, uint16_t);
+    void DrawCircle(int16_t, int16_t, int16_t, uint16_t);
+    uint16_t Colour565(uint8_t, uint8_t, uint8_t);
+    
+    void DrawAscii(unsigned char, uint16_t, uint16_t, uint16_t, uint16_t);
+    void DrawString(char *string, uint16_t, uint16_t, uint8_t, uint16_t);
+    void IntToChars (char*, int, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t, uint16_t);
+    
+    void Swap(int16_t*, int16_t*);
+    void DrawLine(int16_t, int16_t, int16_t, int16_t, uint16_t);
+    
+    protected:
+    SPI spi; // mosi, miso, sclk
+    DigitalOut cs;
+    DigitalOut rst;
+    DigitalOut dc;
+    
+    uint8_t orientation;
+       
+    };
+
+
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SimpleFont.cpp	Thu Aug 28 17:29:23 2014 +0000
@@ -0,0 +1,37 @@
+/* ST7781R TFT Library. 2011 Copyright (c) Seeed Technology Inc. */
+
+const char simpleFont[][8] = {
+  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},  {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},  {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
+  {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},  {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},  {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
+  {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00},  {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},  {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
+  {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},  {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},  {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
+  {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},  {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},  {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
+  {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},  {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},  {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},
+  {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},  {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00},  {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
+  {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},  {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},  {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
+  {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},  {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00},  {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00},
+  {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},  {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},  {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
+  {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},  {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},  {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
+  {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},  {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00},  {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
+  {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},  {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},  {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
+  {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},  {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},  {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
+  {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},  {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},  {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
+  {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},  {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},  {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
+  {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},  {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},  {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00},
+  {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},  {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},  {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
+  {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},  {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},  {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
+  {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},  {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},  {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
+  {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},  {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},  {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
+  {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},  {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},  {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
+  {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},  {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00},  {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
+  {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},  {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},  {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
+  {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},  {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},  {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
+  {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00},  {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},  {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
+  {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},  {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},  {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
+  {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},  {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},  {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
+  {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},  {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},  {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
+  {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},  {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00},  {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
+  {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},  {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00},  {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
+  {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00},  {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},  {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00} 
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Aug 28 17:29:23 2014 +0000
@@ -0,0 +1,91 @@
+/*Ported From Adafruit with modifications*/
+
+
+#include "ILI9340_Driver.h"
+
+//(mosi,miso,sck,cs,rst,d/c)
+ILI9340_Display tft = ILI9340_Display(p5, p6, p7, p24, p25, p26);
+
+//USB Serial - Onboard USB (Requires USB Serial Driver): https://mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
+Serial serial(USBTX, USBRX);
+
+//Serial String Command Parser
+#define NFIELDS (11) //Max Commands
+char* pFields[NFIELDS];
+void ParseCommands(char* Buffer, char** pFields, uint32_t numFields, char* delimiter)
+{
+    char* pString = Buffer;
+    char* pField;
+
+    for (uint32_t i=0; i<numFields; i++) {
+        pField = strtok(pString, delimiter);
+        if (pField != NULL) {
+            pFields[i] = pField;
+        } else {
+            pFields[i] = "";
+        }
+        pString = NULL; //parse next
+    }
+    if (strcmp("init", pFields[0]) == 0) {
+        ILI9340_Display tft = ILI9340_Display(p5, p6, p7, p24, p25, p26);
+        tft.DispInit();
+        tft.FillScreen(ILI9340_WHITE);
+    }
+    if (strcmp("rect", pFields[0]) == 0) {
+        //X,Y,X,Y,R,G,B
+        tft.DrawRect(atoi(pFields[1]),atoi(pFields[2]),atoi(pFields[3]),atoi(pFields[4]),uint16_t(tft.Colour565(atoi(pFields[5]), atoi(pFields[6]), atoi(pFields[7]))));
+    }
+    if (strcmp("frect", pFields[0]) == 0) {
+        tft.FillRect(atoi(pFields[1]), atoi(pFields[2]), atoi(pFields[3]), atoi(pFields[4]), uint16_t(tft.Colour565(atoi(pFields[5]), atoi(pFields[6]), atoi(pFields[7]))));
+    }
+    if (strcmp("dline", pFields[0]) == 0) {
+        tft.DrawLine(atoi(pFields[1]), atoi(pFields[2]), atoi(pFields[3]), atoi(pFields[4]), uint16_t(tft.Colour565(atoi(pFields[5]), atoi(pFields[6]), atoi(pFields[7]))));
+    }
+    if (strcmp("circle", pFields[0]) == 0) {
+        //X,Y,SIZE,R,G,B
+        tft.DrawCircle(atoi(pFields[1]), atoi(pFields[2]), atoi(pFields[3]), uint16_t(tft.Colour565(atoi(pFields[4]), atoi(pFields[5]), atoi(pFields[6]))));
+    }
+    if (strcmp("px", pFields[0]) == 0) {
+        //X,Y,R,G,B
+        tft.DrawPixel(atoi(pFields[1]),atoi(pFields[2]),uint16_t(tft.Colour565(atoi(pFields[3]), atoi(pFields[4]), atoi(pFields[5]))));
+    }
+    if (strcmp("fill", pFields[0]) == 0) {
+        //R,G,B
+        tft.FillScreen(uint16_t(tft.Colour565(atoi(pFields[1]), atoi(pFields[2]), atoi(pFields[3]))));
+    }
+    if (strcmp("text", pFields[0]) == 0) {
+        //text,String,X,Y,Size,Color
+        int i = 0; while(pFields[1][i] != 0){if(pFields[1][i] == '_'){pFields[1][i] = ' ';} i++;}//Replace Char In String (For Spaces)
+        tft.DrawString(pFields[1], atoi(pFields[2]), atoi(pFields[3]), atoi(pFields[4]), uint16_t(tft.Colour565(atoi(pFields[5]), atoi(pFields[6]), atoi(pFields[7]))));
+    }
+    if (strcmp("rot", pFields[0]) == 0) {
+        tft.SetRotation(atoi(pFields[1]));
+    }
+}
+
+int main(int argc, char* argv[])
+{
+    ILI9340_Display tft = ILI9340_Display(p5, p6, p7, p24, p25, p26);
+    tft.DispInit();
+    tft.FillScreen(ILI9340_WHITE);
+    ///////////////////////////////////////////////////////////////////////////
+    //Serial String Parse Commands Example
+    //
+    //                    command  txt           vector   font_size  R   G   B
+    //Set Text On Screen: "text",  "hello world",20,10,   2,         255,255,255
+    //
+    //                            command  vector_start  vector_end  R   G   B
+    //Creating Rectangle Example: "rect",  20,40,        30,70,      255,255,255
+    //
+    //These commands are sent from serial to the MBED
+    //You can easily work out the other commands by looking above and reading
+    //the ones i showed examples for above
+    ////////////////////////////////////////////////////////////////////////////
+    serial.baud(921600);
+    char buf[40];
+    while (1) {
+        serial.scanf("%s", buf);
+        ParseCommands(buf, pFields, NFIELDS, ",");
+    }
+    ////////////////////////////////////////////////////////
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Aug 28 17:29:23 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file