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

ILI9340_Driver.h

Committer:
Elitism
Date:
2014-08-28
Revision:
0:d67893e6f32f

File content as of revision 0:d67893e6f32f:

/* 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