LVGL 9.5.0 嵌入式32位mcu的 ram/rom 精简
为了让lvgl可以在flash只有256KB的mcu上使用,所以在lv_conf.h中做以下调整:
关于RAM运行内存,只需要修改一处 :
LV_MEM_SIZE 默认是 (64 * 1024U) ,我改成了(10* 1024U) 也就是10kb,根据你自己情况调整。
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN /** Size of memory available for `lv_malloc()` in bytes (>= 2kB) */ #define LV_MEM_SIZE (10 * 1024U) /**< [bytes] */ /** Size of the memory expand for `lv_malloc()` in bytes */ #define LV_MEM_POOL_EXPAND_SIZE 0 /** Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too. */ #define LV_MEM_ADR 0 /**< 0: unused*/ /* Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc */ #if LV_MEM_ADR == 0 #undef LV_MEM_POOL_INCLUDE #undef LV_MEM_POOL_ALLOC #endif #endif /*LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN*/关于Flash内存:
1.颜色格式精简: 比如说ST7789用的是RGB565颜色格式,那么把其他颜色格式改成0。
#define LV_DRAW_SW_SUPPORT_RGB565 1 #define LV_DRAW_SW_SUPPORT_RGB565_SWAPPED 1 #define LV_DRAW_SW_SUPPORT_RGB565A8 0 #define LV_DRAW_SW_SUPPORT_RGB888 0 #define LV_DRAW_SW_SUPPORT_XRGB8888 0 #define LV_DRAW_SW_SUPPORT_ARGB8888 0 #define LV_DRAW_SW_SUPPORT_ARGB8888_PREMULTIPLIED 0 #define LV_DRAW_SW_SUPPORT_L8 0 #define LV_DRAW_SW_SUPPORT_AL88 0 #define LV_DRAW_SW_SUPPORT_A8 0 #define LV_DRAW_SW_SUPPORT_I1 0 //复杂渲染 (阴影,圆角等),要不要开看你自己选择 #define LV_DRAW_SW_COMPLEX 12. UI组件精简:
#define LV_USE_ANIMIMG 1 #define LV_USE_ARC 1 #define LV_USE_ARCLABEL 1 #define LV_USE_BAR 1 #define LV_USE_BUTTON 1 #define LV_USE_BUTTONMATRIX 0 //按钮矩阵 ,非触摸屏应用一般也用不着。 #define LV_USE_CALENDAR 0 //日历,一般用不着。 #define LV_USE_CANVAS 1 #define LV_USE_CHART 0 //图表,轻应用一般也用不着,也可以自己用canvas实现。 #define LV_USE_CHECKBOX 0 //复选框,非触摸屏应用一般也用不着。 #define LV_USE_DROPDOWN 0 //展开选择框,非触摸屏应用一般也用不着。 #define LV_USE_IMAGE 1 #define LV_USE_IMAGEBUTTON 0 #define LV_USE_KEYBOARD 0 //键盘,用不着。 #define LV_USE_LABEL 1 #define LV_USE_LED 1 #define LV_USE_LINE 1 #define LV_USE_LIST 1 #define LV_USE_LOTTIE 0 //LOTTIE动画,用不着 #define LV_USE_MENU 1 #define LV_USE_MSGBOX 0 //消息提示框,非触摸屏应用一般也用不着。 #define LV_USE_ROLLER 0 #define LV_USE_SCALE 0 //尺子,非触摸屏应用一般也用不着。 #define LV_USE_SLIDER 0 //滑条,非触摸屏应用一般也用不着。 #define LV_USE_SPAN 1 #define LV_USE_SPINBOX 0 #define LV_USE_SPINNER 0 #define LV_USE_SWITCH 1 #define LV_USE_TABLE 0 #define LV_USE_TABVIEW 1 #define LV_USE_TILEVIEW 1 #define LV_USE_WIN 1
最后精简的flash占用大概120KB左右,精简前占用240KB。
