Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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