Enable small decimals on PageOneValue; fix issues on PageSixValues

This commit is contained in:
Ulrich Meine
2026-08-31 16:33:19 +02:00
parent 18c1da5991
commit 93084c980a
2 changed files with 59 additions and 39 deletions
+51 -34
View File
@@ -31,8 +31,11 @@ private:
bool useSimuData; bool useSimuData;
bool holdValues; bool holdValues;
String flashLED; String flashLED;
String backlightMode; bool smallDecimals;
String tempFormat;
static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2;
// Old values for hold function // Old values for hold function
String sValue1Old = ""; String sValue1Old = "";
@@ -40,38 +43,45 @@ private:
// Data buffer pointer (owned by HstryBuffers) // Data buffer pointer (owned by HstryBuffers)
RingBuffer<uint16_t>* dataHstryBuf = nullptr; RingBuffer<uint16_t>* dataHstryBuf = nullptr;
std::unique_ptr<Chart> dataChart; // Chart object std::unique_ptr<Chart> dataChart = nullptr; // Chart object
// display data value in display <mode> [FULL|HALF] // display data value in display <mode> [FULL|HALF]
void showData(GwApi::BoatValue* bValue1, DisplayMode mode) void showData(GwApi::BoatValue* bValue1, DisplayMode mode)
{ {
int nameXoff, nameYoff, unitXoff, unitYoff, value1Xoff, value1Yoff; int nameXoff, nameYoff, unitX, unitY, unitXoff, unitYoff, valueX, valueY, valueXoff, valueYoff;
const GFXfont *nameFnt, *unitFnt, *valueFnt1, *valueFnt2, *valueFnt3; const GFXfont *nameFnt, *unitFnt;
int valueFontSize1, valueFontSize2, valueFontSize3, DsegFontSize;
if (mode == FULL) { // full size data display if (mode == FULL) { // full size data display
nameXoff = 0; nameXoff = 0;
nameYoff = 0; nameYoff = 0;
nameFnt = &Ubuntu_Bold32pt8b; nameFnt = &Ubuntu_Bold32pt8b;
unitX = 380;
unitY = 100;
unitXoff = 0; unitXoff = 0;
unitYoff = 0; unitYoff = 0;
unitFnt = &Ubuntu_Bold20pt8b; unitFnt = &Ubuntu_Bold20pt8b;
value1Xoff = 0; valueXoff = 0;
value1Yoff = 0; valueYoff = 0;
valueFnt1 = &Ubuntu_Bold20pt8b; valueFontSize1 = 20;
valueFnt2 = &Ubuntu_Bold32pt8b; valueFontSize2 = 30;
valueFnt3 = &DSEG7Classic_BoldItalic60pt7b; valueFontSize3 = 60;
} else { // half size data and chart display } else { // half size data and chart display
nameXoff = -10; nameXoff = -10;
nameYoff = -34; nameYoff = -34;
nameFnt = &Ubuntu_Bold20pt8b; nameFnt = &Ubuntu_Bold20pt8b;
unitXoff = -295; unitX = 10;
unitYoff = 21; unitY = 121;
// unitXoff = -295;
//unitXoff = -280;
//unitYoff = 21;
unitFnt = &Ubuntu_Bold12pt8b; unitFnt = &Ubuntu_Bold12pt8b;
valueFnt1 = &Ubuntu_Bold12pt8b; // value1Xoff = 111;
value1Xoff = 111; valueXoff = 0;
value1Yoff = -119; valueYoff = -119;
valueFnt2 = &Ubuntu_Bold20pt8b; valueFontSize1 = 12;
valueFnt3 = &DSEG7Classic_BoldItalic42pt7b; valueFontSize2 = 20;
valueFontSize3 = 42;
} }
String name1 = xdrDelete(bValue1->getName()); // Value name String name1 = xdrDelete(bValue1->getName()); // Value name
@@ -88,32 +98,38 @@ private:
getdisplay().print(name1); // name getdisplay().print(name1); // name
// Show unit // Show unit
String unitName;
getdisplay().setFont(unitFnt); getdisplay().setFont(unitFnt);
getdisplay().setCursor(305 + unitXoff, 100 + unitYoff);
if (holdValues) { if (holdValues) {
getdisplay().print(unit1Old); // name unitName = unit1Old;
} else { } else {
getdisplay().print(unit1); // name unitName = unit1;
}
if (mode == FULL) {
drawTextRalign(unitX, unitY, unitName);
} else {
getdisplay().setCursor(unitX, unitY);
getdisplay().print(unitName);
} }
// Switch font depending on value format and adjust position // Switch font depending on value format and adjust position
valueX = 380 + valueXoff;
if (bValue1->getFormat() == "formatLatitude" || bValue1->getFormat() == "formatLongitude") { if (bValue1->getFormat() == "formatLatitude" || bValue1->getFormat() == "formatLongitude") {
getdisplay().setFont(valueFnt1); valueY = 180 + valueYoff;
getdisplay().setCursor(20 + value1Xoff, 180 + value1Yoff); DsegFontSize = valueFontSize1;
} else if (bValue1->getFormat() == "formatTime" || bValue1->getFormat() == "formatDate") { } else if (bValue1->getFormat() == "formatTime" || bValue1->getFormat() == "formatDate") {
getdisplay().setFont(valueFnt2); valueY = 200 + valueYoff;
getdisplay().setCursor(20 + value1Xoff, 200 + value1Yoff); DsegFontSize = valueFontSize2;
} else { } else {
getdisplay().setFont(valueFnt3); valueY = 240 + valueYoff;
getdisplay().setCursor(20 + value1Xoff, 240 + value1Yoff); DsegFontSize = valueFontSize3;
} }
// Show bus data // Show bus data
if (!holdValues || useSimuData) { if (!holdValues || useSimuData) {
getdisplay().print(sValue1); // Real value as formated string printBoatValue(sValue1, valueX, valueY, RIGHT, DsegFontSize, smallDecimals);
} else { } else {
getdisplay().print(sValue1Old); // Old value as formated string printBoatValue(sValue1Old, valueX, valueY, RIGHT, DsegFontSize, smallDecimals);
} }
if (valid1 == true) { if (valid1 == true) {
@@ -131,14 +147,13 @@ public:
width = getdisplay().width(); // Screen width width = getdisplay().width(); // Screen width
height = getdisplay().height(); // Screen height height = getdisplay().height(); // Screen height
getdisplay().setTextWrap(false);
// Get config data // Get config data
// lengthformat = commonData->config->getString(commonData->config->lengthFormat);
useSimuData = commonData->config->getBool(commonData->config->useSimuData); useSimuData = commonData->config->getBool(commonData->config->useSimuData);
holdValues = commonData->config->getBool(commonData->config->holdvalues); holdValues = commonData->config->getBool(commonData->config->holdvalues);
flashLED = commonData->config->getString(commonData->config->flashLED); flashLED = commonData->config->getString(commonData->config->flashLED);
backlightMode = commonData->config->getString(commonData->config->backlight); smallDecimals = commonData->config->getBool(commonData->config->smallDecimals);
tempFormat = commonData->config->getString(commonData->config->tempFormat); // [K|°C|°F]
} }
virtual void setupKeys() virtual void setupKeys()
@@ -233,9 +248,9 @@ public:
if (dataHstryBuf) { if (dataHstryBuf) {
dataChart.reset(new Chart(*dataHstryBuf, *commonData, useSimuData)); dataChart.reset(new Chart(*dataHstryBuf, *commonData, useSimuData));
LOG_DEBUG(GwLog::DEBUG, "PageOneValue: Created chart objects for %s", bValName1); LOG_DEBUG(GwLog::DEBUG, "PageOneValue: Created chart object for %s", bValName1);
} else { } else {
LOG_DEBUG(GwLog::DEBUG, "PageOneValue: No chart objects available for %s", bValName1); LOG_DEBUG(GwLog::DEBUG, "PageOneValue: No chart object available for %s", bValName1);
} }
} }
@@ -265,9 +280,11 @@ public:
displaySetPartialWindow(0, 0, width, height); // Set partial update displaySetPartialWindow(0, 0, width, height); // Set partial update
if (dataChart) { // Check only if dataChart object exist^s at all
if (!dataChart->isValid()) { if (!dataChart->isValid()) {
dataChart->init(); // try late initialization if chart object could not be properly initialized earlier due to missing boat data dataChart->init(); // try late initialization if chart object could not be properly initialized earlier due to missing boat data
} }
}
if (pageMode == VALUE || dataHstryBuf == nullptr) { if (pageMode == VALUE || dataHstryBuf == nullptr) {
// show only data value; ignore other pageMode options if no chart supported boat data history buffer is available // show only data value; ignore other pageMode options if no chart supported boat data history buffer is available
+6 -3
View File
@@ -11,11 +11,11 @@ private:
bool holdValues; bool holdValues;
String flashLED; String flashLED;
String backlightMode; String backlightMode;
bool smallDecimals;
static constexpr int8_t LEFT = 0; static constexpr int8_t LEFT = 0;
static constexpr int8_t CENTER = 1; static constexpr int8_t CENTER = 1;
static constexpr int8_t RIGHT = 2; static constexpr int8_t RIGHT = 2;
bool smallDecimals;
static constexpr int SixValues_x1 = 5; static constexpr int SixValues_x1 = 5;
static constexpr int SixValues_DeltaX = 200; static constexpr int SixValues_DeltaX = 200;
@@ -74,12 +74,13 @@ public:
DataFormat[i] = bvalue->getFormat(); // Unit of value DataFormat[i] = bvalue->getFormat(); // Unit of value
} }
#ifdef BOARD_OBP60S3
// Optical warning by limit violation (unused) // Optical warning by limit violation (unused)
if (String(flashLED) == "Limit Violation") { if (String(flashLED) == "Limit Violation") {
setBlinkingLED(false); setBlinkingLED(false);
setFlashLED(false); setFlashLED(false);
} }
#endif
if (bvalue == NULL) if (bvalue == NULL)
return PAGE_OK; return PAGE_OK;
@@ -88,6 +89,7 @@ public:
// Set display in partial refresh mode // Set display in partial refresh mode
displaySetPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update displaySetPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
getdisplay().setTextWrap(false);
getdisplay().setTextColor(commonData->fgcolor); getdisplay().setTextColor(commonData->fgcolor);
for (int i = 0; i < (HowManyValues / 2); i++) { for (int i = 0; i < (HowManyValues / 2); i++) {
@@ -100,7 +102,8 @@ public:
int ValueIndex = i * 2 + j; int ValueIndex = i * 2 + j;
int x0 = SixValues_x1 + j * SixValues_DeltaX; int x0 = SixValues_x1 + j * SixValues_DeltaX;
int y0 = SixValues_y1 + i * SixValues_DeltaY; int y0 = SixValues_y1 + i * SixValues_DeltaY;
LOG_DEBUG(GwLog::DEBUG, "Drawing at PageSixValue: %d %s %f %s %s", ValueIndex, DataName[ValueIndex], DataValue[ValueIndex], DataUnit[ValueIndex], DataFormat[ValueIndex]); //LOG_DEBUG(GwLog::DEBUG, "Drawing at PageSixValue: %d %s %f %s %s", ValueIndex, DataName[ValueIndex],
// DataValue[ValueIndex], DataUnit[ValueIndex], DataFormat[ValueIndex]);
// Show name // Show name
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);