forked from s60sc/ESP32-CAM_MJPEG2SD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ESP32-CAM_MJPEG2SD.ino
86 lines (79 loc) · 1.92 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* 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
*/
#if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 0, 3)
#error Must be compiled with arduino-esp32 core v3.0.3 or higher
#endif
#include "appGlobals.h"
void setup() {
logSetup();
// prep storage
if (startStorage()) {
// Load saved user configuration
if (loadConfig()) {
#ifndef AUXILIARY
// initialise camera
if (psramFound()) {
LOG_INF("PSRAM size: %s", fmtSize(ESP.getPsramSize()));
if (ESP.getPsramSize() > 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");
#else
LOG_INF("AUXILIARY mode without camera");
#endif
}
}
#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
#ifndef AUXILIARY
startSustainTasks();
#endif
#if INCLUDE_SMTP
prepSMTP();
#endif
#if INCLUDE_FTP_HFS
prepUpload();
#endif
#if INCLUDE_UART
prepUart();
#endif
#if INCLUDE_PERIPH
prepPeripherals();
#endif
#if INCLUDE_AUDIO
prepAudio();
#endif
#if INCLUDE_TELEM
prepTelemetry();
#endif
#if INCLUDE_TGRAM
prepTelegram();
#endif
#if INCLUDE_MCPWM
prepMotors();
#endif
#ifndef AUXILIARY
prepRecording();
#endif
#if INCLUDE_PERIPH
startHeartbeat();
#endif
checkMemory();
}
}
void loop() {
// confirm not blocked in setup
LOG_INF("=============== Total tasks: %u ===============\n", uxTaskGetNumberOfTasks() - 1);
delay(1000);
vTaskDelete(NULL); // free 8k ram
}