Skip to content

Commit

Permalink
feat(esp-box-3): Add default examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tore-espressif committed Oct 22, 2024
1 parent 1e5e1ac commit 654a16c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 14 deletions.
4 changes: 4 additions & 0 deletions bsp/esp-box-3/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ dependencies:
icm42670:
version: "^2.0.1"
public: true

examples:
- path: ../../examples/display_audio_photo
- path: ../../examples/display_rotation
4 changes: 0 additions & 4 deletions bsp/esp-box/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,3 @@ dependencies:
icm42670:
version: "^1"
public: true

examples:
- path: ../../examples/display_audio_photo
- path: ../../examples/display_rotation
4 changes: 2 additions & 2 deletions examples/display_audio_photo/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions examples/display_audio_photo/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions examples/display_rotation/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
4 changes: 2 additions & 2 deletions examples/display_rotation/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -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"
15 changes: 9 additions & 6 deletions examples/display_rotation/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -175,31 +178,31 @@ 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);
bsp_display_rotate(display, rotation);
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);
bsp_display_rotate(display, rotation);
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);
bsp_display_rotate(display, rotation);
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);
Expand Down
1 change: 1 addition & 0 deletions examples/display_rotation/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 654a16c

Please sign in to comment.