There are already some libraries for the ST7735 display driver such as the one from Adafruit but made only for Arduino. I needed one for AVR microcontrollers in general, so I made this one. With a bit of twiking it could also be adapted to work with other types of microcontrollers. This library is based on the one from Adafruit but with some functions removed, modified and others added. The interface needs 4 microcontroller pins and it uses SPI for communication.
There are many GUI elements that can be created and above are a few examples such as: selectable menus, scrollbars, checkboxes and animated icons.
Contents:
- Wiring the ST7735 TFT Display
- ST7735 Library
- Initialization function and types of ST7735 modules
- The Colors
- The Cursor and the Coordinate System
- Clearing the display
- Text Functions
- Setting the font family
- Making the font bold
- Creating your own custom fonts
- Display Text
- Display a single character
- Set the font size
- Set the font color
- Display Numbers
- Aligning Elements on Screen
- Text alignment
- Set text boundaries
- Print text on the next line
- Get text width
- Get text height
- Get position of a line of text
- Get cursor position
- Set cursor position
- Get display width and height
- Get last pixel coordinate
- Drawing Primitive Shapes
- Bitmap Images and Icons
- RGB Bitmaps on MCU flash memory
- Bitmaps images from memory cards
- Monochrome Bitmaps/Icons
- Creating Monochrome Icons in GIMP for TFT Displays
- Array of Icons - Icon Sets
- Reading data from ST7735 driver
- Extra Functions
- Library Configuration
- Basic Code Example
- Download ST7735 Library
Wiring the ST7735 TFT display
It is important to note that the power supply voltage for the ST7735 display driver is maximum 3.3V and same for the other input pins. Some TFT modules include a 3.3V regulator and a voltage level shifter in which case it can be used with 5V microcontrollers, if not some level shifting must be done if the microcontroller is not powered from 3.3V.
This schematic is an example that also includes an SD card. Here, MISO is used for DC pin (Data/Command) since the ST7735 doesn't use the MISO in the SPI protocol, and also as MISO (Master In Slave Out) for the SD card. The 74AHC125D can't be used for this pin since is not bi-directional, hence the mosfet level shifter.
ST7735 connection diagram with voltage level shifters and pinout
1 - GND - ground power supply
2 - VCC - 3.3V power supply (minimum 150mA)
3 - SCL - SPI serial clock pin (SCK)
4 - SDA - SPI serial data input/output (MOSI)