Add uptime to serial status output
This commit is contained in:
@@ -582,6 +582,7 @@ void printStatus(const __FlashStringHelper *tag) {
|
||||
Serial.print(F("["));
|
||||
Serial.print(tag);
|
||||
Serial.println(F("]"));
|
||||
printUptime();
|
||||
Serial.print(F("raw="));
|
||||
Serial.print(parkingRawValue);
|
||||
Serial.print(F(" ig="));
|
||||
@@ -623,6 +624,26 @@ void printStatus(const __FlashStringHelper *tag) {
|
||||
Serial.println(autoCalibrationState);
|
||||
}
|
||||
|
||||
void printUptime() {
|
||||
unsigned long totalMs = millis();
|
||||
unsigned long hours = totalMs / 3600000UL;
|
||||
totalMs %= 3600000UL;
|
||||
unsigned long minutes = totalMs / 60000UL;
|
||||
totalMs %= 60000UL;
|
||||
unsigned long seconds = totalMs / 1000UL;
|
||||
unsigned long milliseconds = totalMs % 1000UL;
|
||||
|
||||
Serial.print(F("uptime="));
|
||||
Serial.print(hours);
|
||||
Serial.print(F("h "));
|
||||
Serial.print(minutes);
|
||||
Serial.print(F("m "));
|
||||
Serial.print(seconds);
|
||||
Serial.print(F("s "));
|
||||
Serial.print(milliseconds);
|
||||
Serial.println(F("ms"));
|
||||
}
|
||||
|
||||
void setRelay(int relayPin, boolean state) {
|
||||
digitalWrite(relayPin, state ? LOW : HIGH);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user