Show calibration wait timer in debug output
This commit is contained in:
@@ -622,6 +622,7 @@ void printStatus(const __FlashStringHelper *tag) {
|
||||
Serial.print(forceCalibration ? 1 : 0);
|
||||
Serial.print(F(" autoCalState="));
|
||||
Serial.println(autoCalibrationState);
|
||||
printAutoCalibrationDelayStatus();
|
||||
}
|
||||
|
||||
void printUptime() {
|
||||
@@ -644,6 +645,48 @@ void printUptime() {
|
||||
Serial.println(F("ms"));
|
||||
}
|
||||
|
||||
void printAutoCalibrationDelayStatus() {
|
||||
if (useCount < USES_BEFORE_AUTO_CALIBRATION) {
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.print(F("autoCalOffTimer="));
|
||||
if (ignitionState == HIGH) {
|
||||
Serial.println(F("waiting_for_ig_off"));
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned long elapsedMs = millis() - ignitionOffStartTime;
|
||||
unsigned long remainingMs = 0;
|
||||
if (elapsedMs < AUTO_CALIBRATION_DELAY_MS) {
|
||||
remainingMs = AUTO_CALIBRATION_DELAY_MS - elapsedMs;
|
||||
}
|
||||
|
||||
Serial.print(F("elapsed "));
|
||||
printDuration(elapsedMs);
|
||||
Serial.print(F(" remaining "));
|
||||
printDuration(remainingMs);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void printDuration(unsigned long totalMs) {
|
||||
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(hours);
|
||||
Serial.print(F("h "));
|
||||
Serial.print(minutes);
|
||||
Serial.print(F("m "));
|
||||
Serial.print(seconds);
|
||||
Serial.print(F("s "));
|
||||
Serial.print(milliseconds);
|
||||
Serial.print(F("ms"));
|
||||
}
|
||||
|
||||
void setRelay(int relayPin, boolean state) {
|
||||
digitalWrite(relayPin, state ? LOW : HIGH);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user