From 2a9e8efb3de6c763039546b31316a1f68aaac7c9 Mon Sep 17 00:00:00 2001 From: Robin Dietzel Date: Fri, 3 Feb 2023 11:26:53 +0100 Subject: [PATCH] FIX: removed ui glitches --- floatpump/Core/Src/main.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/floatpump/Core/Src/main.cpp b/floatpump/Core/Src/main.cpp index a02c376..e9cd5b7 100644 --- a/floatpump/Core/Src/main.cpp +++ b/floatpump/Core/Src/main.cpp @@ -226,11 +226,11 @@ int main(void) { display.LCDSetBacklight(S_backlight); + char buf[20]; display.LCDSetCursor(0, 0); - display.LCDSendCString( - const_cast(std::string( - "Fuellstand " + std::to_string(tankLevel0.getPercent()) + " %").c_str())); + sprintf(buf, "Fuellstand %3d %%", tankLevel0.getPercent()); + display.LCDSendCString(buf); display.LCDSetCursor(0, 1); if (S_tankempty) { display.LCDSendCString(const_cast(std::string("Tank Wassermangel ").c_str())); @@ -254,12 +254,13 @@ int main(void) { display.LCDSetCursor(0, 3); if (S_refillcooldown > 0) { int remaining_mins = S_refillcooldown / 60; - if (remaining_mins > 0) - display.LCDSendCString(const_cast(std::string( - "Nsp. wartet: min " + std::to_string(S_refillcooldown / 60)).c_str())); - else - display.LCDSendCString( - const_cast(std::string("Nsp. wartet: s " + std::to_string(S_refillcooldown)).c_str())); + if (remaining_mins > 0) { + sprintf(buf, "Nsp. wartet: %3d min", S_refillcooldown / 60); + display.LCDSendCString(buf); + } else { + sprintf(buf, "Nsp. wartet: %3d sec", S_refillcooldown); + display.LCDSendCString(buf); + } } else if (S_refillempty) { display.LCDSendCString(const_cast(std::string("Nachspeisung mangel ").c_str())); HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET);