mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-09-11 19:55:14 +02:00
Fix some more issues on printBoatValue() function
This commit is contained in:
@@ -660,10 +660,6 @@ static void printBoatValueImpl(const String &sBoatValue, const int16_t x, const
|
||||
decimalPart = sBoatValue.substring(dot + 1);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Small decimals mode
|
||||
// -----------------------------------------------------------------
|
||||
if (smallDecs) {
|
||||
// Measure integer part
|
||||
int16_t ix1, iy1;
|
||||
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);
|
||||
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;
|
||||
uint16_t dw, dh;
|
||||
display.setFont(decimalFont);
|
||||
display.setFont(smallDecs ? decimalFont : mainFont);
|
||||
displayGetTextBounds(decimalPart, 0, 0, &dx1, &dy1, &dw, &dh, dsegAdjust);
|
||||
decW = dx1 + dw;
|
||||
}
|
||||
|
||||
const int16_t totalWidth = intW + decW;
|
||||
int16_t startX;
|
||||
@@ -699,25 +698,11 @@ static void printBoatValueImpl(const String &sBoatValue, const int16_t x, const
|
||||
getdisplay().setCursor(startX, y);
|
||||
getdisplay().print(integerPart);
|
||||
|
||||
// Draw decimal part immediately after integer part
|
||||
display.setFont(decimalFont);
|
||||
// Draw decimal part only when present
|
||||
if (dot != -1 && decimalPart.length() > 0) {
|
||||
display.setFont(smallDecs ? decimalFont : mainFont);
|
||||
getdisplay().setCursor(decimalLeftX, y);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user