change uptime value

This commit is contained in:
Stephan Mühl
2023-04-09 19:41:01 +02:00
parent 2a8149400b
commit d8fe5095f0
2 changed files with 3 additions and 8 deletions

View File

@@ -363,18 +363,12 @@ void PeripheryManager_::checkAlarms()
}
}
const char *PeripheryManager_::readUptime()
const char* PeripheryManager_::readUptime()
{
static char uptime[25]; // Make the array static to keep it from being destroyed when the function returns
unsigned long currentTime = millis();
unsigned long elapsedTime = currentTime - startTime;
unsigned long uptimeSeconds = elapsedTime / 1000;
unsigned long uptimeMinutes = uptimeSeconds / 60;
unsigned long uptimeHours = uptimeMinutes / 60;
unsigned long uptimeDays = uptimeHours / 24;
unsigned long hours = uptimeHours % 24;
unsigned long minutes = uptimeMinutes % 60;
unsigned long seconds = uptimeSeconds % 60;
sprintf(uptime, "P%dDT%dH%dM%dS", uptimeDays, hours, minutes, seconds);
sprintf(uptime, "%lu", uptimeSeconds);
return uptime;
}