-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Hi
I got CYD (cheap yellow display). I did build the micropython (the official one) and below code work. When I use the same step to build lvgl_micropython (this repo). It failed to run, why?
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't create 'SPI' instances
from machine import Pin, SPI
from ili9341 import Display, color565
import time
# Initialize SPI for ILI9341 display
display_spi = SPI(1, baudrate=60000000, sck=Pin(14), mosi=Pin(13))
display = Display(display_spi, dc=Pin(2), cs=Pin(15), rst=Pin(15), width=320, height=240, rotation=90)
# Turn on backlight
backlight = Pin(21, Pin.OUT)
backlight.on()
# Clear display (white background)
display.clear(color565(255, 255, 255))
# Animation parameters
rect_width = 30
rect_height = 30
x = 0
y = 0
dx = 6 # Increased speed
dy = 6 # Increased speed
rect_color = color565(255, 0, 0) # Red rectangle
bg_color = color565(255, 255, 255) # White background
# Animation loop
while True:
# Clear previous rectangle (minimize cleared area)
display.fill_rectangle(x, y, rect_width, rect_height, bg_color)
# Update position
x += dx
y += dy
# Bounce off edges
if x <= 0 or x >= 320 - rect_width:
dx = -dx
if y <= 0 or y >= 240 - rect_height:
dy = -dy
# Draw new rectangle
display.fill_rectangle(x, y, rect_width, rect_height, rect_color)
# Reduced delay for faster animation
time.sleep(0.02) # ~50 FPS
thanks
Peter
Metadata
Metadata
Assignees
Labels
No labels