WIP fixing crashes
This commit is contained in:
parent
02ee10edb9
commit
b820f3fc8d
34
src/main.cpp
34
src/main.cpp
|
|
@ -120,6 +120,8 @@ uint16_t voltage_threshold_counter = 0;
|
|||
|
||||
size_t free_heap = 0;
|
||||
|
||||
int webrequest_blockings = 0;
|
||||
|
||||
void activateSD()
|
||||
{
|
||||
if (SDActive)
|
||||
|
|
@ -358,9 +360,9 @@ uint32_t getBatteryVoltageMv()
|
|||
{
|
||||
uint32_t voltage = analogReadMilliVolts(BAT_VOLTAGE_PIN);
|
||||
voltage *= 2; //*2 because of the voltage divider.
|
||||
Serial.print("Battery Voltage: ");
|
||||
Serial.println(voltage);
|
||||
Serial.println(" mV");
|
||||
// Serial.print("Battery Voltage: ");
|
||||
// Serial.println(voltage);
|
||||
// Serial.println(" mV");
|
||||
return voltage;
|
||||
}
|
||||
|
||||
|
|
@ -1432,7 +1434,15 @@ const String getSysDir(const String filename)
|
|||
|
||||
void loop()
|
||||
{
|
||||
if (audio.isRunning())
|
||||
if (webrequestActive && webrequest_blockings > 5000) {
|
||||
Serial.println("excessive webrequest blocking!");
|
||||
webrequest_blockings = 0;
|
||||
webrequestActive = false;
|
||||
server.end();
|
||||
server.begin();
|
||||
}
|
||||
|
||||
if (audio.isRunning() && !webrequestActive)
|
||||
{
|
||||
if (asyncStop)
|
||||
{
|
||||
|
|
@ -1455,7 +1465,7 @@ void loop()
|
|||
pendingSeek = false;
|
||||
}
|
||||
}
|
||||
else if (asyncStart)
|
||||
else if (asyncStart && !webrequestActive)
|
||||
{
|
||||
asyncStart = false;
|
||||
start();
|
||||
|
|
@ -1484,6 +1494,8 @@ void loop()
|
|||
if (currentNode != nullptr)
|
||||
{
|
||||
String progressPath = getSysDir(progress_file);
|
||||
deactivateRFID();
|
||||
activateSD();
|
||||
writeSongProgress(progressPath.c_str(), currentNode->getCurrentPlayingId(), currentNode->getSecondsPlayed());
|
||||
}
|
||||
|
||||
|
|
@ -1504,7 +1516,7 @@ void loop()
|
|||
asyncTogglePlayPause = false;
|
||||
togglePlayPause();
|
||||
}
|
||||
else if (asyncNext)
|
||||
else if (asyncNext && !webrequestActive)
|
||||
{
|
||||
asyncNext = false;
|
||||
// If the play/start button is held, treat NEXT as volume up
|
||||
|
|
@ -1585,7 +1597,7 @@ void loop()
|
|||
activateSD();
|
||||
}
|
||||
|
||||
if (loopCounter % VOLTAGE_LOOP_INTERVAL == 0)
|
||||
if (loopCounter % VOLTAGE_LOOP_INTERVAL == 0 && !webrequestActive)
|
||||
{
|
||||
lastVoltage = getBatteryVoltageMv();
|
||||
free_heap = xPortGetFreeHeapSize();
|
||||
|
|
@ -1608,7 +1620,13 @@ void loop()
|
|||
}
|
||||
}
|
||||
|
||||
if (webrequestActive) {
|
||||
webrequest_blockings++;
|
||||
}
|
||||
|
||||
loopCounter++;
|
||||
vTaskDelay(1);
|
||||
|
||||
}
|
||||
|
||||
void loop2(void *parameter)
|
||||
|
|
@ -1638,7 +1656,7 @@ void loop2(void *parameter)
|
|||
Serial.println("loop2 started");
|
||||
loggingDone = true;
|
||||
}
|
||||
// vTaskDelay(1);
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue