TFT Display

Introduction

evive has a 1.8” TFT Display which is mainly used for visual feedback. The display has a 128 x 160 colour pixels. The TFT driver (ST7735R) can display full 18-bit colour (262,144 shades).

evive TFT Display

ST7735R Driver

The ST7735 is a single-chip controller/driver for 262K-color, graphic type TFT-LCD. It consists of 396 source line and 162 gate line driving circuits. This chip is capable of connecting directly to an external microprocessor and accepts Serial Peripheral Interface (SPI), 8-bit/9-bit/16-bit/18-bit parallel interface. Display data can be stored in the on-chip display data RAM of 132 x 162 x 18 bits. It can perform display data RAM read/write operation with no external operation clock to minimize power consumption.

Adafruit ST7735 TFT Library

We will use Arduino IDE to control the TFT display.

Two libraries are required for TFT:

  1. Adafruit_ST7735_Library (http://adafru.it/dXk): this contains the low-level code specific to this device.
  2. Adafruit_GFX_Library (http://adafru.it/cBB): handles graphics operations common to many displays.

Download both ZIP files, uncompress and rename the folders to Adafruit_ST7735 (contains Adafruit_ST7735.cpp and .h) and Adafruit_GFX (contains Adafruit_GFX.cpp and .h) respectively. Then place them inside your Arduino libraries folder and restart the Arduino IDE.

After restarting the Arduino software, you should see a new example folder called Adafruit_ST7735 and inside, an example called graphics test. Change the pin details as shown below.

Now upload the sketch to your Arduino. You should see a collection of graphical tests draw out on the TFT.

Display Functions

Following are the functions available for use:


FunctionDescription
drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)Draw a line using two points
drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)Draw a vertical line
drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)Draw a horizontal line
drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Draw a rectangle using one point coordinate, width and height
fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)Draw a filled rectangle using one point coordinate, width and height
fillScreen(uint16_t color)Change screen colour
drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)Draw a circle using center point coordinate and radius of the circle
fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)Draw a filled circle using center point coordinate and radius of the circle
drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)Draw a triangle using three points coordinate
fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)Draw a filled triangle using three points coordinate
drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)Draw a round rectangle using one point coordinate, width, height and radius
fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)Draw a filled round rectangle using one point coordinate, width, height and radius
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)Draw a Bitmap
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg)Draw a Bitmap
setCursor(int16_t x, int16_t y)Set cursor to a location
setTextColor(uint16_t c)Set text colour
setTextColor(uint16_t c, uint16_t bg)Set text colour
setTextSize(uint8_t s)Set text size
setTextWrap(boolean w)Set text wrap
setRotation(uint8_t r)Set rotation
int16_t height(void) const;Get height
int16_t width(void) const;Get width
uint8_t getRotation(void) const;Get Rotation
int16_t getCursorX(void) const;Get curser X position
int16_t getCursorY(void) const;Get curser Y position
println(text)Write text

Example: