TFT

a small robot screen

Authors

Binay Gurung

Modified by: Leo Wong, Christopher Kwan

Printing something

When learning programming, most of the integrated development environment (IDE) you will/might have used will have a console for output and will often be used for debugging for you to keep track of certain variables and to trace-out truth tables or so forth.

In different programming languages, you can print/show your variable's value in the program using print function.

For Example

In C,

int c = 25;
printf("The value of c-squared is : %d",c*c);
//Output will come as "The value of c-squared is : 625"

In Python,

c = 25
print("The value of c-squared is: ",c*c) # c**2
#Output will come as "The value of c-squared is : 625"

In Java,

int c = 25;
System.out.println("The value of c-squared is " + c*c);
//Output will come as "The value of c-squared is : 625"

In our embedded system, usually we do not have a console to output our variable values to when debugging.

However, with the help of TFT (a small LCD monitor), you will be able to "print out" the values of your variable on a monitor.

Initialize TFT

Function Prototype

Parameters

  • orientation - Orientation of the monitor

  • bg_color - Background color

  • text_color - Text color

  • text_color_sp - Special Text color - []

  • highlight_color - Highlight color - {}

The parameters have already been defined for you in lcd.h header-file. It is defined as follows:

* Orientation

* Colors

You may choose one of the following colours according to your own desire for the TFT. Of course! You may also define new color yourself. The following are RGB565 format

Example:

  • x: nth horizontal column ranging from 0 to 15 (16 columns)

  • y: nth vertical row, ranging from 0 to 9 (10 rows)

  • fmt: string with format templates (same as C's printf)

  • ... : variable to replace the placeholder in the string (same as C's printf)

Example

  • color : colour of your pixel (Use the #define colours)

  • x : n-th horizontal pixel, ranging from 0 to 127

  • y : n-th vertical pixel , ranging from 0 to 159

Update

  • period : period of update in ms

Miscellaneous

Example of using TFT

Remember to include the relevant libraries

FYI: There are some functions that will be useful.

Last updated