From db3c3d1ccd26a9cabdbe7afff303657c159379a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Fri, 12 Apr 2024 13:08:12 +0200 Subject: [PATCH] log clean --- lib/patrix/config.cpp | 2 +- src/Fermenter.cpp | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/patrix/config.cpp b/lib/patrix/config.cpp index 192b565..0961577 100644 --- a/lib/patrix/config.cpp +++ b/lib/patrix/config.cpp @@ -88,7 +88,7 @@ void configPrint() { } } - info(" -%-15s = %s", key, valueStr); + info(" %-15s = %s", key, valueStr); } } diff --git a/src/Fermenter.cpp b/src/Fermenter.cpp index c762593..3bcab59 100644 --- a/src/Fermenter.cpp +++ b/src/Fermenter.cpp @@ -61,12 +61,14 @@ void patrixLoop() { heaterPWM = 0; } - const bool emergencyCutOff = heaterPWM > 0 && temperatureCurrent > temperatureTarget + temperatureOver; - if (emergencyCutOff) { + const char *emergencyStr = "HEATING"; + if (heaterPWM > 0 && temperatureCurrent > temperatureTarget + temperatureOver) { heaterPWM = 0; + emergencyStr = "[EMERGENCY CUTOFF]"; + } else if (heaterPWM == 0) { + emergencyStr = "---"; } - heaterPWM = min(CONTROL_PWM_MAX, max(0.0, heaterPWM)); analogWrite(CONTROL_GPIO, (int) round(heaterPWM)); static unsigned long lastDebug = 0; @@ -74,10 +76,16 @@ void patrixLoop() { if (now - lastDebug >= 1000) { lastDebug = now; int heaterPercent = (int) round(100.0 * heaterPWM / CONTROL_PWM_MAX); - debug("p: %.10f | i: %.10f | d: %.10f | current: %5.2f | target: %5.2f | heater: %3d%%", proportional, integral, derivative, temperatureCurrent, temperatureTarget, heaterPercent); - if (emergencyCutOff) { - error("[EMERGENCY CUTOFF] temperatureCurrent (=%5.2f) > temperatureTarget + %5.2f (=%5.2f) [EMERGENCY CUTOFF]", temperatureCurrent, temperatureOver, temperatureTarget); - } + debug( + "p: %.12f | i: %.12f | d: %.12f | current: %5.2f | target: %5.2f | heater: %3d%% | %s", + proportional == 0 ? NAN : proportional, + integral == 0 ? NAN : integral, + derivative == 0 ? NAN : derivative, + temperatureCurrent, + temperatureTarget, + heaterPercent, + emergencyStr + ); } }