Hi, I have a Raspberry Pi Pico, just built lv_micropython firmware successfully a few days ago.
Followed the steps in github:
But when I loaded a font at run-time, the display didn’t show anything.
I referred to this example:
lv_binding_micropython/blob/master/examples/Dynamic_loading_font_example.py
It seems that no data can be read from the SD card.
The files are stored in the /font directory of the sd card, which uses the FAT32 format.
Traceback (most recent call last):
File "<stdin>", line 52, in <module>
File "fs_driver.py", line 23, in fs_open_cb
RuntimeError: fs_open_callback(/font/font-PHT-cn-20.bin) exception: [Errno 2] ENOENT
I don’t know if I need to modify the filesystem configuration before building.
https://docs.lvgl.io/master/libs/fsdrv.html
…/lv_micropython/lib/lv_bindings/lv_conf.h
/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/
#define LV_USE_FS_FATFS 1
#if LV_USE_FS_FATFS
#define LV_FS_FATFS_LETTER 'S' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
But after I changed it like this, the build report was missing the ff.h file.
The SD card needs to be connected to the pin to read and write, but I don’t see the information of the configuration pin from the example.
What should I do if I want to run through this example?
https://docs.lvgl.io/master/widgets/label.html#show-ltr-rtl-and-chinese-texts
My code:
import sys
sys.path.append('.')
from st77xx import *
from xpt2046 import *
try:
script_path = __file__[:__file__.rfind('/')] if __file__.find('/') >= 0 else '.'
except NameError:
script_path = ''
spi=machine.SPI(
1,
baudrate=30_000_000,
polarity=0,
phase=0,
sck=machine.Pin(10,machine.Pin.OUT),
mosi=machine.Pin(11,machine.Pin.OUT),
miso=machine.Pin(12,machine.Pin.IN)
)
lcd=St7789(rot=1,res=(240,320),spi=spi,cs=9,dc=8,bl=13,rst=15,rp2_dma=None,factor=8)
lcd.set_backlight(30)
touch=Xpt2046(spi=spi,cs=16,rot=1,spiPrereadCb=lcd.rp2_wait_dma)
import lvgl as lv
lv.init()
import fs_driver
fs_drv = lv.fs_drv_t()
fs_driver.fs_register(fs_drv, 'S')
scr = lv.scr_act()
scr.clean()
myfont_cn = lv.font_load("S:%s/font/font-PHT-cn-20.bin" % script_path)
label1 = lv.label(scr)
label1.set_style_text_font(myfont_cn, 0) # set the font
label1.set_text("上中下乎")
label1.align(lv.ALIGN.CENTER, 0, 25)
I’m a newer of micropython, any response is welcome.