Fix some more issues on printBoatValue() function

This commit is contained in:
Ulrich Meine
2026-08-31 16:34:33 +02:00
parent 93084c980a
commit 9eb0983ee4
+8 -23
View File
@@ -660,10 +660,6 @@ static void printBoatValueImpl(const String &sBoatValue, const int16_t x, const
decimalPart = sBoatValue.substring(dot + 1); decimalPart = sBoatValue.substring(dot + 1);
} }
// -----------------------------------------------------------------
// Small decimals mode
// -----------------------------------------------------------------
if (smallDecs) {
// Measure integer part // Measure integer part
int16_t ix1, iy1; int16_t ix1, iy1;
uint16_t iw, ih; uint16_t iw, ih;
@@ -671,12 +667,15 @@ static void printBoatValueImpl(const String &sBoatValue, const int16_t x, const
displayGetTextBounds(integerPart, 0, 0, &ix1, &iy1, &iw, &ih, dsegAdjust); displayGetTextBounds(integerPart, 0, 0, &ix1, &iy1, &iw, &ih, dsegAdjust);
intW = ix1 + iw; intW = ix1 + iw;
// Measure decimal part // Measure decimal part only if one actually exists
decW = 0;
if (dot != -1 && decimalPart.length() > 0) {
int16_t dx1, dy1; int16_t dx1, dy1;
uint16_t dw, dh; uint16_t dw, dh;
display.setFont(decimalFont); display.setFont(smallDecs ? decimalFont : mainFont);
displayGetTextBounds(decimalPart, 0, 0, &dx1, &dy1, &dw, &dh, dsegAdjust); displayGetTextBounds(decimalPart, 0, 0, &dx1, &dy1, &dw, &dh, dsegAdjust);
decW = dx1 + dw; decW = dx1 + dw;
}
const int16_t totalWidth = intW + decW; const int16_t totalWidth = intW + decW;
int16_t startX; int16_t startX;
@@ -699,25 +698,11 @@ static void printBoatValueImpl(const String &sBoatValue, const int16_t x, const
getdisplay().setCursor(startX, y); getdisplay().setCursor(startX, y);
getdisplay().print(integerPart); getdisplay().print(integerPart);
// Draw decimal part immediately after integer part // Draw decimal part only when present
display.setFont(decimalFont); if (dot != -1 && decimalPart.length() > 0) {
display.setFont(smallDecs ? decimalFont : mainFont);
getdisplay().setCursor(decimalLeftX, y); getdisplay().setCursor(decimalLeftX, y);
getdisplay().print(decimalPart); getdisplay().print(decimalPart);
return;
}
// -----------------------------------------------------------------
// Normal rendering (no small decimals)
// -----------------------------------------------------------------
display.setFont(mainFont);
if (align == 2) {
drawTextRalign(x, y, sBoatValue, dsegAdjust);
} else if (align == 1) {
drawTextCenter(x, y, sBoatValue, dsegAdjust);
} else {
getdisplay().setCursor(x, y);
getdisplay().print(sBoatValue);
} }
} }