当前位置:网站首页>ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)

ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)

2022-04-23 18:38:00 Please call me Xiao Peng

Tips : This blog serves as a learning note , If there are mistakes, I hope to correct them

One 、ESP32 LVGL transplant ( You can update to the latest version ) Transplant preparation

   Transplant download website :Github, Then you need to download some files , Among them, we found something that belongs to lv_port_esp32lvgl ,lv_demos,lvgl_esp32_drivers Four files . take LVGL、lvgl_demos、lv_esp32_drivers Copy the file in to components File subdirectory .
 Insert picture description here
 Insert picture description here
 Insert picture description here

Two 、 Migrate modified files

   compile , Then the error report is lvgl History settings in components\lv_examples Documents in lv_ex_conf.h Does not match the header file controlled in the process , It needs to be modified to lv_demo_conf.h, And switch the contents , I use it directly here VS Of control files in simulation engineering .
   After compiling, the music appears Demo The font cannot be found in the file in , Then you can go directly here sdkconfig Check the font .
 Insert picture description here

   Solve the problem of compiling Fonts , To configure sdkconfig, Select one of the gears
 Insert picture description here

   Open it and find lvgl Font in , Check among them 12、16 Font number
 Insert picture description here

   There are still errors after compilation , And in main.c There is a wavy line under the header file in the file , And can't jump , At this time, we can use the menu bar at the bottom Click on Win32, Then click edit configuration UI, And then click c_cpp_properties.json, Realization UI Configuration of , This time will be right Vscode Some configuration of the compilation environment , But I still can't jump , At this time, the contents of the project folder that has been mutated should be copied here , Then compile again to solve this problem .
 Insert picture description here
 Insert picture description here

   Good configuration json After compiling the environment again, there are several errors , First solve the errors in the driver , Our memory size is undefined , We're at that point .h In file #define LV_HOR_RES_MAX 240 Specifically 240 The size of the LCD screen should also be set according to the pixels of the LCD screen .
 Insert picture description here

And solve it lvgl_helpers.c Mistakes in , from .c It can be seen from the document that assert((0 <= host) && (SPI_HOST_MAX > host)); Report errors , You can comment out or define directly here #define SPI_HOST_MAX 3 , Here is just an assertion used as a debugging Library . Should be ESP32 Yes 3 individual SPI, Macro definition max 3
   Finally, solve the error in the main function , There are several undefined functions , Let's have a look at lvgl/src/hal Under the document lv_hal_disp.c There is no sub function , Then we'll replace this function with lv_disp_draw_buf_init, This is lv_port_esp32 This document should also be used before, not LVGL8 The version of the hal The firmware API, Just replace it . Besides, there are static lv_disp_buf_t disp_buf; Medium lv_disp_buf_t Unknown type name , This is also API Are not compatible , Here it is modified as lv_disp_draw_buf_t That's all right. . The last one is disp_drv.buffer Display error , This is also before API Are not compatible , Here it is disp_drv.draw_buf that will do , The compilation can be passed .
   Configure LCD pixels .
 Insert picture description here

disp_drv.hor_res = 320;                /*Set the horizontal resolution in pixels*/
disp_drv.ver_res = 240;                /*Set the vertical resolution in pixels*/

   To configure esp32 sdkconfig Configure the LCD control pin .
 Insert picture description here

   adopt sdkconfig Configure chip memory and main frequency , I'm here M5Stock To configure 8M 240Mhz Main frequency .
modify ILI9341 Configuration of conforms to M5Stack.
 Insert picture description here

   Finally, let's download and test to see if it's normal , The test program can be in main.c In file , It needs to be revised , In this file is lvgl7 Version of , Therefore, it needs to be modified to conform to lvgl8 Version of .
 Insert picture description here

   Finally, download the display, but the color display is wrong , At this time, we need to modify sdkconfig The configuration in the .
 Insert picture description here

3、 ... and 、 The final display after transplantation

 Please add a picture description

Four 、 Download link

  M5Stock + LVGL + IDF

版权声明
本文为[Please call me Xiao Peng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210609450077.html