Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
espzav committed Jun 3, 2024
1 parent 44baf7c commit 4587035
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 4 deletions.
3 changes: 3 additions & 0 deletions bsp/esp32_s2_kaluga_kit/include/bsp/esp32_s2_kaluga_kit.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ esp_err_t bsp_spiffs_unmount(void);
.sccb_i2c_port = BSP_I2C_NUM, \
}

#define BSP_CAMERA_VFLIP 1
#define BSP_CAMERA_HMIRROR 0

/**************************************************************************************************
*
* LCD interface
Expand Down
3 changes: 3 additions & 0 deletions bsp/esp32_s3_eye/include/bsp/esp32_s3_eye.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ esp_err_t bsp_i2c_deinit(void);
.sccb_i2c_port = BSP_I2C_NUM, \
}

#define BSP_CAMERA_VFLIP 1
#define BSP_CAMERA_HMIRROR 0

/**************************************************************************************************
*
* SPIFFS
Expand Down
3 changes: 3 additions & 0 deletions bsp/esp32_s3_korvo_2/include/bsp/esp32_s3_korvo_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ esp_io_expander_handle_t bsp_io_expander_init(void);
.sccb_i2c_port = BSP_I2C_NUM, \
}

#define BSP_CAMERA_VFLIP 1
#define BSP_CAMERA_HMIRROR 0

/**************************************************************************************************
*
* uSD card
Expand Down
3 changes: 3 additions & 0 deletions bsp/m5stack_core_s3/include/bsp/m5stack_core_s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ esp_err_t bsp_i2c_deinit(void);
.sccb_i2c_port = BSP_I2C_NUM, \
}

#define BSP_CAMERA_VFLIP 0
#define BSP_CAMERA_HMIRROR 0

/**************************************************************************************************
*
* SPIFFS
Expand Down
19 changes: 15 additions & 4 deletions examples/display_camera/main/display_camera.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*/
Expand Down Expand Up @@ -34,12 +34,18 @@ void app_main(void)
return;
}
sensor_t *s = esp_camera_sensor_get();
s->set_vflip(s, 1);
s->set_vflip(s, BSP_CAMERA_VFLIP);
s->set_hmirror(s, BSP_CAMERA_HMIRROR);
ESP_LOGI(TAG, "Camera Init done");

uint32_t cam_buff_size = BSP_LCD_H_RES * BSP_LCD_V_RES * 2;
uint8_t *cam_buff = heap_caps_malloc(cam_buff_size, MALLOC_CAP_SPIRAM);
assert(cam_buff);

// Create LVGL canvas for camera image
bsp_display_lock(0);
lv_obj_t *camera_canvas = lv_canvas_create(lv_scr_act());
lv_canvas_set_buffer(camera_canvas, cam_buff, BSP_LCD_H_RES, BSP_LCD_V_RES, LV_COLOR_FORMAT_RGB565);
assert(camera_canvas);
lv_obj_center(camera_canvas);
bsp_display_unlock();
Expand All @@ -48,10 +54,15 @@ void app_main(void)
while (1) {
pic = esp_camera_fb_get();
if (pic) {
esp_camera_fb_return(pic);
bsp_display_lock(0);
lv_canvas_set_buffer(camera_canvas, pic->buf, pic->width, pic->height, LV_COLOR_FORMAT_RGB565);
memcpy(cam_buff, pic->buf, cam_buff_size);
if (BSP_LCD_BIGENDIAN) {
/* Swap bytes in RGB565 */
lv_draw_sw_rgb565_swap(cam_buff, cam_buff_size);
}
lv_obj_invalidate(camera_canvas);
bsp_display_unlock();
esp_camera_fb_return(pic);
} else {
ESP_LOGE(TAG, "Get frame failed");
}
Expand Down
1 change: 1 addition & 0 deletions examples/display_camera/sdkconfig.bsp.esp32_s3_eye
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=8192
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
CONFIG_LV_SPRINTF_CUSTOM=y
CAMERA_TASK_STACK_SIZE=4096
# CONFIG_LV_BUILD_EXAMPLES is not set

## LVGL8 ##
Expand Down
1 change: 1 addition & 0 deletions examples/display_camera/sdkconfig.bsp.esp32_s3_korvo_2
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=8192
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
CONFIG_LV_SPRINTF_CUSTOM=y
CAMERA_TASK_STACK_SIZE=4096
# CONFIG_LV_BUILD_EXAMPLES is not set

## LVGL8 ##
Expand Down
2 changes: 2 additions & 0 deletions examples/display_camera/sdkconfig.bsp.m5stack_core_s3
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=8192
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
CONFIG_LV_SPRINTF_CUSTOM=y
CAMERA_TASK_STACK_SIZE=4096

# CONFIG_LV_BUILD_EXAMPLES is not set

## LVGL8 ##
Expand Down
1 change: 1 addition & 0 deletions examples/display_lvgl_demos/sdkconfig.bsp.esp32_s3_eye
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CONFIG_LV_USE_DEMO_BENCHMARK=y
CONFIG_LV_USE_DEMO_STRESS=y
CONFIG_LV_USE_DEMO_MUSIC=y
CONFIG_LV_DEMO_MUSIC_AUTO_PLAY=y
CONFIG_LV_DEMO_MUSIC_SQUARE=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down

0 comments on commit 4587035

Please sign in to comment.