From c1e69dd81bdf37649935555a418cf01afac2a39f Mon Sep 17 00:00:00 2001 From: Ulrich Meine Date: Tue, 1 Sep 2026 22:29:55 +0200 Subject: [PATCH] Enable page Battery for small decimals; small adjustment for PageVoltage --- lib/obp60task/PageBattery.cpp | 47 +++++++++++++++-------------------- lib/obp60task/PageVoltage.cpp | 11 +++++--- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/lib/obp60task/PageBattery.cpp b/lib/obp60task/PageBattery.cpp index e53f12f..e5951c1 100644 --- a/lib/obp60task/PageBattery.cpp +++ b/lib/obp60task/PageBattery.cpp @@ -5,6 +5,10 @@ class PageBattery : public Page { + static constexpr int8_t LEFT = 0; + static constexpr int8_t CENTER = 1; + static constexpr int8_t RIGHT = 2; + int average = 0; // Average type [0...3], 0=off, 1=10s, 2=60s, 3=300s public: @@ -56,6 +60,7 @@ class PageBattery : public Page String backlightMode = config->getString(config->backlight); String powsensor1 = config->getString(config->usePowSensor1); bool simulation = config->getBool(config->useSimuData); + bool smallDecimals = config->getBool(config->smallDecimals); // Get voltage value String name1 = "VBat"; // Value name @@ -218,17 +223,13 @@ class PageBattery : public Page getdisplay().setCursor(20, 90); getdisplay().print(unit1); // Unit - // Show value - getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); - getdisplay().setCursor(180, 90); - - // Show bus data + // Show bus value if(String(powsensor1) != "off"){ - getdisplay().print(value1,2); // Real value as formated string - } - else{ - getdisplay().print("---"); // No sensor data (sensor is off) + svalue1 = formatValue(value1, String("formatXdr:U:V"), *commonData); + } else{ + svalue1 = "---"; } + printBoatValue(svalue1, 380, 90, RIGHT, 30, smallDecimals); // Real value as formated string // ############### Horizontal Line ################ @@ -247,17 +248,13 @@ class PageBattery : public Page getdisplay().setCursor(20, 180); getdisplay().print(unit2); // Unit - // Show value - getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); - getdisplay().setCursor(180, 180); - - // Show bus data + // Show bus value if(String(powsensor1) != "off"){ - getdisplay().print(value2,1); // Real value as formated string - } - else{ - getdisplay().print("---"); // No sensor data (sensor is off) + svalue2 = formatValue(value2, String("formatXdr:U:V"), *commonData); + } else{ + svalue2 = "---"; } + printBoatValue(svalue2, 380, 180, RIGHT, 30, smallDecimals); // Real value as formated string // ############### Horizontal Line ################ @@ -276,17 +273,13 @@ class PageBattery : public Page getdisplay().setCursor(20, 270); getdisplay().print(unit3); // Unit - // Show value - getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); - getdisplay().setCursor(180, 270); - - // Show bus data + // Show bus value if(String(powsensor1) != "off"){ - getdisplay().print(value3,1); // Real value as formated string - } - else{ - getdisplay().print("---"); // No sensor data (sensor is off) + svalue3 = formatValue(value3, String("formatXdr:U:V"), *commonData); + } else{ + svalue3 = "---"; } + printBoatValue(svalue3, 380, 270, RIGHT, 30, smallDecimals); // Real value as formated string return PAGE_UPDATE; }; diff --git a/lib/obp60task/PageVoltage.cpp b/lib/obp60task/PageVoltage.cpp index 000bc88..2f3a033 100644 --- a/lib/obp60task/PageVoltage.cpp +++ b/lib/obp60task/PageVoltage.cpp @@ -117,6 +117,7 @@ public: bool smallDecimals = config->getBool(config->smallDecimals); double value1 = 0; + String svalue = "---"; double valueTrend = 0; // Average over 10 values // Get voltage value @@ -239,10 +240,12 @@ public: printAvg(average, 320, 84, true); // Reading bus data or using simulation data - getdisplay().setFont(&DSEG7Classic_BoldItalic60pt7b); - getdisplay().setCursor(20, 240); - String sValue = formatValue(value1, String("formatXdr:U:V"), *commonData); - printBoatValue(sValue, 300, 240, RIGHT, 60, smallDecimals); + if(valid1 == true || holdvalues == true){ + svalue = formatValue(value1, String("formatXdr:U:V"), *commonData); + } else { + svalue = "---"; // Missing bus data + } + printBoatValue(svalue, 300, 240, RIGHT, 60, smallDecimals); // Show trend indicator if(trend == true){