Skip to content

Commit fd4c53e

Browse files
authored
Merge pull request #38 from helgibbons/main
Pimoroni Display Pack examples - show how to control backlight
2 parents b069295 + b88f46e commit fd4c53e

2 files changed

+24
-2
lines changed

examples/st7789_240x135_simpletest_Pimoroni_Pico_Display_Pack.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
22
# SPDX-License-Identifier: MIT
33

4+
"""
5+
This test will initialize the display using displayio and draw a solid green
6+
background, a smaller purple rectangle, and some yellow text.
7+
"""
48
import board
59
import busio
610
import terminalio
@@ -30,12 +34,23 @@
3034
spi_mosi = board.GP19
3135
spi_clk = board.GP18
3236
spi = busio.SPI(spi_clk, spi_mosi)
37+
backlight = board.GP20
3338

3439
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
40+
3541
display = ST7789(
36-
display_bus, rotation=270, width=240, height=135, rowstart=40, colstart=53
42+
display_bus,
43+
rotation=270,
44+
width=240,
45+
height=135,
46+
rowstart=40,
47+
colstart=53,
48+
backlight_pin=backlight,
3749
)
3850

51+
# Set the backlight
52+
display.brightness = 0.8
53+
3954
# Make the display context
4055
splash = displayio.Group()
4156
display.root_group = splash

examples/st7789_320x240_simpletest_Pimoroni_Pico_Display_2_0.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@
3232
display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
3333

3434
display = ST7789(
35-
display_bus, rotation=270, width=320, height=240, backlight_pin=backlight
35+
display_bus,
36+
rotation=270,
37+
width=320,
38+
height=240,
39+
backlight_pin=backlight,
3640
)
3741

42+
# Set the backlight
43+
display.brightness = 0.8
44+
3845
# Make the display context
3946
splash = displayio.Group()
4047
display.root_group = splash

0 commit comments

Comments
 (0)