/
ESP32-CAM_MJPEG2SD.ino
64 lines (58 loc) · 1.51 KB
/
ESP32-CAM_MJPEG2SD.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Capture ESP32 Cam JPEG images into a AVI file and store on SD
* AVI files stored on the SD card can also be selected and streamed to a browser as MJPEG.
*
* s60sc 2020 - 2024
*/
#include "appGlobals.h"
void setup() {
logSetup();
// prep SD card storage
if (startStorage()) {
// Load saved user configuration
if (loadConfig()) {
// initialise camera
if (psramFound()) {
LOG_INF("PSRAM size: %s", fmtSize(esp_spiram_get_size()));
if (esp_spiram_get_size() > 3 * ONEMEG) prepCam();
else snprintf(startupFailure, SF_LEN, STARTUP_FAIL "Insufficient PSRAM for app");
}
else snprintf(startupFailure, SF_LEN, STARTUP_FAIL "Need PSRAM to be enabled");
}
}
#ifdef DEV_ONLY
devSetup();
#endif
// connect wifi or start config AP if router details not available
startWifi();
startWebServer();
if (strlen(startupFailure)) LOG_WRN("%s", startupFailure);
else {
// start rest of services
startSustainTasks();
#if INCLUDE_SMTP
prepSMTP();
#endif
#if INCLUDE_FTP_HFS
prepUpload();
#endif
prepPeripherals();
#if INCLUDE_AUDIO
prepAudio();
#endif
#if INCLUDE_TELEM
prepTelemetry();
#endif
#if INCLUDE_TGRAM
prepTelegram();
#endif
prepRecording();
checkMemory();
}
}
void loop() {
// confirm not blocked in setup
LOG_INF("=============== Total tasks: %u ===============\n", uxTaskGetNumberOfTasks() - 1);
delay(1000);
vTaskDelete(NULL); // free 8k ram
}