From 9299eb43d9906175f6c80ccd8fe4331e1b86f144 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Wed, 29 Apr 2020 11:09:59 +0200 Subject: [PATCH] Fix for showing bar and meter. --- UI.hpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/UI.hpp b/UI.hpp index 14585e8..5b6eaac 100644 --- a/UI.hpp +++ b/UI.hpp @@ -4535,7 +4535,6 @@ void lcd_display_bar_float(const char* title, float value, float factor, int32_t } else { - for (uint8_t i = 0; i < vi; i++) lcd.write((uint8_t)4); // full block if (vi < LCD_cols) @@ -4593,15 +4592,24 @@ void lcd_display_meter_float(const char* title, float value, float factor, float if (vi == 0) { - lcd.write((uint8_t)vf / 2.0 - 0.5); - lcd.print(F(" ")); + lcd.write((uint8_t)(vf / 2.0 + 0.5)); + for (uint8_t i = 1; i < LCD_cols; i++) + lcd.print(F(" ")); // empty block + } + else if (vi == LCD_cols) + { + for (uint8_t i = 0; i < LCD_cols - 1; i++) + lcd.print(F(" ")); // empty block + lcd.write(4); } else { for (uint8_t i = 0; i < LCD_cols; i++) lcd.print(F(" ")); // empty block - lcd.setCursor(vi - 1, 1); - lcd.write((uint8_t)vf / 2.0 - 0.5); + lcd.setCursor(vi, 1); + lcd.write((uint8_t)(vf / 2.0 + 0.5)); + for (uint8_t i = vi + 1; i < LCD_cols; i++) + lcd.print(F(" ")); // empty block } }