[已解决] 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

fsyzty
Posts: 7
Joined: Wed Dec 22, 2021 7:43 am

[已解决] 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

Postby fsyzty » Wed Dec 22, 2021 7:57 am

抱歉把Arduino的内容发在这个版块了.
在Arduino的示例中LITTLEFS_test.ino SPIFFS_Test.ino FFat_Test.ino已经测试成功, 并且使用ESP32 Sketch Data Upload 可以上传文件到对应的分区.
但是怎样在lv_conf.h中怎样配置这些选项
#define LV_USE_FS_STDIO '\0' /*Uses fopen, fread, etc*/
//#define LV_FS_STDIO_PATH "/home/john/" /*Set the working directory. If commented it will be "./" */

#define LV_USE_FS_POSIX '\0' /*Uses open, read, etc*/
//#define LV_FS_POSIX_PATH "/home/john/" /*Set the working directory. If commented it will be "./" */

#define LV_USE_FS_WIN32 '\0' /*Uses CreateFile, ReadFile, etc*/
//#define LV_FS_WIN32_PATH "C:\\Users\\john\\" /*Set the working directory. If commented it will be ".\\" */

#define LV_USE_FS_FATFS '\0' /*Uses f_open, f_read, etc*/
或者是要修改lv_port_fs.h来实现访问SPIFFS或者LITTLEFS分区文件的目的?
希望得到你们的指点,谢谢!

fsyzty
Posts: 7
Joined: Wed Dec 22, 2021 7:43 am

Re: 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

Postby fsyzty » Mon Dec 27, 2021 1:31 pm

摸索了很多天, 答案很简单:
1.ino中

........
if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED,"/LFS")){
Serial.println("LittleFS Mount Failed");
return;
}
........
加载到/LFS目录.
2.lv_conf.h中
......
#define LV_USE_FS_STDIO 'S' /*Uses fopen, fread, etc*/
#define LV_FS_STDIO_PATH "/LFS/" /*Set the working directory. If commented it will be "./" */
......
3.ino中加载文件:
......
lv_obj_t * img1;
img1 = lv_img_create(lv_scr_act());
lv_img_set_src(img1, "S:wink.png");
lv_obj_align(img1, LV_ALIGN_RIGHT_MID, -20, 0);
......
4.ESP32 Sketch Data Upload上次data目录里面的wink.png到esp32.


一直用LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)尝试,搞不懂为啥一定要加载到目录中.
LFS可改为其他字符.

ESP_ICY
Posts: 404
Joined: Mon Aug 23, 2021 11:10 am

Re: [已解决] 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

Postby ESP_ICY » Tue Dec 28, 2021 3:16 am

感谢您的经验分享

Xin888
Posts: 11
Joined: Wed Dec 15, 2021 8:08 am

Re: [已解决] 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

Postby Xin888 » Tue Dec 28, 2021 4:23 am

楼主有完整源码分享吗, 我最近也一直研究这个,始终不成功,直到看到了你的帖子,大赞!

fsyzty
Posts: 7
Joined: Wed Dec 22, 2021 7:43 am

Re: [已解决] 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

Postby fsyzty » Tue Dec 28, 2021 8:05 am

@Xin888 等级不够没法回私信. 中文字库我也没成功.
data放了一个43.2K的字库,结果esp32反复重启.

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1420
ho 0 tail 12 room 4
load:0x40078000,len:13540
load:0x40080400,len:3604
entry 0x400805f0
Hello Arduino! V8.1.0
I am LVGL_Arduino
[Error] (1.415, +1415) lv_mem_alloc: couldn't allocate memory (1710 bytes) (in lv_mem.c line #138)
[Error] (1.416, +1) lv_mem_alloc: used: 48116 ( 98 ), frag: 20 , biggest free: 832 (in lv_mem.c line #143)
Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.

Core 1 register dump:
PC : 0x40085bcc PS : 0x00060b30 A0 : 0x80111d80 A1 : 0x3ffb2620
A2 : 0x00000000 A3 : 0x3ffb3180 A4 : 0x000006ae A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00a50000 A8 : 0x000000a5 A9 : 0x3ffb25e0
A10 : 0x3ffb260c A11 : 0x00000002 A12 : 0x00060320 A13 : 0xffffffff
A14 : 0x00000000 A15 : 0x00000072 SAR : 0x00000010 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x40085bc5 LEND : 0x40085be7 LCOUNT : 0x00000069


Backtrace:0x40085bc9:0x3ffb26200x40111d7d:0x3ffb2630 0x40111dc5:0x3ffb2670 0x400e3a66:0x3ffb2690 0x40120ac5:0x3ffb26b0 0x400ef1de:0x3ffb26e0 0x400ef84e:0x3ffb2720 0x400d2436:0x3ffb27b0 0x400feebe:0x3ffb2820

Xin888
Posts: 11
Joined: Wed Dec 15, 2021 8:08 am

Re: [已解决] 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

Postby Xin888 » Tue Dec 28, 2021 9:48 am

我的错误好像与你一致, 也不知道是什么问题 (并且反复重启)
esp32_lvgl_外部字体错误.png
esp32_lvgl_外部字体错误.png (36.53 KiB) Viewed 19621 times

fsyzty
Posts: 7
Joined: Wed Dec 22, 2021 7:43 am

Re: [已解决] 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

Postby fsyzty » Tue Dec 28, 2021 11:39 am

参考这个能显示汉字,
https://hellobug.blog.csdn.net/article/ ... /119411924
显示很慢......

1.字库.C修改:
static uint8_t __g_font_buf[144];
static lv_fs_file_t font_f;
static lv_fs_res_t font_res;
static uint32_t font_resCount;
static uint8_t fontisopen = 0;

static uint8_t *__user_font_getdata(int offset,int size){
if (fontisopen==0){

font_res = lv_fs_open(&font_f,"A:/NotoSans_20.bin",LV_FS_MODE_RD);

fontisopen = 1;
}

lv_fs_seek( &font_f , offset ,LV_FS_SEEK_SET);

font_res = lv_fs_read(&font_f , __g_font_buf, size, &font_resCount);
//lv_fs_close(&font_f);//.关闭文件
return __g_font_buf;
}


2.lv_conf.h添加
#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(NotoSans_20)
#define LV_USE_FS_STDIO 'A' /*Uses fopen, fread, etc*/
#define LV_FS_STDIO_PATH "/LFS/" /*Set the working directory. If commented it will be "./" */

3.ino内:

/* Create simple label */
lv_obj_t *label = lv_label_create( lv_scr_act() );
lv_label_set_recolor(label, true);
lv_label_set_text( label, "#0000ff Hello Arduino! 中文测试#(V8.0.X)" );
lv_obj_set_style_text_font(label, &NotoSans_20, 0);
lv_obj_align( label, LV_ALIGN_CENTER, 0, 0 );

字体文件是NotoSans_20.bin, NotoSans_20.c, 字体名 NotoSans_20

Xin888
Posts: 11
Joined: Wed Dec 15, 2021 8:08 am

Re: [已解决] 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

Postby Xin888 » Tue Dec 28, 2021 12:53 pm

你这个是SD卡还SPIFFS文件系统上的?

Xin888
Posts: 11
Joined: Wed Dec 15, 2021 8:08 am

Re: [已解决] 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

Postby Xin888 » Tue Dec 28, 2021 12:54 pm

fsyzty wrote:
Tue Dec 28, 2021 11:39 am
参考这个能显示汉字,
https://hellobug.blog.csdn.net/article/ ... /119411924
显示很慢......

1.字库.C修改:
static uint8_t __g_font_buf[144];
static lv_fs_file_t font_f;
static lv_fs_res_t font_res;
static uint32_t font_resCount;
static uint8_t fontisopen = 0;

static uint8_t *__user_font_getdata(int offset,int size){
if (fontisopen==0){

font_res = lv_fs_open(&font_f,"A:/NotoSans_20.bin",LV_FS_MODE_RD);

fontisopen = 1;
}

lv_fs_seek( &font_f , offset ,LV_FS_SEEK_SET);

font_res = lv_fs_read(&font_f , __g_font_buf, size, &font_resCount);
//lv_fs_close(&font_f);//.关闭文件
return __g_font_buf;
}


2.lv_conf.h添加
#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(NotoSans_20)
#define LV_USE_FS_STDIO 'A' /*Uses fopen, fread, etc*/
#define LV_FS_STDIO_PATH "/LFS/" /*Set the working directory. If commented it will be "./" */

3.ino内:

/* Create simple label */
lv_obj_t *label = lv_label_create( lv_scr_act() );
lv_label_set_recolor(label, true);
lv_label_set_text( label, "#0000ff Hello Arduino! 中文测试#(V8.0.X)" );
lv_obj_set_style_text_font(label, &NotoSans_20, 0);
lv_obj_align( label, LV_ALIGN_CENTER, 0, 0 );

字体文件是NotoSans_20.bin, NotoSans_20.c, 字体名 NotoSans_20

你这个是SD卡上的,还是SPIFFS的?

fsyzty
Posts: 7
Joined: Wed Dec 22, 2021 7:43 am

Re: [已解决] 请问在Arduino中怎样配置LVGL8.1.0访问spiffs里面的字库或图片?

Postby fsyzty » Tue Dec 28, 2021 1:09 pm

不是SD卡. SPIFFS分区.

Who is online

Users browsing this forum: No registered users and 101 guests