From 54f169eada4099cead953f7a234ad18ccbb66ffc Mon Sep 17 00:00:00 2001 From: Mark McGookin Date: Sat, 12 Nov 2022 23:02:06 +0000 Subject: [PATCH 1/5] Small changes to work with Circuit Python 8 Beta 4 on Raspberry Pi Pico. board.SPI didn't exist and needed to be changed to busio.SPI. The Dx reference for pins doesn't work and needs updated to be GPx (for the raspberry pi pico at least) --- examples/st7789_172x320_1.47_simpletest.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/st7789_172x320_1.47_simpletest.py b/examples/st7789_172x320_1.47_simpletest.py index 4d3133b..98a0736 100644 --- a/examples/st7789_172x320_1.47_simpletest.py +++ b/examples/st7789_172x320_1.47_simpletest.py @@ -3,25 +3,26 @@ """ This test will initialize the display using displayio and draw a solid green -background, a smaller purple rectangle, and some yellow text. +background, a smaller purple rectangle, and some yellow text.. """ import board +import busio import terminalio import displayio from adafruit_display_text import label from adafruit_st7789 import ST7789 -BORDER_WIDTH = 20 +BORDER_WIDTH = 28 TEXT_SCALE = 3 # Release any resources currently in use for the displays displayio.release_displays() -spi = board.SPI() -tft_cs = board.D5 -tft_dc = board.D6 -tft_rst = board.D9 +tft_cs = board.GP5 #board.D5 +tft_dc = board.GP6 #board.D6 +tft_rst = board.GP7 #board.D7 +spi = busio.SPI(board.GP2, board.GP3, board.GP4) display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_rst) display = ST7789(display_bus, width=320, height=172, colstart=34, rotation=270) @@ -34,12 +35,13 @@ color_palette = displayio.Palette(1) color_palette[0] = 0x00FF00 # Bright Green bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0) -splash.append(bg_sprite) +splash.append(bg_sprite) # Draw a smaller inner rectangle inner_bitmap = displayio.Bitmap( display.width - (BORDER_WIDTH * 2), display.height - (BORDER_WIDTH * 2), 1 ) + inner_palette = displayio.Palette(1) inner_palette[0] = 0xAA0088 # Purple inner_sprite = displayio.TileGrid( @@ -50,7 +52,7 @@ # Draw a label text_area = label.Label( terminalio.FONT, - text="Hello World!", + text="Hello World!!", color=0xFFFF00, scale=TEXT_SCALE, anchor_point=(0.5, 0.5), From 2b22b10ab4c37129ffd5cdabb5ab473cef39ab70 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 21 Nov 2022 11:04:11 -0600 Subject: [PATCH 2/5] code format --- examples/st7789_172x320_1.47_simpletest.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/st7789_172x320_1.47_simpletest.py b/examples/st7789_172x320_1.47_simpletest.py index 98a0736..b65b9b6 100644 --- a/examples/st7789_172x320_1.47_simpletest.py +++ b/examples/st7789_172x320_1.47_simpletest.py @@ -18,9 +18,9 @@ # Release any resources currently in use for the displays displayio.release_displays() -tft_cs = board.GP5 #board.D5 -tft_dc = board.GP6 #board.D6 -tft_rst = board.GP7 #board.D7 +tft_cs = board.GP5 # board.D5 +tft_dc = board.GP6 # board.D6 +tft_rst = board.GP7 # board.D7 spi = busio.SPI(board.GP2, board.GP3, board.GP4) display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_rst) @@ -35,7 +35,7 @@ color_palette = displayio.Palette(1) color_palette[0] = 0x00FF00 # Bright Green bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0) -splash.append(bg_sprite) +splash.append(bg_sprite) # Draw a smaller inner rectangle inner_bitmap = displayio.Bitmap( From 0dc060893c9dfdd64ea6ab385d2b8d1060749dad Mon Sep 17 00:00:00 2001 From: Mark McGookin Date: Tue, 22 Nov 2022 12:04:00 +0000 Subject: [PATCH 3/5] updated 1.47" screen simple test with Pico compatability and using busio for creating the SPI interface --- examples/st7789_172x320_1.47_simpletest.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/examples/st7789_172x320_1.47_simpletest.py b/examples/st7789_172x320_1.47_simpletest.py index b65b9b6..996365c 100644 --- a/examples/st7789_172x320_1.47_simpletest.py +++ b/examples/st7789_172x320_1.47_simpletest.py @@ -18,11 +18,21 @@ # Release any resources currently in use for the displays displayio.release_displays() -tft_cs = board.GP5 # board.D5 -tft_dc = board.GP6 # board.D6 -tft_rst = board.GP7 # board.D7 +# built-in, silkscreen labelled SPI bus +spi = busio.SPI(board.SCK, board.MOSI, board.MISO) +tft_cs = board.D5 +tft_dc = board.D6 +tft_rst = board.D9 + +# If using a Raspberry Pi Pico or Pico-w +# Uncomment the below code to use GP (General Purpose) pins +# instead of D (Digital) + +# spi = busio.SPI(board.GP2, board.GP3, board.GP4) +# tft_cs = board.GP5 +# tft_dc = board.GP6 +# tft_rst = board.GP7 -spi = busio.SPI(board.GP2, board.GP3, board.GP4) display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_rst) display = ST7789(display_bus, width=320, height=172, colstart=34, rotation=270) From fe8709648571286de79bb1fc3c5e611c62b9a1a1 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 21 Jan 2023 12:07:49 -0600 Subject: [PATCH 4/5] use builtin SPI bus. remove extra punctuation --- examples/st7789_172x320_1.47_simpletest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/st7789_172x320_1.47_simpletest.py b/examples/st7789_172x320_1.47_simpletest.py index 996365c..9fb3a59 100644 --- a/examples/st7789_172x320_1.47_simpletest.py +++ b/examples/st7789_172x320_1.47_simpletest.py @@ -3,7 +3,7 @@ """ This test will initialize the display using displayio and draw a solid green -background, a smaller purple rectangle, and some yellow text.. +background, a smaller purple rectangle, and some yellow text. """ import board import busio @@ -12,6 +12,7 @@ from adafruit_display_text import label from adafruit_st7789 import ST7789 + BORDER_WIDTH = 28 TEXT_SCALE = 3 @@ -19,7 +20,7 @@ displayio.release_displays() # built-in, silkscreen labelled SPI bus -spi = busio.SPI(board.SCK, board.MOSI, board.MISO) +spi = board.SPI() tft_cs = board.D5 tft_dc = board.D6 tft_rst = board.D9 @@ -62,7 +63,7 @@ # Draw a label text_area = label.Label( terminalio.FONT, - text="Hello World!!", + text="Hello World!", color=0xFFFF00, scale=TEXT_SCALE, anchor_point=(0.5, 0.5), From 20dc9f340ad2d892a15fd4d976bb1018c86e25d0 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 21 Jan 2023 12:13:08 -0600 Subject: [PATCH 5/5] code format. move import to apease pylint --- examples/st7789_172x320_1.47_simpletest.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/st7789_172x320_1.47_simpletest.py b/examples/st7789_172x320_1.47_simpletest.py index 9fb3a59..101113f 100644 --- a/examples/st7789_172x320_1.47_simpletest.py +++ b/examples/st7789_172x320_1.47_simpletest.py @@ -6,7 +6,6 @@ background, a smaller purple rectangle, and some yellow text. """ import board -import busio import terminalio import displayio from adafruit_display_text import label @@ -19,16 +18,17 @@ # Release any resources currently in use for the displays displayio.release_displays() -# built-in, silkscreen labelled SPI bus +# built-in, silkscreen labelled SPI bus spi = board.SPI() tft_cs = board.D5 tft_dc = board.D6 tft_rst = board.D9 -# If using a Raspberry Pi Pico or Pico-w -# Uncomment the below code to use GP (General Purpose) pins +# If using a Raspberry Pi Pico or Pico-w +# Uncomment the below code to use GP (General Purpose) pins # instead of D (Digital) +# import busio # spi = busio.SPI(board.GP2, board.GP3, board.GP4) # tft_cs = board.GP5 # tft_dc = board.GP6