{"id":24514621,"url":"https://github.com/gavinlyonsrepo/st7789_tft_rpi","last_synced_at":"2025-04-14T09:21:28.627Z","repository":{"id":263854457,"uuid":"891596104","full_name":"gavinlyonsrepo/ST7789_TFT_RPI","owner":"gavinlyonsrepo","description":"Raspberry Pi library for ST7789 LCD TFT ","archived":false,"fork":false,"pushed_at":"2025-03-14T13:44:28.000Z","size":355,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T22:42:51.079Z","etag":null,"topics":["display","display-driver","display-library","lcd","library","raspberry-pi","raspberrypi","rpi","rpi3","rpi4","st7789","st7789-display","st7789-display-driver","st7789v","tft-display"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gavinlyonsrepo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-20T16:00:00.000Z","updated_at":"2025-03-15T21:28:35.000Z","dependencies_parsed_at":"2024-11-20T17:20:49.619Z","dependency_job_id":"e9a5a22e-defc-4111-bc4a-a52f901bf3dd","html_url":"https://github.com/gavinlyonsrepo/ST7789_TFT_RPI","commit_stats":null,"previous_names":["gavinlyonsrepo/st7789_tft_rpi"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FST7789_TFT_RPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FST7789_TFT_RPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FST7789_TFT_RPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FST7789_TFT_RPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gavinlyonsrepo","download_url":"https://codeload.github.com/gavinlyonsrepo/ST7789_TFT_RPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852189,"owners_count":21171843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["display","display-driver","display-library","lcd","library","raspberry-pi","raspberrypi","rpi","rpi3","rpi4","st7789","st7789-display","st7789-display-driver","st7789v","tft-display"],"created_at":"2025-01-22T01:13:54.310Z","updated_at":"2025-04-14T09:21:28.603Z","avatar_url":"https://github.com/gavinlyonsrepo.png","language":"C++","funding_links":["https://www.paypal.com/paypalme/whitelight976"],"categories":[],"sub_categories":[],"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)\n\n# ST7789 TFT LCD Raspberry PI Display Library\n\n[![Image TFT](https://github.com/gavinlyonsrepo/Display_Lib_RPI/blob/main/extra/images/st7789.jpg)](https://github.com/gavinlyonsrepo/Display_Lib_RPI/blob/main/extra/images/st7789.jpg)\n\n## Table of contents\n\n  * [Overview](#overview)\n  * [See Also](#see-also)\n  * [Installation](#installation)\n  * [Test](#test)\n  * [Documentation](#documentation)\n    * [Fonts](#fonts)\n  * [Software](#software)\n    * [User options](#user-options)\n    * [File-system](#file-system)\n    * [Tool chain](#tool-chain)\n  * [Hardware](#hardware)\n  * [Output](#output)\n  * [Notes](#notes)\n    * [Multiple SPI devices](#multiple-spi-devices)\n    * [Raspberry Pi five](#raspberry-pi-five)\n    * [Display offsets](#display-offsets)\n    * [Hardware spi aux](hardware-spi-aux)\n\n## Overview\n\n* Project Name: ST7789_TFT_RPI\n* Author: Gavin Lyons.\n* Description:\n\n0. A C++ Library to connect 16-bit color ST7789 TFT LCD displays to Raspberry Pi single board computers.\n1. Dynamic install-able Raspberry Pi C++ library.\n2. 15 fonts included, new Fonts can be added by user\n3. Graphics + print class included\n4. Dependency: [bcm2835 Library](http://www.airspayce.com/mikem/bcm2835/), Provides SPI , system timer and GPIO control.\n5. Hardware (SPI0 and SPI1-aux) \u0026 Software SPI\n6. Inverse colour, rotate, sleep modes supported.\n7. 24 bit colour , 16 bit color \u0026 bi-color Bitmaps supported.\n\n## See Also\n\nThis is a truncated port of my combined display library : [Display_Lib_RPI.](https://github.com/gavinlyonsrepo/Display_Lib_RPI) created for a user request.\n\n## Installation\n\n1. Install the dependency bcm2835 Library if not installed\n\t* Install the C libraries of bcm2835, [Installation instructions here](http://www.airspayce.com/mikem/bcm2835/)\n\t* Assuming Latest version is 1.75(03-2025)) open a terminal  Run following command to download and install\n```sh\ncurl -sL http://www.airspayce.com/mikem/bcm2835/bcm2835-1.75.tar.gz | tar xz \ncd bcm2835-1.75\n./configure\nmake\nsudo make check\n```\n\n2. Download the ST7789_TFT_RPI library\n\t* Open a Terminal in a folder where you want to download,build \u0026 test library\n\t* Run following command to download latest release from github.\n\n```sh\ncurl -sL https://github.com/gavinlyonsrepo/ST7789_TFT_RPI/archive/1.0.2.tar.gz | tar xz\n```\n\n3. Run 'make' and 'sudo make install' to run the makefile to build and then install library. \n\t* It will be installed to usr/local/lib and usr/local/include by default. \n\t* You can run 'make help' here to see other make options(uninstall etc).\n\n```sh\ncd ST7789_TFT_RPI-1.0.2\nmake\nsudo make install\n```\n\n## Test\n\n1. Next step is to test your display and installed library with the included test example files, connect display.\n2. Enter the example folder.\n3. Edit the makefile in that folder to select the example file path.\n\t\tSimply edit \"SRC\" variable at top of the makefile. In the \"User SRC directory Option Section\" at top of file.\n\t\tPick an example \"SRC\" directory path and One ONLY.\n5. Run 'make' commmand. This builds the examples file using the just installed library,\n\t\tand creates a test executable file in \"Bin\".\n6. Run 'make run' to run that built executable file. \n\tThis wraps \"sudo\" as the bcm2835 requires root permissions by default.\n7. User should now see the test routine in that file running on the display. Run 'make help' to see other options.\n\n```sh\ncd examples\nmake\nmake run\n```\n\n## Documentation\n\n### Fonts\n\nThe font system readme for the graphic displays is in the 'doc' folder [at link.](extra/doc/fonts/README.md)\n\n## Software\n\n### User options\n\nIn the example files. There are 3 sections in \"Setup()\" function \nwhere user can make adjustments to select for SPI type used, and screen size.\n\n1. USER OPTION 1 GPIO/SPI TYPE\n2. USER OPTION 2 SCREEN SECTION \n3. USER OPTION 3 SPI SPEED , SPI_CE_PIN\n\n*USER OPTION 1 SPI TYPE / GPIO*\n\nThis library supports both Hardware SPI and software SPI.\nThe SetupGPIO function is overloaded(2 off one for HW SPI the other for SW SPI).\nThe parameters set for SetupGPIO define which is used.\nHW SPI is far faster and more reliable than SW SPI\n\n*USER OPTION 2 Screen size  + Offsets*\n\nUser can adjust screen pixel height, screen pixel width and x \u0026 y screen offsets.\nThese offsets can be used in the event of screen damage or manufacturing errors around edge \nsuch as cropped data or defective pixels.\nThe function InitScreenSize sets them.\n\n*USER OPTION 3  SPI SPEED , SPI_CE_PIN*\n\nInitSPI function is overloaded(3 off)\n\n1. Hardware SPI 0 \n2. Hardware SPI 1(aux)\n3. Software SPI\n\nParam SPI_Speed (HW SPI Only)\n\nHere the user can pass the SPI Bus freq in Hertz,\nMaximum 125 Mhz , Minimum 30Khz, The default in file is 8Mhz \nAlthough it is possible to select high speeds for the SPI interface, up to 125MHz,\nDon't expect any speed faster than 32MHz to work reliably.\nIf you set to 0 .Speed is set to bcm2835 constant BCM2835_SPI_CLOCK_DIVIDER_32.\n\nParam SPI_CE_PIN (HW SPI 0 Only)\n\nNote if using Hardware SPI 1(aux) the SPI_CE_PIN is fixed, no choice.\n\nWhich Chip enable pin to use two choices.\n\t* SPICE0 = 0\n\t* SPICE1 = 1\n\nParam SPI_CommDelay (SW SPI Only)\n\nThe user can adjust If user is having reliability issues with SW SPI in some setups.\nThis is a microsecond delay in SW SPI GPIO loop. It is set to 0 by default, Increasing it will slow \ndown SW SPI further.\n\n### File system\n\nIn example folder:\nThe Main.cpp file contains tests showing library functions.\nA bitmap data file contains data for bi-color bitmaps and icons tests.\nThe color bitmaps used in testing are in bitmap folder.\nExamples are set up for 90 degree rotation for a 240X320 display.\n\n| # | example file name  | Description|\n| ------ | ------ |  ------ |\n| 1 | Hello_world_HWSPI_0 | Basic use case hardware spi 0 |\n| 2 | Hello_world_HWSPI_1 | Basic use case hardware spii 1 (aux)|\n| 3 | Hello_world_SWSPI | Basic use case software spi|\n| 4 | Text_Graphic_Functions | Tests text,graphics \u0026 function testing  |\n| 5 | Bitmap_Tests | bitmaps display |\n| 6 | Frame_rate_test_bmp | Frame rate per second (FPS) bitmaps |\n| 7 | Frame_rate_test_two | Frame rate per second (FPS) text and graphics |\n\nThere are 2 makefiles.\n\n1. Root directory, builds and installs library at a system level.\n2. Example directory  builds a chosen example file using installed library to an executable.\nwhich can then be run.\n\nLibrary naming :\n\n1. Library name = librpist7789gl\n2. Linker flags for complier = -lrpist7789gl (also needs -lbcm2835 for bcm2835 library)\n3. Library File suffix  = RVL\n4. Project name = ST7789_TFT_RPI\n\n### Tool chain\n\n* Development Tool chain.\n\t1. Raspberry PI 3 model b ( will not work on RPi 5 see notes)\n\t2. C++, g++ (Debian 12.2.0)\n\t3. Raspbian , Debian 12 bookworm OS, 64 bit.\n\t4. kernel : aarch64 Linux 6.1.0-rpi7-rpi-v8\n\t5. bcm2835 Library v1.75 dependency.\n\n## Hardware\n\nTested and developed on:\n\n* Size 1.69\" IPS color TFT LCD\n* Resolution: 240 (H) RGB x 280 (V) \n* Control chip: st7789v2\n* Display area 27.972 (H) x 32.634 (V)\n* Panel size 30.07 (H) x37.43 (V) x1.56 (d)\n* Logic voltage 3.3V\n\nConnections as setup in main.cpp test file.\n\n| TFT PinNum | Pindesc | RPI HW SPI 0 | RPI SW SPI | RPI HW SPI 1 Aux |\n| --- | --- | --- | --- |  --- |\n| 1 | LED | VCC |  VCC |  VCC |\n| 2 | SS/CS | GPIO8 SPI_CE0 | GPI12 | GPIO16  SPI_AUX_CE2 |\n| 3 | DC | GPIO24 | GPIO24  | GPIO24|\n| 4 | RESET | GPI025  | GPIO25 | GPIO25 |\n| 5 | SDA | GPIO10 SPI_MOSI | GPIO19 | GPIO20 SPI_AUX_MOSI |\n| 6 | SCLK | GPIO11 SPI_CLK | GPIO26 | GPIO21 SPI_AUX_CLK|\n| 7 | VCC | VCC | VCC  |  VCC |\n| 8 | GND | GND | GND | GND |\n\n1. Connect LED backlight pin 1 thru a resistor to VCC.\n2. This is a 3.3V logic device do NOT connect the I/O logic lines to 5V logic device.\n3. Pick any GPIO you want for SW SPI, for HW SPI: reset and DC lines are flexible.\n4. User can select  SPI_CE0  or SPI_CE1 for HW SPI 0\n5. Backlight control is left to user.\n\n## Output\n\n[![output pic](https://github.com/gavinlyonsrepo/Display_Lib_RPI/blob/main/extra/images/st7789output.jpg)](https://github.com/gavinlyonsrepo/Display_Lib_RPI/blob/main/extra/images/st7789output.jpg)\n\n## Notes\n\n### Multiple SPI devices\n\nWhen using hardware SPI for multiple devices on the bus.\nIf the devices require different SPI settings (speed of bus, bit order , chip enable pins , SPI data mode).\nThe user must call function **TFTSPIHWSettings()** before each block of SPI transactions for display in order to refresh the SPI hardware settings for that device. See github [issue #1](https://github.com/gavinlyonsrepo/Display_Lib_RPI/issues/1).\n\n### Raspberry Pi five\n\nWill not work on Raspberry 5 at present as the bcm2835 Library dependency is not updated\nto work yet on Rpi5.\n\n### Display offsets\n\nThe display initialisation requires an offset calculation which differs for different size and resolution displays.\nThis is in the code(Function AdjustWidthHeight()) but the many different size displays are not available for testing or dealt with.\nIf using a display other than 240x320(the default and size of ST7789 VRAM) and if user finds they cannot address all screen\nor their data is offset. Try Setting the pixel width and height of your screen to 240X320 and do not write as \nmuch as possible to the part of the Video RAM you cannot see.\nFor example  if you have a 240X280 display in 0 degree rotation\n1. Set pixel Width = 240 and pixel height = 320\n2. Do not write to the missing 40 pixels in the Y-axis, you still can but it is inefficient.\n\n### Hardware spi aux\n\nSupport for SPI 1 port is included, however the measured frame rate on this port \nis ~50% less than SPI 0 for reasons unknown at time of writing (unrelated to library code).\nSee Frame rate test results file in 'docs'.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavinlyonsrepo%2Fst7789_tft_rpi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgavinlyonsrepo%2Fst7789_tft_rpi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavinlyonsrepo%2Fst7789_tft_rpi/lists"}