mirror of
https://github.com/rzeldent/esp32cam-rtsp.git
synced 2025-11-11 18:56:21 +00:00
Merge pull request #158 from rzeldent:133-esp32-cam-led-flash-not-working
133-esp32-cam-led-flash-not-working
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
"'-D ESP32CAM_AI_THINKER'",
|
||||
"'-D BOARD_HAS_PSRAM'",
|
||||
"'-mfix-esp32-psram-cache-issue'",
|
||||
"'-D FLASH_LED_GPIO=4'",
|
||||
"'-D USER_LED_GPIO=33'",
|
||||
"'-D USER_LED_ON_LEVEL=LOW'",
|
||||
"'-D CAMERA_CONFIG_PIN_PWDN=32'",
|
||||
|
||||
31
src/main.cpp
31
src/main.cpp
@@ -150,6 +150,20 @@ void handle_root()
|
||||
web_server.send(200, "text/html", html);
|
||||
}
|
||||
|
||||
#ifdef FLASH_LED_GPIO
|
||||
void handle_flash()
|
||||
{
|
||||
log_v("handle_flash");
|
||||
// If no value present, use off, otherwise convert v to integer. Depends on analog resolution for max value
|
||||
auto v = web_server.hasArg("v") ? web_server.arg("v").toInt() : 0;
|
||||
// If conversion fails, v = 0
|
||||
analogWrite(FLASH_LED_GPIO, v);
|
||||
|
||||
web_server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
web_server.send(200);
|
||||
}
|
||||
#endif
|
||||
|
||||
void handle_snapshot()
|
||||
{
|
||||
log_v("handle_snapshot");
|
||||
@@ -316,13 +330,21 @@ void setup()
|
||||
// Disable brownout
|
||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.setDebugOutput(true);
|
||||
|
||||
#ifdef USER_LED_GPIO
|
||||
pinMode(USER_LED_GPIO, OUTPUT);
|
||||
digitalWrite(USER_LED_GPIO, !USER_LED_ON_LEVEL);
|
||||
#endif
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.setDebugOutput(true);
|
||||
#ifdef FLASH_LED_GPIO
|
||||
pinMode(FLASH_LED_GPIO, OUTPUT);
|
||||
// Set resolution to 8 bits
|
||||
analogWriteResolution(8);
|
||||
// Turn flash led off
|
||||
analogWrite(FLASH_LED_GPIO, 0);
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_USB_CDC_ON_BOOT
|
||||
// Delay for USB to connect/settle
|
||||
@@ -397,7 +419,10 @@ void setup()
|
||||
web_server.on("/snapshot", HTTP_GET, handle_snapshot);
|
||||
// Camera stream
|
||||
web_server.on("/stream", HTTP_GET, handle_stream);
|
||||
|
||||
#ifdef FLASH_LED_GPIO
|
||||
// Flash led
|
||||
web_server.on("/flash", HTTP_GET, handle_flash);
|
||||
#endif
|
||||
web_server.onNotFound([]()
|
||||
{ iotWebConf.handleNotFound(); });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user