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 Nov 5, 2024
1 parent f55eba1 commit b1e8a42
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 29 deletions.
4 changes: 1 addition & 3 deletions .build-test-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ examples:
disable:
- if: CONFIG_NAME in ["esp-box", "esp-box-lite"]
reason: Do not build examples for deprecated BSPs
- if: (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR < 2) and CONFIG_NAME == "esp-box-3"
reason: Example depends on BSP, which is supported only for IDF >= 5.2
- if: (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR < 3) and CONFIG_NAME == "esp32_p4_function_ev_board"
- if: (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR < 3) and CONFIG_NAME in ["esp32_p4_function_ev_board", "esp-box-3"]
reason: Example depends on BSP, which is supported only for IDF >= 5.3
- if: (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR < 4) and CONFIG_NAME == "m5stack_core_s3"
reason: Example depends on BSP, which is supported only for IDF >= 5.4
Expand Down
4 changes: 2 additions & 2 deletions bsp/esp-box-3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 1 addition & 1 deletion bsp/esp-box-3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ ESP32-S3-BOX-3 also uses a Type-C USB connector that provides 5 V of power input
| AUDIO |:heavy_check_mark:| [espressif/esp_codec_dev](https://components.espressif.com/components/espressif/esp_codec_dev) | ~1.3.1|
|AUDIO_SPEAKER|:heavy_check_mark:| | |
| AUDIO_MIC |:heavy_check_mark:| | |
| SDCARD |:heavy_check_mark:| idf | >=5.2 |
| SDCARD |:heavy_check_mark:| idf | >=5.3 |
| IMU |:heavy_check_mark:| [espressif/icm42670](https://components.espressif.com/components/espressif/icm42670) | ^2.0.1|
<!-- Autogenerated end: Dependencies -->
13 changes: 10 additions & 3 deletions bsp/esp-box-3/esp-box-3.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "driver/gpio.h"
#include "driver/ledc.h"
#include "driver/spi_master.h"
#include "driver/i2c_master.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_check.h"
Expand Down Expand Up @@ -63,8 +62,10 @@ sdmmc_card_t *bsp_sdcard = NULL; // Global SD card handler
/**
* @brief I2C handle for BSP usage
*
* You can call i2c_master_get_bus_handle(BSP_I2C_NUM, i2c_master_bus_handle_t *ret_handle)
* from #include "esp_private/i2c_platform.h"
* In IDF v5.4 you can call i2c_master_get_bus_handle(BSP_I2C_NUM, i2c_master_bus_handle_t *ret_handle)
* from #include "esp_private/i2c_platform.h" to get this handle
*
* For IDF 5.2 and 5.3 you must call bsp_i2c_get_handle()
*/
static i2c_master_bus_handle_t i2c_handle = NULL;
static bool i2c_initialized = false;
Expand Down Expand Up @@ -120,6 +121,12 @@ esp_err_t bsp_i2c_deinit(void)
return ESP_OK;
}

i2c_master_bus_handle_t bsp_i2c_get_handle(void)
{
bsp_i2c_init();
return i2c_handle;
}

static esp_err_t bsp_i2c_device_probe(uint8_t addr)
{
return i2c_master_probe(i2c_handle, addr, 100);
Expand Down
6 changes: 5 additions & 1 deletion bsp/esp-box-3/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tags:
- bsp

dependencies:
idf: ">=5.2" # We use I2C Driver-NG from IDF v5.2
idf: ">=5.3" # We use I2C Driver-NG from IDF v5.2 but esp-codec-dev supports from v5.3
esp_lcd_touch_tt21100: "^1"
esp_lcd_touch_gt911: "^1"
esp_lcd_ili9341: "^1"
Expand All @@ -31,3 +31,7 @@ dependencies:
icm42670:
version: "^2.0.1"
public: true

examples:
- path: ../../examples/display_audio_photo
- path: ../../examples/display_rotation
14 changes: 9 additions & 5 deletions bsp/esp-box-3/include/bsp/esp-box-3.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "sdkconfig.h"
#include "driver/gpio.h"
#include "driver/i2s_std.h"
#include "driver/i2c_master.h"
#include "driver/sdmmc_host.h"
#include "soc/usb_pins.h"
#include "lvgl.h"
Expand Down Expand Up @@ -210,11 +211,6 @@ esp_codec_dev_handle_t bsp_audio_codec_microphone_init(void);
* - Encryption chip ATECC608A (NOT populated on most boards)
* - LCD Touch controller
* - Inertial Measurement Unit ICM-42607-P
*
* After initialization of I2C, use BSP_I2C_NUM macro when creating I2C devices drivers ie.:
* \code{.c}
* icm42670_handle_t imu = icm42670_create(BSP_I2C_NUM, ICM42670_I2C_ADDRESS);
* \endcode
**************************************************************************************************/
#define BSP_I2C_NUM CONFIG_BSP_I2C_NUM

Expand All @@ -239,6 +235,14 @@ esp_err_t bsp_i2c_init(void);
*/
esp_err_t bsp_i2c_deinit(void);

/**
* @brief Get I2C driver handle
*
* @return
* - I2C handle
*/
i2c_master_bus_handle_t bsp_i2c_get_handle(void);

/**************************************************************************************************
*
* SPIFFS
Expand Down
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"
13 changes: 7 additions & 6 deletions examples/display_rotation/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ 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 = bsp_i2c_get_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 +176,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 b1e8a42

Please sign in to comment.