Skip to content

Latest commit

 

History

History
209 lines (154 loc) · 8.43 KB

README.md

File metadata and controls

209 lines (154 loc) · 8.43 KB

Website Rss Donate

 ig

ST7735_TFT_PICO

Table of contents

Overview

  • Name: ST7735_TFT_PICO
  • Description:
  1. Library for a TFT SPI LCD, ST7735 Driver
  2. Raspberry pi PICO RP2040 library.
  3. Inverse colour, rotate, sleep, idle & vertical scroll modes supported.
  4. 12 fonts included
  5. Graphics + print class included.
  6. Sprites, 1,16 and 24 bit colour Bitmaps supported.
  7. Hardware and software SPI
  • Version: 1.7.2
  • Author: Gavin Lyons
  • Developed on Toolchain:
    1. Raspberry pi PICO RP2040
    2. SDK(2.1.0) C++
    3. compiler G++ for arm-none-eabi(13.2.1)
    4. CMAKE(VERSION 3.18) , VScode(1.95.3)
    5. Linux Mint 22.1

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

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.

  1. USER OPTION 0 SPI_SPEED + TYPE
  2. USER OPTION 1 GPIO
  3. USER OPTION 2 SCREEN SECTION
  4. 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 file

Font 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

Functions to support drawing bitmaps, icons & sprites.

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
5 TFTdrawSpriteData 16 bit color 565 32768 Data from array on PICO, Draws background color tranparent
  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
  4. The data array for 3 - 5 is created from BMP files using file data conversion tool link

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  pic1  p2