1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2026-01-26 08:13:05 +01:00

Revert wind speed chart for horizontal charts; changed chart format parameters to <char>; adjusted chart size to OBP standard

Revert wind speed chart for horizontal charts; changed chart format parameters to <char>; adjusted chart size to OBP standard - commit from PageWindPlot-v2
This commit is contained in:
Ulrich Meine
2025-12-14 20:17:36 +01:00
parent 3ce1e31e64
commit d655674529
3 changed files with 75 additions and 65 deletions

View File

@@ -5,7 +5,7 @@
// --- Class Chart --------------- // --- Class Chart ---------------
template <typename T> template <typename T>
Chart<T>::Chart(RingBuffer<T>& dataBuf, int8_t chrtDir, int8_t chrtSz, double dfltRng, CommonData& common, bool useSimuData) Chart<T>::Chart(RingBuffer<T>& dataBuf, char chrtDir, int8_t chrtSz, double dfltRng, CommonData& common, bool useSimuData)
: dataBuf(dataBuf) : dataBuf(dataBuf)
, chrtDir(chrtDir) , chrtDir(chrtDir)
, chrtSz(chrtSz) , chrtSz(chrtSz)
@@ -21,41 +21,43 @@ Chart<T>::Chart(RingBuffer<T>& dataBuf, int8_t chrtDir, int8_t chrtSz, double df
dWidth = getdisplay().width(); dWidth = getdisplay().width();
dHeight = getdisplay().height(); dHeight = getdisplay().height();
if (chrtDir == 0) { if (chrtDir == 'H') {
// horizontal chart timeline direction // horizontal chart timeline direction
timAxis = dWidth; timAxis = dWidth;
switch (chrtSz) { switch (chrtSz) {
case 0: case 0:
valAxis = dHeight - top - bottom; valAxis = dHeight - top - bottom;
cStart = { 0, top }; cStart = { 0, top - 1 };
break; break;
case 1: case 1:
valAxis = (dHeight - top - bottom) / 2 - hGap; valAxis = (dHeight - top - bottom) / 2 - hGap;
cStart = { 0, top }; cStart = { 0, top - 1 };
break; break;
case 2: case 2:
valAxis = (dHeight - top - bottom) / 2 - hGap; valAxis = (dHeight - top - bottom) / 2 - hGap;
cStart = { 0, top + (valAxis + hGap) + hGap }; cStart = { 0, top + (valAxis + hGap) + hGap - 1 };
break; break;
default: default:
LOG_DEBUG(GwLog::ERROR, "displayChart: wrong init parameter"); LOG_DEBUG(GwLog::ERROR, "displayChart: wrong init parameter");
return; return;
} }
} else if (chrtDir == 1) { } else if (chrtDir == 'V') {
// vertical chart timeline direction // vertical chart timeline direction
timAxis = dHeight - top - bottom; timAxis = dHeight - top - bottom;
switch (chrtSz) { switch (chrtSz) {
case 0: case 0:
valAxis = dWidth; valAxis = dWidth;
cStart = { 0, top }; cStart = { 0, top - 1 };
break; break;
case 1: case 1:
valAxis = dWidth / 2 - vGap - 1; // valAxis = dWidth / 2 - vGap - 1;
cStart = { 0, top }; valAxis = dWidth / 2 - vGap;
cStart = { 0, top - 1 };
break; break;
case 2: case 2:
valAxis = dWidth / 2 - vGap - 1; // valAxis = dWidth / 2 - vGap - 1;
cStart = { dWidth / 2 + vGap, top }; valAxis = dWidth / 2 - vGap;
cStart = { dWidth / 2 + vGap - 1, top - 1 };
break; break;
default: default:
LOG_DEBUG(GwLog::ERROR, "displayChart: wrong init parameter"); LOG_DEBUG(GwLog::ERROR, "displayChart: wrong init parameter");
@@ -71,17 +73,21 @@ Chart<T>::Chart(RingBuffer<T>& dataBuf, int8_t chrtDir, int8_t chrtSz, double df
dbMAX_VAL = dataBuf.getMaxVal(); dbMAX_VAL = dataBuf.getMaxVal();
bufSize = dataBuf.getCapacity(); bufSize = dataBuf.getCapacity();
if (dbFormat == "formatCourse" || dbFormat == "FormatWind" || dbFormat == "FormatRot") { if (dbFormat == "formatCourse" || dbFormat == "formatWind" || dbFormat == "formatRot") {
if (dbFormat == "FormatRot") { if (dbFormat == "formatRot") {
chrtDataFmt = 2; // Chart is showing data of rotational <degree> format chrtDataFmt = 'R'; // Chart is showing data of rotational <degree> format
} else { } else {
chrtDataFmt = 1; // Chart is showing data of course / wind <degree> format chrtDataFmt = 'W'; // Chart is showing data of course / wind <degree> format
} }
rngStep = M_TWOPI / 360.0 * 10.0; // +/-10 degrees on each end of chrtMid; we are calculating with SI values rngStep = M_TWOPI / 360.0 * 10.0; // +/-10 degrees on each end of chrtMid; we are calculating with SI values
} else { } else {
chrtDataFmt = 0; // Chart is showing any other data format than <degree> if (dbFormat == "formatDepth") {
chrtDataFmt = 'D'; // Chart ist showing data of <depth> format
} else {
chrtDataFmt = 'S'; // Chart is showing any other data format than <degree>
}
rngStep = 5.0; // +/- 10 for all other values (eg. m/s, m, K, mBar) rngStep = 5.0; // +/- 10 for all other values (eg. m/s, m, K, mBar)
} }
@@ -178,16 +184,19 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
chrtPrevVal = dbMAX_VAL; chrtPrevVal = dbMAX_VAL;
} else { } else {
if (chrtDir == 0) { // horizontal chart if (chrtDir == 'H') { // horizontal chart
x = cStart.x + i; // Position in chart area x = cStart.x + i; // Position in chart area
if (chrtDataFmt == 0) { if (chrtDataFmt == 'S') {
// y = cStart.y + static_cast<int>(((chrtVal - chrtMin) * chrtScl) + 0.5); // calculate chart point and round
y = cStart.y + valAxis - static_cast<int>(((chrtVal - chrtMin) * chrtScl) + 0.5); // calculate chart point and round
} else if (chrtDataFmt == 'D') {
y = cStart.y + static_cast<int>(((chrtVal - chrtMin) * chrtScl) + 0.5); // calculate chart point and round y = cStart.y + static_cast<int>(((chrtVal - chrtMin) * chrtScl) + 0.5); // calculate chart point and round
} else { // degree type value } else { // degree type value
y = cStart.y + static_cast<int>((WindUtils::to2PI(chrtVal - chrtMin) * chrtScl) + 0.5); // calculate chart point and round y = cStart.y + static_cast<int>((WindUtils::to2PI(chrtVal - chrtMin) * chrtScl) + 0.5); // calculate chart point and round
} }
} else { // vertical chart } else { // vertical chart
y = cStart.y + timAxis - i; // Position in chart area y = cStart.y + timAxis - i; // Position in chart area
if (chrtDataFmt == 0) { if (chrtDataFmt == 'S' || chrtDataFmt == 'D') {
x = cStart.x + static_cast<int>(((chrtVal - chrtMin) * chrtScl) + 0.5); // calculate chart point and round x = cStart.x + static_cast<int>(((chrtVal - chrtMin) * chrtScl) + 0.5); // calculate chart point and round
} else { // degree type value } else { // degree type value
x = cStart.x + static_cast<int>((WindUtils::to2PI(chrtVal - chrtMin) * chrtScl) + 0.5); // calculate chart point and round x = cStart.x + static_cast<int>((WindUtils::to2PI(chrtVal - chrtMin) * chrtScl) + 0.5); // calculate chart point and round
@@ -202,7 +211,7 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
prevX = x; prevX = x;
prevY = y; prevY = y;
} else if (chrtDataFmt != 0) { } else if (chrtDataFmt == 'W' || chrtDataFmt == 'R') {
// cross borders check for degree values; shift values to [-PI..0..PI]; when crossing borders, range is 2x PI degrees // cross borders check for degree values; shift values to [-PI..0..PI]; when crossing borders, range is 2x PI degrees
double normCurr = WindUtils::to2PI(chrtVal - chrtMin); double normCurr = WindUtils::to2PI(chrtVal - chrtMin);
double normPrev = WindUtils::to2PI(chrtPrevVal - chrtMin); double normPrev = WindUtils::to2PI(chrtPrevVal - chrtMin);
@@ -212,7 +221,7 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
if (crossedBorders) { // If current value crosses chart borders compared to previous value, split line if (crossedBorders) { // If current value crosses chart borders compared to previous value, split line
// LOG_DEBUG(GwLog::DEBUG, "PageWindPlot Chart: crossedBorders: %d, chrtVal: %.2f, chrtPrevVal: %.2f", crossedBorders, chrtVal, chrtPrevVal); // LOG_DEBUG(GwLog::DEBUG, "PageWindPlot Chart: crossedBorders: %d, chrtVal: %.2f, chrtPrevVal: %.2f", crossedBorders, chrtVal, chrtPrevVal);
bool wrappingFromHighToLow = normCurr < normPrev; // Determine which edge we're crossing bool wrappingFromHighToLow = normCurr < normPrev; // Determine which edge we're crossing
if (chrtDir == 0) { if (chrtDir == 'H') {
int ySplit = wrappingFromHighToLow ? (cStart.y + valAxis) : cStart.y; int ySplit = wrappingFromHighToLow ? (cStart.y + valAxis) : cStart.y;
getdisplay().drawLine(prevX, prevY, x, ySplit, fgColor); getdisplay().drawLine(prevX, prevY, x, ySplit, fgColor);
if (x != prevX) { // line with some horizontal trend if (x != prevX) { // line with some horizontal trend
@@ -231,12 +240,18 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
} }
// Draw line with 2 pixels width + make sure vertical lines are drawn correctly // Draw line with 2 pixels width + make sure vertical lines are drawn correctly
if (chrtDir == 0 || x == prevX) { // horizontal chart & vertical line if (chrtDir == 'H' || x == prevX) { // horizontal chart & vertical line
// if (x == prevX) { // vertical line if (chrtDataFmt == 'D') {
getdisplay().drawLine(x, y, x, cStart.y + valAxis, fgColor);
getdisplay().drawLine(x - 1, y, x - 1, cStart.y + valAxis, fgColor);
}
getdisplay().drawLine(prevX, prevY, x, y, fgColor); getdisplay().drawLine(prevX, prevY, x, y, fgColor);
getdisplay().drawLine(prevX - 1, prevY, x - 1, y, fgColor); getdisplay().drawLine(prevX - 1, prevY, x - 1, y, fgColor);
} else if (chrtDir == 1 || x != prevX) { // vertical chart & line with some horizontal trend -> normal state } else if (chrtDir == 'V' || x != prevX) { // vertical chart & line with some horizontal trend -> normal state
// } else { // line with some horizontal trend -> normal state if (chrtDataFmt == 'D') {
getdisplay().drawLine(x, y, cStart.x + valAxis, y, fgColor);
getdisplay().drawLine(x, y - 1, cStart.x + valAxis, y - 1, fgColor);
}
getdisplay().drawLine(prevX, prevY, x, y, fgColor); getdisplay().drawLine(prevX, prevY, x, y, fgColor);
getdisplay().drawLine(prevX, prevY - 1, x, y - 1, fgColor); getdisplay().drawLine(prevX, prevY - 1, x, y - 1, fgColor);
} }
@@ -249,23 +264,22 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
if (i >= timAxis - 1) { if (i >= timAxis - 1) {
oldChrtIntv = 0; // force reset of buffer start and number of values to show in next display loop oldChrtIntv = 0; // force reset of buffer start and number of values to show in next display loop
if (chrtDataFmt == 1) { // degree of course or wind if (chrtDataFmt == 'W') { // degree of course or wind
recalcRngCntr = true; recalcRngCntr = true;
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot FreeTop: timAxis: %d, i: %d, bufStart: %d, numBufVals: %d, recalcRngCntr: %d", timAxis, i, bufStart, numBufVals, recalcRngCntr); LOG_DEBUG(GwLog::DEBUG, "PageWindPlot FreeTop: timAxis: %d, i: %d, bufStart: %d, numBufVals: %d, recalcRngCntr: %d", timAxis, i, bufStart, numBufVals, recalcRngCntr);
} }
break; break;
} }
} }
} else { } else {
// No valid data available // No valid data available
getdisplay().setFont(&Ubuntu_Bold10pt8b); getdisplay().setFont(&Ubuntu_Bold10pt8b);
int pX, pY; int pX, pY;
if (chrtDir == 0) { // horizontal chart if (chrtDir == 'H') {
pX = cStart.x + (timAxis / 2); pX = cStart.x + (timAxis / 2);
pY = cStart.y + (valAxis / 2) - 10; pY = cStart.y + (valAxis / 2) - 10;
} else { // vertical chart } else {
pX = cStart.x + (valAxis / 2); pX = cStart.x + (valAxis / 2);
pY = cStart.y + (timAxis / 2) - 10; pY = cStart.y + (timAxis / 2) - 10;
} }
@@ -316,7 +330,7 @@ double Chart<T>::getRng(double center, size_t amount)
template <typename T> template <typename T>
void Chart<T>::calcChrtBorders(double& rngMid, double& rngMin, double& rngMax, double& rng) void Chart<T>::calcChrtBorders(double& rngMid, double& rngMin, double& rngMax, double& rng)
{ {
if (chrtDataFmt == 0) { if (chrtDataFmt == 'S' || chrtDataFmt == 'D') {
// Chart data is of any type but 'degree' // Chart data is of any type but 'degree'
double oldRngMin = rngMin; double oldRngMin = rngMin;
@@ -349,7 +363,7 @@ void Chart<T>::calcChrtBorders(double& rngMid, double& rngMin, double& rngMax, d
currMinVal, currMaxVal, rngMin, rngMid, rngMax, rng, rngStep, oldRngMin, oldRngMax, dfltRng, numBufVals); currMinVal, currMaxVal, rngMin, rngMid, rngMax, rng, rngStep, oldRngMin, oldRngMax, dfltRng, numBufVals);
} else { } else {
if (chrtDataFmt == 1) { if (chrtDataFmt == 'W') {
// Chart data is of type 'course' or 'wind' // Chart data is of type 'course' or 'wind'
if ((count == 1 && rngMid == 0) || rngMid == dbMAX_VAL) { if ((count == 1 && rngMid == 0) || rngMid == dbMAX_VAL) {
@@ -378,7 +392,7 @@ void Chart<T>::calcChrtBorders(double& rngMid, double& rngMin, double& rngMax, d
rng * RAD_TO_DEG, rngStep * RAD_TO_DEG); rng * RAD_TO_DEG, rngStep * RAD_TO_DEG);
} }
} else if (chrtDataFmt == 2) { } else if (chrtDataFmt == 'R') {
// Chart data is of type 'rotation'; then we want to have <rndMid> always to be '0' // Chart data is of type 'rotation'; then we want to have <rndMid> always to be '0'
rngMid = 0; rngMid = 0;
} }
@@ -417,7 +431,7 @@ void Chart<T>::drawChrtTimeAxis(int8_t chrtIntv)
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setTextColor(fgColor); getdisplay().setTextColor(fgColor);
if (chrtDir == 0) { // horizontal chart if (chrtDir == 'H') { // horizontal chart
getdisplay().fillRect(0, cStart.y, dWidth, 2, fgColor); getdisplay().fillRect(0, cStart.y, dWidth, 2, fgColor);
timeRng = chrtIntv * 4; // Chart time interval: [1] 4 min., [2] 8 min., [3] 12 min., [4] 16 min., [8] 32 min. timeRng = chrtIntv * 4; // Chart time interval: [1] 4 min., [2] 8 min., [3] 12 min., [4] 16 min., [8] 32 min.
@@ -478,7 +492,7 @@ void Chart<T>::drawChrtValAxis()
{ {
double slots; double slots;
int i, intv; int i, intv;
double cVal, cchrtRng, crngMin; double cVal, cChrtRng, crngMin;
char sVal[6]; char sVal[6];
int sLen; int sLen;
std::unique_ptr<GwApi::BoatValue> tmpBVal; // Temp variable to get formatted and converted data value from OBP60Formatter std::unique_ptr<GwApi::BoatValue> tmpBVal; // Temp variable to get formatted and converted data value from OBP60Formatter
@@ -486,16 +500,17 @@ void Chart<T>::drawChrtValAxis()
tmpBVal->setFormat(dataBuf.getFormat()); tmpBVal->setFormat(dataBuf.getFormat());
tmpBVal->valid = true; tmpBVal->valid = true;
if (chrtDir == 0) { // horizontal chart if (chrtDir == 'H') {
slots = valAxis / 60.0; // number of axis labels slots = valAxis / 60.0; // number of axis labels
tmpBVal->value = chrtRng; tmpBVal->value = chrtRng;
cchrtRng = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted) cChrtRng = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
intv = static_cast<int>(round(cchrtRng / slots)); intv = static_cast<int>(round(cChrtRng / slots));
i = intv; i = intv;
if (chrtSz == 0) { // full size chart -> print multiple value lines if (chrtSz == 0) { // full size chart -> print multiple value lines
getdisplay().setFont(&Ubuntu_Bold12pt8b); getdisplay().setFont(&Ubuntu_Bold12pt8b);
for (int j = 60; j < valAxis - 30; j += 60) { // for (int j = 60; j < valAxis - 30; j += 60) {
for (int j = valAxis - 60; j > 30; j -= 60) {
getdisplay().drawLine(cStart.x, cStart.y + j, cStart.x + timAxis, cStart.y + j, fgColor); 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 getdisplay().fillRect(cStart.x, cStart.y + j - 11, 42, 21, bgColor); // Clear small area to remove potential chart lines
@@ -542,7 +557,7 @@ void Chart<T>::drawChrtValAxis()
} else { } else {
getdisplay().setFont(&Ubuntu_Bold10pt8b); getdisplay().setFont(&Ubuntu_Bold10pt8b);
} }
getdisplay().fillRect(cStart.x, top, valAxis, 2, fgColor); // top chart line getdisplay().fillRect(cStart.x, cStart.y, valAxis, 2, fgColor); // top chart line
tmpBVal->value = chrtMin; tmpBVal->value = chrtMin;
cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted) cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
@@ -560,14 +575,9 @@ void Chart<T>::drawChrtValAxis()
snprintf(sVal, sizeof(sVal), "%.0f", round(cVal)); snprintf(sVal, sizeof(sVal), "%.0f", round(cVal));
drawTextRalign(cStart.x + valAxis - 2, cStart.y - 2, sVal); // Range high end drawTextRalign(cStart.x + valAxis - 2, cStart.y - 2, sVal); // Range high end
for (int j = 0; j <= valAxis + 2; j += ((valAxis + 2) / 2)) { for (int j = 0; j <= valAxis; j += (valAxis / 2)) {
getdisplay().drawLine(cStart.x + j, cStart.y, cStart.x + j, cStart.y + timAxis, fgColor); getdisplay().drawLine(cStart.x + j, cStart.y, cStart.x + j, cStart.y + timAxis, fgColor);
} }
// if (chrtSz == 0) {
// getdisplay().setFont(&Ubuntu_Bold12pt8b);
// drawTextCenter(cStart.x + (valAxis / 4) + 15, cStart.y - 11, dbName); // buffer data name
// }
} }
} }
@@ -575,8 +585,8 @@ void Chart<T>::drawChrtValAxis()
template <typename T> template <typename T>
void Chart<T>::prntCurrValue(GwApi::BoatValue& currValue) void Chart<T>::prntCurrValue(GwApi::BoatValue& currValue)
{ {
const int xPosVal = (chrtDir == 0) ? cStart.x + (timAxis / 2) - 56 : cStart.x + 32; const int xPosVal = (chrtDir == 'H') ? cStart.x + (timAxis / 2) - 56 : cStart.x + 32;
const int yPosVal = (chrtDir == 0) ? cStart.y + valAxis - 7 : cStart.y + timAxis - 7; const int yPosVal = (chrtDir == 'H') ? cStart.y + valAxis - 5 : cStart.y + timAxis - 5;
FormattedData frmtDbData = formatValue(&currValue, *commonData); FormattedData frmtDbData = formatValue(&currValue, *commonData);
double testdbValue = frmtDbData.value; double testdbValue = frmtDbData.value;
@@ -585,7 +595,7 @@ void Chart<T>::prntCurrValue(GwApi::BoatValue& currValue)
// 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, // 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); // testdbValue, currValue.getFormat(), dbUnit, currValue.valid, currValue.getName(), currValue);
getdisplay().fillRect(xPosVal - 1, yPosVal - 34, 125, 41, bgColor); // Clear area for TWS value getdisplay().fillRect(xPosVal - 1, yPosVal - 34, 125, 40, bgColor); // Clear area for TWS value
getdisplay().drawRect(xPosVal, yPosVal - 33, 123, 39, fgColor); // Draw box for TWS value getdisplay().drawRect(xPosVal, yPosVal - 33, 123, 39, fgColor); // Draw box for TWS value
getdisplay().setFont(&DSEG7Classic_BoldItalic16pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic16pt7b);
getdisplay().setCursor(xPosVal + 1, yPosVal); getdisplay().setCursor(xPosVal + 1, yPosVal);

View File

@@ -16,19 +16,18 @@ protected:
GwLog *logger; GwLog *logger;
RingBuffer<T> &dataBuf; // Buffer to display RingBuffer<T> &dataBuf; // Buffer to display
int8_t chrtDir; // Chart timeline direction: [0] = horizontal, [1] = vertical char chrtDir; // Chart timeline direction: 'H' = horizontal, 'V' = vertical
int8_t chrtSz; // Chart size: [0] = full size, [1] = half size left/top, [2] half size right/bottom int8_t chrtSz; // Chart size: [0] = full size, [1] = half size left/top, [2] half size right/bottom
double dfltRng; // Default range of chart, e.g. 30 = [0..30] double dfltRng; // Default range of chart, e.g. 30 = [0..30]
uint16_t fgColor; // color code for any screen writing uint16_t fgColor; // color code for any screen writing
uint16_t bgColor; // color code for screen background uint16_t bgColor; // color code for screen background
bool useSimuData; // flag to indicate if simulation data is active bool useSimuData; // flag to indicate if simulation data is active
int top = 48; // display top header lines // int top = 48; // display top header lines
int bottom = 22; // display bottom lines 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 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 = 20; // gap between 2 vertical charts; actual gap is 2x <gap>
int xOffset = 33; // offset for horizontal axis (time/value), because of space for left vertical axis labeling
int yOffset = 10; // offset for vertical axis (time/value), because of space for top horizontal axis labeling
int dWidth; // Display width int dWidth; // Display width
int dHeight; // Display height int dHeight; // Display height
int timAxis, valAxis; // size of time and value chart axis int timAxis, valAxis; // size of time and value chart axis
@@ -41,7 +40,7 @@ protected:
bool recalcRngCntr = false; // Flag for re-calculation of mid value of chart for wind data types bool recalcRngCntr = false; // Flag for re-calculation of mid value of chart for wind data types
String dbName, dbFormat; // Name and format of data buffer String dbName, dbFormat; // Name and format of data buffer
int chrtDataFmt; // Data format of chart: [0] size values; [1] degree of course or wind; [2] rotational degrees char chrtDataFmt; // Data format of chart: 'S' = size values; 'D' = depth value, 'W' = degree of course or wind; 'R' rotational degrees
double dbMIN_VAL; // Lowest possible value of buffer of type <T> double dbMIN_VAL; // Lowest possible value of buffer of type <T>
double dbMAX_VAL; // Highest possible value of buffer of type <T>; indicates invalid value in buffer double dbMAX_VAL; // Highest possible value of buffer of type <T>; indicates invalid value in buffer
size_t bufSize; // History buffer size: 1.920 values for 32 min. history chart size_t bufSize; // History buffer size: 1.920 values for 32 min. history chart
@@ -63,7 +62,7 @@ protected:
void prntCurrValue(GwApi::BoatValue& currValue); // Add current boat data value to chart void prntCurrValue(GwApi::BoatValue& currValue); // Add current boat data value to chart
public: public:
Chart(RingBuffer<T>& dataBuf, int8_t chrtDir, int8_t chrtSz, double dfltRng, CommonData& common, bool useSimuData); // Chart object of data chart Chart(RingBuffer<T>& dataBuf, char chrtDir, int8_t chrtSz, double dfltRng, CommonData& common, bool useSimuData); // Chart object of data chart
~Chart(); ~Chart();
void showChrt(int8_t chrtIntv, GwApi::BoatValue currValue); // Perform all actions to draw chart void showChrt(int8_t chrtIntv, GwApi::BoatValue currValue); // Perform all actions to draw chart

View File

@@ -167,12 +167,13 @@ public:
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Creating true wind charts"); LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: Creating true wind charts");
auto* twdHstry = pageData.hstryManager->getBuffer("TWD"); auto* twdHstry = pageData.hstryManager->getBuffer("TWD");
auto* twsHstry = pageData.hstryManager->getBuffer("TWS"); auto* twsHstry = pageData.hstryManager->getBuffer("TWS");
twdFlChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twdHstry, 1, 0, dfltRngWd, *commonData, useSimuData));
twsFlChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twsHstry, 0, 0, dfltRngWs, *commonData, useSimuData)); twdFlChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twdHstry, 'V', 0, dfltRngWd, *commonData, useSimuData));
twdHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twdHstry, 1, 1, dfltRngWd, *commonData, useSimuData)); twsFlChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twsHstry, 'H', 0, dfltRngWs, *commonData, useSimuData));
twsHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twsHstry, 1, 2, dfltRngWs, *commonData, useSimuData)); twdHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twdHstry, 'V', 1, dfltRngWd, *commonData, useSimuData));
// twdHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twdHstry, 0, 1, dfltRngWd, *commonData, useSimuData)); twsHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twsHstry, 'V', 2, dfltRngWs, *commonData, useSimuData));
// twsHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*twsHstry, 0, 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); // LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: twdHstry: %p, twsHstry: %p", (void*)twdHstry, (void*)twsHstry);
} }
@@ -181,10 +182,10 @@ public:
auto* awdHstry = pageData.hstryManager->getBuffer("AWD"); auto* awdHstry = pageData.hstryManager->getBuffer("AWD");
auto* awsHstry = pageData.hstryManager->getBuffer("AWS"); auto* awsHstry = pageData.hstryManager->getBuffer("AWS");
awdFlChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*awdHstry, 1, 0, dfltRngWd, *commonData, useSimuData)); 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, 0, 0, dfltRngWs, *commonData, useSimuData)); awsFlChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*awsHstry, 'H', 0, dfltRngWs, *commonData, useSimuData));
awdHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*awdHstry, 1, 1, dfltRngWd, *commonData, useSimuData)); awdHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*awdHstry, 'V', 1, dfltRngWd, *commonData, useSimuData));
awsHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*awsHstry, 1, 2, dfltRngWs, *commonData, useSimuData)); awsHfChart = std::unique_ptr<Chart<uint16_t>>(new Chart<uint16_t>(*awsHstry, 'V', 2, dfltRngWs, *commonData, useSimuData));
} }
// Switch active charts based on showTruW // Switch active charts based on showTruW