mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-01-26 08:13:05 +01:00
adjusted simulation calc in OBPFormatter;
WindPlot + PageOneValue: aligned simulation data handling to standard; added "holdValues"; improved data check for chart buffer data; changed handling of tmpBVal -> always unique_ptr
This commit is contained in:
@@ -192,10 +192,10 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||
rawvalue = value->value;
|
||||
}
|
||||
else {
|
||||
course = 2.53 + float(random(0, 10) / 100.0);
|
||||
course = M_PI_2 + float(random(-17, 17) / 100.0); // create random course/wind values with 90° +/- 10°
|
||||
rawvalue = course;
|
||||
}
|
||||
course = course * 57.2958; // Unit conversion form rad to deg
|
||||
course = course * RAD_TO_DEG; // Unit conversion form rad to deg
|
||||
|
||||
// Format 3 numbers with prefix zero
|
||||
snprintf(buffer,bsize,"%03.0f",course);
|
||||
@@ -210,7 +210,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||
rawvalue = value->value;
|
||||
}
|
||||
else{
|
||||
rawvalue = 4.0 + float(random(0, 40));
|
||||
rawvalue = 4.0 + float(random(-30, 40) / 10.0); // create random speed values from [1..8] m/s
|
||||
speed = rawvalue;
|
||||
}
|
||||
if (String(speedFormat) == "km/h"){
|
||||
@@ -244,7 +244,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||
rawvalue = value->value;
|
||||
}
|
||||
else {
|
||||
rawvalue = 4.0 + float(random(0, 40));
|
||||
rawvalue = 4.0 + float(random(0, 40) / 10.0); // create random wind speed values from [4..8] m/s
|
||||
speed = rawvalue;
|
||||
}
|
||||
if (String(windspeedFormat) == "km/h"){
|
||||
@@ -429,7 +429,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||
rawvalue = value->value;
|
||||
}
|
||||
else {
|
||||
rawvalue = 18.0 + float(random(0, 100)) / 10.0;
|
||||
rawvalue = 18.0 + float(random(0, 100)) / 10.0; // create random depth values from [18..28] metres
|
||||
depth = rawvalue;
|
||||
}
|
||||
if(String(lengthFormat) == "ft"){
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "OBPDataOperations.h"
|
||||
#include "BoatDataCalibration.h" // Functions lib for data instance calibration
|
||||
#include <math.h>
|
||||
|
||||
// --- Class HstryBuf ---------------
|
||||
HstryBuf::HstryBuf(const String& name, int size, BoatValueList* boatValues, GwLog* log)
|
||||
@@ -26,34 +25,29 @@ void HstryBuf::add(double value)
|
||||
{
|
||||
if (value >= hstryMin && value <= hstryMax) {
|
||||
hstryBuf.add(value);
|
||||
LOG_DEBUG(GwLog::DEBUG, "HstryBuf::add: name: %s, value: %.3f", hstryBuf.getName(), value);
|
||||
}
|
||||
}
|
||||
|
||||
void HstryBuf::handle(bool useSimuData)
|
||||
void HstryBuf::handle(bool useSimuData, CommonData& common)
|
||||
{
|
||||
GwApi::BoatValue* calBVal;
|
||||
//GwApi::BoatValue* tmpBVal;
|
||||
std::unique_ptr<GwApi::BoatValue> tmpBVal; // Temp variable to get formatted and converted data value from OBP60Formatter
|
||||
|
||||
// create temporary boat value for calibration purposes and retrieval of simulation value
|
||||
//tmpBVal = new GwApi::BoatValue(boatDataName.c_str());
|
||||
tmpBVal = std::unique_ptr<GwApi::BoatValue>(new GwApi::BoatValue(boatDataName));
|
||||
tmpBVal->setFormat(boatValue->getFormat());
|
||||
tmpBVal->value = boatValue->value;
|
||||
tmpBVal->valid = boatValue->valid;
|
||||
|
||||
if (boatValue->valid) {
|
||||
// Calibrate boat value before adding it to history buffer
|
||||
calBVal = new GwApi::BoatValue(boatDataName.c_str());
|
||||
calBVal->setFormat(boatValue->getFormat());
|
||||
calBVal->value = boatValue->value;
|
||||
calBVal->valid = boatValue->valid;
|
||||
calibrationData.calibrateInstance(calBVal, logger);
|
||||
add(calBVal->value);
|
||||
|
||||
delete calBVal;
|
||||
calBVal = nullptr;
|
||||
calibrationData.calibrateInstance(tmpBVal.get(), logger);
|
||||
add(tmpBVal->value);
|
||||
|
||||
} else if (useSimuData) { // add simulated value to history buffer
|
||||
double simValue = hstryBuf.getLast();
|
||||
if (boatDataName == "TWD" || boatDataName == "AWD") {
|
||||
simValue += static_cast<double>(random(-349, 349) / 1000.0);
|
||||
simValue = WindUtils::to2PI(simValue);
|
||||
} else if (boatDataName == "TWS" || boatDataName == "AWS") {
|
||||
simValue += static_cast<double>(random(-5000, 5000) / 1000.0);
|
||||
simValue = constrain(simValue, 0, 40);
|
||||
}
|
||||
double simValue = formatValue(tmpBVal.get(), common).value; // simulated value is generated at <formatValue>
|
||||
add(simValue);
|
||||
}
|
||||
}
|
||||
@@ -96,17 +90,17 @@ void HstryBuffers::addBuffer(const String& name)
|
||||
double bufferMaxVal = bufferParams[name].bufferMaxVal; // Max value for this history buffer
|
||||
|
||||
hstryBuffers[name]->init(valueFormat, hstryUpdFreq, mltplr, bufferMinVal, bufferMaxVal);
|
||||
LOG_DEBUG(GwLog::DEBUG, "HstryBuffers-new buffer added: name: %s, format: %s, multiplier: %d, min value: %.2f, max value: %.2f", name, valueFormat, mltplr, bufferMinVal, bufferMaxVal);
|
||||
LOG_DEBUG(GwLog::DEBUG, "HstryBuffers: new buffer added: name: %s, format: %s, multiplier: %d, min value: %.2f, max value: %.2f", name, valueFormat, mltplr, bufferMinVal, bufferMaxVal);
|
||||
}
|
||||
|
||||
// Handle history buffers
|
||||
void HstryBuffers::handleHstryBufs(bool useSimuData)
|
||||
void HstryBuffers::handleHstryBufs(bool useSimuData, CommonData& common)
|
||||
{
|
||||
|
||||
// Handle all registered history buffers
|
||||
for (auto& pair : hstryBuffers) {
|
||||
auto& buf = pair.second;
|
||||
buf->handle(useSimuData);
|
||||
buf->handle(useSimuData, common);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
#include "OBPRingBuffer.h"
|
||||
#include "obp60task.h"
|
||||
#include "Pagedata.h"
|
||||
#include <map>
|
||||
|
||||
class HstryBuf {
|
||||
@@ -19,7 +20,7 @@ public:
|
||||
HstryBuf(const String& name, int size, BoatValueList* boatValues, GwLog* log);
|
||||
void init(const String& format, int updFreq, int mltplr, double minVal, double maxVal);
|
||||
void add(double value);
|
||||
void handle(bool useSimuData);
|
||||
void handle(bool useSimuData, CommonData& common);
|
||||
};
|
||||
|
||||
class HstryBuffers {
|
||||
@@ -61,7 +62,7 @@ private:
|
||||
public:
|
||||
HstryBuffers(int size, BoatValueList* boatValues, GwLog* log);
|
||||
void addBuffer(const String& name);
|
||||
void handleHstryBufs(bool useSimuData);
|
||||
void handleHstryBufs(bool useSimuData, CommonData& common);
|
||||
RingBuffer<uint16_t>* getBuffer(const String& name);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Function lib for display of boat data in various chart formats
|
||||
#include "OBPcharts.h"
|
||||
#include "OBP60Extensions.h"
|
||||
#include "OBPDataOperations.h"
|
||||
#include "OBPRingBuffer.h"
|
||||
|
||||
// --- Class Chart ---------------
|
||||
@@ -183,6 +184,8 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
|
||||
}
|
||||
|
||||
calcChrtBorders(chrtMid, chrtMin, chrtMax, chrtRng);
|
||||
LOG_DEBUG(GwLog::DEBUG, "calcChrtBorders: min: %.3f, mid: %.3f, max: %.3f, rng: %.3f", chrtMin, chrtMid, chrtMax, chrtRng);
|
||||
|
||||
chrtScl = double(valAxis) / chrtRng; // Chart scale: pixels per value step
|
||||
|
||||
// Do we have valid buffer data?
|
||||
@@ -501,6 +504,10 @@ void Chart<T>::drawChrtValAxis()
|
||||
slots = valAxis / 60.0; // number of axis labels
|
||||
tmpBVal->value = chrtRng;
|
||||
cChrtRng = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
|
||||
if (useSimuData) {
|
||||
// cannot use <formatValue> in this case, because that would change the range value to some random data
|
||||
cChrtRng = tmpBVal->value; // take SI value in this case -> need to be improved
|
||||
}
|
||||
intv = static_cast<int>(round(cChrtRng / slots));
|
||||
i = intv;
|
||||
|
||||
@@ -517,10 +524,8 @@ void Chart<T>::drawChrtValAxis()
|
||||
loopEnd = valAxis - 30;
|
||||
loopStp = 60;
|
||||
}
|
||||
LOG_DEBUG(GwLog::DEBUG, "Chart drawValAxis: chrtDataFmt: %c, loopStrt: %d, loopEnd: %d, loopIntv: %d", chrtDataFmt, loopStrt, loopEnd, loopStp);
|
||||
|
||||
for (int j = loopStrt; (loopStp > 0) ? (j < loopEnd) : (j > loopEnd); j += loopStp) {
|
||||
LOG_DEBUG(GwLog::DEBUG, "Chart drawValAxis2: j: %d, i: %d", j, i);
|
||||
getdisplay().drawLine(cStart.x, cStart.y + j, cStart.x + timAxis, cStart.y + j, fgColor);
|
||||
|
||||
getdisplay().fillRect(cStart.x, cStart.y + j - 11, 42, 21, bgColor); // Clear small area to remove potential chart lines
|
||||
@@ -535,6 +540,9 @@ void Chart<T>::drawChrtValAxis()
|
||||
|
||||
tmpBVal->value = (chrtDataFmt == 'D') ? chrtMin : chrtMax;
|
||||
cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
|
||||
if (useSimuData) { // dirty fix for problem that OBP60Formatter can only be used without data simulation -> returns random values in simulation mode
|
||||
cVal = tmpBVal->value; // no value conversion here
|
||||
}
|
||||
sLen = snprintf(sVal, sizeof(sVal), "%.0f", round(cVal));
|
||||
getdisplay().fillRect(cStart.x, cStart.y + 2, 42, 16, bgColor); // Clear small area to remove potential chart lines
|
||||
getdisplay().setCursor(cStart.x + ((3 - sLen) * 10), cStart.y + 16);
|
||||
@@ -542,6 +550,9 @@ void Chart<T>::drawChrtValAxis()
|
||||
|
||||
tmpBVal->value = chrtMid;
|
||||
cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
|
||||
if (useSimuData) { // dirty fix for problem that OBP60Formatter can only be used without data simulation -> returns random values in simulation mode
|
||||
cVal = tmpBVal->value; // no value conversion here
|
||||
}
|
||||
sLen = snprintf(sVal, sizeof(sVal), "%.0f", round(cVal));
|
||||
getdisplay().fillRect(cStart.x, cStart.y + (valAxis / 2) - 9, 42, 16, bgColor); // Clear small area to remove potential chart lines
|
||||
getdisplay().setCursor(cStart.x + ((3 - sLen) * 10), cStart.y + (valAxis / 2) + 5);
|
||||
@@ -550,6 +561,9 @@ void Chart<T>::drawChrtValAxis()
|
||||
|
||||
tmpBVal->value = (chrtDataFmt == 'D') ? chrtMax : chrtMin;
|
||||
cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
|
||||
if (useSimuData) { // dirty fix for problem that OBP60Formatter can only be used without data simulation -> returns random values in simulation mode
|
||||
cVal = tmpBVal->value; // no value conversion here
|
||||
}
|
||||
sLen = snprintf(sVal, sizeof(sVal), "%.0f", round(cVal));
|
||||
getdisplay().fillRect(cStart.x, cStart.y + valAxis - 16, 42, 16, bgColor); // Clear small area to remove potential chart lines
|
||||
getdisplay().setCursor(cStart.x + ((3 - sLen) * 10), cStart.y + valAxis - 1);
|
||||
@@ -571,17 +585,26 @@ void Chart<T>::drawChrtValAxis()
|
||||
|
||||
tmpBVal->value = chrtMin;
|
||||
cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
|
||||
if (useSimuData) { // dirty fix for problem that OBP60Formatter can only be used without data simulation -> returns random values in simulation mode
|
||||
cVal = tmpBVal->value; // no value conversion here
|
||||
}
|
||||
snprintf(sVal, sizeof(sVal), "%.0f", round(cVal));
|
||||
getdisplay().setCursor(cStart.x, cStart.y - 2);
|
||||
getdisplay().printf("%s", sVal); // Range low end
|
||||
|
||||
tmpBVal->value = chrtMid;
|
||||
cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
|
||||
if (useSimuData) { // dirty fix for problem that OBP60Formatter can only be used without data simulation -> returns random values in simulation mode
|
||||
cVal = tmpBVal->value; // no value conversion here
|
||||
}
|
||||
snprintf(sVal, sizeof(sVal), "%.0f", round(cVal));
|
||||
drawTextCenter(cStart.x + (valAxis / 2), cStart.y - 10, sVal); // Range mid end
|
||||
|
||||
tmpBVal->value = chrtMax;
|
||||
cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
|
||||
if (useSimuData) { // dirty fix for problem that OBP60Formatter can only be used without data simulation -> returns random values in simulation mode
|
||||
cVal = tmpBVal->value; // no value conversion here
|
||||
}
|
||||
snprintf(sVal, sizeof(sVal), "%.0f", round(cVal));
|
||||
drawTextRalign(cStart.x + valAxis - 2, cStart.y - 2, sVal); // Range high end
|
||||
|
||||
@@ -599,21 +622,16 @@ void Chart<T>::prntCurrValue(GwApi::BoatValue& currValue)
|
||||
const int yPosVal = (chrtDir == 'H') ? cStart.y + valAxis - 7 : cStart.y + timAxis - 7;
|
||||
|
||||
FormattedData frmtDbData = formatValue(&currValue, *commonData);
|
||||
double testdbValue = frmtDbData.value;
|
||||
String sdbValue = frmtDbData.svalue; // value (string)
|
||||
String sdbValue = frmtDbData.svalue; // value as formatted string
|
||||
String dbUnit = frmtDbData.unit; // Unit of value
|
||||
// LOG_DEBUG(GwLog::DEBUG, "Chart CurrValue: dbValue: %.2f, sdbValue: %s, fmrtDbValue: %.2f, dbFormat: %s, dbUnit: %s, Valid: %d, Name: %s, Address: %p", currValue.value, sdbValue,
|
||||
// testdbValue, currValue.getFormat(), dbUnit, currValue.valid, currValue.getName(), currValue);
|
||||
// LOG_DEBUG(GwLog::DEBUG, "Chart CurrValue: dbValue: %.2f, sdbValue: %s, dbFormat: %s, dbUnit: %s, Valid: %d, Name: %s, Address: %p", currValue.value, sdbValue,
|
||||
// currValue.getFormat(), dbUnit, currValue.valid, currValue.getName(), currValue);
|
||||
|
||||
getdisplay().fillRect(xPosVal - 1, yPosVal - 35, 125, 41, bgColor); // Clear area for TWS value
|
||||
getdisplay().drawRect(xPosVal, yPosVal - 34, 123, 40, fgColor); // Draw box for TWS value
|
||||
getdisplay().fillRect(xPosVal - 1, yPosVal - 35, 128, 41, bgColor); // Clear area for TWS value
|
||||
getdisplay().drawRect(xPosVal, yPosVal - 34, 126, 40, fgColor); // Draw box for TWS value
|
||||
getdisplay().setFont(&DSEG7Classic_BoldItalic16pt7b);
|
||||
getdisplay().setCursor(xPosVal + 1, yPosVal);
|
||||
if (useSimuData) {
|
||||
getdisplay().printf("%2.1f", currValue.value); // Value
|
||||
} else {
|
||||
getdisplay().print(sdbValue); // Value
|
||||
}
|
||||
getdisplay().print(sdbValue); // alue
|
||||
|
||||
getdisplay().setFont(&Ubuntu_Bold10pt8b);
|
||||
getdisplay().setCursor(xPosVal + 76, yPosVal - 17);
|
||||
|
||||
@@ -26,7 +26,7 @@ protected:
|
||||
int top = 44; // chart gap at top of display (25 lines for standard gap + 19 lines for axis labels)
|
||||
int bottom = 25; // chart gap at bottom of display to keep space for status line
|
||||
int hGap = 11; // gap between 2 horizontal charts; actual gap is 2x <gap>
|
||||
int vGap = 20; // gap between 2 vertical charts; actual gap is 2x <gap>
|
||||
int vGap = 17; // gap between 2 vertical charts; actual gap is 2x <gap>
|
||||
int dWidth; // Display width
|
||||
int dHeight; // Display height
|
||||
int timAxis, valAxis; // size of time and value chart axis
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
#include "OBPDataOperations.h"
|
||||
#include "BoatDataCalibration.h"
|
||||
#include "OBPcharts.h"
|
||||
|
||||
@@ -30,8 +31,6 @@ private:
|
||||
// Data buffer pointer (owned by HstryBuffers)
|
||||
RingBuffer<uint16_t>* dataHstryBuf = nullptr;
|
||||
std::unique_ptr<Chart<uint16_t>> dataFlChart, dataHfChart; // Chart object, full and half size
|
||||
// Active chart and value
|
||||
Chart<uint16_t>* dataChart = nullptr;
|
||||
|
||||
void showData(GwApi::BoatValue* bValue1, char size)
|
||||
{
|
||||
@@ -81,16 +80,13 @@ private:
|
||||
// Show unit
|
||||
getdisplay().setFont(unitFnt);
|
||||
getdisplay().setCursor(270 + unitXoff, 100 + unitYoff);
|
||||
if (holdValues == false) {
|
||||
//getdisplay().print(unit1); // Unit
|
||||
drawTextRalign(298 + unitXoff, 100 + unitYoff, unit1); // Unit
|
||||
|
||||
} else {
|
||||
// getdisplay().print(unit1Old);
|
||||
if (holdValues) {
|
||||
drawTextRalign(298 + unitXoff, 100 + unitYoff, unit1Old);
|
||||
} else {
|
||||
drawTextRalign(298 + unitXoff, 100 + unitYoff, unit1); // Unit
|
||||
}
|
||||
|
||||
// Switch font if format for any values
|
||||
// Switch font depending on value format and adjust position
|
||||
if (bValue1->getFormat() == "formatLatitude" || bValue1->getFormat() == "formatLongitude") {
|
||||
getdisplay().setFont(valueFnt1);
|
||||
getdisplay().setCursor(20 + value1Xoff, 180 + value1Yoff);
|
||||
@@ -103,11 +99,12 @@ private:
|
||||
}
|
||||
|
||||
// Show bus data
|
||||
if (holdValues == false) {
|
||||
if (!holdValues || useSimuData) {
|
||||
getdisplay().print(sValue1); // Real value as formated string
|
||||
} else {
|
||||
getdisplay().print(sValue1Old); // Old value as formated string
|
||||
}
|
||||
|
||||
if (valid1 == true) {
|
||||
sValue1Old = sValue1; // Save the old value
|
||||
unit1Old = unit1; // Save the old unit
|
||||
@@ -195,17 +192,22 @@ public:
|
||||
setFlashLED(false);
|
||||
}
|
||||
#endif
|
||||
if (!dataFlChart) { // Create chart objects if they don't exist
|
||||
// buffer initialization cannot be performed here, because <displayNew> is not executed at system start for default page
|
||||
/* if (!dataFlChart) { // Create chart objects if they don't exist
|
||||
GwApi::BoatValue* bValue1 = pageData.values[0]; // Page boat data element
|
||||
String bValName1 = bValue1->getName(); // Value name
|
||||
String bValFormat = bValue1->getFormat(); // Value format
|
||||
|
||||
dataHstryBuf = pageData.hstryBuffers->getBuffer(bValName1);
|
||||
|
||||
dataFlChart.reset(new Chart<uint16_t>(*dataHstryBuf, 'H', 0, Chart<uint16_t>::dfltChartRng[bValFormat], *commonData, useSimuData));
|
||||
dataHfChart.reset(new Chart<uint16_t>(*dataHstryBuf, 'H', 2, Chart<uint16_t>::dfltChartRng[bValFormat], *commonData, useSimuData));
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageOneValue: Created chart objects for %s", bValName1);
|
||||
}
|
||||
if (dataHstryBuf) {
|
||||
dataFlChart.reset(new Chart<uint16_t>(*dataHstryBuf, 'H', 0, Chart<uint16_t>::dfltChartRng[bValFormat], *commonData, useSimuData));
|
||||
dataHfChart.reset(new Chart<uint16_t>(*dataHstryBuf, 'H', 2, Chart<uint16_t>::dfltChartRng[bValFormat], *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);
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
int displayPage(PageData& pageData)
|
||||
@@ -224,10 +226,27 @@ public:
|
||||
setFlashLED(false);
|
||||
}
|
||||
|
||||
if (!dataFlChart) { // Create chart objects if they don't exist
|
||||
GwApi::BoatValue* bValue1 = pageData.values[0]; // Page boat data element
|
||||
String bValName1 = bValue1->getName(); // Value name
|
||||
String bValFormat = bValue1->getFormat(); // Value format
|
||||
|
||||
dataHstryBuf = pageData.hstryBuffers->getBuffer(bValName1);
|
||||
|
||||
if (dataHstryBuf) {
|
||||
dataFlChart.reset(new Chart<uint16_t>(*dataHstryBuf, 'H', 0, Chart<uint16_t>::dfltChartRng[bValFormat], *commonData, useSimuData));
|
||||
dataHfChart.reset(new Chart<uint16_t>(*dataHstryBuf, 'H', 2, Chart<uint16_t>::dfltChartRng[bValFormat], *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);
|
||||
}
|
||||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bValue1 == NULL)
|
||||
return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG, "Drawing at PageOneValue, %s: %f", bValue1->getName().c_str(), bValue1->value);
|
||||
|
||||
LOG_DEBUG(GwLog::DEBUG, "Drawing at PageOneValue, %s, %.3f", bValue1->getName().c_str(), bValue1->value);
|
||||
|
||||
// Draw page
|
||||
//***********************************************************
|
||||
@@ -238,11 +257,15 @@ public:
|
||||
showData(bValue1, 'F');
|
||||
|
||||
} else if (pageMode == 'C') { // show only data chart
|
||||
dataFlChart->showChrt(dataIntv, *bValue1, true);
|
||||
if (dataFlChart) {
|
||||
dataFlChart->showChrt(dataIntv, *bValue1, true);
|
||||
}
|
||||
|
||||
} else if (pageMode == 'B') { // show data value and chart
|
||||
showData(bValue1, 'H');
|
||||
dataHfChart->showChrt(dataIntv, *bValue1, false);
|
||||
if (dataHfChart) {
|
||||
dataHfChart->showChrt(dataIntv, *bValue1, false);
|
||||
}
|
||||
}
|
||||
|
||||
return PAGE_UPDATE;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
#include "OBPDataOperations.h"
|
||||
#include "OBPcharts.h"
|
||||
|
||||
// ****************************************************************
|
||||
@@ -21,6 +22,7 @@ private:
|
||||
int dataIntv = 1; // Update interval for wind history chart:
|
||||
// (1)|(2)|(3)|(4)|(8) x 240 seconds for 4, 8, 12, 16, 32 min. history chart
|
||||
bool useSimuData;
|
||||
//bool holdValues;
|
||||
String flashLED;
|
||||
String backlightMode;
|
||||
|
||||
@@ -63,7 +65,7 @@ public:
|
||||
|
||||
// Get config data
|
||||
useSimuData = common.config->getBool(common.config->useSimuData);
|
||||
// holdValues = common.config->getBool(common.config->holdvalues);
|
||||
//holdValues = common.config->getBool(common.config->holdvalues);
|
||||
flashLED = common.config->getString(common.config->flashLED);
|
||||
backlightMode = common.config->getString(common.config->backlight);
|
||||
|
||||
@@ -149,28 +151,40 @@ public:
|
||||
}
|
||||
oldShowTruW = !showTruW; // Force chart update in displayPage
|
||||
#endif
|
||||
// buffer initialization cannot be performed here, because <displayNew> is not executed at system start for default page
|
||||
|
||||
if (!twdFlChart) { // Create true wind charts if they don't exist
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Creating true wind charts");
|
||||
/* if (!twdFlChart) { // Create true wind charts if they don't exist
|
||||
twdHstry = pageData.hstryBuffers->getBuffer("TWD");
|
||||
twsHstry = pageData.hstryBuffers->getBuffer("TWS");
|
||||
|
||||
twdFlChart.reset(new Chart<uint16_t>(*twdHstry, 'V', 0, dfltRngWd, *commonData, useSimuData));
|
||||
twsFlChart.reset(new Chart<uint16_t>(*twsHstry, 'H', 0, dfltRngWs, *commonData, useSimuData));
|
||||
twdHfChart.reset(new Chart<uint16_t>(*twdHstry, 'V', 1, dfltRngWd, *commonData, useSimuData));
|
||||
twsHfChart.reset(new Chart<uint16_t>(*twsHstry, 'V', 2, dfltRngWs, *commonData, useSimuData));
|
||||
if (twdHstry) {
|
||||
twdFlChart.reset(new Chart<uint16_t>(*twdHstry, 'V', 0, dfltRngWd, *commonData, useSimuData));
|
||||
twdHfChart.reset(new Chart<uint16_t>(*twdHstry, 'V', 1, dfltRngWd, *commonData, useSimuData));
|
||||
}
|
||||
if (twsHstry) {
|
||||
twsFlChart.reset(new Chart<uint16_t>(*twsHstry, 'H', 0, dfltRngWs, *commonData, useSimuData));
|
||||
twsHfChart.reset(new Chart<uint16_t>(*twsHstry, 'V', 2, dfltRngWs, *commonData, useSimuData));
|
||||
}
|
||||
}
|
||||
|
||||
if (!awdFlChart) { // Create apparent wind charts if they don't exist
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Creating apparent wind charts");
|
||||
awdHstry = pageData.hstryBuffers->getBuffer("AWD");
|
||||
awsHstry = pageData.hstryBuffers->getBuffer("AWS");
|
||||
|
||||
awdFlChart.reset(new Chart<uint16_t>(*awdHstry, 'V', 0, dfltRngWd, *commonData, useSimuData));
|
||||
awsFlChart.reset(new Chart<uint16_t>(*awsHstry, 'H', 0, dfltRngWs, *commonData, useSimuData));
|
||||
awdHfChart.reset(new Chart<uint16_t>(*awdHstry, 'V', 1, dfltRngWd, *commonData, useSimuData));
|
||||
awsHfChart.reset(new Chart<uint16_t>(*awsHstry, 'V', 2, dfltRngWs, *commonData, useSimuData));
|
||||
}
|
||||
if (awdHstry) {
|
||||
awdFlChart.reset(new Chart<uint16_t>(*awdHstry, 'V', 0, dfltRngWd, *commonData, useSimuData));
|
||||
awdHfChart.reset(new Chart<uint16_t>(*awdHstry, 'V', 1, dfltRngWd, *commonData, useSimuData));
|
||||
}
|
||||
if (awsHstry) {
|
||||
awsFlChart.reset(new Chart<uint16_t>(*awsHstry, 'H', 0, dfltRngWs, *commonData, useSimuData));
|
||||
awsHfChart.reset(new Chart<uint16_t>(*awsHstry, 'V', 2, dfltRngWs, *commonData, useSimuData));
|
||||
}
|
||||
if (twdHstry && twsHstry && awdHstry && awsHstry) {
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Created wind charts");
|
||||
} else {
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Some/all chart objects for wind data missing");
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
int displayPage(PageData& pageData)
|
||||
@@ -178,6 +192,39 @@ public:
|
||||
LOG_DEBUG(GwLog::LOG, "Display PageWindPlot");
|
||||
ulong pageTime = millis();
|
||||
|
||||
if (!twdFlChart) { // Create true wind charts if they don't exist
|
||||
twdHstry = pageData.hstryBuffers->getBuffer("TWD");
|
||||
twsHstry = pageData.hstryBuffers->getBuffer("TWS");
|
||||
|
||||
if (twdHstry) {
|
||||
twdFlChart.reset(new Chart<uint16_t>(*twdHstry, 'V', 0, dfltRngWd, *commonData, useSimuData));
|
||||
twdHfChart.reset(new Chart<uint16_t>(*twdHstry, 'V', 1, dfltRngWd, *commonData, useSimuData));
|
||||
}
|
||||
if (twsHstry) {
|
||||
twsFlChart.reset(new Chart<uint16_t>(*twsHstry, 'H', 0, dfltRngWs, *commonData, useSimuData));
|
||||
twsHfChart.reset(new Chart<uint16_t>(*twsHstry, 'V', 2, dfltRngWs, *commonData, useSimuData));
|
||||
}
|
||||
}
|
||||
|
||||
if (!awdFlChart) { // Create apparent wind charts if they don't exist
|
||||
awdHstry = pageData.hstryBuffers->getBuffer("AWD");
|
||||
awsHstry = pageData.hstryBuffers->getBuffer("AWS");
|
||||
|
||||
if (awdHstry) {
|
||||
awdFlChart.reset(new Chart<uint16_t>(*awdHstry, 'V', 0, dfltRngWd, *commonData, useSimuData));
|
||||
awdHfChart.reset(new Chart<uint16_t>(*awdHstry, 'V', 1, dfltRngWd, *commonData, useSimuData));
|
||||
}
|
||||
if (awsHstry) {
|
||||
awsFlChart.reset(new Chart<uint16_t>(*awsHstry, 'H', 0, dfltRngWs, *commonData, useSimuData));
|
||||
awsHfChart.reset(new Chart<uint16_t>(*awsHstry, 'V', 2, dfltRngWs, *commonData, useSimuData));
|
||||
}
|
||||
if (twdHstry && twsHstry && awdHstry && awsHstry) {
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Created wind charts");
|
||||
} else {
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Some/all chart objects for wind data missing");
|
||||
}
|
||||
}
|
||||
|
||||
if (showTruW != oldShowTruW) {
|
||||
|
||||
// Switch active charts based on showTruW
|
||||
@@ -199,6 +246,7 @@ public:
|
||||
|
||||
oldShowTruW = showTruW;
|
||||
}
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: draw with data %s: %.2f, %s: %.2f", wdBVal->getName().c_str(), wdBVal->value, wsBVal->getName().c_str(), wsBVal->value);
|
||||
|
||||
// Draw page
|
||||
//***********************************************************
|
||||
@@ -208,14 +256,22 @@ public:
|
||||
getdisplay().setTextColor(commonData->fgcolor);
|
||||
|
||||
if (chrtMode == 'D') {
|
||||
wdFlChart->showChrt(dataIntv, *wdBVal, true);
|
||||
if (wdFlChart) {
|
||||
wdFlChart->showChrt(dataIntv, *wdBVal, true);
|
||||
}
|
||||
|
||||
} else if (chrtMode == 'S') {
|
||||
wsFlChart->showChrt(dataIntv, *wsBVal, true);
|
||||
if (wsFlChart) {
|
||||
wsFlChart->showChrt(dataIntv, *wsBVal, true);
|
||||
}
|
||||
|
||||
} else if (chrtMode == 'B') {
|
||||
wdHfChart->showChrt(dataIntv, *wdBVal, true);
|
||||
wsHfChart->showChrt(dataIntv, *wsBVal, true);
|
||||
if (wdHfChart) {
|
||||
wdHfChart->showChrt(dataIntv, *wdBVal, true);
|
||||
}
|
||||
if (wsHfChart) {
|
||||
wsHfChart->showChrt(dataIntv, *wsBVal, true);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: page time %ldms", millis() - pageTime);
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include "LedSpiTask.h"
|
||||
#include "OBPDataOperations.h"
|
||||
|
||||
#define MAX_PAGE_NUMBER 10 // Max number of pages for show data
|
||||
|
||||
typedef std::vector<GwApi::BoatValue *> ValueList;
|
||||
|
||||
class HstryBuffers;
|
||||
|
||||
typedef struct{
|
||||
GwApi *api;
|
||||
String pageName;
|
||||
|
||||
@@ -815,7 +815,7 @@ void OBP60Task(GwApi *api){
|
||||
trueWind.addWinds();
|
||||
}
|
||||
// Handle history buffers for certain boat data for windplot page and other usage
|
||||
hstryBufList.handleHstryBufs(useSimuData);
|
||||
hstryBufList.handleHstryBufs(useSimuData, commonData);
|
||||
|
||||
// Clear display
|
||||
// getdisplay().fillRect(0, 0, getdisplay().width(), getdisplay().height(), commonData.bgcolor);
|
||||
|
||||
Reference in New Issue
Block a user