This commit is contained in:
michael
2024-09-24 02:53:36 +02:00
parent 085c47b651
commit 85375b6505
3 changed files with 124 additions and 103 deletions

View File

@@ -16,20 +16,24 @@ static const char *TAG = "server_cam";
void PowerResetCamera() void PowerResetCamera()
{ {
#if CAM_PIN_PWDN == GPIO_NUM_NC // Use reset only if pin is available
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "No power down pin availbale to reset camera");
#else
ESP_LOGD(TAG, "Resetting camera by power down line"); ESP_LOGD(TAG, "Resetting camera by power down line");
gpio_config_t conf; gpio_config_t conf;
conf.intr_type = GPIO_INTR_DISABLE; conf.intr_type = GPIO_INTR_DISABLE;
conf.pin_bit_mask = 1LL << GPIO_NUM_32; conf.pin_bit_mask = 1LL << CAM_PIN_PWDN;
conf.mode = GPIO_MODE_OUTPUT; conf.mode = GPIO_MODE_OUTPUT;
conf.pull_down_en = GPIO_PULLDOWN_DISABLE; conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
conf.pull_up_en = GPIO_PULLUP_DISABLE; conf.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&conf); gpio_config(&conf);
// carefull, logic is inverted compared to reset pin // carefull, logic is inverted compared to reset pin
gpio_set_level(GPIO_NUM_32, 1); gpio_set_level(CAM_PIN_PWDN, 1);
vTaskDelay(1000 / portTICK_PERIOD_MS); vTaskDelay(1000 / portTICK_PERIOD_MS);
gpio_set_level(GPIO_NUM_32, 0); gpio_set_level(CAM_PIN_PWDN, 0);
vTaskDelay(1000 / portTICK_PERIOD_MS); vTaskDelay(1000 / portTICK_PERIOD_MS);
#endif
} }
esp_err_t handler_lightOn(httpd_req_t *req) esp_err_t handler_lightOn(httpd_req_t *req)

View File

@@ -58,13 +58,7 @@
//#define CONFIG_IDF_TARGET_ARCH_XTENSA //not needed with platformio/espressif32 @ 5.2.0 //#define CONFIG_IDF_TARGET_ARCH_XTENSA //not needed with platformio/espressif32 @ 5.2.0
//Statusled + ClassControllCamera
#define BLINK_GPIO GPIO_NUM_33 // PIN for red board LED
//ClassControllCamera //ClassControllCamera
#define FLASH_GPIO GPIO_NUM_4 // PIN for flashlight LED
#define USE_PWM_LEDFLASH // if __LEDGLOBAL is defined, a global variable is used for LED control, otherwise locally and each time a new
#define CAM_LIVESTREAM_REFRESHRATE 500 // Camera livestream feature: Waiting time in milliseconds to refresh image #define CAM_LIVESTREAM_REFRESHRATE 500 // Camera livestream feature: Waiting time in milliseconds to refresh image
// #define GRAYSCALE_AS_DEFAULT // #define GRAYSCALE_AS_DEFAULT
@@ -195,8 +189,6 @@
#define Digital_Transition_Area_Forward 9.7 // Pre-run zero crossing only happens from approx. 9.7 onwards #define Digital_Transition_Area_Forward 9.7 // Pre-run zero crossing only happens from approx. 9.7 onwards
//#define DEBUG_DETAIL_ON //#define DEBUG_DETAIL_ON
@@ -212,112 +204,125 @@
//******* camera model //******* camera model
#if defined(CAMERA_MODEL_WROVER_KIT) #if defined(CAMERA_MODEL_WROVER_KIT)
#define PWDN_GPIO_NUM -1 #define CAM_PIN_PWDN GPIO_NUM_NC //power down is not used
#define RESET_GPIO_NUM -1 #define CAM_PIN_RESET GPIO_NUM_NC //software reset will be performed
#define XCLK_GPIO_NUM 21 #define CAM_PIN_XCLK GPIO_NUM_21
#define SIOD_GPIO_NUM 26 #define CAM_PIN_SIOD GPIO_NUM_26
#define SIOC_GPIO_NUM 27 #define CAM_PIN_SIOC GPIO_NUM_27
#define Y9_GPIO_NUM 35 #define CAM_PIN_D7 GPIO_NUM_35
#define Y8_GPIO_NUM 34 #define CAM_PIN_D6 GPIO_NUM_34
#define Y7_GPIO_NUM 39 #define CAM_PIN_D5 GPIO_NUM_39
#define Y6_GPIO_NUM 36 #define CAM_PIN_D4 GPIO_NUM_36
#define Y5_GPIO_NUM 19 #define CAM_PIN_D3 GPIO_NUM_19
#define Y4_GPIO_NUM 18 #define CAM_PIN_D2 GPIO_NUM_18
#define Y3_GPIO_NUM 5 #define CAM_PIN_D1 GPIO_NUM_5
#define Y2_GPIO_NUM 4 #define CAM_PIN_D0 GPIO_NUM_4
#define VSYNC_GPIO_NUM 25 #define CAM_PIN_VSYNC GPIO_NUM_25
#define HREF_GPIO_NUM 23 #define CAM_PIN_HREF GPIO_NUM_23
#define PCLK_GPIO_NUM 22 #define CAM_PIN_PCLK GPIO_NUM_22
#elif defined(CAMERA_MODEL_M5STACK_PSRAM) #elif defined(CAMERA_MODEL_M5STACK_PSRAM)
#define PWDN_GPIO_NUM -1 #define CAM_PIN_PWDN GPIO_NUM_NC
#define RESET_GPIO_NUM 15 #define CAM_PIN_RESET GPIO_NUM_15
#define XCLK_GPIO_NUM 27 #define CAM_PIN_XCLK GPIO_NUM_27
#define SIOD_GPIO_NUM 25 #define CAM_PIN_SIOD GPIO_NUM_25
#define SIOC_GPIO_NUM 23 #define CAM_PIN_SIOC GPIO_NUM_23
#define Y9_GPIO_NUM 19 #define CAM_PIN_D7 GPIO_NUM_19
#define Y8_GPIO_NUM 36 #define CAM_PIN_D6 GPIO_NUM_36
#define Y7_GPIO_NUM 18 #define CAM_PIN_D5 GPIO_NUM_18
#define Y6_GPIO_NUM 39 #define CAM_PIN_D4 GPIO_NUM_39
#define Y5_GPIO_NUM 5 #define CAM_PIN_D3 GPIO_NUM_5
#define Y4_GPIO_NUM 34 #define CAM_PIN_D2 GPIO_NUM_34
#define Y3_GPIO_NUM 35 #define CAM_PIN_D1 GPIO_NUM_35
#define Y2_GPIO_NUM 32 #define CAM_PIN_D0 GPIO_NUM_32
#define VSYNC_GPIO_NUM 22 #define CAM_PIN_VSYNC GPIO_NUM_22
#define HREF_GPIO_NUM 26 #define CAM_PIN_HREF GPIO_NUM_26
#define PCLK_GPIO_NUM 21 #define CAM_PIN_PCLK GPIO_NUM_21
#elif defined(CAMERA_MODEL_AI_THINKER) #elif defined(CAMERA_MODEL_AI_THINKER)
#define PWDN_GPIO_NUM GPIO_NUM_32 #define CAM_PIN_PWDN GPIO_NUM_32
#define RESET_GPIO_NUM -1 #define CAM_PIN_RESET GPIO_NUM_NC //software reset will be performed
#define XCLK_GPIO_NUM GPIO_NUM_0 #define CAM_PIN_XCLK GPIO_NUM_0
#define SIOD_GPIO_NUM GPIO_NUM_26 #define CAM_PIN_SIOD GPIO_NUM_26
#define SIOC_GPIO_NUM GPIO_NUM_27 #define CAM_PIN_SIOC GPIO_NUM_27
#define Y9_GPIO_NUM GPIO_NUM_35 #define CAM_PIN_D7 GPIO_NUM_35
#define Y8_GPIO_NUM GPIO_NUM_34 #define CAM_PIN_D6 GPIO_NUM_34
#define Y7_GPIO_NUM GPIO_NUM_39 #define CAM_PIN_D5 GPIO_NUM_39
#define Y6_GPIO_NUM GPIO_NUM_36 #define CAM_PIN_D4 GPIO_NUM_36
#define Y5_GPIO_NUM GPIO_NUM_21 #define CAM_PIN_D3 GPIO_NUM_21
#define Y4_GPIO_NUM GPIO_NUM_19 #define CAM_PIN_D2 GPIO_NUM_19
#define Y3_GPIO_NUM GPIO_NUM_18 #define CAM_PIN_D1 GPIO_NUM_18
#define Y2_GPIO_NUM GPIO_NUM_5 #define CAM_PIN_D0 GPIO_NUM_5
#define VSYNC_GPIO_NUM GPIO_NUM_25 #define CAM_PIN_VSYNC GPIO_NUM_25
#define HREF_GPIO_NUM GPIO_NUM_23 #define CAM_PIN_HREF GPIO_NUM_23
#define PCLK_GPIO_NUM GPIO_NUM_22 #define CAM_PIN_PCLK GPIO_NUM_22
#else #else
#error "Camera model not selected" #error "Camera model not selected"
#endif //camera model #endif //camera model
// ******* Board type // ******* Board type
#ifdef BOARD_WROVER_KIT // WROVER-KIT PIN Map #if defined(BOARD_WROVER_KIT) // WROVER-KIT PIN Map
// SD card (operated with SDMMC peripheral)
//-------------------------------------------------
#define GPIO_SDCARD_CLK GPIO_NUM_14
#define GPIO_SDCARD_CMD GPIO_NUM_15
#define GPIO_SDCARD_D0 GPIO_NUM_2
#ifndef __SD_USE_ONE_LINE_MODE__
#define GPIO_SDCARD_D1 GPIO_NUM_4
#define GPIO_SDCARD_D2 GPIO_NUM_12
#define GPIO_SDCARD_D3 GPIO_NUM_13
#else
#define GPIO_SDCARD_D1 GPIO_NUM_NC
#define GPIO_SDCARD_D2 GPIO_NUM_NC
#define GPIO_SDCARD_D3 GPIO_NUM_13
#endif
#define CAM_PIN_PWDN -1 //power down is not used //Statusled + ClassControllCamera
#define CAM_PIN_RESET -1 //software reset will be performed #define BLINK_GPIO GPIO_NUM_33 // PIN for red board LED, On the board the LED is on the IO2, but it is used for the SD
#define CAM_PIN_XCLK 21
#define CAM_PIN_SIOD 26
#define CAM_PIN_SIOC 27
#define CAM_PIN_D7 35 //ClassControllCamera
#define CAM_PIN_D6 34 #define FLASH_GPIO GPIO_NUM_12 // PIN for flashlight LED
#define CAM_PIN_D5 39 #define USE_PWM_LEDFLASH // if __LEDGLOBAL is defined, a global variable is used for LED control, otherwise locally and each time a new
#define CAM_PIN_D4 36
#define CAM_PIN_D3 19
#define CAM_PIN_D2 18
#define CAM_PIN_D1 5
#define CAM_PIN_D0 4
#define CAM_PIN_VSYNC 25
#define CAM_PIN_HREF 23
#define CAM_PIN_PCLK 22
#endif //// WROVER-KIT PIN Map #elif defined(BOARD_M5STACK_PSRAM) // M5STACK PSRAM PIN Map
//Statusled + ClassControllCamera
#define BLINK_GPIO GPIO_NUM_33 // PIN for red board LED
//ClassControllCamera
#define FLASH_GPIO GPIO_NUM_4 // PIN for flashlight LED
#define USE_PWM_LEDFLASH // if __LEDGLOBAL is defined, a global variable is used for LED control, otherwise locally and each time a new
#ifdef BOARD_ESP32CAM_AITHINKER // ESP32Cam (AiThinker) PIN Map #elif defined(BOARD_ESP32CAM_AITHINKER) // ESP32Cam (AiThinker) PIN Map
// SD card (operated with SDMMC peripheral)
//-------------------------------------------------
#define GPIO_SDCARD_CLK GPIO_NUM_14
#define GPIO_SDCARD_CMD GPIO_NUM_15
#define GPIO_SDCARD_D0 GPIO_NUM_2
#ifndef __SD_USE_ONE_LINE_MODE__
#define GPIO_SDCARD_D1 GPIO_NUM_4
#define GPIO_SDCARD_D2 GPIO_NUM_12
#define GPIO_SDCARD_D3 GPIO_NUM_13
#else
#define GPIO_SDCARD_D1 GPIO_NUM_NC
#define GPIO_SDCARD_D2 GPIO_NUM_NC
#define GPIO_SDCARD_D3 GPIO_NUM_13
#endif
#define CAM_PIN_PWDN 32 //Statusled + ClassControllCamera
#define CAM_PIN_RESET -1 //software reset will be performed #define BLINK_GPIO GPIO_NUM_33 // PIN for red board LED
#define CAM_PIN_XCLK 0
#define CAM_PIN_SIOD 26
#define CAM_PIN_SIOC 27
#define CAM_PIN_D7 35 //ClassControllCamera
#define CAM_PIN_D6 34 #define FLASH_GPIO GPIO_NUM_4 // PIN for flashlight LED
#define CAM_PIN_D5 39 #define USE_PWM_LEDFLASH // if __LEDGLOBAL is defined, a global variable is used for LED control, otherwise locally and each time a new
#define CAM_PIN_D4 36
#define CAM_PIN_D3 21
#define CAM_PIN_D2 19
#define CAM_PIN_D1 18
#define CAM_PIN_D0 5
#define CAM_PIN_VSYNC 25
#define CAM_PIN_HREF 23
#define CAM_PIN_PCLK 22
#endif // ESP32Cam (AiThinker) PIN Map #endif // ESP32Cam (AiThinker) PIN Map
// ******* LED definition // ******* LED definition
#ifdef USE_PWM_LEDFLASH #ifdef USE_PWM_LEDFLASH
@@ -332,6 +337,7 @@
#endif //USE_PWM_LEDFLASH #endif //USE_PWM_LEDFLASH
//softAP //softAP
#ifdef ENABLE_SOFTAP #ifdef ENABLE_SOFTAP
#define EXAMPLE_ESP_WIFI_SSID "AI-on-the-Edge" #define EXAMPLE_ESP_WIFI_SSID "AI-on-the-Edge"

View File

@@ -114,8 +114,19 @@ bool Init_NVS_SDCard()
// Set bus width to use: // Set bus width to use:
#ifdef __SD_USE_ONE_LINE_MODE__ #ifdef __SD_USE_ONE_LINE_MODE__
slot_config.width = 1; slot_config.width = 1;
#ifdef SOC_SDMMC_USE_GPIO_MATRIX
slot_config.clk = GPIO_SDCARD_CLK;
slot_config.cmd = GPIO_SDCARD_CMD;
slot_config.d0 = GPIO_SDCARD_D0;
#endif
#else #else
slot_config.width = 4; slot_config.width = 4;
#ifdef SOC_SDMMC_USE_GPIO_MATRIX
slot_config.d1 = GPIO_SDCARD_D1;
slot_config.d2 = GPIO_SDCARD_D2;
slot_config.d3 = GPIO_SDCARD_D3;
#endif
#endif #endif
// Enable internal pullups on enabled pins. The internal pullups // Enable internal pullups on enabled pins. The internal pullups
@@ -128,7 +139,7 @@ bool Init_NVS_SDCard()
// dies führt jedoch bei schlechten Kopien des AI_THINKER Boards // dies führt jedoch bei schlechten Kopien des AI_THINKER Boards
// zu Problemen mit der SD Initialisierung und eventuell sogar zur reboot-loops. // zu Problemen mit der SD Initialisierung und eventuell sogar zur reboot-loops.
// Um diese Probleme zu kompensieren, wird der PullUp manuel gesetzt. // Um diese Probleme zu kompensieren, wird der PullUp manuel gesetzt.
gpio_set_pull_mode(GPIO_NUM_13, GPIO_PULLUP_ONLY); // HS2_D3 gpio_set_pull_mode(GPIO_SDCARD_D3, GPIO_PULLUP_ONLY); // HS2_D3
// Options for mounting the filesystem. // Options for mounting the filesystem.
// If format_if_mount_failed is set to true, SD card will be partitioned and // If format_if_mount_failed is set to true, SD card will be partitioned and