Created
April 13, 2023 10:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Author
tsl0922
commented
Apr 14, 2023
- https://circuitpython.org/board/luatos_core_esp32c3
- https://github.com/adafruit/Adafruit_CircuitPython_ST7735R
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment