【esp32 学习笔记】将 lvgl 融入esp-idf项目中

lvgl科普

lvgl 主要特点:

Github库整体了解

版本号编排原则

屏幕兼容性

LVGL  问题处理:

 

lvgl 与 FreeRTOS

由于esp-idf本身带了 FreeRTOS系统,因此需要关注一下操作系统相关的内容:

void lvgl_thread(void)
{
    while(1) {
        uint32_t time_till_next;
        time_till_next = lv_timer_handler(); /*lv_lock/lv_unlock is called internally*/
        thread_sleep(time_till_next); /* sleep for a while */
    }
}

void other_thread(void)
{
    /* You must always hold the mutex while using LVGL APIs */
    lv_lock();
    lv_obj_t *img = lv_image_create(lv_screen_active());
    lv_unlock();

    while(1) {
        lv_lock();
        /* change to the next image */
        lv_image_set_src(img, next_image);
        lv_unlock();
        thread_sleep(2000);
    }
}

以上的内容,总结一下:

1. 如果要用到操作系统,LV_USE_OS宏定义应该被设置。

2. 每当在其他线程(不是 lv_timer_handler() 函数所在的线程 )使用lvgl函数的时候,在其之前使用 lv_lock() lv_unlock() 两个函数

lvgl的例程

esp-idf的官方例程(i2c_oled)当中用到了 lvgl,在yml文件中看到依赖三个相关esp32组件

首先,进行sdkconfig,修改以下选项:

  • XTAL频率修改,修改为26MHz。
  • 默认字体修改,搜索框搜索font,选择12px的 Montserrat(lvgl自带的字体)(选10px的字体在0.96"OLED上看不清,选14px的字又太大,12px刚刚好)

 

 

posted @   FBshark  阅读(450)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示