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;
|
size_t free_heap = 0;
|
||||||
|
|
||||||
|
int webrequest_blockings = 0;
|
||||||
|
|
||||||
void activateSD()
|
void activateSD()
|
||||||
{
|
{
|
||||||
if (SDActive)
|
if (SDActive)
|
||||||
|
|
@ -358,9 +360,9 @@ uint32_t getBatteryVoltageMv()
|
||||||
{
|
{
|
||||||
uint32_t voltage = analogReadMilliVolts(BAT_VOLTAGE_PIN);
|
uint32_t voltage = analogReadMilliVolts(BAT_VOLTAGE_PIN);
|
||||||
voltage *= 2; //*2 because of the voltage divider.
|
voltage *= 2; //*2 because of the voltage divider.
|
||||||
Serial.print("Battery Voltage: ");
|
// Serial.print("Battery Voltage: ");
|
||||||
Serial.println(voltage);
|
// Serial.println(voltage);
|
||||||
Serial.println(" mV");
|
// Serial.println(" mV");
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1432,7 +1434,15 @@ const String getSysDir(const String filename)
|
||||||
|
|
||||||
void loop()
|
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)
|
if (asyncStop)
|
||||||
{
|
{
|
||||||
|
|
@ -1455,7 +1465,7 @@ void loop()
|
||||||
pendingSeek = false;
|
pendingSeek = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (asyncStart)
|
else if (asyncStart && !webrequestActive)
|
||||||
{
|
{
|
||||||
asyncStart = false;
|
asyncStart = false;
|
||||||
start();
|
start();
|
||||||
|
|
@ -1484,6 +1494,8 @@ void loop()
|
||||||
if (currentNode != nullptr)
|
if (currentNode != nullptr)
|
||||||
{
|
{
|
||||||
String progressPath = getSysDir(progress_file);
|
String progressPath = getSysDir(progress_file);
|
||||||
|
deactivateRFID();
|
||||||
|
activateSD();
|
||||||
writeSongProgress(progressPath.c_str(), currentNode->getCurrentPlayingId(), currentNode->getSecondsPlayed());
|
writeSongProgress(progressPath.c_str(), currentNode->getCurrentPlayingId(), currentNode->getSecondsPlayed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1504,7 +1516,7 @@ void loop()
|
||||||
asyncTogglePlayPause = false;
|
asyncTogglePlayPause = false;
|
||||||
togglePlayPause();
|
togglePlayPause();
|
||||||
}
|
}
|
||||||
else if (asyncNext)
|
else if (asyncNext && !webrequestActive)
|
||||||
{
|
{
|
||||||
asyncNext = false;
|
asyncNext = false;
|
||||||
// If the play/start button is held, treat NEXT as volume up
|
// If the play/start button is held, treat NEXT as volume up
|
||||||
|
|
@ -1585,7 +1597,7 @@ void loop()
|
||||||
activateSD();
|
activateSD();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loopCounter % VOLTAGE_LOOP_INTERVAL == 0)
|
if (loopCounter % VOLTAGE_LOOP_INTERVAL == 0 && !webrequestActive)
|
||||||
{
|
{
|
||||||
lastVoltage = getBatteryVoltageMv();
|
lastVoltage = getBatteryVoltageMv();
|
||||||
free_heap = xPortGetFreeHeapSize();
|
free_heap = xPortGetFreeHeapSize();
|
||||||
|
|
@ -1608,7 +1620,13 @@ void loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (webrequestActive) {
|
||||||
|
webrequest_blockings++;
|
||||||
|
}
|
||||||
|
|
||||||
loopCounter++;
|
loopCounter++;
|
||||||
|
vTaskDelay(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop2(void *parameter)
|
void loop2(void *parameter)
|
||||||
|
|
@ -1638,7 +1656,7 @@ void loop2(void *parameter)
|
||||||
Serial.println("loop2 started");
|
Serial.println("loop2 started");
|
||||||
loggingDone = true;
|
loggingDone = true;
|
||||||
}
|
}
|
||||||
// vTaskDelay(1);
|
vTaskDelay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue