[fix][lvgl][romfs] modfiy lvgl and romfs config

This commit is contained in:
jzlv 2021-09-26 13:37:12 +08:00
parent c8b80283d1
commit b2aada479b
5 changed files with 763 additions and 756 deletions

View File

@ -1,6 +1,7 @@
################# Add global include #################
list(APPEND ADD_INCLUDE
"${CMAKE_CURRENT_SOURCE_DIR}"
${CMAKE_SOURCE_DIR}/bsp/bsp_common/mcu_lcd/
)
#######################################################

View File

@ -14,14 +14,15 @@
/* clang-format off */
#include <stdint.h>
#include "mcu_lcd.h"
/*====================
Graphical settings
*====================*/
/* Maximal horizontal and vertical resolution to support by the library.*/
#define LV_HOR_RES_MAX (240)
#define LV_VER_RES_MAX (320)
#define LV_HOR_RES_MAX (LCD_W)
#define LV_VER_RES_MAX (LCD_H)
/* Color depth:
* - 1: 1 byte per pixel
@ -98,9 +99,9 @@
/* Automatically defrag. on free. Defrag. means joining the adjacent free cells. */
#define LV_MEM_AUTO_DEFRAG 1
#else /*LV_MEM_CUSTOM*/
#define LV_MEM_CUSTOM_INCLUDE "drv_mmheap.h" /*Header for the dynamic memory function*/
#define LV_MEM_CUSTOM_ALLOC mmheap_alloc /*Wrapper to malloc*/
#define LV_MEM_CUSTOM_FREE mmheap_free /*Wrapper to free*/
#define LV_MEM_CUSTOM_INCLUDE "stdio.h" /*Header for the dynamic memory function*/
#define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/
#define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
#endif /*LV_MEM_CUSTOM*/
/* Use the standard memcpy and memset instead of LVGL's own functions.
@ -221,10 +222,10 @@
#endif
/*1: Add a `user_data` to drivers and objects*/
#define LV_USE_USER_DATA 0
#define LV_USE_USER_DATA 1
/*1: Show CPU usage and FPS count in the right bottom corner*/
#define LV_USE_PERF_MONITOR 0
#define LV_USE_PERF_MONITOR 1
/*1: Use the functions and types from the older API if possible */
#define LV_USE_API_EXTENSION_V6 1
@ -279,7 +280,7 @@
/* Attribute to mark large constant arrays for example
* font's bitmaps */
#define LV_ATTRIBUTE_LARGE_CONST
#define LV_ATTRIBUTE_LARGE_CONST const
/* Prefix performance critical functions to place them into a faster memory (e.g RAM)
* Uses 15-20 kB extra memory */
@ -388,7 +389,7 @@
#define LV_FONT_MONTSERRAT_10 0
#define LV_FONT_MONTSERRAT_12 1
#define LV_FONT_MONTSERRAT_14 0
#define LV_FONT_MONTSERRAT_16 0
#define LV_FONT_MONTSERRAT_16 1
#define LV_FONT_MONTSERRAT_18 0
#define LV_FONT_MONTSERRAT_20 0
#define LV_FONT_MONTSERRAT_22 0
@ -396,7 +397,7 @@
#define LV_FONT_MONTSERRAT_26 0
#define LV_FONT_MONTSERRAT_28 0
#define LV_FONT_MONTSERRAT_30 0
#define LV_FONT_MONTSERRAT_32 0
#define LV_FONT_MONTSERRAT_32 1
#define LV_FONT_MONTSERRAT_34 0
#define LV_FONT_MONTSERRAT_36 0
#define LV_FONT_MONTSERRAT_38 0

View File

@ -14,15 +14,6 @@ extern "C" {
#include LV_CONF_KCONFIG_EXTERNAL_INCLUDE
#else
#if defined ESP_PLATFORM
#include "sdkconfig.h"
#include "esp_attr.h"
#endif
#ifdef __NuttX__
#include <nuttx/config.h>
#endif
#endif /*LV_CONF_KCONFIG_EXTERNAL_INCLUDE*/
/*******************

View File

@ -24,10 +24,6 @@
#include "drv_mmheap.h"
#include "bl_romfs.h"
#define ROMFH_HRD 0
#define ROMFH_DIR 1
#define ROMFH_REG 2
#define ROMFH_UNKNOW 3.
static uint32_t romfs_endaddr(void);
static int dirent_type(void *addr);
@ -339,6 +335,15 @@ int romfs_close(romfs_file_t *fp)
return -1;
}
int romfs_size(romfs_file_t *fp)
{
if(fp == NULL){
return -1;
}
return dirent_size(fp->f_arg);
}
size_t romfs_read(romfs_file_t *fp, char *buf, size_t length)
{
char *payload_buf;
@ -466,9 +471,8 @@ int romfs_stat(const char *path, romfs_stat_t *st)
return 0;
}
romfs_dir_t *romfs_opendir(const char *path)
int romfs_opendir(romfs_dir_t *dp,const char *path)
{
romfs_dir_t *dp = NULL;
char *start_addr;
char *end_addr;
int res;
@ -478,14 +482,14 @@ romfs_dir_t *romfs_opendir(const char *path)
/* sure romfs_root is valid */
if (romfs_root == NULL) {
ROMFS_ERROR("ERROR: romfs_root is null.\r\n");
return NULL;
return -1;
}
dp = (romfs_dir_t *)mmheap_alloc(sizeof(romfs_dir_t) + ROMFS_MAX_NAME_LEN + 1);
// dp = (romfs_dir_t *)malloc(sizeof(romfs_dir_t) + ROMFS_MAX_NAME_LEN + 1);
if (NULL == dp) {
return NULL;
return -2;
}
memset(dp, 0, sizeof(romfs_dir_t) + ROMFS_MAX_NAME_LEN + 1);
memset(dp, 0, sizeof(romfs_dir_t));
res = dirent_file((char *)path, (void **)&start_addr, (void **)&end_addr);
ROMFS_DEBUG("romfs: open dir path = %s, start = %p, end = %p\r\n", path, start_addr, end_addr);
@ -495,19 +499,18 @@ romfs_dir_t *romfs_opendir(const char *path)
dp->dir_start_addr = (char *)(romfs_root + ALIGNUP16(strlen(romfs_root + 16) + 1) + 16 + 64);
} else {
if (0 == dirent_childaddr(start_addr)) {
return NULL;
return -3;
} else {
dp->dir_start_addr = (char *)(romfs_root + dirent_childaddr(start_addr));
}
}
dp->dir_end_addr = end_addr;
dp->dir_cur_addr = NULL;
return dp;
return 0;
}
/* open err */
mmheap_free(dp);
return NULL;
return -4;
}
romfs_dirent_t *romfs_readdir(romfs_dir_t *dir)
@ -569,6 +572,12 @@ romfs_dirent_t *romfs_readdir(romfs_dir_t *dir)
}
}
if(ROMFH_DIR == dirent_type(dir->dir_cur_addr)){
dir->cur_dirent.d_type = ROMFH_DIR;
}else if(ROMFH_REG == dirent_type(dir->dir_cur_addr)){
dir->cur_dirent.d_type = ROMFH_REG;
}
return &(dir->cur_dirent);
}
@ -578,7 +587,6 @@ int romfs_closedir(romfs_dir_t *dir)
return -1;
}
mmheap_free(dir);
return 0;
}

View File

@ -45,6 +45,11 @@
#define ROMFS_MOUNTPOINT "/romfs" /* must '/' */
#define ROMFS_MAX_NAME_LEN (64)
#define ROMFH_HRD 0
#define ROMFH_DIR 1
#define ROMFH_REG 2
#define ROMFH_UNKNOW 3
#define ROMFS_S_IFDIR 0x0040000
#define ROMFS_S_IFREG 0x0100000
@ -80,7 +85,7 @@ typedef struct {
typedef struct {
int d_ino; /* file number */
uint8_t d_type; /* type of file */
char d_name[]; /* file name */
char d_name[ROMFS_MAX_NAME_LEN + 1]; /* file name */
} romfs_dirent_t;
/* opendir 得到的目录结构体 */
@ -94,10 +99,11 @@ typedef struct {
int romfs_mount(void);
int romfs_open(romfs_file_t *fp, const char *path, int flags);
int romfs_close(romfs_file_t *fp);
int romfs_size(romfs_file_t *fp);
size_t romfs_read(romfs_file_t *fp, char *buf, size_t length);
size_t romfs_lseek(romfs_file_t *fp, int off, romfs_whence_t whence);
int romfs_stat(const char *path, romfs_stat_t *st);
romfs_dir_t *romfs_opendir(const char *path);
int romfs_opendir(romfs_dir_t *dp,const char *path);
romfs_dirent_t *romfs_readdir(romfs_dir_t *dir);
int romfs_closedir(romfs_dir_t *dir);