mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-01-26 08:13:05 +01:00
General history buffers working; fine tuning required
This commit is contained in:
@@ -125,8 +125,10 @@ public:
|
||||
|
||||
static RingBuffer<uint16_t>* wdHstry; // Wind direction data buffer
|
||||
static RingBuffer<uint16_t>* wsHstry; // Wind speed data buffer
|
||||
static String wdName, wdFormat; // Wind direction name and format
|
||||
static String wsName, wsFormat; // Wind speed name and format
|
||||
static RingBuffer<uint16_t>* twdHstry; // Wind direction data buffer for TWD
|
||||
static RingBuffer<uint16_t>* twsHstry; // Wind speed data buffer for TWS
|
||||
static RingBuffer<uint16_t>* awdHstry; // Wind direction data buffer for AWD
|
||||
static RingBuffer<uint16_t>* awsHstry; // Wind speed data buffer for AWS
|
||||
|
||||
// Separate chart objects for true wind and apparent wind
|
||||
static std::unique_ptr<Chart<uint16_t>> twdFlChart, awdFlChart; // chart object for wind direction chart, full size
|
||||
@@ -139,8 +141,8 @@ public:
|
||||
static Chart<uint16_t>* wdHfChart;
|
||||
static Chart<uint16_t>* wsHfChart;
|
||||
|
||||
static GwApi::BoatValue* wdBVal = new GwApi::BoatValue("TWD"); // temp BoatValue for wind direction unit identification; required by OBP60Formater
|
||||
static GwApi::BoatValue* wsBVal = new GwApi::BoatValue("TWS"); // temp BoatValue for wind speed unit identification; required by OBP60Formater */
|
||||
static GwApi::BoatValue* wdBVal; // BoatValue for wind direction
|
||||
static GwApi::BoatValue* wsBVal; // BoatValue for wind speed
|
||||
double dfltRngWd = 60.0 * DEG_TO_RAD; // default range for course chart from min to max value in RAD
|
||||
double dfltRngWs = 7.5; // default range for wind speed chart from min to max value in m/s
|
||||
|
||||
@@ -163,24 +165,20 @@ public:
|
||||
|
||||
if (showTruW != oldShowTruW) {
|
||||
if (!twdFlChart) { // Create true wind charts if they don't exist
|
||||
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Creating true wind charts");
|
||||
auto* twdHstry = pageData.hstryManager->getBuffer("TWD");
|
||||
auto* twsHstry = pageData.hstryManager->getBuffer("TWS");
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Creating true wind charts");
|
||||
twdHstry = pageData.hstryBuffers->getBuffer("TWD");
|
||||
twsHstry = pageData.hstryBuffers->getBuffer("TWS");
|
||||
|
||||
twdFlChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twdHstry, 'V', 0, dfltRngWd, *commonData, useSimuData));
|
||||
twsFlChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twsHstry, 'H', 0, dfltRngWs, *commonData, useSimuData));
|
||||
twdHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twdHstry, 'V', 1, dfltRngWd, *commonData, useSimuData));
|
||||
twsHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twsHstry, 'V', 2, dfltRngWs, *commonData, useSimuData));
|
||||
// twdHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twdHstry, 'H', 1, dfltRngWd, *commonData, useSimuData));
|
||||
// twsHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twsHstry, 'H', 2, dfltRngWs, *commonData, useSimuData));
|
||||
// LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: twdHstry: %p, twsHstry: %p", (void*)twdHstry, (void*)twsHstry);
|
||||
}
|
||||
|
||||
if (!awdFlChart) { // Create apparent wind charts if they don't exist
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Creating apparent wind charts");
|
||||
auto* awdHstry = pageData.hstryManager->getBuffer("AWD");
|
||||
auto* awsHstry = pageData.hstryManager->getBuffer("AWS");
|
||||
awdHstry = pageData.hstryBuffers->getBuffer("AWD");
|
||||
awsHstry = pageData.hstryBuffers->getBuffer("AWS");
|
||||
|
||||
awdFlChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*awdHstry, 'V', 0, dfltRngWd, *commonData, useSimuData));
|
||||
awsFlChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*awsHstry, 'H', 0, dfltRngWs, *commonData, useSimuData));
|
||||
@@ -190,24 +188,25 @@ public:
|
||||
|
||||
// Switch active charts based on showTruW
|
||||
if (showTruW) {
|
||||
wdHstry = pageData.hstryManager->getBuffer("TWD");
|
||||
wsHstry = pageData.hstryManager->getBuffer("TWS");
|
||||
wdHstry = twdHstry;
|
||||
wsHstry = twsHstry;
|
||||
wdFlChart = twdFlChart.get();
|
||||
wsFlChart = twsFlChart.get();
|
||||
wdHfChart = twdHfChart.get();
|
||||
wsHfChart = twsHfChart.get();
|
||||
wdBVal = bvalue[0];
|
||||
wsBVal = bvalue[1];
|
||||
} else {
|
||||
wdHstry = pageData.hstryManager->getBuffer("AWD");
|
||||
wsHstry = pageData.hstryManager->getBuffer("AWS");
|
||||
wdHstry = awdHstry;
|
||||
wsHstry = awsHstry;
|
||||
wdFlChart = awdFlChart.get();
|
||||
wsFlChart = awsFlChart.get();
|
||||
wdHfChart = awdHfChart.get();
|
||||
wsHfChart = awsHfChart.get();
|
||||
wdBVal = bvalue[2];
|
||||
wsBVal = bvalue[3];
|
||||
}
|
||||
|
||||
wdHstry->getMetaData(wdName, wdFormat);
|
||||
wsHstry->getMetaData(wsName, wsFormat);
|
||||
|
||||
oldShowTruW = showTruW;
|
||||
}
|
||||
|
||||
@@ -219,27 +218,17 @@ public:
|
||||
getdisplay().setTextColor(commonData->fgcolor);
|
||||
|
||||
if (chrtMode == 'D') {
|
||||
wdBVal->value = wdHstry->getLast();
|
||||
wdBVal->valid = wdBVal->value != wdHstry->getMaxVal();
|
||||
wdFlChart->showChrt(dataIntv, *bvalue[0]);
|
||||
wdFlChart->showChrt(dataIntv, *wdBVal);
|
||||
|
||||
} else if (chrtMode == 'S') {
|
||||
wsBVal->value = wsHstry->getLast();
|
||||
wsBVal->valid = wsBVal->value != wsHstry->getMaxVal();
|
||||
wsFlChart->showChrt(dataIntv, *bvalue[1]);
|
||||
wsFlChart->showChrt(dataIntv, *wsBVal);
|
||||
|
||||
} else if (chrtMode == 'B') {
|
||||
wdBVal->value = wdHstry->getLast();
|
||||
wdBVal->valid = wdBVal->value != wdHstry->getMaxVal();
|
||||
wsBVal->value = wsHstry->getLast();
|
||||
wsBVal->valid = wsBVal->value != wsHstry->getMaxVal();
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot showChrt: wsBVal.name: %s, format: %s, wsBVal.value: %.1f, valid: %d, address: %p", wsBVal->getName(), wsBVal->getFormat(), wsBVal->value,
|
||||
wsBVal->valid, wsBVal);
|
||||
wdHfChart->showChrt(dataIntv, *bvalue[0]);
|
||||
wsHfChart->showChrt(dataIntv, *bvalue[1]);
|
||||
wdHfChart->showChrt(dataIntv, *wdBVal);
|
||||
wsHfChart->showChrt(dataIntv, *wsBVal);
|
||||
}
|
||||
|
||||
LOG_DEBUG(GwLog::LOG, "PageWindPlot: page time %ldms", millis() - pageTime);
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: page time %ldms", millis() - pageTime);
|
||||
return PAGE_UPDATE;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user