Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gavinlyonsrepo/st7735_tft_pico
TFT SPI LCD, ST7735 Driver, Raspberry pi PICO RP2040 display library. C++ SDK
https://github.com/gavinlyonsrepo/st7735_tft_pico
display display-library lcd lcd-display library pico raspberry-pi raspberry-pi-pico raspberrypi raspberrypipico rp2040 rpi rpi-pico rpipico sdk-cpp spi st7735 tft tft-display tft-lcd
Last synced: 3 days ago
JSON representation
TFT SPI LCD, ST7735 Driver, Raspberry pi PICO RP2040 display library. C++ SDK
- Host: GitHub
- URL: https://github.com/gavinlyonsrepo/st7735_tft_pico
- Owner: gavinlyonsrepo
- License: gpl-3.0
- Created: 2022-11-05T20:20:56.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-22T15:09:20.000Z (7 months ago)
- Last Synced: 2024-04-22T16:39:08.551Z (7 months ago)
- Topics: display, display-library, lcd, lcd-display, library, pico, raspberry-pi, raspberry-pi-pico, raspberrypi, raspberrypipico, rp2040, rpi, rpi-pico, rpipico, sdk-cpp, spi, st7735, tft, tft-display, tft-lcd
- Language: C++
- Homepage:
- Size: 589 KB
- Stars: 16
- Watchers: 7
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Website](https://img.shields.io/badge/Website-Link-blue.svg)](https://gavinlyonsrepo.github.io/) [![Rss](https://img.shields.io/badge/Subscribe-RSS-yellow.svg)](https://gavinlyonsrepo.github.io//feed.xml) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/paypalme/whitelight976)
![ ig ](https://github.com/gavinlyonsrepo/pic_16F18346_projects/blob/master/images/st7735/pcb.jpg)
# ST7735_TFT_PICO
## Table of contents
* [Overview](#overview)
* [Test](#test)
* [Software](#software)
* [API](#api)
* [User Options](#user-options)
* [Fonts](#fonts)
* [Bitmap](#bitmap)
* [Hardware](#hardware)
* [Output](#output)## Overview
* Name: ST7735_TFT_PICO
* Description:0. Library for a TFT SPI LCD, ST7735 Driver
1. Raspberry pi PICO RP2040 library.
2. Inverse colour, rotate, sleep, idle & vertical scroll modes supported.
3. 12 fonts included
4. Graphics + print class included.
5. bi-color, 16 bit and 24 colour Bitmaps supported.
6. Hardware and software SPI* Author: Gavin Lyons
* Port of my Raspberry PI library version 1.5 at [github link.](https://github.com/gavinlyonsrepo/ST7735_TFT_RPI)
* Developed on Toolchain:
1. Raspberry pi PICO RP2040
2. SDK(1.4.0) C++
3. compiler G++ for arm-none-eabi((15:10.3-2021.07-4)
4. CMAKE(VERSION 3.12) , VScode(1.84.2)
5. Linux Mint 21.2## Test
There are example files included. User picks the one they want
by editing the CMakeLists.txt :: add_executable(${PROJECT_NAME} section.
Comment in one path and one path only.| Filename | Function | Note |
| --- | --- | --- |
| ST7735_TFT_HELLO | Hello world | --- |
| ST7735_TFT_TESTS | Text + fonts | --- |
| ST7735_TFT_GRAPHICS| Graphics | --- |
| ST7735_TFT_FUNCTIONS_FPS| Functions(like rotate scroll) + FPS test 702| --- |
| ST7735_TFT_BMP_DATA | bi colour, 24 & 16 bitmaps tests + FPS test 701| Bitmap data is stored in arrays on PICO |## Software
### API
The API (application programming interface) documentation is at link hosted on github pages and generated by Doxygen.
[ URL API Link ](https://gavinlyonsrepo.github.io/misc/software_docs/ST7735_TFT_PICO/index.html)
### User Options
In the main.cpp example files. There are four sections in "Setup()" function
where user can make adjustments to select for SPI type used, PCB type used and screen size.0. USER OPTION 0 SPI_SPEED + TYPE
1. USER OPTION 1 GPIO
2. USER OPTION 2 SCREEN SECTION
3. USER OPTION 3 PCB_TYPE*USER OPTION 0 SPI SPEED*
Here the user can pass the SPI Bus freq in kiloHertz, Currently set to 8 Mhz.
Max SPI speed on the PICO is 62.5Mhz. There is a file with SPI test results for the FPS tests in extra/doc folder. "nd parameter is the SPI interface(spi0 spi1 etc).If users wants software SPI just call this method
with just one argument for the optional GPIO software uS delay,
which by default is zero. Setting this higher can be used to slow down Software SPI
which may be beneficial in some setups.*USER OPTION 1 GPIO*
The 5 GPIO pins used, the clock and data lines must be the clock and data lines
of spi interface chosen in option 0 if using hardware SPI.*USER OPTION 2 Screen size + Offsets*
In the main.cpp file, in USER OPTION 2 .
User can adjust screen pixel height, screen pixel width and x & y screen offsets.
These offsets can be used in the event of screen damage or manufacturing errors around edge
such as cropped data or defective pixels.
The function TFTInitScreenSize sets them.*USER OPTION 3 PCB Version*
Select your PCB controller type by passing an enum type to function TFTInitPCBType.
Default is "TFT_ST7735R_Red". If you select the wrong one if may still work but with inverted colors.| Number | Description | Enum label| Tested on |
| ---- | ---- | --- | --- |
| 1 | ST7735B controller| TFT_ST7735B | n/a |
| 2 | ST7735R "Green Tab" | TFT_ST7735R_Green | n/a |
| 3 | ST7735R "Red Tab" | TFT_ST7735R_Red | RED PCB v1.1, 1.44 , 128 x 128 pixels |
| 4 | ST7735S "Black Tab" | TFT_ST7735S_Black | RED PCB v1.2, 1.8 , 128 x 160 pixels |### Fonts
Font data table:
| num | enum name | Char size XbyY | ASCII range | Size bytes | Size Scale-able |
| ------ | ------ | ------ | ------ | ------ | ----- |
| 1 | $_Default | 5x8 |0-0xFF, Full Extended|1275 |Y|
| 2 | $_Thick | 7x8 |0x20-0x5A, no lowercase letters |406|Y|
| 3 | $_SevenSeg | 4x8 |0x20-0x7A |360|Y|
| 4 | $_Wide | 8x8 |0x20-0x5A, no lowercase letters|464|Y|
| 5 | $_Tiny | 3x8 |0x20-0x7E |285|Y|
| 6 | $_Homespun | 7x8 |0x20-0x7E |658|Y|
| 7 | $_Bignum | 16x32 |0x2D-0x3A ,0-10 - . / : |896|N|
| 8 | $_Mednum | 16x16 |0x2D-0x3A ,0-10 - . / :|448|N|
| 9 | $_ArialRound| 16x24 | 0x20-0x7E |4608|N|
| 10 | $_ArialBold | 16x16 |0x20-0x7E |3072|N|
| 11 | $_Mia| 8x16 | 0x20-0x7E |1520|N|
| 12 | $_Dedica | 6x12 |0x20-0x7E |1152|N|1. $ = TFTFont
2. A print class is available to print out many data types.
3. Fonts 1-6 are byte high(at text size 1) scale-able fonts, columns of padding added by SW.
4. Font 7-8 are large numerical fonts and cannot be scaled(just one size).
5. Fonts 9-12 Alphanumeric fonts and cannot be scaled(just one size)
These fonts are optional and can be removed from program
by commenting out the relevant TFT_OPTIONAL_FONT_X define in the ST7735_TFT_Font.hpp fileFont Methods:
| Font num | Method | Size parameter | Notes |
| ------ | ------ | ------ | ------ |
| 1-6 | drawChar|Y| draws single character |
| 1-6 | drawText |Y| draws character array |
| 7-12 | drawChar|N| draws single character |
| 7-12 | drawText|N| draws character array |
| 1-12 | print |~| Polymorphic print class which will print out many data types |These functions return a number in event of an error, such as wrong font chosen , ASCII character outside chosen fonts range, character out of screen bounds and invalid character array pointer object. See API docs for details
### Bitmap
There are 4 functions to support drawing bitmaps,
| Num | Function Name | Colour support | bitmap size Max | Note |
| ------ | ------ | ------ | ------ | ------ |
| 1 | TFTdrawIcon | bi-colour | (8 x (0-Max_y)) 128 bytes max | Data vertically addressed |
| 2 | TFTdrawBitmap | bi-colour | 2048 bytes | Data horizontally addressed |
| 3 | TFTdrawBitmap16Data | 16 bit color 565 | 32768 | Data from array on PICO |
| 4 | TFTdrawBitmap24Data | 24 bit color | 49152 | Data from array on PICO, Converted by software to 16-bit color |1. Bitmap size in kiloBytes = (screenWidth * screenHeight * bitsPerPixel)/(1024 * 8)
2. Math in bitmap size column 2-5 assumes 128x128 pixel screen.
3. The data array for 1 and 2 is created from image files using file data conversion tool [link](https://javl.github.io/image2cpp/)
4. The data array for 3 and 4 is created from BMP files using file data conversion tool [link](https://notisrac.github.io/FileToCArray/)These functions will return error codes in event of an error, see API docs for details.
## Hardware
Connections as setup in main.cpp test file.
| TFT PinNum | Pindesc | HW SPI |
| --- | --- | --- |
| 1 | LED | VCC |
| 2 | SCLK | GPIO18 |
| 3 | SDA | GPIO19 |
| 4 | A0/DC | GPIO3 |
| 5 | RESET | GPIO17 |
| 6 | SS/CS | GPIO2 |
| 7 | GND | GND |
| 8 | VCC | VCC |1. NOTE connect LED backlight pin 1 thru a 150R/220R ohm resistor to 3.3/5V VCC.
2. This is a 3.3V logic device do NOT connect the I/O logic lines to 5V logic device.
3. You can connect VCC to 5V if there is a 3.3 volt regulator on back of TFT module.
4. SW SPI pick any GPIO you like , HW SPI SCLK and SDA will be tied to spio interface.
5. Backlight on/off control is left to user.## Output
Output of some of the test routine's. Left to right
1. Bitmap (bi-color) A background and a foreground, 128 X 128 pixels.
2. Different sizes of default font. Size 2 3 4 & 5 shown.
3. Different Fonts at font size 2, fonts 1-6 All these fonts are scale-able
4. Graphics.
5. Clock Demo Test 11, showing icons, and font 7 "BigNums"
6. 24 bit RGB test image displayed from a data array , 128 X 128 pixels.
7. 16 bit 565 test image displayed from a data array , 128 X 128 pixels.
8. Fonts 7-12![ pic ](https://github.com/gavinlyonsrepo/ST7735_TFT_PICO/blob/main/extra/doc/images/row1.jpg)
![ pic1 ](https://github.com/gavinlyonsrepo/ST7735_TFT_RPI/blob/main/extra/images/4.jpg)
![ p2](https://github.com/gavinlyonsrepo/ST7735_TFT_RPI/blob/main/extra/images/5.jpg)