From 1ea63d7612d4fe479a17417f10c06af670a61592 Mon Sep 17 00:00:00 2001 From: Ulrich Meine <145987006+Scorgan01@users.noreply.github.com> Date: Wed, 2 Sep 2026 21:46:06 +0200 Subject: [PATCH] Enable PageDST810 for small decimals and some code cleanup --- lib/obp60task/PageDST810.cpp | 65 ++++++++++++++++++------------- lib/obp60task/PageFourValues.cpp | 32 ++------------- lib/obp60task/PageFourValues2.cpp | 32 ++------------- 3 files changed, 45 insertions(+), 84 deletions(-) diff --git a/lib/obp60task/PageDST810.cpp b/lib/obp60task/PageDST810.cpp index 93021c2..8a52460 100644 --- a/lib/obp60task/PageDST810.cpp +++ b/lib/obp60task/PageDST810.cpp @@ -5,6 +5,11 @@ class PageDST810 : public Page { + private: + static constexpr int8_t LEFT = 0; + static constexpr int8_t CENTER = 1; + static constexpr int8_t RIGHT = 2; + public: PageDST810(CommonData &common){ commonData = &common; @@ -24,6 +29,9 @@ public: GwConfigHandler *config = commonData->config; GwLog *logger = commonData->logger; + int valueX, valueY; + int DsegFontSize; + // Old values for hold function static String svalue1old = ""; static String unit1old = ""; @@ -40,6 +48,7 @@ public: bool holdvalues = config->getBool(config->holdvalues); String flashLED = config->getString(config->flashLED); String backlightMode = config->getString(config->backlight); + bool smallDecimals = config->getBool(config->smallDecimals); // Get boat values #1 GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue) @@ -100,7 +109,8 @@ public: // Show name getdisplay().setFont(&Ubuntu_Bold20pt8b); getdisplay().setCursor(20, 55); - getdisplay().print("Depth"); // Page name +// getdisplay().print("Depth"); // Page name + getdisplay().print(name1); // Page name // Show unit getdisplay().setFont(&Ubuntu_Bold12pt8b); @@ -112,16 +122,15 @@ public: getdisplay().print(unit1old); } - // Set font - getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); - getdisplay().setCursor(180, 90); - // Show bus data + valueX = 380; + valueY = 90; + DsegFontSize = 30; if(holdvalues == false){ - getdisplay().print(svalue1); // Real value as formated string + printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - getdisplay().print(svalue1old); // Old value as formated string + printBoatValue(svalue1old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid1 == true){ svalue1old = svalue1; // Save the old value @@ -138,7 +147,8 @@ public: // Show name getdisplay().setFont(&Ubuntu_Bold20pt8b); getdisplay().setCursor(20, 145); - getdisplay().print("Speed"); // Page name +// getdisplay().print("Speed"); // Page name + getdisplay().print(name2); // Page name // Show unit getdisplay().setFont(&Ubuntu_Bold12pt8b); @@ -150,16 +160,15 @@ public: getdisplay().print(unit2old); } - // Setfont - getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); - getdisplay().setCursor(180, 180); - // Show bus data + valueX = 380; + valueY = 180; + DsegFontSize = 30; if(holdvalues == false){ - getdisplay().print(svalue2); // Real value as formated string + printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - getdisplay().print(svalue2old); // Old value as formated string + printBoatValue(svalue2old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid2 == true){ svalue2old = svalue2; // Save the old value @@ -176,7 +185,8 @@ public: // Show name getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setCursor(20, 220); - getdisplay().print("Log"); // Page name +// getdisplay().print("Log"); // Page name + getdisplay().print(name3); // Page name // Show unit getdisplay().setFont(&Ubuntu_Bold8pt8b); @@ -188,16 +198,15 @@ public: getdisplay().print(unit3old); } - // Set font - getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); - getdisplay().setCursor(80, 270); - // Show bus data + valueX = 190; + valueY = 270; + DsegFontSize = 20; if(holdvalues == false){ - getdisplay().print(svalue3); // Real value as formated string + printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - getdisplay().print(svalue3old); // Old value as formated string + printBoatValue(svalue3old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid3 == true){ svalue3old = svalue3; // Save the old value @@ -214,7 +223,8 @@ public: // Show name getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setCursor(220, 220); - getdisplay().print("Temp"); // Page name +// getdisplay().print("Temp"); // Page name + getdisplay().print(name4); // Page name // Show unit getdisplay().setFont(&Ubuntu_Bold8pt8b); @@ -226,16 +236,15 @@ public: getdisplay().print(unit4old); } - // Set font - getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); - getdisplay().setCursor(280, 270); - // Show bus data + valueX = 390; + valueY = 270; + DsegFontSize = 20; if(holdvalues == false){ - getdisplay().print(svalue4); // Real value as formated string + printBoatValue(svalue4, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - getdisplay().print(svalue4old); // Old value as formated string + printBoatValue(svalue4old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid4 == true){ svalue4old = svalue4; // Save the old value diff --git a/lib/obp60task/PageFourValues.cpp b/lib/obp60task/PageFourValues.cpp index 23fe5d7..b2d5e3a 100644 --- a/lib/obp60task/PageFourValues.cpp +++ b/lib/obp60task/PageFourValues.cpp @@ -123,20 +123,14 @@ class PageFourValues : public Page if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){ valueY = 55; DsegFontSize = 12; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(120, 55); } else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){ valueY = 67; DsegFontSize = 20; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(150, 58); } else{ valueY = 67; DsegFontSize = 20; - getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); - getdisplay().setCursor(180, 65); } // Show bus data @@ -144,7 +138,7 @@ class PageFourValues : public Page printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - printBoatValue(svalue1old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string + printBoatValue(svalue1old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid1 == true){ svalue1old = svalue1; // Save the old value @@ -177,20 +171,14 @@ class PageFourValues : public Page if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){ valueY = 123; DsegFontSize = 12; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(120, 123); } else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){ valueY = 135; DsegFontSize = 20; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(150, 123); } else{ valueY = 135; DsegFontSize = 20; - getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); - getdisplay().setCursor(180, 133); } // Show bus data @@ -198,7 +186,7 @@ class PageFourValues : public Page printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - printBoatValue(svalue2old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string + printBoatValue(svalue2old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid2 == true){ svalue2old = svalue2; // Save the old value @@ -231,20 +219,14 @@ class PageFourValues : public Page if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){ valueY = 191; DsegFontSize = 16; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(120, 191); } else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){ valueY = 203; DsegFontSize = 20; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(150, 191); } else{ valueY = 203; DsegFontSize = 20; - getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); - getdisplay().setCursor(180, 201); } // Show bus data @@ -252,7 +234,7 @@ class PageFourValues : public Page printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - printBoatValue(svalue3old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string + printBoatValue(svalue3old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid3 == true){ svalue3old = svalue3; // Save the old value @@ -285,20 +267,14 @@ class PageFourValues : public Page if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){ valueY = 271; DsegFontSize = 16; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(120, 259); } else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){ valueY = 271; DsegFontSize = 20; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(150, 259); } else{ valueY = 271; DsegFontSize = 20; - getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); - getdisplay().setCursor(180, 269); } // Show bus data @@ -306,7 +282,7 @@ class PageFourValues : public Page printBoatValue(svalue4, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - printBoatValue(svalue4old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string + printBoatValue(svalue4old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid4 == true){ svalue4old = svalue4; // Save the old value diff --git a/lib/obp60task/PageFourValues2.cpp b/lib/obp60task/PageFourValues2.cpp index af1edcf..e34cc34 100644 --- a/lib/obp60task/PageFourValues2.cpp +++ b/lib/obp60task/PageFourValues2.cpp @@ -123,20 +123,14 @@ class PageFourValues2 : public Page if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){ valueY = 90; DsegFontSize = 20; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(100, 90); } else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){ valueY = 80; DsegFontSize = 20; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(180, 77); } else{ valueY = 90; DsegFontSize = 30; - getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); - getdisplay().setCursor(180, 90); } // Show bus data @@ -144,7 +138,7 @@ class PageFourValues2 : public Page printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - printBoatValue(svalue1old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string + printBoatValue(svalue1old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid1 == true){ svalue1old = svalue1; // Save the old value @@ -177,20 +171,14 @@ class PageFourValues2 : public Page if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){ valueY = 180; DsegFontSize = 20; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(100, 180); } else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){ valueY = 170; DsegFontSize = 20; - getdisplay().setFont(&Ubuntu_Bold12pt8b); - getdisplay().setCursor(180, 158); } else{ valueY = 180; DsegFontSize = 30; - getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); - getdisplay().setCursor(180, 180); } // Show bus data @@ -198,7 +186,7 @@ class PageFourValues2 : public Page printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - printBoatValue(svalue2old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string + printBoatValue(svalue2old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid2 == true){ svalue2old = svalue2; // Save the old value @@ -232,20 +220,14 @@ class PageFourValues2 : public Page if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){ valueY = 250; DsegFontSize = 10; - getdisplay().setFont(&Ubuntu_Bold8pt8b); - getdisplay().setCursor(50, 240); } else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){ valueY = 253; DsegFontSize = 10; - getdisplay().setFont(&Ubuntu_Bold8pt8b); - getdisplay().setCursor(100, 240); } else{ valueY = 270; DsegFontSize = 20; - getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); - getdisplay().setCursor(80, 270); } // Show bus data @@ -253,7 +235,7 @@ class PageFourValues2 : public Page printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - printBoatValue(svalue3old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string + printBoatValue(svalue3old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid3 == true){ svalue3old = svalue3; // Save the old value @@ -287,20 +269,14 @@ class PageFourValues2 : public Page if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){ valueY = 250; DsegFontSize = 10; - getdisplay().setFont(&Ubuntu_Bold8pt8b); - getdisplay().setCursor(250, 240); } else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){ valueY = 253; DsegFontSize = 10; - getdisplay().setFont(&Ubuntu_Bold8pt8b); - getdisplay().setCursor(300, 240); } else{ valueY = 270; DsegFontSize = 20; - getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); - getdisplay().setCursor(280, 270); } // Show bus data @@ -308,7 +284,7 @@ class PageFourValues2 : public Page printBoatValue(svalue4, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string } else{ - printBoatValue(svalue4old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string + printBoatValue(svalue4old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string } if(valid4 == true){ svalue4old = svalue4; // Save the old value