Skip to content

Instantly share code, notes, and snippets.

@aallan
Last active January 24, 2024 05:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aallan/2e86e36177b42c919697c9d8682e36e8 to your computer and use it in GitHub Desktop.
Save aallan/2e86e36177b42c919697c9d8682e36e8 to your computer and use it in GitHub Desktop.
Hello World example for the RP2040 1.28-inch TFT display watch board
"""
"Hello World!"
For https://www.tindie.com/products/adz1122/pi-pico-rp2040-128-inch-tft-display-watch-board/
Using GC9A01 Display Driver for MicroPython (https://github.com/russhughes/gc9a01_mpy)
DISPLAY
=======
Pin
---
GP13 Backlight (BL)
GP12 Reset (RST)
GP8 Data/Command (DC)
GP9 Chip Select (CS)
GP10 Clock (CLK)
GP11 MOSI/DIN
SWITCH
======
Pin
---
GP17 Switch 1 (S1)
GP18 Switch 2 (S2)
???? Pressing S3 appears to crash the code?
GYRO
====
This is a QMIC88658
See https://datasheet.lcsc.com/lcsc/2108161930_QST-QMI8658C_C2842151.pdf
Connected to I2C1 on the default pins
Pin
===
GP7 SCL
GP8 SDA
"""
from machine import Pin, SPI, I2C
import time
import gc9a01
import vga1_bold_16x32 as font
fg = gc9a01.color565( 255, 255, 255)
bg = gc9a01.color565( 0, 0, 0 )
spi = SPI(1, baudrate=60000000, 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.init()
tft.rotation(0)
tft.fill(0)
col_max = tft.width() - font.WIDTH*6
row_max = tft.height() - font.HEIGHT
tft.text(font, "Hello!", int(col_max/2), int(row_max/2), fg, bg )
button17 = machine.Pin(17, machine.Pin.IN, machine.Pin.PULL_UP)
button18 = machine.Pin(18, machine.Pin.IN, machine.Pin.PULL_UP)
i2c = I2C(1)
addr = i2c.scan()
print( "I2C = ", addr )
while True:
print("button17 = ", button17.value())
print("button18 = ", button18.value())
print(" ")
time.sleep(2.0)
@aallan
Copy link
Author

aallan commented Apr 26, 2023

I am using Thonny to program. I do not see a library for gc9a01 or vga1_bold_16x32. How can I get these modules installed?

See the comment in the header, "Using GC9A01 Display Driver for MicroPython (https://github.com/russhughes/gc9a01_mpy)"

@freakout242
Copy link

I saw that comment, I guess I am just to new to thonny. Can't figure out how to install a library/driver from github in it.

@dbuggz
Copy link

dbuggz commented May 6, 2023

FYI https://github.com/russhughes/gc9a01_mpy/blob/main/firmware/RP2/firmware.uf2 is Micropython v1.19.1 with the driver built in.
Just download it and copy it to the Pico drive you see when powering on with the 'boot' button pressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment