Team2 display
[edit]
On this wiki page there is an instruction to setup the display and a Raspberry Pi Pico and run an example code, which shows a small animation on the screen.
Specifications[edit]
- Operating voltage: 3.3V/5V
- Interface: SPI
- LCD type: IPS
- Controller: GC9A01
- Resolution: 240 (H)RGB x 240(V)
- Display size: Φ32.4mm
- Pixel size: 0.135(H)x 0.135(V)mm
- Dimension: 40.4 × 37.5(mm) Φ37.5(mm)
Pinout[edit]
- VCC: Voltage at the common collector
- GND: Ground
- DIN: Data In
- CLK: Clock
- CS: Chip Select
- DC: Data command pin
- RST: Reset
- BL: Backlight
Advantages and Disadvantages[edit]
Advantages[edit]
- Cheap (~22€)
- Small and flat design
- Clock shaped
Disadvantages[edit]
- Does not work with Raspberry Pi natively, needs tinkering in that regard
- The delivered wires are very long for a smartwatch
How to get it to work[edit]
In this section the display and the Raspberry Pi Pico will be set up to work together.
Setup[edit]
Before starting, make sure you have Micropython installed on your Pi Pico and the Thonny IDE on your PC.
Boot the Pico with necessary firmware[edit]
The first step to get the display to work with the Raspberry Pi Pico is to install a GC9A01 driver on the Pico.
- Therefore you have to download firmware.uf2
- Press and hold BOOTSEL pin of Raspberry Pi Pico and connect the USB cable, it will create a drive as RPI-RP2.
- Now drag and drog/copy firmware.uf2 file from firmware folder to RPI-RP2 Drive. It will reboot your raspberry pi pico.
Wiring[edit]
You can just plug in the delivered cable into the display and this tutorial we connected the display with the Pico this way: \n LCD Pins to Pi Pico pins
- VCC to 3V3
- GND to GND
- DIN to GP11
- CLK to GP10
- CS to GP9
- DC to GP8
- RST to GP12
- BL to GP13
Example code (Flying toasts)[edit]
For this example you have to download all files except the Toaster.py from here and upload it to the Pi Pico.
Then you can copy the following file to your Pi Pico. As you can see, this code uses bitmaps to print the animations on the screen. The other files are including the position and the look of those bitmaps.
"""
toasters.py
An example using bitmap to draw sprites on the display.
Spritesheet from CircuitPython_Flying_Toasters
https://learn.adafruit.com/circuitpython-sprite-animation-pendant-mario-clouds-flying-toasters
"""
import random
from machine import Pin, SPI
import gc9a01
import t1, t2, t3, t4, t5
TOASTERS = [t1, t2, t3, t4]
TOAST = [t5]
class toast():
'''
toast class to keep track of a sprites locaton and step
'''
def __init__(self, sprites, x, y):
self.sprites = sprites
self.steps = len(sprites)
self.x = x
self.y = y
self.step = random.randint(0, self.steps-1)
self.speed = random.randint(2, 5)
def move(self):
if self.x <= 0:
self.speed = random.randint(2, 5)
self.x = 240 - 64
self.step += 1
self.step %= self.steps
self.x -= self.speed
def main():
"""
Initialize the display and draw flying toasters and toast
"""
spi = SPI(1, baudrate=40000000, sck=Pin(10), mosi=Pin(11))
tft = gc9a01.GC9A01(
spi,
240,
240,
reset=Pin(12, Pin.OUT),
cs=Pin(9, Pin.OUT),
dc=Pin(8, Pin.OUT),
backlight=Pin(13, Pin.OUT),
rotation=0)
tft.fill(gc9a01.BLACK)
# create toast spites in random positions
sprites = [
toast(TOASTERS, 240-64, 0),
toast(TOAST, 240-64*2, 80),
toast(TOASTERS, 240-64*4, 160)
]
# move and draw sprites
while True:
for man in sprites:
bitmap = man.sprites[man.step]
tft.fill_rect(
man.x+bitmap.WIDTH-man.speed,
man.y,
man.speed,
bitmap.HEIGHT,
gc9a01.BLACK)
man.move()
if man.x > 0:
tft.bitmap(bitmap, man.x, man.y)
else:
tft.fill_rect(
0,
man.y,
bitmap.WIDTH,
bitmap.HEIGHT,
gc9a01.BLACK)
main()
After uploading all required files and starting the script in the ThonnyIDE, you should see flying toast and toasters. Congratulations.