bablokb / pico-st7735

Pico display library for the ST7735
23 stars 8 forks source link

ST7735 TFT-Library for the Raspberry Pi Pico

Status

The code compiles and runs. It was tested with a no-name 1.8" TFT with 128x160 pixel.

Overview

This is a port of the Adafruit's ST7735-library for the Pi Pico. The code is a copy of https://github.com/gavinlyonsrepo/pic_16F18346_projects with some added features (TFT_ENABLE_*-defines, rotation) and some modifications.

The code was developed for PIC MCUs, but porting it to the Pico was straightforward.

The library-code is in directory lib-st7735. A demo and test-program is in another repository https://github.com/bablokb/pico-st7735-demo.

You can build, run and debug as you do with other projects from within VS-Code, the editor automagically detects that the executable is within a subdirectory instead of within the top-level dir.

Library-configuration

The library has many functions and to keep the footprint small, you must selectively include only the features you need. Currently, the library supports the following #defines, which you should set in the CMakeLists.txt:

Fonts

The ST7735-library uses a small standard-font, which is impossible to read unless you are really near the screen. You can scale the font, but the result is ugly.

The solution to the problem are glyph-fonts. They take up a lot of space, too much for most MCUs, but since the Pico has a lot of flash, this is no problem here.

This repository only distributes a single glyph-font lib-st7735/include/FreeMonoOblique12pt7b.h, others are available from the original Adafruit project https://github.com/adafruit/Adafruit-GFX-Library/.

To use these fonts, you need to #define TFT_ENABLE_FONTS and set the font before drawing text. See Test9() in the demo-program for an example.

Font-Subsets

Very often, a complete font is not necessary. The project https://github.com/bablokb/pic-st7735 provides a utility to create a subset of the font only with the necessary characters in the subdirectory fc_subset. You should read complete instructions in the above mentioned Adafruit-GFX-library repo (subdirectory fontconvert).

Handling of subsets needs some care, see Test9A() for an example. Since the Pico has a lot of memory, it is usually better to use the complete fonts.