This commit is contained in:
hg
2014-02-23 23:42:22 +01:00
parent a8d1708512
commit 0c111dd818
3 changed files with 11 additions and 6 deletions

View File

@ -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;
}
}