From da7ed99c150b8ed8c4988810080a85ef36138745 Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 21 Feb 2026 14:36:44 +0800 Subject: [PATCH] Signed-off-by: kevin --- code/esp32c3_espidf/components/lvgl | 2 +- code/esp32c3_espidf/main/lv_port_fs.c | 30 ++++++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/code/esp32c3_espidf/components/lvgl b/code/esp32c3_espidf/components/lvgl index 9be768d..0a05078 160000 --- a/code/esp32c3_espidf/components/lvgl +++ b/code/esp32c3_espidf/components/lvgl @@ -1 +1 @@ -Subproject commit 9be768db427c6af5b33b0fb4d22c6b84a5acd83f +Subproject commit 0a050784550d3d38355ce5f1676315f881edfa4c diff --git a/code/esp32c3_espidf/main/lv_port_fs.c b/code/esp32c3_espidf/main/lv_port_fs.c index ed9e333..44fcec5 100644 --- a/code/esp32c3_espidf/main/lv_port_fs.c +++ b/code/esp32c3_espidf/main/lv_port_fs.c @@ -157,7 +157,9 @@ static lv_fs_res_t fs_close(lv_fs_drv_t *drv, void *file_p) lv_fs_res_t res = LV_FS_RES_NOT_IMP; - int r = fclose(file_p); + FILE *f = (FILE *)file_p; + + int r = fclose(f); if (r != 0) { @@ -192,20 +194,25 @@ static lv_fs_res_t fs_read(lv_fs_drv_t *drv, void *file_p, void *buf, uint32_t b FILE *f = (FILE *)file_p; size_t bytes_read = fread(buf, 1, btr, f); - *br = (uint32_t)bytes_read; + uint32_t bytes_read_int32 = (uint32_t)bytes_read; - if (*br == btr) + if (br != NULL) // 逆天 居然会传入NULL + { + *br = bytes_read_int32; + } + + if (bytes_read_int32 == btr) { res = LV_FS_RES_OK; } else { - ESP_LOGE(TAG, "文件读取字节数量错误需要读取%lu 已读取%lu", btr, *br); + ESP_LOGE(TAG, "文件读取字节数量错误需要读取%lu 已读取%lu", btr, bytes_read_int32); res = LV_FS_RES_UNKNOWN; } - ESP_LOGI(TAG, "文件读取字节数量:读取%lu 已读取%lu", btr, *br); + ESP_LOGI(TAG, "文件读取字节数量:读取%lu 已读取%lu", btr, bytes_read_int32); return res; } @@ -228,16 +235,19 @@ static lv_fs_res_t fs_write(lv_fs_drv_t *drv, void *file_p, const void *buf, uin FILE *f = (FILE *)file_p; size_t bytes_written = fwrite(buf, 1, btw, f); - *bw = (uint32_t)bytes_written; - - if (*bw == btw) + uint32_t bytes_written_int32 = (uint32_t)bytes_written; + if (bw != NULL) + { + *bw = bytes_written_int32; + } + if (bytes_written_int32 == btw) { res = LV_FS_RES_OK; } else { - ESP_LOGE(TAG, "文件写入字节数量错误需要写入%lu 已写入%lu", btw, *bw); + ESP_LOGE(TAG, "文件写入字节数量错误需要写入%lu 已写入%lu", btw, bytes_written_int32); res = LV_FS_RES_UNKNOWN; } @@ -257,7 +267,7 @@ static lv_fs_res_t fs_seek(lv_fs_drv_t *drv, void *file_p, uint32_t pos, lv_fs_w lv_fs_res_t res = LV_FS_RES_NOT_IMP; /*Add your code here*/ - ESP_LOGI(TAG, "fs_seek:pop%lu whence%d",pos,whence); + ESP_LOGI(TAG, "fs_seek:pop%lu whence%d", pos, whence); FILE *f = (FILE *)file_p; int std_whence;