From 04ea564bdbf8f3cb5e35e0b55c6921a07d77fb7b Mon Sep 17 00:00:00 2001 From: Ulrich Meine <145987006+Scorgan01@users.noreply.github.com> Date: Wed, 1 Jul 2026 02:42:02 +0200 Subject: [PATCH] Add late chart object initialization to pages with charts --- lib/obp60task/PageOneValue.cpp | 6 ++++- lib/obp60task/PageTwoValues.cpp | 12 ++++++--- lib/obp60task/PageWeather.cpp | 47 +++++++++++++++------------------ lib/obp60task/PageWindPlot.cpp | 8 +++--- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/lib/obp60task/PageOneValue.cpp b/lib/obp60task/PageOneValue.cpp index f41ea09..689c067 100644 --- a/lib/obp60task/PageOneValue.cpp +++ b/lib/obp60task/PageOneValue.cpp @@ -243,7 +243,7 @@ public: dataHstryBuf = pageData.hstryBuffers->getBuffer(bValName1); if (dataHstryBuf) { - dataChart.reset(new Chart(*dataHstryBuf, Chart::dfltChrtDta[bValFormat].range, *commonData, useSimuData)); + dataChart.reset(new Chart(*dataHstryBuf, *commonData, useSimuData)); LOG_DEBUG(GwLog::DEBUG, "PageOneValue: Created chart objects for %s", bValName1); } else { LOG_DEBUG(GwLog::DEBUG, "PageOneValue: No chart objects available for %s", bValName1); @@ -276,6 +276,10 @@ public: displaySetPartialWindow(0, 0, width, height); // Set partial update + if (!dataChart->isValid()) { + dataChart->init(); // try late initialization if chart object could not be properly initialized earlier due to missing boat data + } + if (pageMode == VALUE || dataHstryBuf == nullptr) { // show only data value; ignore other pageMode options if no chart supported boat data history buffer is available showData(bValue1, FULL); diff --git a/lib/obp60task/PageTwoValues.cpp b/lib/obp60task/PageTwoValues.cpp index 82e9d32..847f12b 100644 --- a/lib/obp60task/PageTwoValues.cpp +++ b/lib/obp60task/PageTwoValues.cpp @@ -203,7 +203,7 @@ public: #if defined BOARD_OBP60S3 if (key == 5 && pageMode != VALUES) { #elif defined BOARD_OBP40S3 - if (key == 2 && pageMode != VALUES) { + if (key == 2 && pageMode != VALUES) { #endif if (dataIntv == 1) { dataIntv = 2; @@ -246,8 +246,8 @@ public: dataHstryBuf[i] = pageData.hstryBuffers->getBuffer(bValName); if (dataHstryBuf[i]) { - dataChart[i].reset(new Chart(*dataHstryBuf[i], Chart::dfltChrtDta[bValFormat].range, *commonData, useSimuData)); - LOG_DEBUG(GwLog::DEBUG, "PageTwoValues: Created chart object%d for %s", i, bValName.c_str()); + dataChart[i].reset(new Chart(*dataHstryBuf[i], *commonData, useSimuData)); + LOG_DEBUG(GwLog::DEBUG, "PageTwoValues: Created chart object %d for %s", i, bValName.c_str()); } else { LOG_DEBUG(GwLog::DEBUG, "PageTwoValues: No chart object available for %s", bValName.c_str()); } @@ -283,6 +283,12 @@ public: displaySetPartialWindow(0, 0, width, height); // Set partial update + for (int i = 0; i < NUMVALUES; i++) { + if (!dataChart[i]->isValid()) { + dataChart[i]->init(); // try late initialization if chart object could not be properly initialized earlier due to missing boat data + } + } + if (pageMode == VALUES || (dataHstryBuf[0] == nullptr && dataHstryBuf[1] == nullptr)) { // show only data value; ignore other pageMode options if no chart supported boat data history buffer is available showData(bValue, FULL); diff --git a/lib/obp60task/PageWeather.cpp b/lib/obp60task/PageWeather.cpp index 4d7f6ab..9eb6e72 100644 --- a/lib/obp60task/PageWeather.cpp +++ b/lib/obp60task/PageWeather.cpp @@ -110,8 +110,8 @@ private: // print lines for data separation of bottom data values getdisplay().fillRect(0, 191, 400, 2, commonData->fgcolor); // horizontal line - getdisplay().fillRect(133, 192, 2, 83, commonData->fgcolor); // vertical lines - getdisplay().fillRect(266, 192, 2, 83, commonData->fgcolor); + getdisplay().fillRect(133, 192, 2, 84, commonData->fgcolor); // vertical lines + getdisplay().fillRect(266, 192, 2, 84, commonData->fgcolor); } public: @@ -218,20 +218,18 @@ public: String bValFormat = bValue->getFormat(); // Value format dataHstryBuf[i] = pageData.hstryBuffers->getBuffer(bValName); - // if (dataHstryBuf[i]->getFormat() == "") { // data format might have been unknown at time of buffer creation - // dataHstryBuf[i]->setFormat(bValFormat); // in that case, we specify it here, because we need it for printing of buffer data - // } +// if (dataHstryBuf[i]->getFormat() == "") { // data format might have been unknown at time of buffer creation +// dataHstryBuf[i]->setFormat(bValFormat); // in that case, we specify it here, because we need it for printing of buffer data +// } if (dataHstryBuf[i]) { - dataChart[i].reset(new Chart(*dataHstryBuf[i], Chart::dfltChrtDta[bValFormat].range, *commonData, useSimuData)); + dataChart[i].reset(new Chart(*dataHstryBuf[i], *commonData, useSimuData)); LOG_DEBUG(GwLog::DEBUG, "PageWeather: Created chart object %d for %s, format: %s", i, bValName.c_str(), dataHstryBuf[i]->getFormat().c_str()); } else { LOG_DEBUG(GwLog::DEBUG, "PageWeather: No chart object available for %s", bValName.c_str()); } } } - - setupKeys(); // Adjust key definition depending on and chart-supported boat data type } int displayPage(PageData& pageData) @@ -265,24 +263,23 @@ public: displaySetPartialWindow(0, 0, width, height); // Set partial update - if (dataHstryBuf != nullptr) { - if (dataHstryBuf[0]->getFormat() == "") { // data format might have been unknown at time of buffer creation - dataHstryBuf[0]->setFormat(bValue[0]->getFormat()); // in that case, we specify it here, because we need it for printing of buffer data - } - - // if (pageMode == VAL_CHART && dataHstryBuf != nullptr) { - if (pageMode == VAL_CHART) { - if (dataChart[0]) { - dataChart[0]->showChrt(HORIZONTAL, TWO_THIRD_TOP, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue[0]); - } - showData(bValue); - - } else if (pageMode == CHART) { // show only data chart - if (dataChart[0]) { - dataChart[0]->showChrt(HORIZONTAL, FULL_SIZE, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue[0]); - } - } + if (dataHstryBuf == nullptr) { // no buffer for main boat data item, no page display + return PAGE_UPDATE; } + if (!dataChart[0]->isValid()) { + dataChart[0]->init(); // try late initialization if chart object could not be properly initialized earlier due to missing boat data + } + + if (pageMode == VAL_CHART) { + if (dataChart[0]) { + dataChart[0]->showChrt(HORIZONTAL, TWO_THIRD_TOP, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue[0]); + } + showData(bValue); + + } else if (pageMode == CHART && dataChart[0]) { // show only data chart, but that has to exist + dataChart[0]->showChrt(HORIZONTAL, FULL_SIZE, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue[0]); + } + return PAGE_UPDATE; }; }; diff --git a/lib/obp60task/PageWindPlot.cpp b/lib/obp60task/PageWindPlot.cpp index 8f6554c..9a77d2b 100644 --- a/lib/obp60task/PageWindPlot.cpp +++ b/lib/obp60task/PageWindPlot.cpp @@ -168,10 +168,10 @@ public: twsHstry = pageData.hstryBuffers->getBuffer("TWS"); if (twdHstry) { - twdChart.reset(new Chart(*twdHstry, Chart::dfltChrtDta["formatCourse"].range, *commonData, useSimuData)); + twdChart.reset(new Chart(*twdHstry, *commonData, useSimuData)); } if (twsHstry) { - twsChart.reset(new Chart(*twsHstry, Chart::dfltChrtDta["formatKnots"].range, *commonData, useSimuData)); + twsChart.reset(new Chart(*twsHstry, *commonData, useSimuData)); } } @@ -180,10 +180,10 @@ public: awsHstry = pageData.hstryBuffers->getBuffer("AWS"); if (awdHstry) { - awdChart.reset(new Chart(*awdHstry, Chart::dfltChrtDta["formatCourse"].range, *commonData, useSimuData)); + awdChart.reset(new Chart(*awdHstry, *commonData, useSimuData)); } if (awsHstry) { - awsChart.reset(new Chart(*awsHstry, Chart::dfltChrtDta["formatKnots"].range, *commonData, useSimuData)); + awsChart.reset(new Chart(*awsHstry, *commonData, useSimuData)); } if (twdHstry && twsHstry && awdHstry && awsHstry) { LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Created wind charts");