diff --git a/boards/esp32cam_m5stack_camera.json b/boards/esp32cam_m5stack_camera.json index 3c242c2..7ca87cf 100644 --- a/boards/esp32cam_m5stack_camera.json +++ b/boards/esp32cam_m5stack_camera.json @@ -28,7 +28,7 @@ "'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'", "'-D CAMERA_CONFIG_FB_COUNT=1'", "'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_DRAM'", - "'-D SCCB_I2C_PORT=I2C_NUM_0'" + "'-D SCCB_I2C_PORT=I2C_NUM_0'", "'-D GROVE_SDA=13'", "'-D GROVE_SCL=4'" ], diff --git a/boards/esp32cam_m5stack_camera_psram.json b/boards/esp32cam_m5stack_camera_psram.json index 155dfaf..d112035 100644 --- a/boards/esp32cam_m5stack_camera_psram.json +++ b/boards/esp32cam_m5stack_camera_psram.json @@ -30,7 +30,7 @@ "'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'", "'-D CAMERA_CONFIG_FB_COUNT=2'", "'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'", - "'-D SCCB_I2C_PORT=I2C_NUM_0'" + "'-D SCCB_I2C_PORT=I2C_NUM_0'", "'-D GROVE_SDA=13'", "'-D GROVE_SCL=4'" ], diff --git a/boards/esp32cam_m5stack_esp32cam.json b/boards/esp32cam_m5stack_esp32cam.json index 02f7130..ee41ecf 100644 --- a/boards/esp32cam_m5stack_esp32cam.json +++ b/boards/esp32cam_m5stack_esp32cam.json @@ -32,7 +32,7 @@ "'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'", "'-D CAMERA_CONFIG_FB_COUNT=2'", "'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_PSRAM'", - "'-D SCCB_I2C_PORT=I2C_NUM_0'" + "'-D SCCB_I2C_PORT=I2C_NUM_0'", "'-D MICROPHONE_GPIO=32'", "'-D GROVE_SDA=13'", "'-D GROVE_SCL=4'" diff --git a/boards/esp32cam_ttgo_t_camera.json b/boards/esp32cam_ttgo_t_camera.json index 255d569..3cd7062 100644 --- a/boards/esp32cam_ttgo_t_camera.json +++ b/boards/esp32cam_ttgo_t_camera.json @@ -28,7 +28,7 @@ "'-D CAMERA_CONFIG_LEDC_CHANNEL=LEDC_CHANNEL_0'", "'-D CAMERA_CONFIG_FB_COUNT=1'", "'-D CAMERA_CONFIG_FB_LOCATION=CAMERA_FB_IN_DRAM'", - "'-D SCCB_I2C_PORT=I2C_NUM_0'" + "'-D SCCB_I2C_PORT=I2C_NUM_0'", "'-D LCD_SSD1306_PIN_SDA=21'", "'-D LCD_SSD1306_PIN_SCL=22'", "'-D BUTTON_RIGHT_PIN=34'", diff --git a/src/main.cpp b/src/main.cpp index 6ce0471..8899780 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -213,13 +213,12 @@ esp_err_t initialize_camera() { log_v("initialize_camera"); - constexpr auto pixformat = PIXFORMAT_JPEG; log_i("Frame size: %s", param_frame_size.value()); auto frame_size = lookup_frame_size(param_frame_size.value()); log_i("JPEG quality: %d", param_jpg_quality.value()); auto jpeg_quality = param_jpg_quality.value(); log_i("Frame duration: %d ms", param_frame_duration.value()); - camera_config_t camera_config = { + const camera_config_t camera_config = { .pin_pwdn = CAMERA_CONFIG_PIN_PWDN, // GPIO pin for camera power down line .pin_reset = CAMERA_CONFIG_PIN_RESET, // GPIO pin for camera reset line .pin_xclk = CAMERA_CONFIG_PIN_XCLK, // GPIO pin for camera XCLK line @@ -239,7 +238,7 @@ esp_err_t initialize_camera() .xclk_freq_hz = CAMERA_CONFIG_CLK_FREQ_HZ, // Frequency of XCLK signal, in Hz. EXPERIMENTAL: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode .ledc_timer = CAMERA_CONFIG_LEDC_TIMER, // LEDC timer to be used for generating XCLK .ledc_channel = CAMERA_CONFIG_LEDC_CHANNEL, // LEDC channel to be used for generating XCLK - .pixel_format = pixformat, // Format of the pixel data: PIXFORMAT_ + YUV422|GRAYSCALE|RGB565|JPEG + .pixel_format = PIXFORMAT_JPEG, // Format of the pixel data: PIXFORMAT_ + YUV422|GRAYSCALE|RGB565|JPEG .frame_size = frame_size, // Size of the output image: FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA .jpeg_quality = jpeg_quality, // Quality of JPEG output. 0-63 lower means higher quality .fb_count = CAMERA_CONFIG_FB_COUNT, // Number of frame buffers to be allocated. If more than one, then each frame will be acquired (double speed) @@ -337,11 +336,8 @@ void setup() log_i("Board: %s", BOARD_NAME); log_i("Starting " APP_TITLE "..."); - if (CAMERA_CONFIG_FB_LOCATION == CAMERA_FB_IN_PSRAM) - { - if (!psramInit()) - log_e("Failed to initialize PSRAM"); - } + if (CAMERA_CONFIG_FB_LOCATION == CAMERA_FB_IN_PSRAM && !psramInit()) + log_e("Failed to initialize PSRAM"); param_group_camera.addItem(¶m_frame_duration); param_group_camera.addItem(¶m_frame_size); @@ -388,6 +384,7 @@ void setup() break; } + esp_camera_deinit(); log_e("Failed to initialize camera. Error: 0x%0x. Frame size: %s, frame rate: %d ms, jpeg quality: %d", camera_init_result, param_frame_size.value(), param_frame_duration.value(), param_jpg_quality.value()); delay(500); } @@ -411,6 +408,4 @@ void loop() if (camera_server) camera_server->doLoop(); - - sleep(0); } \ No newline at end of file