From 3fae2f08fe344bd41b1a0056cdbf3cbafac3a1f6 Mon Sep 17 00:00:00 2001 From: Wu Jian Gang Date: Thu, 5 Jan 2023 19:47:25 +0800 Subject: [PATCH] example: Update lv_demos to use package manager --- examples/lv_demos/CMakeLists.txt | 7 +-- examples/lv_demos/main/CMakeLists.txt | 2 +- examples/lv_demos/main/idf_component.yml | 3 ++ examples/lv_demos/main/lv_demos.c | 66 +++++++++++------------- examples/lv_demos/sdkconfig.defaults | 31 +++++------ 5 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 examples/lv_demos/main/idf_component.yml diff --git a/examples/lv_demos/CMakeLists.txt b/examples/lv_demos/CMakeLists.txt index 03b230c..623fff2 100644 --- a/examples/lv_demos/CMakeLists.txt +++ b/examples/lv_demos/CMakeLists.txt @@ -4,8 +4,9 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(EXTRA_COMPONENT_DIRS ../../components) - add_compile_options(-fdiagnostics-color=always) -project(lv_demos) +# The following line can be removed after LVGL update to v8.3.5. +add_compile_options(-Wno-format) + +project(lv_demos) \ No newline at end of file diff --git a/examples/lv_demos/main/CMakeLists.txt b/examples/lv_demos/main/CMakeLists.txt index 6e17d52..5bf9ded 100644 --- a/examples/lv_demos/main/CMakeLists.txt +++ b/examples/lv_demos/main/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register( SRCS - "lv_demos.c") + "lv_demos.c") \ No newline at end of file diff --git a/examples/lv_demos/main/idf_component.yml b/examples/lv_demos/main/idf_component.yml new file mode 100644 index 0000000..aa69202 --- /dev/null +++ b/examples/lv_demos/main/idf_component.yml @@ -0,0 +1,3 @@ +## IDF Component Manager Manifest File +dependencies: + espressif/esp-box: "2.*" \ No newline at end of file diff --git a/examples/lv_demos/main/lv_demos.c b/examples/lv_demos/main/lv_demos.c index 0ebc6d8..57707d1 100644 --- a/examples/lv_demos/main/lv_demos.c +++ b/examples/lv_demos/main/lv_demos.c @@ -1,38 +1,23 @@ -/** - * @file lv_demos.c - * @brief Evaluate demos provided by LVGL - * @version 0.1 - * @date 2021-10-19 - * - * @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd. +/* + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: CC0-1.0 */ -#include "bsp_board.h" -#include "bsp_lcd.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "lv_demos.h" -#include "lv_port.h" -#include "lvgl.h" +#include "bsp/esp-bsp.h" + +#include "demos/lv_demos.h" void app_main(void) { - ESP_ERROR_CHECK(bsp_board_init()); + /* Initialize I2C (for touch and audio) */ + bsp_i2c_init(); - ESP_ERROR_CHECK(lv_port_init()); - bsp_lcd_set_backlight(true); + /* Initialize display and LVGL */ + bsp_display_start(); + + /* Set display brightness to 100% */ + bsp_display_backlight_on(); /** * @brief Demos provided by LVGL. @@ -40,12 +25,23 @@ void app_main(void) * @note Only enable one demo every time. * */ +#if LV_USE_DEMO_WIDGETS lv_demo_widgets(); /* A widgets example. This is what you get out of the box */ - // lv_demo_music(); /* A modern, smartphone-like music player demo. */ - // lv_demo_stress(); /* A stress test for LVGL. */ - // lv_demo_benchmark(); /* A demo to measure the performance of LVGL or to compare different settings. */ +#endif - do { - lv_task_handler(); - } while (vTaskDelay(1), true); -} +#if LV_USE_DEMO_KEYPAD_AND_ENCODER + lv_demo_keypad_encoder(); /* Demonstrate the usage of encoder and keyboard */ +#endif + +#if LV_USE_DEMO_BENCHMARK + lv_demo_benchmark(); /* A demo to measure the performance of LVGL or to compare different settings. */ +#endif + +#if LV_USE_DEMO_STRESS + lv_demo_stress(); /* A stress test for LVGL. */ +#endif + +#if LV_USE_DEMO_MUSIC + lv_demo_music(); /* A modern, smartphone-like music player demo. */ +#endif +} \ No newline at end of file diff --git a/examples/lv_demos/sdkconfig.defaults b/examples/lv_demos/sdkconfig.defaults index 7720641..8fb0f52 100644 --- a/examples/lv_demos/sdkconfig.defaults +++ b/examples/lv_demos/sdkconfig.defaults @@ -1,18 +1,19 @@ CONFIG_IDF_TARGET="esp32s3" -CONFIG_ESPTOOLPY_FLASHMODE_QIO=y -CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y -# CONFIG_ESPTOOLPY_FLASHSIZE_DETECT is not set -CONFIG_ALL_DISABLE=y -CONFIG_MODEL_IN_SDCARD=y -# CONFIG_USE_WAKENET is not set -# CONFIG_USE_MULTINET is not set -CONFIG_LV_COLOR_16_SWAP=y -CONFIG_LV_MEM_SIZE_KILOBYTES=48 -CONFIG_LV_FONT_MONTSERRAT_12=y -CONFIG_LV_FONT_MONTSERRAT_16=y -CONFIG_LV_USE_DEMO_WIDGETS=y -CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y + +CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y + +CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y + CONFIG_ESP32S3_DATA_CACHE_64KB=y CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y -CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y -CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y +CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y + +CONFIG_ESPTOOLPY_FLASHMODE_QIO=y +CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y + +CONFIG_LV_COLOR_16_SWAP=y +CONFIG_LV_FONT_MONTSERRAT_12=y +CONFIG_LV_FONT_MONTSERRAT_16=y +CONFIG_LV_MEM_SIZE_KILOBYTES=48 +# Temporary disable demos, can turn on when LVGL at Espressif Component Registry update to 8.3.5 +# CONFIG_LV_USE_DEMO_WIDGETS=y \ No newline at end of file