User avatar
mytechnotalent
Posts: 15
Joined: Thu Feb 18, 2021 7:25 pm
Location: Washington, D.C.
Contact: Twitter

TFT ST7735 Raspberry Pi Pico C Driver

Sun Feb 28, 2021 5:59 pm

Is anyone aware of a TFT ST7735 Raspberry Pi Pico C driver available for the Pico using C? I have one for MicroPython however I wanted to use this with the C SDK but I can't seem to find any.

Any information and/or with a simple code example would be helpful. Thanks in advance.
Kevin Thomas
Senior Software Engineer in Test

User avatar
HermannSW
Posts: 4017
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: TFT ST7735 Raspberry Pi Pico C Driver

Mon Mar 01, 2021 1:56 am

Pico not mentioned, but Raspberry.
ST7735S and C:
https://github.com/michal037/driver-ST7735S
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/raspiraw
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
mytechnotalent
Posts: 15
Joined: Thu Feb 18, 2021 7:25 pm
Location: Washington, D.C.
Contact: Twitter

Re: TFT ST7735 Raspberry Pi Pico C Driver

Mon Mar 01, 2021 2:39 am

HermannSW wrote:
Mon Mar 01, 2021 1:56 am
Pico not mentioned, but Raspberry.
ST7735S and C:
https://github.com/michal037/driver-ST7735S
Thank you HermannSW! I will see what I can do but this is based on the WiringPi lib that I am not sure will compile inside of the Pico as it is a microcontroller with limited memory.
Kevin Thomas
Senior Software Engineer in Test

User avatar
tipam
Posts: 115
Joined: Fri Dec 30, 2011 1:32 pm

Re: TFT ST7735 Raspberry Pi Pico C Driver

Thu Apr 15, 2021 4:53 pm

Thank you HermannSW! I will see what I can do but this is based on the WiringPi lib that I am not sure will compile inside of the Pico as it is a microcontroller with limited memory.
Did you get the driver working for the Pico?
Raspberry Pi == small computer == big dreams

martinkooij
Posts: 53
Joined: Sun Feb 28, 2021 5:22 pm
Location: The Netherlands

Re: TFT ST7735 Raspberry Pi Pico C Driver

Thu Apr 15, 2021 5:49 pm

In the community libraries above I have a reference to HAL drivers that mentions your display as being tested...

https://github.com/tuupola/hagl_pico_mipi

I haven't used it myself. Just a pointer...

Have fun tinkering!
Martin

User avatar
tipam
Posts: 115
Joined: Fri Dec 30, 2011 1:32 pm

Re: TFT ST7735 Raspberry Pi Pico C Driver

Fri Apr 16, 2021 9:55 pm

martinkooij wrote:
Thu Apr 15, 2021 5:49 pm
In the community libraries above I have a reference to HAL drivers that mentions your display as being tested...

https://github.com/tuupola/hagl_pico_mipi

I haven't used it myself. Just a pointer...

Have fun tinkering!
Martin
Thanks! I'll tinker!!
Raspberry Pi == small computer == big dreams

User avatar
mytechnotalent
Posts: 15
Joined: Thu Feb 18, 2021 7:25 pm
Location: Washington, D.C.
Contact: Twitter

Re: TFT ST7735 Raspberry Pi Pico C Driver

Fri Apr 16, 2021 11:04 pm

No luck.
Kevin Thomas
Senior Software Engineer in Test

User avatar
tipam
Posts: 115
Joined: Fri Dec 30, 2011 1:32 pm

Re: TFT ST7735 Raspberry Pi Pico C Driver

Fri Apr 16, 2021 11:32 pm

mytechnotalent wrote:
Fri Apr 16, 2021 11:04 pm
No luck.
Works a treat with a cheap 128x160 LCD (st7735)!
Frame-rate averaging around 40+ FPS for the demos:

Image
(right click image and open in new tab to view)

Had to do a bit of fiddling though ... on my RPi I opened a terminal win and entered the following;
(I am assuming that CMake is already installed)

Code: Select all

git clone https://github.com/tuupola/pico_effects.git
git clone https://github.com/raspberrypi/pico-sdk.git
cd pico-effects/external
git clone https://github.com/tuupola/hagl_pico_mipi.git hagl_hal
git clone https://github.com/tuupola/hagl.git
cd ..
cmake ..
cd build
make
(Note: I didn't use tuupola's instructions as I had permission issues!)

I then encountered an error when making the project - it seems as though passing a 'uint64_t' to the timer function 'busy_wait_until' is no longer valid (line 210 in 'main.c' of pico-effects)

I changed the code to read:

Code: Select all

absolute_time_t updatetime;
update_us_since_boot(&updatetime, start + US_PER_FRAME_60_FPS);
busy_wait_until(updatetime);
Lastly, I reconfigured the 'CMakeLists.txt' in the pico-effects folder with the following changes for my particular ST7735 160x128 screen ...

Code: Select all

target_compile_definitions(firmware PRIVATE
  MIPI_DISPLAY_PIN_RST=21
  MIPI_DISPLAY_WIDTH=128
  MIPI_DISPLAY_HEIGHT=160
  MIPI_DISPLAY_DEPTH=16
  MIPI_DISPLAY_OFFSET_X=0
  MIPI_DISPLAY_OFFSET_Y=0
  MIPI_DISPLAY_INVERT=0
)
I then rebuilt with 'make' and a 'firmware.uf2' appeared in the build folder :D

Oh, and I used the following GPIO pins on my Pico connecting to my screen;

Code: Select all

Pico      Screen
  Pin 21 = RST
  Pin 19 = SDA (MOSI)
  Pin 18 = SCL (CLK)
  Pin 17 = CS
  Pin 16 = DC
  3v3_OUT = VCC
  GND = GND
I hope that helps!

TIP: If you want to change the image, upload a small image (around 80x80 in size) to https://lvgl.io/tools/imageconverter and download a 'c array' ... select the '16 && LV_COLOR_16_SWAP != 0' byte section and paste into the head.h file (with correct width and height)
Raspberry Pi == small computer == big dreams

tuupola
Posts: 11
Joined: Tue Mar 02, 2021 9:03 pm
Contact: Website

Re: TFT ST7735 Raspberry Pi Pico C Driver

Sun Apr 18, 2021 10:47 am

tipam wrote:
Fri Apr 16, 2021 11:32 pm
Had to do a bit of fiddling though ... on my RPi I opened a terminal win and entered the following;
(I am assuming that CMake is already installed)

Code: Select all

git clone https://github.com/tuupola/pico_effects.git
git clone https://github.com/raspberrypi/pico-sdk.git
cd pico-effects/external
git clone https://github.com/tuupola/hagl_pico_mipi.git hagl_hal
git clone https://github.com/tuupola/hagl.git
cd ..
cmake ..
cd build
make
(Note: I didn't use tuupola's instructions as I had permission issues!)

I think you do not have ssh keys set up for GitHub? I changed the instructions to use https based cloning which should work without ssh keys. The following should work now:

Code: Select all

$ git clone --recursive https://github.com/tuupola/pico_effects.git
tipam wrote:
Fri Apr 16, 2021 11:32 pm
I then encountered an error when making the project - it seems as though passing a 'uint64_t' to the timer function 'busy_wait_until' is no longer valid (line 210 in 'main.c' of pico-effects)

I changed the code to read:

Code: Select all

absolute_time_t updatetime;
update_us_since_boot(&updatetime, start + US_PER_FRAME_60_FPS);
busy_wait_until(updatetime);

Did you compile without NDEBUG flag? Pico SDK has different datatypes for time related functions depending on whether NDEBUG is set or not.Or maybe something has changed with the SDK recently, will check.
--
Mika Tuupola
https://appelsiini.net/

User avatar
tipam
Posts: 115
Joined: Fri Dec 30, 2011 1:32 pm

Re: TFT ST7735 Raspberry Pi Pico C Driver

Sun Apr 18, 2021 11:16 am

tuupola wrote:
Sun Apr 18, 2021 10:47 am
tipam wrote:
Fri Apr 16, 2021 11:32 pm
Had to do a bit of fiddling though ... on my RPi I opened a terminal win and entered the following;
(I am assuming that CMake is already installed)

Code: Select all

git clone https://github.com/tuupola/pico_effects.git
git clone https://github.com/raspberrypi/pico-sdk.git
cd pico-effects/external
git clone https://github.com/tuupola/hagl_pico_mipi.git hagl_hal
git clone https://github.com/tuupola/hagl.git
cd ..
cmake ..
cd build
make
(Note: I didn't use tuupola's instructions as I had permission issues!)

I think you do not have ssh keys set up for GitHub? I changed the instructions to use https based cloning which should work without ssh keys. The following should work now:

Code: Select all

$ git clone --recursive https://github.com/tuupola/pico_effects.git
Fantastic! ... that's nice and simple :D
tipam wrote:
Fri Apr 16, 2021 11:32 pm
I then encountered an error when making the project - it seems as though passing a 'uint64_t' to the timer function 'busy_wait_until' is no longer valid (line 210 in 'main.c' of pico-effects)

I changed the code to read:

Code: Select all

absolute_time_t updatetime;
update_us_since_boot(&updatetime, start + US_PER_FRAME_60_FPS);
busy_wait_until(updatetime);

Did you compile without NDEBUG flag? Pico SDK has different datatypes for time related functions depending on whether NDEBUG is set or not.Or maybe something has changed with the SDK recently, will check.
No, I didn't compile with the NDEBUG flag - maybe that could fix it?

Thanks for you're drivers - they're great!
Last edited by tipam on Mon Apr 19, 2021 8:25 am, edited 1 time in total.
Raspberry Pi == small computer == big dreams

User avatar
mytechnotalent
Posts: 15
Joined: Thu Feb 18, 2021 7:25 pm
Location: Washington, D.C.
Contact: Twitter

Re: TFT ST7735 Raspberry Pi Pico C Driver

Sun Apr 18, 2021 11:49 am

tipam wrote:
Sun Apr 18, 2021 11:16 am
tuupola wrote:
Sun Apr 18, 2021 10:47 am
tipam wrote:
Fri Apr 16, 2021 11:32 pm
Had to do a bit of fiddling though ... on my RPi I opened a terminal win and entered the following;
(I am assuming that CMake is already installed)

Very helpful! Is there any code to actually work with text on this device as these all seem to be image libs.
Kevin Thomas
Senior Software Engineer in Test


tuupola
Posts: 11
Joined: Tue Mar 02, 2021 9:03 pm
Contact: Website

Re: TFT ST7735 Raspberry Pi Pico C Driver

Mon Apr 19, 2021 9:02 pm

tipam wrote:
Sun Apr 18, 2021 11:16 am
No, I didn't compile with the NDEBUG flag - maybe that could fix it?

I just checked and NDEBUG is set by default and code should build ok with the latest Pico SDK. I can reproduce the error only if I force the debug build with:

Code: Select all

$ git clone --recursive https://github.com/tuupola/pico_effects.git
$ cd pico_effects/build
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
$ make -j8

One possibility is that you tried to compile with old version of Pico SDK which had NDEBUG logic reversed. This was fixed mid march.
tipam wrote:
Sun Apr 18, 2021 11:16 am
Thanks for you're drivers - they're great!

Thanks :)
--
Mika Tuupola
https://appelsiini.net/

Return to “SDK”