diff --git a/tasmota/settings.h b/tasmota/settings.h
index 8eadf12b7..81ee3baf8 100644
--- a/tasmota/settings.h
+++ b/tasmota/settings.h
@@ -367,7 +367,7 @@ struct {
uint8_t free_esp32_446[10]; // 446
- uint8_t esp32_webcam_resolution; // 450 - not used yet
+ uint8_t esp32_webcam_resolution; // 450
#endif // ESP8266 - ESP32
char serial_delimiter; // 451
diff --git a/tasmota/xdrv_39_webcam.ino b/tasmota/xdrv_39_webcam.ino
index f161e1ea0..a092bfecd 100644
--- a/tasmota/xdrv_39_webcam.ino
+++ b/tasmota/xdrv_39_webcam.ino
@@ -591,7 +591,7 @@ void detect_motion(void) {
void wc_show_stream(void) {
#ifndef USE_SCRIPT
if (CamServer) {
- WSContentSend_P(PSTR("

"),
+ WSContentSend_P(PSTR("
"),
WiFi.localIP().toString().c_str());
}
#endif
@@ -623,6 +623,11 @@ uint32_t wc_set_streamserver(uint32_t flag) {
return 0;
}
+void WcStreamControl(uint32_t resolution) {
+ wc_set_streamserver(resolution);
+ wc_setup(resolution);
+}
+
void wc_loop(void) {
if (CamServer) { CamServer->handleClient(); }
if (wc_stream_active) { handleMjpeg_task(); }
@@ -661,28 +666,34 @@ flash led = gpio4
red led = gpio 33
*/
+void WcInit(void) {
+ if (Settings.esp32_webcam_resolution > 10) {
+ Settings.esp32_webcam_resolution = 0;
+ }
+}
+
/*********************************************************************************************\
* Commands
\*********************************************************************************************/
-#define D_CMND_WC "Webcam"
+#define D_CMND_WEBCAM "Webcam"
const char kWCCommands[] PROGMEM = "|" // no prefix
- D_CMND_WC
+ D_CMND_WEBCAM
;
void (* const WCCommand[])(void) PROGMEM = {
- &CmndWC,
+ &CmndWebcam,
};
-void CmndWC(void) {
+void CmndWebcam(void) {
uint32_t flag = 0;
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 10)) {
- wc_set_streamserver(XdrvMailbox.payload);
- wc_setup(XdrvMailbox.payload);
+ Settings.esp32_webcam_resolution = XdrvMailbox.payload;
+ WcStreamControl(Settings.esp32_webcam_resolution);
}
if (CamServer) { flag = 1; }
- Response_P(PSTR("{\"" D_CMND_WC "\":{\"Streaming\":\"%s\"}"),GetStateText(flag));
+ Response_P(PSTR("{\"" D_CMND_WEBCAM "\":{\"Streaming\":\"%s\"}"),GetStateText(flag));
}
/*********************************************************************************************\
@@ -700,11 +711,15 @@ bool Xdrv39(uint8_t function) {
wc_pic_setup();
break;
case FUNC_WEB_ADD_MAIN_BUTTON:
+ WcStreamControl(Settings.esp32_webcam_resolution);
wc_show_stream();
break;
case FUNC_COMMAND:
result = DecodeCommand(kWCCommands, WCCommand);
break;
+ case FUNC_PRE_INIT:
+ WcInit();
+ break;
}
return result;
}