mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-09-11 19:55:14 +02:00
Add late chart object initialization to pages with charts
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <pageMode> 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 (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 && 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]) {
|
||||
} 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;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user