Commit 6c7333bf authored by Simon Gölzhäuser's avatar Simon Gölzhäuser
Browse files

Small improvements

parent 741ce9d0
......@@ -95,8 +95,8 @@ https://github.com/jameszah/ESP32-CAM-Video-Recorder-junior
// General
// --------------------------------------------------
#define RECORD_TRIGGERDISTANCE (90 * 10) // 90cm
#define RECORD_TURNOFFDELAY (1 * 60 * 1000) // 1min
#define RECORD_TRIGGERDISTANCE 900 // mm
#define RECORD_TURNOFFDELAY 30000 // ms
RTC_PCF8523 g_rtc;
VL53L1X g_sensor;
......@@ -628,7 +628,7 @@ void initDistanceSensor() {
/**
* Reads the text files in directory /config.
* rec_trigger_dist: Recording trigger distance (mandatory, unit cm)
* rec_turnoff_delay: Recording turnoff delay (mandatory, unit ms)
* rec_turnoff_delay: Recording turnoff delay (mandatory, unit s)
* wifi_ssid: WiFi SSID (optional)
* wifi_pass: WiFi password (optional)
* bearer: Server upload bearer token (optional)
......@@ -644,32 +644,32 @@ void readConfigFile() {
File fConfig = SD_MMC.open("/config/rec_trigger_dist.txt", "r");
if (fConfig) {
g_nRecordTriggerDistance = fConfig.parseInt();
g_nRecordTriggerDistance = fConfig.parseInt() * 10;
fConfig.close();
#ifdef SERIALPRINTS
Serial.printf("Recording trigger distance: %d\n", g_nRecordTriggerDistance);
Serial.printf("Recording trigger distance: %dcm\n", (g_nRecordTriggerDistance / 10));
#endif
g_fLog.printf("Recording trigger distance: %d\n", g_nRecordTriggerDistance);
g_fLog.printf("Recording trigger distance: %dcm\n", (g_nRecordTriggerDistance / 10));
} else {
#ifdef SERIALPRINTS
Serial.println("Recording trigger distance: NONE");
Serial.printf("Recording trigger distance: NONE (default %dcm)\n", (g_nRecordTriggerDistance / 10));
#endif
g_fLog.println("Recording trigger distance: NONE");
g_fLog.printf("Recording trigger distance: NONE (default %dcm)\n", (g_nRecordTriggerDistance / 10));
}
fConfig = SD_MMC.open("/config/rec_turnoff_delay.txt", "r");
if (fConfig) {
g_lRecordTurnOffDelay = fConfig.parseInt();
g_lRecordTurnOffDelay = fConfig.parseInt() * 1000;
fConfig.close();
#ifdef SERIALPRINTS
Serial.printf("Recording turnoff delay: %d\n", g_lRecordTurnOffDelay);
Serial.printf("Recording turnoff delay: %ds\n", (g_lRecordTurnOffDelay / 1000));
#endif
g_fLog.printf("Recording turnoff delay: %d\n", g_lRecordTurnOffDelay);
g_fLog.printf("Recording turnoff delay: %ds\n", (g_lRecordTurnOffDelay / 1000));
} else {
#ifdef SERIALPRINTS
Serial.println("Recording turnoff delay: NONE");
Serial.printf("Recording turnoff delay: NONE (default %ds)\n", (g_lRecordTurnOffDelay / 1000));
#endif
g_fLog.println("Recording turnoff delay: NONE");
g_fLog.printf("Recording turnoff delay: NONE (default %ds)\n", (g_lRecordTurnOffDelay / 1000));
}
fConfig = SD_MMC.open("/config/wifi_ssid.txt", "r");
......@@ -888,7 +888,7 @@ bool uploadFile(char fileName[50]) {
char response[200] = {'\0'};
long lLastRead = millis();
int nIndex = 0;
while (g_WifiClient.available() || ((lLastRead + 5000) >= millis())){
while (g_WifiClient.available() || ((lLastRead + 10000) >= millis())){
if (g_WifiClient.available()) {
if (nIndex == 0) {
response[nIndex] = '\t';
......@@ -1681,6 +1681,10 @@ void handleRecording() {
if (nDistance <= g_nRecordTriggerDistance) {
lRecordingStart = millis();
if (!g_bShouldRecord) {
#ifdef SERIALPRINTS
Serial.printf("Recording triggered at distance %d\n", nDistance);
#endif
g_fLog.printf("Recording triggered at distance %d\n", nDistance);
getAviFileName(g_aviFileName);
g_bShouldRecord = true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment