From f0f48093f5fc82d103dc878db921b7fa52fd933d Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Tue, 22 Oct 2024 17:57:51 +0200 Subject: [PATCH] feat(esp-box-3): Add default examples --- bsp/esp-box-3/CMakeLists.txt | 4 ++-- bsp/esp-box-3/idf_component.yml | 4 ++++ bsp/esp-box/idf_component.yml | 4 ---- .../display_audio_photo/main/idf_component.yml | 4 ++-- examples/display_audio_photo/sdkconfig.defaults | 1 + examples/display_rotation/main/CMakeLists.txt | 1 + examples/display_rotation/main/idf_component.yml | 4 ++-- examples/display_rotation/main/main.c | 15 +++++++++------ examples/display_rotation/sdkconfig.defaults | 1 + 9 files changed, 22 insertions(+), 16 deletions(-) diff --git a/bsp/esp-box-3/CMakeLists.txt b/bsp/esp-box-3/CMakeLists.txt index f58e73ad..623999b7 100644 --- a/bsp/esp-box-3/CMakeLists.txt +++ b/bsp/esp-box-3/CMakeLists.txt @@ -2,6 +2,6 @@ idf_component_register( SRCS "esp-box-3.c" "esp-box-3_idf5.c" INCLUDE_DIRS "include" PRIV_INCLUDE_DIRS "priv_include" - REQUIRES esp_driver_i2s esp_driver_gpio esp_driver_sdmmc spiffs - PRIV_REQUIRES fatfs esp_lcd esp_driver_spi esp_driver_i2c + REQUIRES driver spiffs + PRIV_REQUIRES fatfs esp_lcd ) diff --git a/bsp/esp-box-3/idf_component.yml b/bsp/esp-box-3/idf_component.yml index f47d2ad4..539e05c6 100644 --- a/bsp/esp-box-3/idf_component.yml +++ b/bsp/esp-box-3/idf_component.yml @@ -31,3 +31,7 @@ dependencies: icm42670: version: "^2.0.1" public: true + +examples: + - path: ../../examples/display_audio_photo + - path: ../../examples/display_rotation diff --git a/bsp/esp-box/idf_component.yml b/bsp/esp-box/idf_component.yml index b4b4e97d..999b4b0e 100644 --- a/bsp/esp-box/idf_component.yml +++ b/bsp/esp-box/idf_component.yml @@ -29,7 +29,3 @@ dependencies: icm42670: version: "^1" public: true - -examples: - - path: ../../examples/display_audio_photo - - path: ../../examples/display_rotation diff --git a/examples/display_audio_photo/main/idf_component.yml b/examples/display_audio_photo/main/idf_component.yml index fc28d292..19518415 100644 --- a/examples/display_audio_photo/main/idf_component.yml +++ b/examples/display_audio_photo/main/idf_component.yml @@ -1,6 +1,6 @@ description: BSP Display Audio Photo Example dependencies: esp_jpeg: "*" - esp-box: + esp-box-3: version: "*" - override_path: "../../../bsp/esp-box" + override_path: "../../../bsp/esp-box-3" diff --git a/examples/display_audio_photo/sdkconfig.defaults b/examples/display_audio_photo/sdkconfig.defaults index 9f4a5db4..59e852cb 100644 --- a/examples/display_audio_photo/sdkconfig.defaults +++ b/examples/display_audio_photo/sdkconfig.defaults @@ -12,6 +12,7 @@ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_SPIFFS_PAGE_SIZE=1024 CONFIG_LV_SPRINTF_CUSTOM=y # CONFIG_LV_BUILD_EXAMPLES is not set +CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n ## LVGL8 ## CONFIG_LV_USE_PERF_MONITOR=y diff --git a/examples/display_rotation/main/CMakeLists.txt b/examples/display_rotation/main/CMakeLists.txt index 914c3a10..418ff41a 100644 --- a/examples/display_rotation/main/CMakeLists.txt +++ b/examples/display_rotation/main/CMakeLists.txt @@ -1,4 +1,5 @@ idf_component_register(SRCS "main.c" + REQUIRES driver INCLUDE_DIRS ".") lvgl_port_create_c_image("images/esp_logo.png" "images/gen/" "ARGB8888" "NONE") diff --git a/examples/display_rotation/main/idf_component.yml b/examples/display_rotation/main/idf_component.yml index 621521bc..81d49c90 100644 --- a/examples/display_rotation/main/idf_component.yml +++ b/examples/display_rotation/main/idf_component.yml @@ -1,5 +1,5 @@ description: BSP Display rotation example dependencies: - esp-box: + esp-box-3: version: "*" - override_path: "../../../bsp/esp-box" + override_path: "../../../bsp/esp-box-3" diff --git a/examples/display_rotation/main/main.c b/examples/display_rotation/main/main.c index 51e41047..3dfb85e8 100644 --- a/examples/display_rotation/main/main.c +++ b/examples/display_rotation/main/main.c @@ -8,6 +8,7 @@ #include "bsp/esp-bsp.h" #include "lvgl.h" #if BSP_CAPS_IMU +#include "esp_private/i2c_platform.h" #include "icm42670.h" #endif @@ -140,9 +141,11 @@ static void app_lvgl_display(void) #if BSP_CAPS_IMU static void app_imu_init(void) { - imu = icm42670_create(BSP_I2C_NUM, ICM42670_I2C_ADDRESS); + i2c_master_bus_handle_t i2c_handle; + i2c_master_get_bus_handle(BSP_I2C_NUM, &i2c_handle); + ESP_ERROR_CHECK(icm42670_create(i2c_handle, ICM42670_I2C_ADDRESS, &imu)); if (imu) { - /* Configuration of the acceleremeter and gyroscope */ + /* Configuration of the accelerometer and gyroscope */ const icm42670_cfg_t imu_cfg = { .acce_fs = ACCE_FS_2G, .acce_odr = ACCE_ODR_400HZ, @@ -175,7 +178,7 @@ static void app_imu_read(void) icm42670_complimentory_filter(imu, &acce_val, &gyro_val, &angle); ESP_LOGI(TAG, "Angle roll: %.2f pitch: %.2f ", angle.roll, angle.pitch); - if (acce_val.x > 5) { + if (acce_val.y < -0.6) { if (rotation != LV_DISPLAY_ROTATION_0) { rotation = LV_DISPLAY_ROTATION_0; bsp_display_lock(0); @@ -183,7 +186,7 @@ static void app_imu_read(void) lv_label_set_text_fmt(lbl_rotation, "Rotation %d°", app_lvgl_get_rotation_degrees(rotation)); bsp_display_unlock(); } - } else if (acce_val.x < -5) { + } else if (acce_val.y > 0.6) { if (rotation != LV_DISPLAY_ROTATION_180) { rotation = LV_DISPLAY_ROTATION_180; bsp_display_lock(0); @@ -191,7 +194,7 @@ static void app_imu_read(void) lv_label_set_text_fmt(lbl_rotation, "Rotation %d°", app_lvgl_get_rotation_degrees(rotation)); bsp_display_unlock(); } - } else if (acce_val.y > 5) { + } else if (acce_val.x > 0.6) { if (rotation != LV_DISPLAY_ROTATION_270) { rotation = LV_DISPLAY_ROTATION_270; bsp_display_lock(0); @@ -199,7 +202,7 @@ static void app_imu_read(void) lv_label_set_text_fmt(lbl_rotation, "Rotation %d°", app_lvgl_get_rotation_degrees(rotation)); bsp_display_unlock(); } - } else if (acce_val.y < -5) { + } else if (acce_val.x < -0.6) { if (rotation != LV_DISPLAY_ROTATION_90) { rotation = LV_DISPLAY_ROTATION_90; bsp_display_lock(0); diff --git a/examples/display_rotation/sdkconfig.defaults b/examples/display_rotation/sdkconfig.defaults index c862604d..20785c31 100644 --- a/examples/display_rotation/sdkconfig.defaults +++ b/examples/display_rotation/sdkconfig.defaults @@ -3,6 +3,7 @@ # CONFIG_IDF_TARGET="esp32s3" # CONFIG_LV_BUILD_EXAMPLES is not set +CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n ## LVGL8 ## CONFIG_LV_USE_PERF_MONITOR=y