pimoroni-pico/drivers/st7789
Phil Howard 5510c82564 PicoDisplay: Fix rotation offset for #562.
Pico Display would have a pixel offset at 90 and 180 degree rotations.

Add a special case offset tweak for these, and demystify the rotate_180 variable.
2024-04-17 12:44:40 +01:00
..
CMakeLists.txt Cleaner RASET, CASET and MADCTL handling 2021-03-29 13:18:31 +01:00
README.md ST7789/PicoGraphics: Update docs. 2022-06-13 20:12:03 +01:00
st7789.cmake ST7789: Convert Parallel IO to PIO + DMA. 2022-06-17 11:03:55 +01:00
st7789.cpp PicoDisplay: Fix rotation offset for #562. 2024-04-17 12:44:40 +01:00
st7789.hpp Wrap pio.h includes in NO_QSTR so a fresh Micropython build doesn't fall over. 2023-09-08 18:59:25 +01:00
st7789_parallel.pio ST7789: Convert Parallel IO to PIO + DMA. 2022-06-17 11:03:55 +01:00

README.md

ST7789 Display Driver for Pimoroni LCDs

The ST7789 driver supports both Parallel and Serial (SPI) ST7789 displays and is intended for use with:

  • Pico Display
  • Pico Display 2.0
  • Tufty 2040
  • Pico Explorer
  • 240x240 Round & Square SPI LCD Breakouts

Setup

Construct an instance of the ST7789 driver with either Parallel or SPI pins.

Parallel:

ST7789 st7789(WIDTH, HEIGHT, ROTATE_0, {
    Tufty2040::LCD_CS,   // Chip-Select
    Tufty2040::LCD_DC,   // Data-Command
    Tufty2040::LCD_WR,   // Write
    Tufty2040::LCD_RD,   // Read
    Tufty2040::LCD_D0,   // Data 0 (start of a bank of 8 pins)
    Tufty2040::BACKLIGHT // Backlight
});

SPI:

ST7789 st7789(WIDTH, HEIGHT, ROTATE_0, false, {
    PIMORONI_SPI_DEFAULT_INSTANCE, // SPI instance
    SPI_BG_FRONT_CS,               // Chip-select
    SPI_DEFAULT_SCK,               // SPI Clock
    SPI_DEFAULT_MOSI,              // SPI Out
    PIN_UNUSED,                    // SPI In
    SPI_DEFAULT_DC,                // SPI Data/Command
    PIN_UNUSED                     // Backlight
});

Reference

Update

ST7789's update accepts an instance of PicoGraphics in any colour mode:

st7789.update(&graphics);

Set Backlight

If a backlight pin has been configured, you can set the backlight from 0 to 255:

st7789.set_backlight(128)