diff --git a/lib/obp60task/PageAutopilot.cpp b/lib/obp60task/PageAutopilot.cpp index b57c159..4671938 100644 --- a/lib/obp60task/PageAutopilot.cpp +++ b/lib/obp60task/PageAutopilot.cpp @@ -31,6 +31,10 @@ const float Compass_LineDelta = 8.0;// Compass band: 1deg = 5 Pixels, 10deg = 50 class PageAutopilot : public Page { + static constexpr int8_t LEFT = 0; + static constexpr int8_t CENTER = 1; + static constexpr int8_t RIGHT = 2; + int WhichDataCompass = ShowHDM; // Start value int WhichDataDisplay = ShowHDM; // Start value @@ -85,6 +89,7 @@ class PageAutopilot : public Page bool holdvalues = config->getBool(config->holdvalues); String flashLED = config->getString(config->flashLED); String backlightMode = config->getString(config->backlight); + bool smallDecimals = config->getBool(config->smallDecimals); GwApi::BoatValue *bvalue; String DataName[HowManyValues]; @@ -130,14 +135,12 @@ class PageAutopilot : public Page getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setCursor(10, 120); getdisplay().print(DataUnits[WhichDataDisplay]); - getdisplay().setCursor(190, 120); - getdisplay().setFont(&DSEG7Classic_BoldItalic42pt7b); - + if(holdvalues == false){ - getdisplay().print(DataText[WhichDataDisplay]); // Real value as formated string + printBoatValue(DataText[WhichDataDisplay], 190, 120, LEFT, 42, smallDecimals); // Real value as formated string } else{ - getdisplay().print(OldDataText[WhichDataDisplay]); // Old value as formated string + printBoatValue(OldDataText[WhichDataDisplay], 190, 120, LEFT, 42, smallDecimals); // Old value as formated string } if(DataValid[WhichDataDisplay] == true){ OldDataText[WhichDataDisplay] = DataText[WhichDataDisplay]; // Save the old value diff --git a/lib/obp60task/PageBME280.cpp b/lib/obp60task/PageBME280.cpp index e54b629..a82bc91 100644 --- a/lib/obp60task/PageBME280.cpp +++ b/lib/obp60task/PageBME280.cpp @@ -5,6 +5,10 @@ class PageBME280 : public Page { + static constexpr int8_t LEFT = 0; + static constexpr int8_t CENTER = 1; + static constexpr int8_t RIGHT = 2; + public: PageBME280(CommonData &common){ commonData = &common; @@ -37,6 +41,7 @@ class PageBME280 : public Page String flashLED = config->getString(config->flashLED); String backlightMode = config->getString(config->backlight); String useenvsensor = config->getString(config->useEnvSensor); + bool smallDecimals = config->getBool(config->smallDecimals); // Get sensor values #1 String name1 = "Temp"; // Value name @@ -121,12 +126,8 @@ class PageBME280 : public Page getdisplay().setCursor(20, 90); getdisplay().print(unit1); // Unit - // Switch font if format for any values - getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); - getdisplay().setCursor(180, 90); - // Show bus data - getdisplay().print(svalue1); // Real value as formated string + printBoatValue(svalue1, 380, 90, RIGHT, 30, smallDecimals); // Real value as formated string // ############### Horizontal Line ################ @@ -145,12 +146,8 @@ class PageBME280 : public Page getdisplay().setCursor(20, 180); getdisplay().print(unit2); // Unit - // Switch font if format for any values - getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); - getdisplay().setCursor(180, 180); - // Show bus data - getdisplay().print(svalue2); // Real value as formated string + printBoatValue(svalue2, 380, 180, RIGHT, 30, smallDecimals); // Real value as formated string // ############### Horizontal Line ################ @@ -169,12 +166,8 @@ class PageBME280 : public Page getdisplay().setCursor(20, 270); getdisplay().print(unit3); // Unit - // Switch font if format for any values - getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b); - getdisplay().setCursor(140, 270); - // Show bus data - getdisplay().print(svalue3); // Real value as formated string + printBoatValue(svalue3, 380, 270, RIGHT, 30, smallDecimals); // Real value as formated string return PAGE_UPDATE; }; diff --git a/lib/obp60task/PageCompass.cpp b/lib/obp60task/PageCompass.cpp index f5e14b5..45e5edf 100644 --- a/lib/obp60task/PageCompass.cpp +++ b/lib/obp60task/PageCompass.cpp @@ -24,6 +24,10 @@ const float Compass_LineDelta = 8.0;// Compass band: 1deg = 5 Pixels, 10deg = 50 class PageCompass : public Page { + static constexpr int8_t LEFT = 0; + static constexpr int8_t CENTER = 1; + static constexpr int8_t RIGHT = 2; + int WhichDataCompass = ShowHDM; int WhichDataDisplay = ShowHDM; @@ -75,6 +79,7 @@ class PageCompass : public Page bool holdvalues = config->getBool(config->holdvalues); String flashLED = config->getString(config->flashLED); String backlightMode = config->getString(config->backlight); + bool smallDecimals = config->getBool(config->smallDecimals); GwApi::BoatValue *bvalue; String DataName[HowManyValues]; @@ -122,14 +127,12 @@ class PageCompass : public Page getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setCursor(10, 120); getdisplay().print(DataUnits[WhichDataDisplay]); - getdisplay().setCursor(190, 120); - getdisplay().setFont(&DSEG7Classic_BoldItalic42pt7b); - + if(holdvalues == false){ - getdisplay().print(DataText[WhichDataDisplay]); // Real value as formated string + printBoatValue(DataText[WhichDataDisplay], 190, 120, LEFT, 42, smallDecimals); // Real value as formated string } else{ - getdisplay().print(OldDataText[WhichDataDisplay]); // Old value as formated string + printBoatValue(OldDataText[WhichDataDisplay], 190, 120, LEFT, 42, smallDecimals); // Old value as formated string } if(DataValid[WhichDataDisplay] == true){ OldDataText[WhichDataDisplay] = DataText[WhichDataDisplay]; // Save the old value diff --git a/lib/obp60task/PageCurrent.cpp b/lib/obp60task/PageCurrent.cpp index 96f9e37..5b1e3f1 100644 --- a/lib/obp60task/PageCurrent.cpp +++ b/lib/obp60task/PageCurrent.cpp @@ -39,10 +39,10 @@ struct Points { // Screen coordinates for four boat data values (top-left, bottom-left, top-right, bottom-right) static constexpr Points POS[] = { - { 10, 65, 10, 95, 10, 115 }, // Position top left for value, name, unit - { 10, 270, 10, 220, 10, 190 }, // Position bottom left - { 295, 65, 390, 95, 390, 115 }, // Position top right - { 295, 270, 390, 220, 390, 190 } // Position bottom right + { 101, 65, 10, 95, 10, 115 }, // Position top left for value, name, unit + { 101, 270, 10, 220, 10, 190 }, // Position bottom left + { 395, 65, 390, 95, 390, 115 }, // Position top right + { 395, 270, 390, 220, 390, 190 } // Position bottom right }; // Define wave visual (XBM Format) @@ -75,6 +75,10 @@ static const uint8_t wave_bitmap[] PROGMEM = { class PageCurrent : public Page { private: + static constexpr int8_t LEFT = 0; + static constexpr int8_t CENTER = 1; + static constexpr int8_t RIGHT = 2; + GwLog* logger; int width; // Screen width @@ -86,6 +90,7 @@ private: bool holdValues; String flashLED; String backlightMode; + bool smallDecimals; String leeKStd; double leeK; movingAvgAngle SetAvg {8}; // Store average of the last 8 values of SET angle values @@ -317,6 +322,7 @@ public: holdValues = commonData->config->getBool(commonData->config->holdvalues); flashLED = commonData->config->getString(commonData->config->flashLED); backlightMode = commonData->config->getString(commonData->config->backlight); + smallDecimals = commonData->config->getBool(commonData->config->smallDecimals); leeKStd = commonData->config->getString(commonData->config->leeKStd); auto it = leeKMap.find(leeKStd.c_str()); @@ -435,12 +441,10 @@ public: unit = unit.substring(0, 6); // String length limit for value unit // Show boat data value - getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); - getdisplay().setCursor(POS[i].x1, POS[i].y1); if (!holdValues || useSimuData) { - getdisplay().print(sValue); + printBoatValue(sValue, POS[i].x1, POS[i].y1, RIGHT, 20, smallDecimals); } else { - getdisplay().print(sValueOld[i]); + printBoatValue(sValueOld[i], POS[i].x1, POS[i].y1, RIGHT, 20, smallDecimals); } // Show name