Parcourir la source

Update main.cpp

If the camera could only be initialized on the second attempt, "Camera Framebuffer Check" and "Print camera infos" was skipped.
SybexX il y a 11 mois
Parent
commit
26770d877e
1 fichiers modifiés avec 6 ajouts et 4 suppressions
  1. 6 4
      code/main/main.cpp

+ 6 - 4
code/main/main.cpp

@@ -122,7 +122,7 @@ bool Init_NVS_SDCard()
     if (ret != ESP_OK)
     if (ret != ESP_OK)
     {
     {
         ESP_LOGE(TAG, "Failed to create a new on-chip LDO power control driver");
         ESP_LOGE(TAG, "Failed to create a new on-chip LDO power control driver");
-        return ret;
+        return false;
     }
     }
     host.pwr_ctrl_handle = pwr_ctrl_handle;
     host.pwr_ctrl_handle = pwr_ctrl_handle;
 #endif
 #endif
@@ -174,7 +174,7 @@ bool Init_NVS_SDCard()
         .format_if_mount_failed = false,
         .format_if_mount_failed = false,
         .max_files = 12,                         // previously -> 2022-09-21: 5, 2023-01-02: 7 
         .max_files = 12,                         // previously -> 2022-09-21: 5, 2023-01-02: 7 
         .allocation_unit_size = 0,               // 0 = auto
         .allocation_unit_size = 0,               // 0 = auto
-        .disk_status_check_enable = 0
+        .disk_status_check_enable = 0,
     };
     };
 
 
     sdmmc_card_t* card;
     sdmmc_card_t* card;
@@ -291,7 +291,7 @@ extern "C" void app_main(void)
                     setSystemStatusFlag(SYSTEM_STATUS_HEAP_TOO_SMALL);
                     setSystemStatusFlag(SYSTEM_STATUS_HEAP_TOO_SMALL);
                     StatusLED(PSRAM_INIT, 3, true);
                     StatusLED(PSRAM_INIT, 3, true);
                 }
                 }
-                else { // OK
+                else { // PSRAM OK
                     // Init camera
                     // Init camera
                     // ********************************************
                     // ********************************************
                     PowerResetCamera();
                     PowerResetCamera();
@@ -322,10 +322,12 @@ extern "C" void app_main(void)
                             LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Camera init failed (" + std::string(camStatusHex) +
                             LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Camera init failed (" + std::string(camStatusHex) +
                                                                     ")! Check camera module and/or proper electrical connection");
                                                                     ")! Check camera module and/or proper electrical connection");
                             setSystemStatusFlag(SYSTEM_STATUS_CAM_BAD);
                             setSystemStatusFlag(SYSTEM_STATUS_CAM_BAD);
+                            Camera.LightOnOff(false);   // make sure flashlight is off
                             StatusLED(CAM_INIT, 1, true);
                             StatusLED(CAM_INIT, 1, true);
                         }
                         }
                     }
                     }
-                    else { // ESP_OK -> Camera init OK --> continue to perform camera framebuffer check
+
+                    if (camStatus == ESP_OK) { // ESP_OK -> Camera init OK --> continue to perform camera framebuffer check
                         // Camera framebuffer check
                         // Camera framebuffer check
                         // ********************************************
                         // ********************************************
                         if (!Camera.testCamera()) {
                         if (!Camera.testCamera()) {