Skip to content

Instantly share code, notes, and snippets.

@tsl0922
Created April 13, 2023 10:25
Show Gist options
  • Save tsl0922/e38bcd7615ecb29a62b8eecc3783bf64 to your computer and use it in GitHub Desktop.
Save tsl0922/e38bcd7615ecb29a62b8eecc3783bf64 to your computer and use it in GitHub Desktop.
LuatOS ESP32C3-CORE CircuitPython example code for 1.8 inch, 128x160, ST7735 TFT display
import time
import board
import busio
import displayio
import terminalio
from adafruit_display_text import label
from adafruit_display_shapes.rect import Rect
from adafruit_display_shapes.circle import Circle
from adafruit_display_shapes.roundrect import RoundRect
from adafruit_display_shapes.triangle import Triangle
from adafruit_st7735r import ST7735R
displayio.release_displays()
spi = busio.SPI(board.IO2, MOSI=board.IO3, MISO=board.IO10)
bus = displayio.FourWire(spi, command=board.IO6, chip_select=board.IO7, baudrate=27000000)
display = ST7735R(bus, width=128, height=160, rotation=180)
group = displayio.Group()
display.show(group)
rect = Rect(10, 10, 80, 40, fill=0x00FF00)
circle = Circle(110, 110, 10, fill=0x00FF00, outline=0xFF00FF)
triangle = Triangle(20, 70, 10, 100, 40, 140, fill=0x00FF00, outline=0xFF00FF)
roundrect = RoundRect(50, 60, 40, 80, 10, fill=0x0, outline=0xFF00FF, stroke=3)
text_area = label.Label(terminalio.FONT, text="hello", color = 0xFF00FF)
text_area.x = 20
text_area.y = 20
group.append(rect)
group.append(circle)
group.append(triangle)
group.append(roundrect)
group.append(text_area)
while True:
tm = time.localtime()
text_area.text = "Time:\n{}:{}:{}".format(tm.tm_hour, tm.tm_min, tm.tm_sec)
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment