changes
This commit is contained in:
@ -1,14 +1,18 @@
|
||||
|
||||
#include <WString.h>
|
||||
#include "uptime.h"
|
||||
|
||||
|
||||
|
||||
|
||||
UptimeCmd::UptimeCmd(Uptime *uptime) : m_uptime(uptime) {
|
||||
|
||||
}
|
||||
|
||||
String UptimeCmd::exec(String params) {
|
||||
return m_uptime->getDays() + String(" ") +
|
||||
String res = m_uptime->getDays() + String(" ") +
|
||||
m_uptime->getHours() + String(":") + m_uptime->getMinutes() + String(":") + m_uptime->getSeconds();
|
||||
return res;
|
||||
}
|
||||
|
||||
Uptime::Uptime() : m_uptimeCmd(this), m_seconds(0), m_minutes(0), m_hours(0), m_days(0) {
|
||||
@ -24,6 +28,7 @@ void Uptime::begin(CmdServer *cmdServer) {
|
||||
void Uptime::exec() {
|
||||
static unsigned long lastMillis = 0;
|
||||
|
||||
|
||||
unsigned long currentMillis = millis();
|
||||
if (currentMillis >= (lastMillis + 1000)) {
|
||||
m_seconds += ((currentMillis - lastMillis) / 1000);
|
||||
@ -42,4 +47,5 @@ void Uptime::exec() {
|
||||
|
||||
lastMillis = currentMillis;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user