lvgl 之常见配置项修改

简介

lv_conf.h 文件用于常见LVGL功能项配置

一、常规配置项

//屏幕水平宽度 根据实际使用修改
#define LV_HOR_RES_MAX 800 
 
//屏幕水平高度 根据实际使用修改
#define LV_VER_RES_MAX 480

COLOR SETTINGS

颜色设置

/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
#define LV_COLOR_DEPTH     32   //屏幕色深配置

MEMORY SETTINGS

内存设置

//这里默认的是128K 用作lvgl的动态内存分配。可以根据实际情况修改,但是要大于等于2KB
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
#  define LV_MEM_SIZE    (128U * 1024U)          /*[bytes]*/

//在右下角显示CPU使用率和FPS计数
/*1: Show CPU usage and FPS count in the right bottom corner*/
#define LV_USE_PERF_MONITOR     0

//在左下角显示使用的内存和内存碎片
/*1: Show the used memory and the memory fragmentation  in the left bottom corner
 * Requires LV_MEM_CUSTOM = 0*/
#define LV_USE_MEM_MONITOR      0

HAL SETTINGS

显示设置

//默认显示刷新周期。LVG将在这段时间内重新绘制改变的区域
/*Default display refresh period. LVG will redraw changed ares with this period time*/
#define LV_DISP_DEF_REFR_PERIOD     16      /*[ms]*/

输入设备的扫描时间周期,就是轮询按键鼠标的时间。默认16ms。
/*Input device read period in milliseconds*/
#define LV_INDEV_DEF_READ_PERIOD    16      /*[ms]*/


/*使用自定义滴答源,以毫秒为单位告诉运行时间。
*它消除了使用' lv_tick_inc() ')手动更新tick的需要*/
#define LV_TICK_CUSTOM     1

Asserts

/*如果操作失败或发现无效数据,启用断言。
如果LV_USE_LOG被启用,失败时会打印错误信息/

//检查该参数是否为NULL。(非常快,推荐)
#define LV_USE_ASSERT_NULL          1   /*Check if the parameter is NULL. (Very fast, recommended)*/

//检查内存是否分配成功。(非常快,推荐)
#define LV_USE_ASSERT_MALLOC        1   /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/

Logging

日志打印设置

// 日志打印使能
/*Enable the log module*/
#define LV_USE_LOG      1

/*日志的重要性:
*LV_LOG_LEVEL_TRACE许多日志提供详细信息
*LV_LOG_LEVEL_INFO记录重要事件
*LV_LOG_LEVEL_WARN日志,如果不需要的事情发生了,但没有导致问题
*LV_LOG_LEVEL_ERROR仅为关键问题,当系统可能失败时
*LV_LOG_LEVEL_USER仅用户添加的日志
*LV_LOG_LEVEL_NONE不记录任何内容*/
#  define LV_LOG_LEVEL    LV_LOG_LEVEL_WARN

TEXT SETTINGS

字符编码设置

/**
 * Select a character encoding for strings.
 * Your IDE or editor should have the same character encoding
 * - LV_TXT_ENC_UTF8
 * - LV_TXT_ENC_ASCII
 */
#define LV_TXT_ENC LV_TXT_ENC_UTF8   //使用LV_TXT_ENC_UTF8作为编码,  注意:编辑器编码模式需与这个保持一致

FONT USAGE

字体设置

/*Optionally declare custom fonts here.
 *You can use these fonts as default font too and they will be available globally.
 *E.g. #define LV_FONT_CUSTOM_DECLARE   LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/
#define LV_FONT_CUSTOM_DECLARE    //自定义字体设置, 留空表示不设置

/*Always set a default font*/
#define LV_FONT_DEFAULT &lv_font_montserrat_14    //设置默认字体为lv_font_montserrat_14

/*Enable handling large font and/or fonts with a lot of characters.
 *The limit depends on the font size, font face and bpp.
 *Compiler error will be triggered if a font needs it.*/
#define LV_FONT_FMT_TXT_LARGE   0    //字体设置过多,报错则打开此项

二、驱动配置项

1.显示驱动配置项(Linux)

/*-----------------------------------------
 *  Linux frame buffer device (/dev/fbx)
 *-----------------------------------------*/
#ifndef USE_FBDEV
#  define USE_FBDEV           0
#endif

#ifndef USE_SS_FBDEV
#  define USE_SS_FBDEV        1  //为1则使用Linux framebuffer显示驱动
#  define SS_FBDEV_V2         1
#  define SS_FBDEV_V3         0
#endif

#if USE_FBDEV || USE_SS_FBDEV
#  define FBDEV_PATH          "/dev/fb0"  //选择fb设备
#endif

2.LVGL显示驱动初始化流程

application (总:应用层调用lv_init() 初始化显示驱动)

|-------> lv_init()

|-------> lv_port_disp_init()

|------------------> lv_disp_draw_buf_init() 配置绘制 buffer;

|------------------> lv_disp_drv_init() 配置底层驱动,挂接绘制函数 flush_cb;

|-------------------------------> lv_disp_drv_register() 注册驱动;

函数调用关系如下:

 

3.其它显示驱动配置项展示

/*----------------
 *    SSD1963
 *--------------*/
#ifndef USE_SSD1963
#  define USE_SSD1963         0
#endif


/*----------------
 *    R61581
 *--------------*/
#ifndef USE_R61581
#  define USE_R61581          0
#endif


/*------------------------------
 *  ST7565 (Monochrome, low res.)
 *-----------------------------*/
#ifndef USE_ST7565
#  define USE_ST7565          0
#endif


/*------------------------------
 *  GC9A01 (color, low res.)
 *-----------------------------*/
#ifndef USE_GC9A01
#  define USE_GC9A01          0
#endif

触摸驱动配置项(Linux)

/*-------------------------------------------------
 * Mouse or touchpad as evdev interface (for Linux based systems)
 *------------------------------------------------*/
#ifndef USE_EVDEV
#  define USE_EVDEV           1     //为1则使用Linux触摸驱动
#endif

#ifndef USE_BSD_EVDEV
#  define USE_BSD_EVDEV       0
#endif

#if USE_EVDEV || USE_BSD_EVDEV
// 选择触摸输入设备
#  define EVDEV_NAME   "/dev/input/event0"        /*You can use the "evtest" Linux tool to get the list of devices and test them*/
#  define EVDEV_SWAP_AXES         0               /*Swap the x and y axes of the touchscreen*/

补充中

。。。
。。。
。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值