mirror of
https://github.com/rzeldent/esp32cam-rtsp.git
synced 2025-11-13 11:46:21 +00:00
Added functions for flasg from API
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
"'-D ESP32CAM_AI_THINKER'",
|
"'-D ESP32CAM_AI_THINKER'",
|
||||||
"'-D BOARD_HAS_PSRAM'",
|
"'-D BOARD_HAS_PSRAM'",
|
||||||
"'-mfix-esp32-psram-cache-issue'",
|
"'-mfix-esp32-psram-cache-issue'",
|
||||||
|
"'-D FLASH_LED_GPIO=4'",
|
||||||
"'-D USER_LED_GPIO=33'",
|
"'-D USER_LED_GPIO=33'",
|
||||||
"'-D USER_LED_ON_LEVEL=LOW'",
|
"'-D USER_LED_ON_LEVEL=LOW'",
|
||||||
"'-D CAMERA_CONFIG_PIN_PWDN=32'",
|
"'-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);
|
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()
|
void handle_snapshot()
|
||||||
{
|
{
|
||||||
log_v("handle_snapshot");
|
log_v("handle_snapshot");
|
||||||
@@ -316,13 +330,21 @@ void setup()
|
|||||||
// Disable brownout
|
// Disable brownout
|
||||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
|
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
|
||||||
|
|
||||||
|
Serial.begin(115200);
|
||||||
|
Serial.setDebugOutput(true);
|
||||||
|
|
||||||
#ifdef USER_LED_GPIO
|
#ifdef USER_LED_GPIO
|
||||||
pinMode(USER_LED_GPIO, OUTPUT);
|
pinMode(USER_LED_GPIO, OUTPUT);
|
||||||
digitalWrite(USER_LED_GPIO, !USER_LED_ON_LEVEL);
|
digitalWrite(USER_LED_GPIO, !USER_LED_ON_LEVEL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Serial.begin(115200);
|
#ifdef FLASH_LED_GPIO
|
||||||
Serial.setDebugOutput(true);
|
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
|
#ifdef ARDUINO_USB_CDC_ON_BOOT
|
||||||
// Delay for USB to connect/settle
|
// Delay for USB to connect/settle
|
||||||
@@ -397,7 +419,10 @@ void setup()
|
|||||||
web_server.on("/snapshot", HTTP_GET, handle_snapshot);
|
web_server.on("/snapshot", HTTP_GET, handle_snapshot);
|
||||||
// Camera stream
|
// Camera stream
|
||||||
web_server.on("/stream", HTTP_GET, handle_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([]()
|
web_server.onNotFound([]()
|
||||||
{ iotWebConf.handleNotFound(); });
|
{ iotWebConf.handleNotFound(); });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user