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

optimized chart initialization for PageWindPlot; added chart options to PageOneValue;

printing of current boat value on horizontal half charts is selectable;
fixed value axis direction for depth and other boat data; changed time axis labels to full numbers;
changed "INTV" button label to "ZOOM"
This commit is contained in:
Ulrich Meine
2025-12-23 18:16:53 +01:00
parent 362338a7dd
commit 69754b85fd
7 changed files with 364 additions and 243 deletions

View File

@@ -434,7 +434,7 @@ void drawTextRalign(int16_t x, int16_t y, String text) {
int16_t x1, y1; int16_t x1, y1;
uint16_t w, h; uint16_t w, h;
getdisplay().getTextBounds(text, 0, 150, &x1, &y1, &w, &h); getdisplay().getTextBounds(text, 0, 150, &x1, &y1, &w, &h);
getdisplay().setCursor(x - w, y); getdisplay().setCursor(x - w - 1, y); // '-1' required since some strings wrap around w/o it
getdisplay().print(text); getdisplay().print(text);
} }

View File

@@ -259,44 +259,6 @@ bool WindUtils::calcWinds(const double* awaVal, const double* awsVal,
} }
} }
/* // we don't need this -> AWD is calculated in calcTwdSA
// Calc AWD from existing AWA and HDT/HDM
bool WindUtils::calcATWD(const double* waVal, const double* hdtVal, const double* hdmVal, const double* varVal, const double* cogVal, const double* sogVal, double* wdVal)
{
double wd, hdt;
GwApi::BoatValue* calBVal; // temp variable just for data calibration
bool isCalculated = false;
if (*waVal == DBL_MAX) {
return false;
}
if (*hdtVal != DBL_MAX) {
hdt = *hdtVal; // Use HDT if available
} else {
hdt = calcHDT(hdmVal, varVal, cogVal, sogVal);
}
if (hdt != DBL_MAX) {
wd = *waVal + hdt;
wd = to2PI(wd);
isCalculated = true;
}
// Calibrate AWD/TWD if required
calBVal = new GwApi::BoatValue("AWD"); // temporary solution for calibration of history buffer values
calBVal->value = wd;
calBVal->setFormat(awdBVal->getFormat());
calBVal->valid = true;
calibrationData.calibrateInstance(calBVal, logger); // Check if boat data value is to be calibrated
*wdVal = calBVal->value;
delete calBVal;
calBVal = nullptr;
return isCalculated;
} */
// Calculate true wind data and add to obp60task boat data list // Calculate true wind data and add to obp60task boat data list
bool WindUtils::addWinds() bool WindUtils::addWinds()
{ {

View File

@@ -3,9 +3,6 @@
#include "OBPRingBuffer.h" #include "OBPRingBuffer.h"
#include "obp60task.h" #include "obp60task.h"
#include <map> #include <map>
#include <memory>
#include <limits>
#include <cmath>
class HstryBuf { class HstryBuf {
private: private:
@@ -46,16 +43,18 @@ private:
{"AWA", {1000, 10000, -M_PI, M_PI, "formatWind"}}, {"AWA", {1000, 10000, -M_PI, M_PI, "formatWind"}},
{"AWD", {1000, 10000, 0.0, M_TWOPI, "formatCourse"}}, {"AWD", {1000, 10000, 0.0, M_TWOPI, "formatCourse"}},
{"AWS", {1000, 1000, 0.0, 65.0, "formatKnots"}}, {"AWS", {1000, 1000, 0.0, 65.0, "formatKnots"}},
{"DBS", {1000, 100, 0.0, 650, "formatDepth"}}, {"COG", {1000, 10000, 0.0, M_TWOPI, "formatCourse"}},
{"DBT", {1000, 100, 0.0, 650, "formatDepth"}}, {"DBS", {1000, 100, 0.0, 650.0, "formatDepth"}},
{"DPT", {1000, 100, 0.0, 650, "formatDepth"}}, {"DBT", {1000, 100, 0.0, 650.0, "formatDepth"}},
{"HDT", {1000, 10000, 0.0, M_TWOPI, "formatCourse"}}, {"DPT", {1000, 100, 0.0, 650.0, "formatDepth"}},
{"HDM", {1000, 10000, 0.0, M_TWOPI, "formatCourse"}}, {"HDM", {1000, 10000, 0.0, M_TWOPI, "formatCourse"}},
{"HDT", {1000, 10000, 0.0, M_TWOPI, "formatCourse"}},
{"ROT", {1000, 10000, -M_PI / 180.0 * 99.0, M_PI / 180.0 * 99.0, "formatRot"}}, // min/max is -/+ 99 degrees for rotational angle
{"SOG", {1000, 1000, 0.0, 65.0, "formatKnots"}},
{"STW", {1000, 1000, 0.0, 65.0, "formatKnots"}},
{"TWA", {1000, 10000, -M_PI, M_PI, "formatWind"}}, {"TWA", {1000, 10000, -M_PI, M_PI, "formatWind"}},
{"TWD", {1000, 10000, 0.0, M_TWOPI, "formatCourse"}}, {"TWD", {1000, 10000, 0.0, M_TWOPI, "formatCourse"}},
{"TWS", {1000, 1000, 0.0, 65.0, "formatKnots"}}, {"TWS", {1000, 1000, 0.0, 65.0, "formatKnots"}},
{"SOG", {1000, 1000, 0.0, 65.0, "formatKnots"}},
{"STW", {1000, 1000, 0.0, 65.0, "formatKnots"}},
{"WTemp", {1000, 100, 0.0, 650.0, "kelvinToC"}} {"WTemp", {1000, 100, 0.0, 650.0, "kelvinToC"}}
}; };
@@ -106,6 +105,5 @@ public:
bool calcWinds(const double* awaVal, const double* awsVal, bool calcWinds(const double* awaVal, const double* awsVal,
const double* cogVal, const double* stwVal, const double* sogVal, const double* hdtVal, const double* cogVal, const double* stwVal, const double* sogVal, const double* hdtVal,
const double* hdmVal, const double* varVal, double* twdVal, double* twsVal, double* twaVal, double* awdVal); const double* hdmVal, const double* varVal, double* twdVal, double* twsVal, double* twaVal, double* awdVal);
bool calcATWD(const double* waVal, const double* hdtVal, const double* hdmVal, const double* varVal, const double* cogVal, const double* sogVal, double* wdVal);
bool addWinds(); bool addWinds();
}; };

View File

@@ -4,6 +4,13 @@
#include "OBPRingBuffer.h" #include "OBPRingBuffer.h"
// --- Class Chart --------------- // --- Class Chart ---------------
// Chart - object holding the actual chart, incl. data buffer and format definition
// Parameters: <chrtDir> chart timeline direction: 'H' = horizontal, 'V' = vertical;
// <chrtSz> chart size: [0] = full size, [1] = half size left/top, [2] half size right/bottom;
// <dfltRng> default range of chart, e.g. 30 = [0..30];
// <common> common program data; required for logger and color data
// <useSimuData> flag to indicate if simulation data is active
template <typename T> template <typename T>
Chart<T>::Chart(RingBuffer<T>& dataBuf, char 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)
@@ -23,7 +30,7 @@ Chart<T>::Chart(RingBuffer<T>& dataBuf, char chrtDir, int8_t chrtSz, double dflt
if (chrtDir == 'H') { if (chrtDir == 'H') {
// horizontal chart timeline direction // horizontal chart timeline direction
timAxis = dWidth; timAxis = dWidth - 1;
switch (chrtSz) { switch (chrtSz) {
case 0: case 0:
valAxis = dHeight - top - bottom; valAxis = dHeight - top - bottom;
@@ -41,12 +48,13 @@ Chart<T>::Chart(RingBuffer<T>& dataBuf, char chrtDir, int8_t chrtSz, double dflt
LOG_DEBUG(GwLog::ERROR, "displayChart: wrong init parameter"); LOG_DEBUG(GwLog::ERROR, "displayChart: wrong init parameter");
return; return;
} }
} else if (chrtDir == 'V') { } 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 - 1;
cStart = { 0, top - 1 }; cStart = { 0, top - 1 };
break; break;
case 1: case 1:
@@ -106,21 +114,39 @@ Chart<T>::~Chart()
} }
// Perform all actions to draw chart // Perform all actions to draw chart
// Parameters are chart time interval, and the current boat data value to be printed // Parameters: <chrtIntv> chart time interval, <currValue> current boat data value to be printed, <showCurrValue> current boat data shall be shown yes/no
template <typename T> template <typename T>
void Chart<T>::showChrt(int8_t chrtIntv, GwApi::BoatValue currValue) void Chart<T>::showChrt(int8_t chrtIntv, GwApi::BoatValue currValue, bool showCurrValue)
{ {
drawChrt(chrtIntv, currValue); drawChrt(chrtIntv, currValue);
drawChrtTimeAxis(chrtIntv); drawChrtTimeAxis(chrtIntv);
drawChrtValAxis(); drawChrtValAxis();
if (bufDataValid) { if (bufDataValid) {
// uses BoatValue temp variable <currValue> to format latest buffer value if (showCurrValue) {
// doesn't work unfortunately when 'simulation data' is active, because OBP60Formatter generates own simulation value in that case // uses BoatValue temp variable <currValue> to format latest buffer value
currValue.value = dataBuf.getLast(); // doesn't work unfortunately when 'simulation data' is active, because OBP60Formatter generates own simulation value in that case
currValue.valid = currValue.value != dbMAX_VAL; currValue.value = dataBuf.getLast();
Chart<T>::prntCurrValue(currValue); currValue.valid = currValue.value != dbMAX_VAL;
LOG_DEBUG(GwLog::DEBUG, "Chart drawChrt: currValue-value: %.1f, Valid: %d, Name: %s, Address: %p", currValue.value, currValue.valid, currValue.getName(), (void*)&currValue); Chart<T>::prntCurrValue(currValue);
LOG_DEBUG(GwLog::DEBUG, "OBPcharts showChrt: currValue-value: %.1f, Valid: %d, Name: %s, Address: %p", currValue.value, currValue.valid, currValue.getName(), (void*)&currValue);
}
} else { // No valid data available -> print message
getdisplay().setFont(&Ubuntu_Bold10pt8b);
int pX, pY;
if (chrtDir == 'H') {
pX = cStart.x + (timAxis / 2);
pY = cStart.y + (valAxis / 2) - 10;
} else {
pX = cStart.x + (valAxis / 2);
pY = cStart.y + (timAxis / 2) - 10;
}
getdisplay().fillRect(pX - 37, pY - 10, 78, 24, bgColor); // Clear area for message
drawTextCenter(pX, pY, "No data");
LOG_DEBUG(GwLog::LOG, "Page chart: No valid data available");
} }
} }
@@ -131,7 +157,6 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
double chrtVal; // Current data value double chrtVal; // Current data value
double chrtScl; // Scale for data values in pixels per value double chrtScl; // Scale for data values in pixels per value
static double chrtPrevVal; // Last data value in chart area static double chrtPrevVal; // Last data value in chart area
// bool bufDataValid = false; // Flag to indicate if buffer data is valid
static int numNoData; // Counter for multiple invalid data values in a row static int numNoData; // Counter for multiple invalid data values in a row
int x, y; // x and y coordinates for drawing int x, y; // x and y coordinates for drawing
@@ -144,7 +169,6 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
if (chrtIntv != oldChrtIntv || count == 1) { if (chrtIntv != oldChrtIntv || count == 1) {
// new data interval selected by user; this is only x * 230 values instead of 240 seconds (4 minutes) per interval step // new data interval selected by user; this is only x * 230 values instead of 240 seconds (4 minutes) per interval step
// intvBufSize = timAxis * chrtIntv; // obsolete
numBufVals = min(count, (timAxis - 60) * chrtIntv); // keep free or release 60 values on chart for plotting of new values numBufVals = min(count, (timAxis - 60) * chrtIntv); // keep free or release 60 values on chart for plotting of new values
bufStart = max(0, count - numBufVals); bufStart = max(0, count - numBufVals);
lastAddedIdx = currIdx; lastAddedIdx = currIdx;
@@ -186,7 +210,8 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
if (chrtDir == 'H') { // 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 == 'S') {
if (chrtDataFmt == 'S') { // speed data format -> print low values at bottom
// 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
y = cStart.y + valAxis - 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') { } else if (chrtDataFmt == 'D') {
@@ -194,8 +219,10 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
} 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 == 'S' || chrtDataFmt == 'D') { 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
@@ -266,27 +293,11 @@ void Chart<T>::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue)
if (chrtDataFmt == 'W') { // 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: chart end: timAxis: %d, i: %d, bufStart: %d, numBufVals: %d, recalcRngCntr: %d", timAxis, i, bufStart, numBufVals, recalcRngCntr);
} }
break; break;
} }
} }
} else {
// No valid data available
getdisplay().setFont(&Ubuntu_Bold10pt8b);
int pX, pY;
if (chrtDir == 'H') {
pX = cStart.x + (timAxis / 2);
pY = cStart.y + (valAxis / 2) - 10;
} else {
pX = cStart.x + (valAxis / 2);
pY = cStart.y + (timAxis / 2) - 10;
}
getdisplay().fillRect(pX - 33, pY - 10, 66, 24, bgColor); // Clear area for message
drawTextCenter(pX, pY, "No data");
LOG_DEBUG(GwLog::LOG, "PageWindPlot: No valid data available");
} }
} }
@@ -330,38 +341,8 @@ 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 == 'S' || chrtDataFmt == 'D') { if (chrtDataFmt == 'W' || chrtDataFmt == 'R') {
// Chart data is of any type but 'degree' // Chart data is of type 'course', 'wind' or 'rot'
double oldRngMin = rngMin;
double oldRngMax = rngMax;
// Chart starts at lowest range value, but at least '0' or includes even negative values
double currMinVal = dataBuf.getMin(numBufVals);
LOG_DEBUG(GwLog::DEBUG, "calcChrtRange0a: currMinVal: %.1f, currMaxVal: %.1f, rngMin: %.1f, rngMid: %.1f, rngMax: %.1f, rng: %.1f, rngStep: %.1f, oldRngMin: %.1f, oldRngMax: %.1f, dfltRng: %.1f, numBufVals: %d",
currMinVal, dataBuf.getMax(numBufVals), rngMin, rngMid, rngMax, rng, rngStep, oldRngMin, oldRngMax, dfltRng, numBufVals);
if (currMinVal != dbMAX_VAL) { // current min value is valid
if (currMinVal > 0 && dbMIN_VAL == 0) { // Chart range starts at least at '0' or includes negative values
rngMin = 0;
} else if (currMinVal < oldRngMin || (oldRngMin < 0 && (currMinVal > (oldRngMin + rngStep)))) { // decrease rngMin if required or increase if lowest value is higher than old rngMin
rngMin = std::floor(currMinVal / rngStep) * rngStep;
}
} // otherwise keep rngMin unchanged
double currMaxVal = dataBuf.getMax(numBufVals);
if (currMaxVal != dbMAX_VAL) { // current max value is valid
if ((currMaxVal > oldRngMax) || (currMaxVal < (oldRngMax - rngStep))) { // increase rngMax if required or decrease if lowest value is lower than old rngMax
rngMax = std::ceil(currMaxVal / rngStep) * rngStep;
rngMax = std::max(rngMax, rngMin + dfltRng); // keep at least default chart range
}
} // otherwise keep rngMax unchanged
rngMid = (rngMin + rngMax) / 2.0;
rng = rngMax - rngMin;
LOG_DEBUG(GwLog::DEBUG, "calcChrtRange1a: currMinVal: %.1f, currMaxVal: %.1f, rngMin: %.1f, rngMid: %.1f, rngMax: %.1f, rng: %.1f, rngStep: %.1f, oldRngMin: %.1f, oldRngMax: %.1f, dfltRng: %.1f, numBufVals: %d",
currMinVal, currMaxVal, rngMin, rngMid, rngMax, rng, rngStep, oldRngMin, oldRngMax, dfltRng, numBufVals);
} else {
if (chrtDataFmt == 'W') { if (chrtDataFmt == 'W') {
// Chart data is of type 'course' or 'wind' // Chart data is of type 'course' or 'wind'
@@ -416,8 +397,38 @@ void Chart<T>::calcChrtBorders(double& rngMid, double& rngMin, double& rngMax, d
// LOG_DEBUG(GwLog::DEBUG, "calcChrtRange2: diffRng: %.1f°, halfRng: %.1f°", diffRng * RAD_TO_DEG, halfRng * RAD_TO_DEG); // LOG_DEBUG(GwLog::DEBUG, "calcChrtRange2: diffRng: %.1f°, halfRng: %.1f°", diffRng * RAD_TO_DEG, halfRng * RAD_TO_DEG);
rng = halfRng * 2.0; rng = halfRng * 2.0;
LOG_DEBUG(GwLog::DEBUG, "calcChrtRange2b: rngMid: %.1f°, rngMin: %.1f°, rngMax: %.1f°, diffRng: %.1f°, rng: %.1f°, rngStep: %.1f°", rngMid * RAD_TO_DEG, rngMin * RAD_TO_DEG, rngMax * RAD_TO_DEG, // LOG_DEBUG(GwLog::DEBUG, "calcChrtRange2b: rngMid: %.1f°, rngMin: %.1f°, rngMax: %.1f°, diffRng: %.1f°, rng: %.1f°, rngStep: %.1f°", rngMid * RAD_TO_DEG, rngMin * RAD_TO_DEG, rngMax * RAD_TO_DEG,
diffRng * RAD_TO_DEG, rng * RAD_TO_DEG, rngStep * RAD_TO_DEG); // diffRng * RAD_TO_DEG, rng * RAD_TO_DEG, rngStep * RAD_TO_DEG);
} else {
double oldRngMin = rngMin;
double oldRngMax = rngMax;
// Chart starts at lowest range value, but at least '0' or includes even negative values
double currMinVal = dataBuf.getMin(numBufVals);
// LOG_DEBUG(GwLog::DEBUG, "calcChrtRange0a: currMinVal: %.1f, currMaxVal: %.1f, rngMin: %.1f, rngMid: %.1f, rngMax: %.1f, rng: %.1f, rngStep: %.1f, oldRngMin: %.1f, oldRngMax: %.1f, dfltRng: %.1f, numBufVals: %d",
// currMinVal, dataBuf.getMax(numBufVals), rngMin, rngMid, rngMax, rng, rngStep, oldRngMin, oldRngMax, dfltRng, numBufVals);
if (currMinVal != dbMAX_VAL) { // current min value is valid
if (currMinVal > 0 && dbMIN_VAL == 0) { // Chart range starts at least at '0' or includes negative values
rngMin = 0;
} else if (currMinVal < oldRngMin || (oldRngMin < 0 && (currMinVal > (oldRngMin + rngStep)))) { // decrease rngMin if required or increase if lowest value is higher than old rngMin
rngMin = std::floor(currMinVal / rngStep) * rngStep;
}
} // otherwise keep rngMin unchanged
double currMaxVal = dataBuf.getMax(numBufVals);
if (currMaxVal != dbMAX_VAL) { // current max value is valid
if ((currMaxVal > oldRngMax) || (currMaxVal < (oldRngMax - rngStep))) { // increase rngMax if required or decrease if lowest value is lower than old rngMax
rngMax = std::ceil(currMaxVal / rngStep) * rngStep;
rngMax = std::max(rngMax, rngMin + dfltRng); // keep at least default chart range
}
} // otherwise keep rngMax unchanged
rngMid = (rngMin + rngMax) / 2.0;
rng = rngMax - rngMin;
// LOG_DEBUG(GwLog::DEBUG, "calcChrtRange1a: currMinVal: %.1f, currMaxVal: %.1f, rngMin: %.1f, rngMid: %.1f, rngMax: %.1f, rng: %.1f, rngStep: %.1f, oldRngMin: %.1f, oldRngMax: %.1f, dfltRng: %.1f, numBufVals: %d",
// currMinVal, currMaxVal, rngMin, rngMid, rngMax, rng, rngStep, oldRngMin, oldRngMax, dfltRng, numBufVals);
} }
} }
@@ -425,52 +436,40 @@ void Chart<T>::calcChrtBorders(double& rngMid, double& rngMin, double& rngMax, d
template <typename T> template <typename T>
void Chart<T>::drawChrtTimeAxis(int8_t chrtIntv) void Chart<T>::drawChrtTimeAxis(int8_t chrtIntv)
{ {
int timeRng;
float slots, intv, i; float slots, intv, i;
char sTime[6]; char sTime[6];
int timeRng = chrtIntv * 4; // chart time interval: [1] 4 min., [2] 8 min., [3] 12 min., [4] 16 min., [8] 32 min.
getdisplay().setFont(&Ubuntu_Bold8pt8b); getdisplay().setFont(&Ubuntu_Bold8pt8b);
getdisplay().setTextColor(fgColor); getdisplay().setTextColor(fgColor);
if (chrtDir == 'H') { // 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. slots = 5; // number of axis labels
slots = timAxis / 80.0; // number of axis labels intv = timAxis / (slots - 1); // minutes per chart axis interval (interval is 1 less than slots)
intv = timeRng / slots; // minutes per chart axis interval
i = timeRng; // Chart axis label start at -32, -16, -12, ... minutes i = timeRng; // Chart axis label start at -32, -16, -12, ... minutes
for (int j = 0; j < timAxis - 30; j += 80) { // fill time axis with values but keep area free on right hand side for value label for (float j = 0; j < timAxis - 1; j += intv) { // fill time axis with values but keep area free on right hand side for value label
// LOG_DEBUG(GwLog::DEBUG, "ChartTimeAxis: timAxis: %d, {x,y}: {%d,%d}, i: %.1f, j: %d, chrtIntv: %d, intv: %.1f, slots: %.1f", timAxis, cStart.x, cStart.y, i, j, chrtIntv, intv, slots);
// Format time label based on interval
if (chrtIntv < 3) {
snprintf(sTime, sizeof(sTime), "-%.1f", i);
} else {
snprintf(sTime, sizeof(sTime), "-%.0f", std::round(i));
}
// draw text with appropriate offset // draw text with appropriate offset
// int tOffset = (j == 0) ? 13 : (chrtIntv < 3 ? -4 : -4);
int tOffset = j == 0 ? 13 : -4; int tOffset = j == 0 ? 13 : -4;
snprintf(sTime, sizeof(sTime), "-%.0f", i);
drawTextCenter(cStart.x + j + tOffset, cStart.y - 8, sTime); drawTextCenter(cStart.x + j + tOffset, cStart.y - 8, sTime);
getdisplay().drawLine(cStart.x + j, cStart.y, cStart.x + j, cStart.y + 5, fgColor); // draw short vertical time mark getdisplay().drawLine(cStart.x + j, cStart.y, cStart.x + j, cStart.y + 5, fgColor); // draw short vertical time mark
i -= intv; i -= chrtIntv;
} }
} else { // vertical chart } else { // vertical chart
timeRng = chrtIntv * 4; // chart time interval: [1] 4 min., [2] 8 min., [3] 12 min., [4] 16 min., [8] 32 min. slots = 5; // number of axis labels
slots = timAxis / 75.0; // number of axis labels intv = timAxis / (slots - 1); // minutes per chart axis interval (interval is 1 less than slots)
intv = timeRng / slots; // minutes per chart axis interval i = timeRng; // Chart axis label start at -32, -16, -12, ... minutes
i = -intv; // chart axis label start at -32, -16, -12, ... minutes
for (int j = 75; j < (timAxis - 75); j += 75) { // don't print time label at upper and lower end of time axis for (float j = intv; j < timAxis - 1; j += intv) { // don't print time label at upper and lower end of time axis
if (chrtIntv < 3) { // print 1 decimal if time range is single digit (4 or 8 minutes)
snprintf(sTime, sizeof(sTime), "%.1f", i);
} else {
snprintf(sTime, sizeof(sTime), "%.0f", std::floor(i));
}
i -= chrtIntv; // we start not at top chart position
snprintf(sTime, sizeof(sTime), "-%.0f", i);
getdisplay().drawLine(cStart.x, cStart.y + j, cStart.x + valAxis, cStart.y + j, fgColor); // Grid line getdisplay().drawLine(cStart.x, cStart.y + j, cStart.x + valAxis, cStart.y + j, fgColor); // Grid line
if (chrtSz == 0) { // full size chart if (chrtSz == 0) { // full size chart
@@ -480,8 +479,6 @@ void Chart<T>::drawChrtTimeAxis(int8_t chrtIntv)
} else if (chrtSz == 2) { // half size chart; right side } else if (chrtSz == 2) { // half size chart; right side
drawTextCenter(dWidth / 2, cStart.y + j, sTime); // time value; print mid screen drawTextCenter(dWidth / 2, cStart.y + j, sTime); // time value; print mid screen
} }
i -= intv;
} }
} }
} }
@@ -509,8 +506,21 @@ void Chart<T>::drawChrtValAxis()
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 = valAxis - 60; j > 30; j -= 60) { int loopStrt, loopEnd, loopStp;
if (chrtDataFmt == 'S') {
loopStrt = valAxis - 60;
loopEnd = 30;
loopStp = -60;
} else {
loopStrt = 60;
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().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
@@ -523,7 +533,7 @@ void Chart<T>::drawChrtValAxis()
} else { // half size chart -> print just edge values + middle chart line } else { // half size chart -> print just edge values + middle chart line
getdisplay().setFont(&Ubuntu_Bold10pt8b); getdisplay().setFont(&Ubuntu_Bold10pt8b);
tmpBVal->value = chrtMin; tmpBVal->value = (chrtDataFmt == 'D') ? chrtMin : chrtMax;
cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted) cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
sLen = snprintf(sVal, sizeof(sVal), "%.0f", round(cVal)); 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().fillRect(cStart.x, cStart.y + 2, 42, 16, bgColor); // Clear small area to remove potential chart lines
@@ -538,7 +548,7 @@ void Chart<T>::drawChrtValAxis()
getdisplay().printf("%s", sVal); // Range mid value getdisplay().printf("%s", sVal); // Range mid value
getdisplay().drawLine(cStart.x + 43, cStart.y + (valAxis / 2), cStart.x + timAxis, cStart.y + (valAxis / 2), fgColor); getdisplay().drawLine(cStart.x + 43, cStart.y + (valAxis / 2), cStart.x + timAxis, cStart.y + (valAxis / 2), fgColor);
tmpBVal->value = chrtMax; tmpBVal->value = (chrtDataFmt == 'D') ? chrtMax : chrtMin;
cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted) cVal = formatValue(tmpBVal.get(), *commonData).cvalue; // value (converted)
sLen = snprintf(sVal, sizeof(sVal), "%.0f", round(cVal)); 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().fillRect(cStart.x, cStart.y + valAxis - 16, 42, 16, bgColor); // Clear small area to remove potential chart lines
@@ -586,7 +596,7 @@ template <typename T>
void Chart<T>::prntCurrValue(GwApi::BoatValue& currValue) void Chart<T>::prntCurrValue(GwApi::BoatValue& currValue)
{ {
const int xPosVal = (chrtDir == 'H') ? 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 == 'H') ? cStart.y + valAxis - 5 : cStart.y + timAxis - 5; const int yPosVal = (chrtDir == 'H') ? cStart.y + valAxis - 7 : cStart.y + timAxis - 7;
FormattedData frmtDbData = formatValue(&currValue, *commonData); FormattedData frmtDbData = formatValue(&currValue, *commonData);
double testdbValue = frmtDbData.value; double testdbValue = frmtDbData.value;
@@ -595,8 +605,8 @@ 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, 40, bgColor); // Clear area for TWS value getdisplay().fillRect(xPosVal - 1, yPosVal - 35, 125, 41, bgColor); // Clear area for TWS value
getdisplay().drawRect(xPosVal, yPosVal - 33, 123, 39, fgColor); // Draw box for TWS value getdisplay().drawRect(xPosVal, yPosVal - 34, 123, 40, fgColor); // Draw box for TWS value
getdisplay().setFont(&DSEG7Classic_BoldItalic16pt7b); getdisplay().setFont(&DSEG7Classic_BoldItalic16pt7b);
getdisplay().setCursor(xPosVal + 1, yPosVal); getdisplay().setCursor(xPosVal + 1, yPosVal);
if (useSimuData) { if (useSimuData) {

View File

@@ -6,16 +6,16 @@ struct Pos {
int x; int x;
int y; int y;
}; };
template <typename T> class RingBuffer; template <typename T> class RingBuffer;
class GwLog; class GwLog;
template <typename T> template <typename T> class Chart {
class Chart {
protected: protected:
CommonData *commonData; CommonData* commonData;
GwLog *logger; GwLog* logger;
RingBuffer<T> &dataBuf; // Buffer to display RingBuffer<T>& dataBuf; // Buffer to display
char chrtDir; // Chart timeline direction: 'H' = horizontal, 'V' = 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]
@@ -23,7 +23,6 @@ protected:
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 = 44; // chart gap at top of display (25 lines for standard gap + 19 lines for axis labels) 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 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>
@@ -59,11 +58,22 @@ protected:
void calcChrtBorders(double& rngMid, double& rngMin, double& rngMax, double& rng); // Calculate chart points for value axis and return range between <min> and <max> void calcChrtBorders(double& rngMid, double& rngMin, double& rngMax, double& rng); // Calculate chart points for value axis and return range between <min> and <max>
void drawChrtTimeAxis(int8_t chrtIntv); // Draw time axis of chart, value and lines void drawChrtTimeAxis(int8_t chrtIntv); // Draw time axis of chart, value and lines
void drawChrtValAxis(); // Draw value axis of chart, value and lines void drawChrtValAxis(); // Draw value axis of chart, value and lines
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:
// Define default chart range for each boat data type
static std::map<String, double> dfltChartRng;
Chart(RingBuffer<T>& dataBuf, char 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, bool showCurrValue); // Perform all actions to draw chart
};
template <typename T>
std::map<String, double> Chart<T>::dfltChartRng = {
{ "formatWind", 60.0 * DEG_TO_RAD }, // default course range 60 degrees
{ "formatCourse", 60.0 * DEG_TO_RAD }, // default course range 60 degrees
{ "formatKnots", 5.1 }, // default speed range in m/s
{ "formatDepth", 15 }, // default depth range in m
{ "kelvinToC", 30 } // default temp range in °C/K
}; };

View File

@@ -3,112 +3,254 @@
#include "Pagedata.h" #include "Pagedata.h"
#include "OBP60Extensions.h" #include "OBP60Extensions.h"
#include "BoatDataCalibration.h" #include "BoatDataCalibration.h"
#include "OBPcharts.h"
class PageOneValue : public Page class PageOneValue : public Page {
{ private:
public: GwLog* logger;
PageOneValue(CommonData &common){
commonData = &common; int width; // Screen width
common.logger->logDebug(GwLog::LOG,"Instantiate PageOneValue"); int height; // Screen height
bool keylock = false; // Keylock
char pageMode = 'V'; // Page mode: 'V' for value, 'C' for chart, 'B' for both
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
String lengthformat;
bool useSimuData;
bool holdValues;
String flashLED;
String backlightMode;
// Old values for hold function
String sValue1Old = "";
String unit1Old = "";
// 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)
{
int nameXoff, nameYoff, unitXoff, unitYoff, value1Xoff, value1Yoff;
const GFXfont *nameFnt, *unitFnt, *valueFnt1, *valueFnt2, *valueFnt3;
if (size == 'F') { // full size data display
nameXoff = 0;
nameYoff = 0;
nameFnt = &Ubuntu_Bold32pt8b;
unitXoff = 0;
unitYoff = 0;
unitFnt = &Ubuntu_Bold20pt8b;
value1Xoff = 0;
value1Yoff = 0;
valueFnt1 = &Ubuntu_Bold20pt8b;
valueFnt2 = &Ubuntu_Bold32pt8b;
valueFnt3 = &DSEG7Classic_BoldItalic60pt7b;
} else { // half size data and chart display
nameXoff = 105;
nameYoff = -40;
nameFnt = &Ubuntu_Bold20pt8b;
unitXoff = -33;
unitYoff = -40;
unitFnt = &Ubuntu_Bold12pt8b;
valueFnt1 = &Ubuntu_Bold12pt8b;
value1Xoff = 105;
value1Yoff = -105;
valueFnt2 = &Ubuntu_Bold20pt8b;
valueFnt3 = &DSEG7Classic_BoldItalic30pt7b;
}
String name1 = xdrDelete(bValue1->getName()); // Value name
name1 = name1.substring(0, 6); // String length limit for value name
calibrationData.calibrateInstance(bValue1, logger); // Check if boat data value is to be calibrated
double value1 = bValue1->value; // Value as double in SI unit
bool valid1 = bValue1->valid; // Valid information
String sValue1 = formatValue(bValue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
String unit1 = formatValue(bValue1, *commonData).unit; // Unit of value
// Show name
getdisplay().setTextColor(commonData->fgcolor);
getdisplay().setFont(nameFnt);
getdisplay().setCursor(20 + nameXoff, 100 + nameYoff);
getdisplay().print(name1); // name
// 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);
drawTextRalign(298 + unitXoff, 100 + unitYoff, unit1Old);
}
// Switch font if format for any values
if (bValue1->getFormat() == "formatLatitude" || bValue1->getFormat() == "formatLongitude") {
getdisplay().setFont(valueFnt1);
getdisplay().setCursor(20 + value1Xoff, 180 + value1Yoff);
} else if (bValue1->getFormat() == "formatTime" || bValue1->getFormat() == "formatDate") {
getdisplay().setFont(valueFnt2);
getdisplay().setCursor(20 + value1Xoff, 200 + value1Yoff);
} else {
getdisplay().setFont(valueFnt3);
getdisplay().setCursor(20 + value1Xoff, 240 + value1Yoff);
}
// Show bus data
if (holdValues == false) {
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
}
} }
virtual int handleKey(int key){ public:
// Code for keylock PageOneValue(CommonData& common)
if(key == 11){ {
commonData = &common;
logger = commonData->logger;
LOG_DEBUG(GwLog::LOG, "Instantiate PageOneValue");
width = getdisplay().width(); // Screen width
height = getdisplay().height(); // Screen height
// Get config data
lengthformat = common.config->getString(common.config->lengthFormat);
useSimuData = common.config->getBool(common.config->useSimuData);
holdValues = common.config->getBool(common.config->holdvalues);
flashLED = common.config->getString(common.config->flashLED);
backlightMode = common.config->getString(common.config->backlight);
}
virtual void setupKeys()
{
Page::setupKeys();
commonData->keydata[0].label = "MODE";
#if defined BOARD_OBP60S3
commonData->keydata[4].label = "ZOOM";
#elif defined BOARD_OBP40S3
commonData->keydata[1].label = "ZOOM";
#endif
}
// Key functions
virtual int handleKey(int key)
{
// Set page mode value | full chart | value/half chart
if (key == 1) {
if (pageMode == 'V') {
pageMode = 'C';
} else if (pageMode == 'C') {
pageMode = 'B';
} else {
pageMode = 'V';
}
return 0; // Commit the key
}
// Set interval for history chart update time (interval)
#if defined BOARD_OBP60S3
if (key == 5) {
#elif defined BOARD_OBP40S3
if (key == 2) {
#endif
if (dataIntv == 1) {
dataIntv = 2;
} else if (dataIntv == 2) {
dataIntv = 3;
} else if (dataIntv == 3) {
dataIntv = 4;
} else if (dataIntv == 4) {
dataIntv = 8;
} else {
dataIntv = 1;
}
return 0; // Commit the key
}
// Keylock function
if (key == 11) { // Code for keylock
commonData->keylock = !commonData->keylock; commonData->keylock = !commonData->keylock;
return 0; // Commit the key return 0; // Commit the key
} }
return key; return key;
} }
int displayPage(PageData &pageData){ virtual void displayNew(PageData& pageData)
GwConfigHandler *config = commonData->config; {
GwLog *logger = commonData->logger; #ifdef BOARD_OBP60S3
// Clear optical warning
if (flashLED == "Limit Violation") {
setBlinkingLED(false);
setFlashLED(false);
}
#endif
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
// Old values for hold function dataHstryBuf = pageData.hstryBuffers->getBuffer(bValName1);
static String svalue1old = "";
static String unit1old = "";
// Get config data dataFlChart.reset(new Chart<uint16_t>(*dataHstryBuf, 'H', 0, Chart<uint16_t>::dfltChartRng[bValFormat], *commonData, useSimuData));
String lengthformat = config->getString(config->lengthFormat); dataHfChart.reset(new Chart<uint16_t>(*dataHstryBuf, 'H', 2, Chart<uint16_t>::dfltChartRng[bValFormat], *commonData, useSimuData));
// bool simulation = config->getBool(config->useSimuData); LOG_DEBUG(GwLog::DEBUG, "PageOneValue: Created chart objects for %s", bValName1);
bool holdvalues = config->getBool(config->holdvalues); }
String flashLED = config->getString(config->flashLED); }
String backlightMode = config->getString(config->backlight);
int displayPage(PageData& pageData)
// Get boat values {
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
String name1 = xdrDelete(bvalue1->getName()); // Value name LOG_DEBUG(GwLog::LOG, "Display PageOneValue");
name1 = name1.substring(0, 6); // String length limit for value name GwConfigHandler* config = commonData->config;
calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated GwLog* logger = commonData->logger;
double value1 = bvalue1->value; // Value as double in SI unit
bool valid1 = bvalue1->valid; // Valid information // Get boat value for page
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places GwApi::BoatValue* bValue1 = pageData.values[0]; // Page boat data element
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
// Optical warning by limit violation (unused) // Optical warning by limit violation (unused)
if(String(flashLED) == "Limit Violation"){ if (String(flashLED) == "Limit Violation") {
setBlinkingLED(false); setBlinkingLED(false);
setFlashLED(false); setFlashLED(false);
} }
// Logging boat values // Logging boat values
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement? if (bValue1 == NULL)
LOG_DEBUG(GwLog::LOG,"Drawing at PageOneValue, %s: %f", name1.c_str(), value1); return PAGE_OK; // WTF why this statement?
LOG_DEBUG(GwLog::LOG, "Drawing at PageOneValue, %s: %f", bValue1->getName().c_str(), bValue1->value);
// Draw page // Draw page
//*********************************************************** //***********************************************************
/// Set display in partial refresh mode getdisplay().setPartialWindow(0, 0, width, height); // Set partial update
getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
// Show name if (pageMode == 'V') { // show only data value
getdisplay().setTextColor(commonData->fgcolor); showData(bValue1, 'F');
getdisplay().setFont(&Ubuntu_Bold32pt8b);
getdisplay().setCursor(20, 100);
getdisplay().print(name1); // Page name
// Show unit } else if (pageMode == 'C') { // show only data chart
getdisplay().setFont(&Ubuntu_Bold20pt8b); dataFlChart->showChrt(dataIntv, *bValue1, true);
getdisplay().setCursor(270, 100);
if(holdvalues == false){
getdisplay().print(unit1); // Unit
}
else{
getdisplay().print(unit1old);
}
// Switch font if format for any values } else if (pageMode == 'B') { // show data value and chart
if(bvalue1->getFormat() == "formatLatitude" || bvalue1->getFormat() == "formatLongitude"){ showData(bValue1, 'H');
getdisplay().setFont(&Ubuntu_Bold20pt8b); dataHfChart->showChrt(dataIntv, *bValue1, false);
getdisplay().setCursor(20, 180);
}
else if(bvalue1->getFormat() == "formatTime" || bvalue1->getFormat() == "formatDate"){
getdisplay().setFont(&Ubuntu_Bold32pt8b);
getdisplay().setCursor(20, 200);
}
else{
getdisplay().setFont(&DSEG7Classic_BoldItalic60pt7b);
getdisplay().setCursor(20, 240);
}
// Show bus data
if(holdvalues == false){
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
} }
return PAGE_UPDATE; return PAGE_UPDATE;
}; };
}; };
static Page* createPage(CommonData &common){ static Page* createPage(CommonData& common)
{
return new PageOneValue(common); return new PageOneValue(common);
} }
@@ -120,10 +262,10 @@ static Page* createPage(CommonData &common){
* this will be number of BoatValue pointers in pageData.values * this will be number of BoatValue pointers in pageData.values
*/ */
PageDescription registerPageOneValue( PageDescription registerPageOneValue(
"OneValue", // Page name "OneValue", // Page name
createPage, // Action createPage, // Action
1, // Number of bus values depends on selection in Web configuration 1, // Number of bus values depends on selection in Web configuration
true // Show display header on/off true // Show display header on/off
); );
#endif #endif

View File

@@ -2,7 +2,6 @@
#include "Pagedata.h" #include "Pagedata.h"
#include "OBP60Extensions.h" #include "OBP60Extensions.h"
#include "OBPDataOperations.h"
#include "OBPcharts.h" #include "OBPcharts.h"
// **************************************************************** // ****************************************************************
@@ -77,9 +76,9 @@ public:
commonData->keydata[0].label = "MODE"; commonData->keydata[0].label = "MODE";
#if defined BOARD_OBP60S3 #if defined BOARD_OBP60S3
commonData->keydata[1].label = "SRC"; commonData->keydata[1].label = "SRC";
commonData->keydata[4].label = "INTV"; commonData->keydata[4].label = "ZOOM";
#elif defined BOARD_OBP40S3 #elif defined BOARD_OBP40S3
commonData->keydata[1].label = "INTV"; commonData->keydata[1].label = "ZOOM";
#endif #endif
} }
@@ -209,14 +208,14 @@ public:
getdisplay().setTextColor(commonData->fgcolor); getdisplay().setTextColor(commonData->fgcolor);
if (chrtMode == 'D') { if (chrtMode == 'D') {
wdFlChart->showChrt(dataIntv, *wdBVal); wdFlChart->showChrt(dataIntv, *wdBVal, true);
} else if (chrtMode == 'S') { } else if (chrtMode == 'S') {
wsFlChart->showChrt(dataIntv, *wsBVal); wsFlChart->showChrt(dataIntv, *wsBVal, true);
} else if (chrtMode == 'B') { } else if (chrtMode == 'B') {
wdHfChart->showChrt(dataIntv, *wdBVal); wdHfChart->showChrt(dataIntv, *wdBVal, true);
wsHfChart->showChrt(dataIntv, *wsBVal); wsHfChart->showChrt(dataIntv, *wsBVal, true);
} }
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: page time %ldms", millis() - pageTime); LOG_DEBUG(GwLog::DEBUG, "PageWindPlot: page time %ldms", millis() - pageTime);