[2022 Digi-Key Innovation Design Competition] 4. ESP32-S2-Kaluga-1 running LVGL
[Copy link]
I have been quite busy in the past two weeks, and I only found time to test several cases in the Kaluga official repository "esp-dev-kits". Currently, except for the touchpad case, all others are working properly. However, through the analysis of the LCD component and the corresponding cases, I found that the official case only provides the LCD driver, but not the GUI, and the case only has the function of displaying the picture on the entire screen, so I decided to try to introduce lvgl.
1. Obtain from lv_port_esp warehouse
The one used here is a complete transplant repository "lv_port_esp32" from the lvgl homepage on GitHub - link: .
Figure 4-1 Screenshot of GitHub homepage
According to experience, using the recursive cloning parameter "--recursive" indeed caused an error, so I chose to clone directly without parameters: "git clone https://github.com/lvgl/lv_port_esp32.git". In this way, there will be three linked repositories that have not been downloaded, and then they can be downloaded separately and placed in the directory with the same name.
The associated warehouse 1 is lvgl. I clicked the web link directly to go there, hoping to ensure the project version compatibility. However, an error was still reported during the compilation. Fortunately, I just commented out the useless statements.
Warehouse 1: . I also got an error when cloning this warehouse. I successfully downloaded the zip file on the page and then naturally unzipped it to the "../components/lvgl" directory.
Warehouse 2: . This warehouse only has several display driver source files, which can be directly cloned successfully and is located at "../components/lvgl_esp32_drivers".
Warehouse 3: . The name of this warehouse is "lv_demo". In order to avoid mistakes (subsequent analysis of CMakeLists also determines that the name must be changed), after cloning, I changed the directory name to "lv_examples", and finally located at "../components/lv_examples/lv_examplees".
Figure 4-2 Direct cloning (non-recursive) of the three missing subdirectories (the third one is one level below lv_examples)
Figure 4-3 Path locations of three linked warehouses l
2. Project configuration (based on VS Code)
Directly use VS Code to open the root directory "lv_port_esp32", first select the MCU type "esp32s2" in the status bar, then click the "gear" button in the status bar - equivalent to executing "idf.py menuconfig", and finally execute build.
For the specific menuconfig configuration, I made the following modifications:
Figure 4-4 Status bar tool button of esp-idf plugin
Figure 4-5 lvgl configuration
Figure 4-6 LVGL ESP Drivers
Figure 4-7 LVGL ESP Drivers——Display Pin Assignments and Kaluga Schematic
Judging from the pin distribution, the LCD Touch pin and Camera pin of the Kaluga board are reused, so the touch screen is not turned on here.
3. Compile the project
The build will report two errors, both located in "../components/lv_examples/lv_examples/lv_demo.h".
One is that the header file "../lv_demo_conf.h" cannot be found. There are two ways to modify it: rename lv_demo_conf_template.h in the same directory to lv_demo_conf.h (this header file is not actually enabled), or simply comment out this header file connection.
The second is the conditional compilation of the version check. I don’t know if it is a selection problem in the download stage. The version check here does not meet 8.0.0, so the error message "#error" will be output. I simply comment it out.
Figure 4-8 Error reporting and modification methods in lv_demo.h
During the link phase, an error is reported that the lv_demo_widgets() function (located in ../lv_examples/src/lv_demo_widgets/lv_demo_widgets.c) is undefined. This is because the lv_demo_conf.h header file is not enabled, and the macro definition "LV_USE_DEMO_WIDGETS" is missing. However, when I try to add this macro, a large number of type mismatch errors (mainly various lvgl structures) are reported in the lv_demo_widgets.c source file. I guess it is because the version does not match 8.0.0.
Therefore, main.c is modified here, demo is not used, and only two labels are displayed, as follows:
static void create_demo_application(void)
{
/* When using a monochrome display we only show "Hello World" centered on the
* screen */
/* use a pretty small demo for monochrome displays */
/* Get the current screen */
lv_obj_t * scr = lv_disp_get_scr_act(NULL);
/*Create a Label on the currently active screen*/
lv_obj_t * label1 = lv_label_create(scr, NULL);
lv_obj_t * label2 = lv_label_create(scr, NULL); //added by author
/*Modify the Label's text*/
lv_label_set_text(label1, "Hello\nworld");
lv_label_set_text(label2, "Nihao Shijie! Wonderful Tianjin!");
/* Align the Label to the center
* NULL means align on parent (which is the screen now)
* 0, 0 at the end means an x, y offset after alignment*/
lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_align(label2, NULL, LV_ALIGN_CENTER, 0, 50);//added by author
#if defined CONFIG_LV_TFT_DISPLAY_MONOCHROME || \ //moved by author
defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S
/* Otherwise we show the selected demo */
#if defined CONFIG_LV_USE_DEMO_WIDGETS
lv_demo_widgets();
#elif defined CONFIG_LV_USE_DEMO_KEYPAD_AND_ENCODER
lv_demo_keypad_encoder();
#elif defined CONFIG_LV_USE_DEMO_BENCHMARK
lv_demo_benchmark();
#elif defined CONFIG_LV_USE_DEMO_STRESS
lv_demo_stress();
#else
#error "No demo application selected."
#endif
#endif
}
Figure 4-9 lvgl test case effect
|