Created
February 7, 2024 22:15
-
-
Save PGNetHun/f5cbeffd45e79b9949f4d14a1a3b1484 to your computer and use it in GitHub Desktop.
Raspberry Pi Pico W with ILI9341 display - LVGL v9 example
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 lvgl as lv | |
import fs_driver | |
if not lv.is_initialized(): | |
print("Init LVGL") | |
lv.init() | |
print("Init LVGL - DONE") | |
print("Init LVGL FS driver") | |
fs_drv = lv.fs_drv_t() | |
fs_driver.fs_register(fs_drv, 'A', 0) | |
print("Init LVGL FS driver - DONE") | |
import lv_utils | |
if lv_utils.event_loop.is_running(): | |
print("Deinit lv_utils.event_loop") | |
lv_utils.event_loop.current_instance.deinit() | |
print("Deinit lv_utils.event_loop - DONE") | |
print("Create SPI") | |
import machine | |
spi = machine.SPI( | |
0, | |
baudrate=24_000_000, | |
sck=machine.Pin(6, machine.Pin.OUT), | |
mosi=machine.Pin(7, machine.Pin.OUT) | |
) | |
print("Create SPI - DONE") | |
print("Init Ili9341") | |
import ili9xxx | |
drv = ili9xxx.Ili9341(rot=3, spi=spi, cs=13, dc=15, | |
rst=14, factor=8, doublebuffer=False) | |
print("Init Ili9341 - DONE") | |
print("Show screen") | |
screen = lv.obj() | |
print("Show label using font") | |
font = lv.binfont_create("A:KeepCalmMedium-32.font") | |
label2 = lv.label(screen) | |
label2.align(lv.ALIGN.TOP_MID, 0, 10) | |
label2.set_style_text_color(lv.color_black(), 0) | |
label2.set_style_text_font(font, 0) | |
label2.set_text("Hello World!") | |
print("Show button") | |
button = lv.button(screen) | |
button.center() | |
label = lv.label(button) | |
label.set_text("Hello World!") | |
label.center() | |
lv.screen_load(screen) | |
print("Show screen - DONE") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment