Skip to content

Instantly share code, notes, and snippets.

@wildestpixel
Created February 6, 2021 18:42
Show Gist options
  • Save wildestpixel/70208a0581d30bcee7b328a408e4ef9c to your computer and use it in GitHub Desktop.
Save wildestpixel/70208a0581d30bcee7b328a408e4ef9c to your computer and use it in GitHub Desktop.
Pimoroni Pico Display Pack Circuitpython 6.2b1 bitmap gradient
"""
adapted from http://helloraspberrypi.blogspot.com/2021/01/raspberry-pi-picocircuitpython-st7789.html
"""
import os
import board
import time
import terminalio
import displayio
import busio
from adafruit_display_text import label
import adafruit_st7789
print("==============================")
print(os.uname())
print("Hello Raspberry Pi Pico/CircuitPython ST7789 SPI IPS Display")
print(adafruit_st7789.__name__ + " version: " + adafruit_st7789.__version__)
print()
# Release any resources currently in use for the displays
displayio.release_displays()
tft_cs = board.GP17
tft_dc = board.GP16
#tft_res = board.GP23
spi_mosi = board.GP19
spi_clk = board.GP18
spi = busio.SPI(spi_clk, MOSI=spi_mosi)
display_bus = displayio.FourWire(
spi, command=tft_dc, chip_select=tft_cs
)
display = adafruit_st7789.ST7789(display_bus,
width=135, height=240,
rowstart=40, colstart=53)
display.rotation = 270
group = displayio.Group(max_size=10)
display.show(group)
bitmap = displayio.Bitmap(240, 135, 135)
palette = displayio.Palette(135)
for p in range(135):
palette[p] = (0x010000*p) + (0x0100*p) + p
for y in range(135):
for x in range(240):
bitmap[x,y] = y
tileGrid = displayio.TileGrid(bitmap, pixel_shader=palette, x=0, y=0)
group.append(tileGrid)
time.sleep(3.0)
while True:
for p in range(135):
palette[p] = p
time.sleep(3.0)
for p in range(135):
palette[p] = 0x0100 * p
time.sleep(3.0)
for p in range(135):
palette[p] = 0x010000 * p
time.sleep(3.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment