Enable PageDST810 for small decimals and some code cleanup

This commit is contained in:
Ulrich Meine
2026-09-02 21:46:06 +02:00
parent 9186491b5e
commit 1ea63d7612
3 changed files with 45 additions and 84 deletions
+37 -28
View File
@@ -5,6 +5,11 @@
class PageDST810 : public Page class PageDST810 : public Page
{ {
private:
static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2;
public: public:
PageDST810(CommonData &common){ PageDST810(CommonData &common){
commonData = &common; commonData = &common;
@@ -24,6 +29,9 @@ public:
GwConfigHandler *config = commonData->config; GwConfigHandler *config = commonData->config;
GwLog *logger = commonData->logger; GwLog *logger = commonData->logger;
int valueX, valueY;
int DsegFontSize;
// Old values for hold function // Old values for hold function
static String svalue1old = ""; static String svalue1old = "";
static String unit1old = ""; static String unit1old = "";
@@ -40,6 +48,7 @@ public:
bool holdvalues = config->getBool(config->holdvalues); bool holdvalues = config->getBool(config->holdvalues);
String flashLED = config->getString(config->flashLED); String flashLED = config->getString(config->flashLED);
String backlightMode = config->getString(config->backlight); String backlightMode = config->getString(config->backlight);
bool smallDecimals = config->getBool(config->smallDecimals);
// Get boat values #1 // Get boat values #1
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue) GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
@@ -100,7 +109,8 @@ public:
// Show name // Show name
getdisplay().setFont(&Ubuntu_Bold20pt8b); getdisplay().setFont(&Ubuntu_Bold20pt8b);
getdisplay().setCursor(20, 55); getdisplay().setCursor(20, 55);
getdisplay().print("Depth"); // Page name // getdisplay().print("Depth"); // Page name
getdisplay().print(name1); // Page name
// Show unit // Show unit
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
@@ -112,16 +122,15 @@ public:
getdisplay().print(unit1old); getdisplay().print(unit1old);
} }
// Set font
getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b);
getdisplay().setCursor(180, 90);
// Show bus data // Show bus data
valueX = 380;
valueY = 90;
DsegFontSize = 30;
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue1); // Real value as formated string printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue1old); // Old value as formated string printBoatValue(svalue1old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string
} }
if(valid1 == true){ if(valid1 == true){
svalue1old = svalue1; // Save the old value svalue1old = svalue1; // Save the old value
@@ -138,7 +147,8 @@ public:
// Show name // Show name
getdisplay().setFont(&Ubuntu_Bold20pt8b); getdisplay().setFont(&Ubuntu_Bold20pt8b);
getdisplay().setCursor(20, 145); getdisplay().setCursor(20, 145);
getdisplay().print("Speed"); // Page name // getdisplay().print("Speed"); // Page name
getdisplay().print(name2); // Page name
// Show unit // Show unit
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
@@ -150,16 +160,15 @@ public:
getdisplay().print(unit2old); getdisplay().print(unit2old);
} }
// Setfont
getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b);
getdisplay().setCursor(180, 180);
// Show bus data // Show bus data
valueX = 380;
valueY = 180;
DsegFontSize = 30;
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue2); // Real value as formated string printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue2old); // Old value as formated string printBoatValue(svalue2old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string
} }
if(valid2 == true){ if(valid2 == true){
svalue2old = svalue2; // Save the old value svalue2old = svalue2; // Save the old value
@@ -176,7 +185,8 @@ public:
// Show name // Show name
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(20, 220); getdisplay().setCursor(20, 220);
getdisplay().print("Log"); // Page name // getdisplay().print("Log"); // Page name
getdisplay().print(name3); // Page name
// Show unit // Show unit
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
@@ -188,16 +198,15 @@ public:
getdisplay().print(unit3old); getdisplay().print(unit3old);
} }
// Set font
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(80, 270);
// Show bus data // Show bus data
valueX = 190;
valueY = 270;
DsegFontSize = 20;
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue3); // Real value as formated string printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue3old); // Old value as formated string printBoatValue(svalue3old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string
} }
if(valid3 == true){ if(valid3 == true){
svalue3old = svalue3; // Save the old value svalue3old = svalue3; // Save the old value
@@ -214,7 +223,8 @@ public:
// Show name // Show name
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(220, 220); getdisplay().setCursor(220, 220);
getdisplay().print("Temp"); // Page name // getdisplay().print("Temp"); // Page name
getdisplay().print(name4); // Page name
// Show unit // Show unit
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
@@ -226,16 +236,15 @@ public:
getdisplay().print(unit4old); getdisplay().print(unit4old);
} }
// Set font
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(280, 270);
// Show bus data // Show bus data
valueX = 390;
valueY = 270;
DsegFontSize = 20;
if(holdvalues == false){ if(holdvalues == false){
getdisplay().print(svalue4); // Real value as formated string printBoatValue(svalue4, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ else{
getdisplay().print(svalue4old); // Old value as formated string printBoatValue(svalue4old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Old value as formated string
} }
if(valid4 == true){ if(valid4 == true){
svalue4old = svalue4; // Save the old value svalue4old = svalue4; // Save the old value
+4 -28
View File
@@ -123,20 +123,14 @@ class PageFourValues : public Page
if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){ if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){
valueY = 55; valueY = 55;
DsegFontSize = 12; DsegFontSize = 12;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(120, 55);
} }
else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){ else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){
valueY = 67; valueY = 67;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(150, 58);
} }
else{ else{
valueY = 67; valueY = 67;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(180, 65);
} }
// Show bus data // Show bus data
@@ -144,7 +138,7 @@ class PageFourValues : public Page
printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ 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){ if(valid1 == true){
svalue1old = svalue1; // Save the old value svalue1old = svalue1; // Save the old value
@@ -177,20 +171,14 @@ class PageFourValues : public Page
if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){ if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){
valueY = 123; valueY = 123;
DsegFontSize = 12; DsegFontSize = 12;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(120, 123);
} }
else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){ else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){
valueY = 135; valueY = 135;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(150, 123);
} }
else{ else{
valueY = 135; valueY = 135;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(180, 133);
} }
// Show bus data // Show bus data
@@ -198,7 +186,7 @@ class PageFourValues : public Page
printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ 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){ if(valid2 == true){
svalue2old = svalue2; // Save the old value svalue2old = svalue2; // Save the old value
@@ -231,20 +219,14 @@ class PageFourValues : public Page
if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){ if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){
valueY = 191; valueY = 191;
DsegFontSize = 16; DsegFontSize = 16;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(120, 191);
} }
else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){ else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){
valueY = 203; valueY = 203;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(150, 191);
} }
else{ else{
valueY = 203; valueY = 203;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(180, 201);
} }
// Show bus data // Show bus data
@@ -252,7 +234,7 @@ class PageFourValues : public Page
printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ 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){ if(valid3 == true){
svalue3old = svalue3; // Save the old value svalue3old = svalue3; // Save the old value
@@ -285,20 +267,14 @@ class PageFourValues : public Page
if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){ if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){
valueY = 271; valueY = 271;
DsegFontSize = 16; DsegFontSize = 16;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(120, 259);
} }
else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){ else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){
valueY = 271; valueY = 271;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(150, 259);
} }
else{ else{
valueY = 271; valueY = 271;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(180, 269);
} }
// Show bus data // Show bus data
@@ -306,7 +282,7 @@ class PageFourValues : public Page
printBoatValue(svalue4, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string printBoatValue(svalue4, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ 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){ if(valid4 == true){
svalue4old = svalue4; // Save the old value svalue4old = svalue4; // Save the old value
+4 -28
View File
@@ -123,20 +123,14 @@ class PageFourValues2 : public Page
if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){ if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){
valueY = 90; valueY = 90;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(100, 90);
} }
else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){ else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){
valueY = 80; valueY = 80;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(180, 77);
} }
else{ else{
valueY = 90; valueY = 90;
DsegFontSize = 30; DsegFontSize = 30;
getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b);
getdisplay().setCursor(180, 90);
} }
// Show bus data // Show bus data
@@ -144,7 +138,7 @@ class PageFourValues2 : public Page
printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string printBoatValue(svalue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ 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){ if(valid1 == true){
svalue1old = svalue1; // Save the old value svalue1old = svalue1; // Save the old value
@@ -177,20 +171,14 @@ class PageFourValues2 : public Page
if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){ if(bvalue2->getFormat() == "formatLatitude" || bvalue2->getFormat() == "formatLongitude"){
valueY = 180; valueY = 180;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(100, 180);
} }
else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){ else if(bvalue2->getFormat() == "formatTime" || bvalue2->getFormat() == "formatDate"){
valueY = 170; valueY = 170;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&Ubuntu_Bold12pt8b);
getdisplay().setCursor(180, 158);
} }
else{ else{
valueY = 180; valueY = 180;
DsegFontSize = 30; DsegFontSize = 30;
getdisplay().setFont(&DSEG7Classic_BoldItalic30pt7b);
getdisplay().setCursor(180, 180);
} }
// Show bus data // Show bus data
@@ -198,7 +186,7 @@ class PageFourValues2 : public Page
printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string printBoatValue(svalue2, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ 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){ if(valid2 == true){
svalue2old = svalue2; // Save the old value svalue2old = svalue2; // Save the old value
@@ -232,20 +220,14 @@ class PageFourValues2 : public Page
if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){ if(bvalue3->getFormat() == "formatLatitude" || bvalue3->getFormat() == "formatLongitude"){
valueY = 250; valueY = 250;
DsegFontSize = 10; DsegFontSize = 10;
getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(50, 240);
} }
else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){ else if(bvalue3->getFormat() == "formatTime" || bvalue3->getFormat() == "formatDate"){
valueY = 253; valueY = 253;
DsegFontSize = 10; DsegFontSize = 10;
getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(100, 240);
} }
else{ else{
valueY = 270; valueY = 270;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(80, 270);
} }
// Show bus data // Show bus data
@@ -253,7 +235,7 @@ class PageFourValues2 : public Page
printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string printBoatValue(svalue3, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ 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){ if(valid3 == true){
svalue3old = svalue3; // Save the old value svalue3old = svalue3; // Save the old value
@@ -287,20 +269,14 @@ class PageFourValues2 : public Page
if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){ if(bvalue4->getFormat() == "formatLatitude" || bvalue4->getFormat() == "formatLongitude"){
valueY = 250; valueY = 250;
DsegFontSize = 10; DsegFontSize = 10;
getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(250, 240);
} }
else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){ else if(bvalue4->getFormat() == "formatTime" || bvalue4->getFormat() == "formatDate"){
valueY = 253; valueY = 253;
DsegFontSize = 10; DsegFontSize = 10;
getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setCursor(300, 240);
} }
else{ else{
valueY = 270; valueY = 270;
DsegFontSize = 20; DsegFontSize = 20;
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
getdisplay().setCursor(280, 270);
} }
// Show bus data // Show bus data
@@ -308,7 +284,7 @@ class PageFourValues2 : public Page
printBoatValue(svalue4, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string printBoatValue(svalue4, valueX, valueY, RIGHT, DsegFontSize, smallDecimals); // Real value as formated string
} }
else{ 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){ if(valid4 == true){
svalue4old = svalue4; // Save the old value svalue4old = svalue4; // Save the old value