mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-09-11 19:55:14 +02:00
Update OBPcharts for more reliable parameterization
This commit is contained in:
+49
-48
@@ -103,8 +103,7 @@ bool Chart::init()
|
||||
chrtRng = dfltRng;
|
||||
recalcRngMid = true; // initialize <chrtMid> and chart borders on first chart display call
|
||||
|
||||
if (dbFormat.isEmpty()) {
|
||||
// data buffer may not exist yet, because boat data object is not available yet
|
||||
if (dbFormat.isEmpty()) { // data buffer may not exist yet, because boat data object is not available yet
|
||||
initValid = false; // chart object will get invalid data during initialization
|
||||
} else {
|
||||
initValid = true;
|
||||
@@ -122,8 +121,7 @@ bool Chart::init()
|
||||
// <prntName>; print data name on horizontal half chart [true|false]
|
||||
// <showCurrValue>: print current boat data value [true|false]
|
||||
// <currValue>: current boat data value; used only for test on valid data
|
||||
// void Chart::showChrt(ChrtDirection chrtDire, ChrtSize chrtSze, const int8_t chrtIntv, bool prntName, bool showCurrValue, GwApi::BoatValue currValue)
|
||||
void Chart::showChrt(const char chrtDir, const int8_t chrtSz, const int8_t chrtIntv, bool prntName, bool showCurrValue, GwApi::BoatValue currValue)
|
||||
void Chart::showChrt(const ChrtDir chrtDir, ChrtSize chrtSz, const int8_t chrtIntv, bool prntName, bool showCurrValue, GwApi::BoatValue currValue)
|
||||
{
|
||||
if (!setChartDimensions(chrtDir, chrtSz)) {
|
||||
return; // wrong chart dimension parameters
|
||||
@@ -146,31 +144,30 @@ void Chart::showChrt(const char chrtDir, const int8_t chrtSz, const int8_t chrtI
|
||||
}
|
||||
|
||||
// define dimensions and start points for chart
|
||||
// bool Chart::setChartDimensions(const ChrtDirection direction, const ChrtSize size)
|
||||
bool Chart::setChartDimensions(const char direction, const int8_t size)
|
||||
bool Chart::setChartDimensions(const ChrtDir chrtDir, const ChrtSize chrtSz)
|
||||
{
|
||||
if ((direction != HORIZONTAL && direction != VERTICAL) || (size < 0 || size > 3)) {
|
||||
if ((chrtDir != HORIZONTAL && chrtDir != VERTICAL) || (chrtSz < 0 || chrtSz > 3)) {
|
||||
LOG_DEBUG(GwLog::ERROR, "obp60:setChartDimensions %s: wrong parameters", dataBuf.getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (direction == HORIZONTAL) {
|
||||
if (chrtDir == HORIZONTAL) {
|
||||
// horizontal chart timeline direction
|
||||
timAxis = dWidth - 1;
|
||||
switch (size) {
|
||||
case 0:
|
||||
switch (chrtSz) {
|
||||
case ChrtSize::FULL_SIZE:
|
||||
valAxis = dHeight - top - bottom;
|
||||
cRoot = { 0, top - 1 };
|
||||
break;
|
||||
case 1:
|
||||
case HALF_SIZE_LEFT_TOP:
|
||||
valAxis = (dHeight - top - bottom) / 2 - hGap;
|
||||
cRoot = { 0, top - 1 };
|
||||
break;
|
||||
case 2:
|
||||
case HALF_SIZE_RIGHT_BOTTOM:
|
||||
valAxis = (dHeight - top - bottom) / 2 - hGap;
|
||||
cRoot = { 0, top + (valAxis + hGap) + hGap - 1 };
|
||||
break;
|
||||
case 3:
|
||||
case TWO_THIRD_TOP:
|
||||
valAxis = (dHeight - top - bottom) * 0.667 - hGap;
|
||||
cRoot = { 0, top - 1 };
|
||||
break;
|
||||
@@ -179,19 +176,19 @@ bool Chart::setChartDimensions(const char direction, const int8_t size)
|
||||
cRoot = { 0, top - 1 };
|
||||
}
|
||||
|
||||
} else if (direction == VERTICAL) {
|
||||
} else if (chrtDir == VERTICAL) {
|
||||
// vertical chart timeline direction
|
||||
timAxis = dHeight - top - bottom;
|
||||
switch (size) {
|
||||
case 0:
|
||||
switch (chrtSz) {
|
||||
case FULL_SIZE:
|
||||
valAxis = dWidth - 1;
|
||||
cRoot = { 0, top - 1 };
|
||||
break;
|
||||
case 1:
|
||||
case HALF_SIZE_LEFT_TOP:
|
||||
valAxis = dWidth / 2 - vGap;
|
||||
cRoot = { 0, top - 1 };
|
||||
break;
|
||||
case 2:
|
||||
case HALF_SIZE_RIGHT_BOTTOM:
|
||||
valAxis = dWidth / 2 - vGap;
|
||||
cRoot = { dWidth / 2 + vGap - 1, top - 1 };
|
||||
break;
|
||||
@@ -200,13 +197,13 @@ bool Chart::setChartDimensions(const char direction, const int8_t size)
|
||||
cRoot = { 0, top - 1 };
|
||||
}
|
||||
}
|
||||
// LOG_DEBUG(GwLog::DEBUG, "obp60:setChartDimensions %s: direction: %c, size: %d, dWidth: %d, dHeight: %d, timAxis: %d, valAxis: %d, cRoot{%d, %d}, top: %d, bottom: %d, hGap: %d, vGap: %d",
|
||||
// dataBuf.getName(), direction, size, dWidth, dHeight, timAxis, valAxis, cRoot.x, cRoot.y, top, bottom, hGap, vGap);
|
||||
// LOG_DEBUG(GwLog::DEBUG, "obp60:setChartDimensions %s: chrtDir: %c, size: %d, dWidth: %d, dHeight: %d, timAxis: %d, valAxis: %d, cRoot{%d, %d}, top: %d, bottom: %d, hGap: %d, vGap: %d",
|
||||
// dataBuf.getName(), chrtDir, size, dWidth, dHeight, timAxis, valAxis, cRoot.x, cRoot.y, top, bottom, hGap, vGap);
|
||||
return true;
|
||||
}
|
||||
|
||||
// draw chart
|
||||
void Chart::drawChrt(const char chrtDir, const int8_t chrtIntv, GwApi::BoatValue& currValue)
|
||||
void Chart::drawChrt(const ChrtDir chrtDir, const int8_t chrtIntv, GwApi::BoatValue& currValue)
|
||||
{
|
||||
double chrtScale; // Scale for data values in pixels per value
|
||||
|
||||
@@ -230,7 +227,6 @@ void Chart::drawChrt(const char chrtDir, const int8_t chrtIntv, GwApi::BoatValue
|
||||
numNoData++;
|
||||
bufDataValid = true;
|
||||
|
||||
// if (numNoData > THRESHOLD_NO_DATA) { // If more than 4 invalid values in a row, flag for invalid data
|
||||
if (numNoData > THRESHOLD_NO_DATA * (dataBuf.getUpdFreq() / 1000)) { // If more than <THRESHOLD> invalid values in a row, flag for invalid data
|
||||
bufDataValid = false;
|
||||
return;
|
||||
@@ -371,7 +367,7 @@ void Chart::calcChrtBorders(double& rngMin, double& rngMid, double& rngMax, doub
|
||||
}
|
||||
|
||||
// Draw chart graph
|
||||
void Chart::drawChartLines(const char direction, const int8_t chrtIntv, const double chrtScale)
|
||||
void Chart::drawChartLines(const ChrtDir chrtDir, const int8_t chrtIntv, const double chrtScale)
|
||||
{
|
||||
double chrtVal; // Current data value
|
||||
Pos point, prevPoint; // current and previous chart point
|
||||
@@ -406,7 +402,7 @@ void Chart::drawChartLines(const char direction, const int8_t chrtIntv, const do
|
||||
chrtVal = chrtAvg.reading(chrtVal);
|
||||
}
|
||||
|
||||
point = setCurrentChartPoint(i, direction, chrtVal, chrtScale);
|
||||
point = setCurrentChartPoint(i, chrtDir, chrtVal, chrtScale);
|
||||
|
||||
if (i >= (numBufVals / chrtIntv) - 5) // log chart data of 1 line (adjust for test purposes)
|
||||
LOG_DEBUG(GwLog::DEBUG, "PageWindPlot Chart: i: %d, chrtVal: %.2f, chrtMin: %.2f, {x,y} {%d,%d}", i, chrtVal, chrtMin, x, y);
|
||||
@@ -427,7 +423,7 @@ void Chart::drawChartLines(const char direction, const int8_t chrtIntv, const do
|
||||
// LOG_DEBUG(GwLog::DEBUG, "PageWindPlot Chart: crossedBorders: %d, chrtVal: %.2f, chrtPrevVal: %.2f", crossedBorders, chrtVal, chrtPrevVal);
|
||||
bool wrappingFromHighToLow = normCurrVal < normPrevVal; // Determine which edge we're crossing
|
||||
|
||||
if (direction == HORIZONTAL) {
|
||||
if (chrtDir == HORIZONTAL) {
|
||||
int ySplit = wrappingFromHighToLow ? (cRoot.y + valAxis) : cRoot.y;
|
||||
drawBoldLine(prevPoint.x, prevPoint.y, point.x, ySplit);
|
||||
prevPoint.y = wrappingFromHighToLow ? cRoot.y : (cRoot.y + valAxis);
|
||||
@@ -441,7 +437,7 @@ void Chart::drawChartLines(const char direction, const int8_t chrtIntv, const do
|
||||
}
|
||||
|
||||
if (chrtDataFmt == DEPTH) {
|
||||
if (direction == HORIZONTAL) { // horizontal chart
|
||||
if (chrtDir == HORIZONTAL) { // horizontal chart
|
||||
drawBoldLine(point.x, point.y, point.x, cRoot.y + valAxis);
|
||||
} else { // vertical chart
|
||||
drawBoldLine(point.x, point.y, cRoot.x + valAxis, point.y);
|
||||
@@ -470,11 +466,11 @@ void Chart::drawChartLines(const char direction, const int8_t chrtIntv, const do
|
||||
}
|
||||
|
||||
// Set current chart point to draw
|
||||
Pos Chart::setCurrentChartPoint(const int i, const char direction, const double chrtVal, const double chrtScale)
|
||||
Pos Chart::setCurrentChartPoint(const int i, const ChrtDir chrtDir, const double chrtVal, const double chrtScale)
|
||||
{
|
||||
Pos currentPoint;
|
||||
|
||||
if (direction == HORIZONTAL) {
|
||||
if (chrtDir == HORIZONTAL) {
|
||||
currentPoint.x = cRoot.x + i; // Position in chart area
|
||||
|
||||
if (chrtDataFmt == WIND || chrtDataFmt == ROTATION) { // degree type value
|
||||
@@ -499,7 +495,7 @@ Pos Chart::setCurrentChartPoint(const int i, const char direction, const double
|
||||
}
|
||||
|
||||
// chart time axis label + lines
|
||||
void Chart::drawChrtTimeAxis(const char chrtDir, const int8_t chrtSz, const int8_t chrtIntv)
|
||||
void Chart::drawChrtTimeAxis(const ChrtDir chrtDir, const ChrtSize chrtSz, const int8_t chrtIntv)
|
||||
{
|
||||
int axSlots, intv, i, timeRng;
|
||||
char sTime[6];
|
||||
@@ -539,7 +535,7 @@ void Chart::drawChrtTimeAxis(const char chrtDir, const int8_t chrtSz, const int8
|
||||
getdisplay().fillRect(0, cRoot.y + j - 9, 32, 15, bgColor); // clear small area to remove potential chart lines
|
||||
getdisplay().setCursor((4 - strlen(sTime)) * 7, cRoot.y + j + 3); // time value; print left screen; value right-formated
|
||||
getdisplay().printf("%s", sTime); // time value
|
||||
} else if (chrtSz == HALF_SIZE_RIGHT) { // half size chart; right side
|
||||
} else if (chrtSz == HALF_SIZE_RIGHT_BOTTOM) { // half size chart; right side
|
||||
drawTextCenter(dWidth / 2, cRoot.y + j, sTime); // time value; print mid screen
|
||||
}
|
||||
i -= chrtIntv;
|
||||
@@ -548,11 +544,11 @@ void Chart::drawChrtTimeAxis(const char chrtDir, const int8_t chrtSz, const int8
|
||||
}
|
||||
|
||||
// chart value axis labels + lines
|
||||
void Chart::drawChrtValAxis(const char chrtDir, const int8_t chrtSz, bool prntName)
|
||||
void Chart::drawChrtValAxis(const ChrtDir chrtDir, const ChrtSize chrtSz, const bool prntName)
|
||||
{
|
||||
const GFXfont* font;
|
||||
constexpr bool NO_LABEL = false;
|
||||
constexpr bool LABEL = true;
|
||||
// constexpr bool NO_LABEL = false;
|
||||
// constexpr bool LABEL = true;
|
||||
|
||||
getdisplay().setTextColor(fgColor);
|
||||
|
||||
@@ -560,13 +556,14 @@ void Chart::drawChrtValAxis(const char chrtDir, const int8_t chrtSz, bool prntNa
|
||||
|
||||
if (chrtSz == FULL_SIZE) {
|
||||
|
||||
// print buffer data name on left hand side of time axis (max. size 5 characters)
|
||||
font = &Ubuntu_Bold12pt8b;
|
||||
getdisplay().setFont(font);
|
||||
getdisplay().fillRect(cRoot.x + timAxis - 57, cRoot.y + 2, 58, 20, bgColor); // clear small area to remove potential chart lines
|
||||
String name = xdrDelete(dbName); // Value name
|
||||
drawTextRalign(cRoot.x + timAxis - 1, cRoot.y + 19, name.substring(0, 5));
|
||||
|
||||
if (prntName) {
|
||||
// print buffer data name on left hand side of time axis (max. size 5 characters)
|
||||
font = &Ubuntu_Bold12pt8b;
|
||||
getdisplay().setFont(font);
|
||||
getdisplay().fillRect(cRoot.x + timAxis - 57, cRoot.y + 2, 58, 20, bgColor); // clear small area to remove potential chart lines
|
||||
String name = xdrDelete(dbName); // Value name
|
||||
drawTextRalign(cRoot.x + timAxis - 1, cRoot.y + 19, name.substring(0, 5));
|
||||
}
|
||||
if (chrtDataFmt == WIND) {
|
||||
prntHorizChartThreeValueAxisLabel(font);
|
||||
return;
|
||||
@@ -594,9 +591,13 @@ void Chart::drawChrtValAxis(const char chrtDir, const int8_t chrtSz, bool prntNa
|
||||
|
||||
} else { // vertical chart
|
||||
|
||||
if (chrtSz == FULL_SIZE) {
|
||||
font = &Ubuntu_Bold12pt8b;
|
||||
getdisplay().setFont(font); // use larger font
|
||||
if (prntName) {
|
||||
if (chrtSz == FULL_SIZE) {
|
||||
font = &Ubuntu_Bold12pt8b;
|
||||
} else {
|
||||
font = &Ubuntu_Bold10pt8b;
|
||||
}
|
||||
getdisplay().setFont(font);
|
||||
String name = xdrDelete(dbName); // Value name
|
||||
drawTextRalign(cRoot.x + (valAxis * 0.42), cRoot.y - 2, name.substring(0, 6)); // print buffer data name (max. size 6 characters)
|
||||
}
|
||||
@@ -607,10 +608,10 @@ void Chart::drawChrtValAxis(const char chrtDir, const int8_t chrtSz, bool prntNa
|
||||
}
|
||||
|
||||
// Print current data value
|
||||
void Chart::prntCurrValue(const char direction, GwApi::BoatValue& currValue)
|
||||
void Chart::prntCurrValue(const ChrtDir chrtDir, GwApi::BoatValue& currValue)
|
||||
{
|
||||
const int xPosVal = (direction == HORIZONTAL) ? cRoot.x + (timAxis / 2) - 74 : cRoot.x + 31;
|
||||
const int yPosVal = (direction == HORIZONTAL) ? cRoot.y + valAxis : cRoot.y + timAxis;
|
||||
const int xPosVal = (chrtDir == HORIZONTAL) ? cRoot.x + (timAxis / 2) - 74 : cRoot.x + 31;
|
||||
const int yPosVal = (chrtDir == HORIZONTAL) ? cRoot.y + valAxis : cRoot.y + timAxis;
|
||||
|
||||
FormattedData frmtDbData = formatValue(&currValue, *commonData, NO_SIMUDATA);
|
||||
String sdbValue = frmtDbData.svalue; // value as formatted string
|
||||
@@ -638,13 +639,13 @@ void Chart::prntCurrValue(const char direction, GwApi::BoatValue& currValue)
|
||||
}
|
||||
|
||||
// print message for no valid data availabletemplate <typename T>
|
||||
void Chart::prntNoValidData(const char direction)
|
||||
void Chart::prntNoValidData(const ChrtDir chrtDir)
|
||||
{
|
||||
Pos p;
|
||||
|
||||
getdisplay().setFont(&Ubuntu_Bold10pt8b);
|
||||
|
||||
if (direction == HORIZONTAL) {
|
||||
if (chrtDir == HORIZONTAL) {
|
||||
p.x = cRoot.x + (timAxis / 2);
|
||||
p.y = cRoot.y + (valAxis / 2) - 10;
|
||||
} else {
|
||||
|
||||
+24
-28
@@ -20,24 +20,28 @@ class GwLog;
|
||||
|
||||
class Chart {
|
||||
public:
|
||||
/* enum class ChrtDirection {
|
||||
HORIZONTALE,
|
||||
VERTICALE
|
||||
};
|
||||
enum ChrtDir {
|
||||
HORIZONTAL,
|
||||
VERTICAL
|
||||
};
|
||||
|
||||
enum class ChrtSize {
|
||||
FULL_SIZEE,
|
||||
HALF_SIZE_LEFTE,
|
||||
HALF_SIZE_RIGHTE,
|
||||
TWO_THIRD_TOPE
|
||||
}; */
|
||||
enum ChrtSize {
|
||||
FULL_SIZE,
|
||||
HALF_SIZE_LEFT_TOP,
|
||||
HALF_SIZE_RIGHT_BOTTOM,
|
||||
TWO_THIRD_TOP
|
||||
};
|
||||
|
||||
static constexpr bool PRNT_NAME = true;
|
||||
static constexpr bool NO_PRNT_NAME = false;
|
||||
static constexpr bool PRNT_VALUE = true;
|
||||
static constexpr bool NO_PRNT_VALUE = false;
|
||||
|
||||
Chart(RingBuffer<uint16_t>& dataBuf, CommonData& common, bool useSimuData); // Chart object of data chart
|
||||
~Chart();
|
||||
bool init(); // initialize chart object parameters
|
||||
bool isValid() { return initValid; }; // Checks if chart object has been fully initialized
|
||||
void showChrt(const char chrtDir, const int8_t chrtSz, const int8_t chrtIntv, bool prntName, bool showCurrValue, GwApi::BoatValue currValue); // Perform all actions to draw chart
|
||||
// void showChrt(ChrtDirection chrtDir, ChrtSize chrtSz, const int8_t chrtIntv, bool prntName, bool showCurrValue, GwApi::BoatValue currValue); // Perform all actions to draw chart
|
||||
void showChrt(const ChrtDir chrtDir, const ChrtSize chrtSz, const int8_t chrtIntv, bool prntName, bool showCurrValue, GwApi::BoatValue currValue); // Perform all actions to draw chart
|
||||
|
||||
protected:
|
||||
CommonData* commonData;
|
||||
@@ -54,13 +58,6 @@ protected:
|
||||
OTHER
|
||||
};
|
||||
|
||||
static constexpr char HORIZONTAL = 'H';
|
||||
static constexpr char VERTICAL = 'V';
|
||||
static constexpr int8_t FULL_SIZE = 0;
|
||||
static constexpr int8_t HALF_SIZE_LEFT = 1;
|
||||
static constexpr int8_t HALF_SIZE_RIGHT = 2;
|
||||
static constexpr int8_t TWO_THIRD_TOP = 3;
|
||||
|
||||
static constexpr int8_t MIN_FREE_VALUES = 60; // free 60 values when chart line reaches chart end
|
||||
static constexpr int8_t THRESHOLD_NO_DATA = 3; // max. seconds of invalid values in a row
|
||||
static constexpr int8_t VALAXIS_SLOTS = 5; // no. of value axis labels
|
||||
@@ -124,17 +121,16 @@ protected:
|
||||
{ "formatXdr:P:P", { 4000.0, 1000.0 } } // default pressure range in Pascal (hPa * 100); XDR <B> (bar) format is represented in gateway in the same way
|
||||
};
|
||||
|
||||
bool setChartDimensions(const char direction, const int8_t size); // define dimensions and start points for chart
|
||||
// bool setChartDimensions(const ChrtDirection direction, const ChrtSize size); // define dimensions and start points for chart
|
||||
void drawChrt(const char chrtDir, const int8_t chrtIntv, GwApi::BoatValue& currValue); // Draw chart line
|
||||
bool setChartDimensions(const ChrtDir direction, const ChrtSize chrtSz); // define dimensions and start points for chart
|
||||
void drawChrt(const ChrtDir chrtDir, const int8_t chrtIntv, GwApi::BoatValue& currValue); // Draw chart line
|
||||
void getBufferStartNSize(const int8_t chrtIntv); // Identify buffer size and buffer start position for chart
|
||||
void calcChrtBorders(double& rngMin, double& rngMid, double& rngMax, double& rng); // Calculate chart points for value axis and return range between <min> and <max>
|
||||
void drawChartLines(const char direction, const int8_t chrtIntv, const double chrtScale); // Draw chart graph
|
||||
Pos setCurrentChartPoint(const int i, const char direction, const double chrtVal, const double chrtScale); // Set current chart point to draw
|
||||
void drawChrtTimeAxis(const char chrtDir, const int8_t chrtSz, const int8_t chrtIntv); // Draw time axis of chart, value and lines
|
||||
void drawChrtValAxis(const char chrtDir, const int8_t chrtSz, bool prntLabel); // Draw value axis of chart, value and lines
|
||||
void prntCurrValue(const char chrtDir, GwApi::BoatValue& currValue); // Add current boat data value to chart
|
||||
void prntNoValidData(const char chrtDir); // print message for no valid data available
|
||||
void drawChartLines(const ChrtDir direction, const int8_t chrtIntv, const double chrtScale); // Draw chart graph
|
||||
Pos setCurrentChartPoint(const int i, const ChrtDir chrtDir, const double chrtVal, const double chrtScale); // Set current chart point to draw
|
||||
void drawChrtTimeAxis(const ChrtDir chrtDir, const ChrtSize chrtSz, const int8_t chrtIntv); // Draw time axis of chart, value and lines
|
||||
void drawChrtValAxis(const ChrtDir chrtDir, const ChrtSize chrtSz, const bool prntLabel); // Draw value axis of chart, value and lines
|
||||
void prntCurrValue(const ChrtDir chrtDir, GwApi::BoatValue& currValue); // Add current boat data value to chart
|
||||
void prntNoValidData(const ChrtDir chrtDir); // print message for no valid data available
|
||||
double getAngleRng(const double center, size_t amount); // Calculate range between chart center and edges
|
||||
void prntVerticChartThreeValueAxisLabel(const GFXfont* font); // print value axis label with only three values: top, mid, and bottom for vertical chart
|
||||
void prntHorizChartThreeValueAxisLabel(const GFXfont* font); // print value axis label with only three values: top, mid, and bottom for horizontal chart
|
||||
|
||||
@@ -19,17 +19,6 @@ private:
|
||||
HALF
|
||||
};
|
||||
|
||||
static constexpr char HORIZONTAL = 'H';
|
||||
static constexpr char VERTICAL = 'V';
|
||||
static constexpr int8_t FULL_SIZE = 0;
|
||||
static constexpr int8_t HALF_SIZE_TOP = 1;
|
||||
static constexpr int8_t HALF_SIZE_BOTTOM = 2;
|
||||
|
||||
static constexpr bool PRNT_NAME = true;
|
||||
static constexpr bool NO_PRNT_NAME = false;
|
||||
static constexpr bool PRNT_VALUE = true;
|
||||
static constexpr bool NO_PRNT_VALUE = false;
|
||||
|
||||
int width; // Screen width
|
||||
int height; // Screen height
|
||||
|
||||
@@ -286,13 +275,13 @@ public:
|
||||
|
||||
} else if (pageMode == CHART) { // show only data chart
|
||||
if (dataChart) {
|
||||
dataChart->showChrt(HORIZONTAL, FULL_SIZE, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue1);
|
||||
dataChart->showChrt(Chart::HORIZONTAL, Chart::FULL_SIZE, dataIntv, Chart::PRNT_NAME, Chart::PRNT_VALUE, *bValue1);
|
||||
}
|
||||
|
||||
} else if (pageMode == BOTH) { // show data value and chart
|
||||
showData(bValue1, HALF);
|
||||
if (dataChart) {
|
||||
dataChart->showChrt(HORIZONTAL, HALF_SIZE_BOTTOM, dataIntv, NO_PRNT_NAME, NO_PRNT_VALUE, *bValue1);
|
||||
dataChart->showChrt(Chart::HORIZONTAL, Chart::HALF_SIZE_RIGHT_BOTTOM, dataIntv, Chart::NO_PRNT_NAME, Chart::NO_PRNT_VALUE, *bValue1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,6 @@ private:
|
||||
HALF
|
||||
};
|
||||
|
||||
static constexpr char HORIZONTAL = 'H';
|
||||
static constexpr char VERTICAL = 'V';
|
||||
static constexpr int8_t FULL_SIZE = 0;
|
||||
static constexpr int8_t HALF_SIZE_TOP = 1;
|
||||
static constexpr int8_t HALF_SIZE_BOTTOM = 2;
|
||||
|
||||
static constexpr bool PRNT_NAME = true;
|
||||
static constexpr bool NO_PRNT_NAME = false;
|
||||
static constexpr bool PRNT_VALUE = true;
|
||||
static constexpr bool NO_PRNT_VALUE = false;
|
||||
|
||||
static constexpr int YOFFSET = 130; // y offset for display of 2nd boat value
|
||||
|
||||
int width; // Screen width
|
||||
@@ -296,28 +285,28 @@ public:
|
||||
} else if (pageMode == VAL1_CHART) { // show data value 1 and chart
|
||||
showData({ bValue[0] }, HALF);
|
||||
if (dataChart[0]) {
|
||||
dataChart[0]->showChrt(HORIZONTAL, HALF_SIZE_BOTTOM, dataIntv, NO_PRNT_NAME, NO_PRNT_VALUE, *bValue[0]);
|
||||
dataChart[0]->showChrt(Chart::HORIZONTAL, Chart::HALF_SIZE_RIGHT_BOTTOM, dataIntv, Chart::NO_PRNT_NAME, Chart::NO_PRNT_VALUE, *bValue[0]);
|
||||
}
|
||||
|
||||
} else if (pageMode == VAL2_CHART) { // show data value 2 and chart
|
||||
showData({ bValue[1] }, HALF);
|
||||
if (dataChart[1]) {
|
||||
dataChart[1]->showChrt(HORIZONTAL, HALF_SIZE_BOTTOM, dataIntv, NO_PRNT_NAME, NO_PRNT_VALUE, *bValue[1]);
|
||||
dataChart[1]->showChrt(Chart::HORIZONTAL, Chart::HALF_SIZE_RIGHT_BOTTOM, dataIntv, Chart::NO_PRNT_NAME, Chart::NO_PRNT_VALUE, *bValue[1]);
|
||||
}
|
||||
|
||||
} else if (pageMode == CHARTS) { // show both data charts
|
||||
if (dataChart[0]) {
|
||||
if (dataChart[1]) {
|
||||
dataChart[0]->showChrt(HORIZONTAL, HALF_SIZE_TOP, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue[0]);
|
||||
dataChart[0]->showChrt(Chart::HORIZONTAL, Chart::HALF_SIZE_LEFT_TOP, dataIntv, Chart::PRNT_NAME, Chart::PRNT_VALUE, *bValue[0]);
|
||||
} else {
|
||||
dataChart[0]->showChrt(HORIZONTAL, FULL_SIZE, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue[0]);
|
||||
dataChart[0]->showChrt(Chart::HORIZONTAL, Chart::FULL_SIZE, dataIntv, Chart::PRNT_NAME, Chart::PRNT_VALUE, *bValue[0]);
|
||||
}
|
||||
}
|
||||
if (dataChart[1]) {
|
||||
if (dataChart[0]) {
|
||||
dataChart[1]->showChrt(HORIZONTAL, HALF_SIZE_BOTTOM, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue[1]);
|
||||
dataChart[1]->showChrt(Chart::HORIZONTAL, Chart::HALF_SIZE_RIGHT_BOTTOM, dataIntv, Chart::PRNT_NAME, Chart::PRNT_VALUE, *bValue[1]);
|
||||
} else {
|
||||
dataChart[1]->showChrt(HORIZONTAL, FULL_SIZE, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue[1]);
|
||||
dataChart[1]->showChrt(Chart::HORIZONTAL, Chart::FULL_SIZE, dataIntv, Chart::PRNT_NAME, Chart::PRNT_VALUE, *bValue[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,22 +13,6 @@ private:
|
||||
VAL_CHART,
|
||||
CHART
|
||||
};
|
||||
/* enum DisplayMode {
|
||||
FULL,
|
||||
HALF
|
||||
}; */
|
||||
|
||||
static constexpr char HORIZONTAL = 'H';
|
||||
static constexpr char VERTICAL = 'V';
|
||||
static constexpr int8_t FULL_SIZE = 0;
|
||||
static constexpr int8_t HALF_SIZE_TOP = 1;
|
||||
static constexpr int8_t HALF_SIZE_BOTTOM = 2;
|
||||
static constexpr int8_t TWO_THIRD_TOP = 3;
|
||||
|
||||
static constexpr bool PRNT_NAME = true;
|
||||
static constexpr bool NO_PRNT_NAME = false;
|
||||
static constexpr bool PRNT_VALUE = true;
|
||||
static constexpr bool NO_PRNT_VALUE = false;
|
||||
|
||||
static constexpr int XOFFSET = 133; // x offset for display of boat values
|
||||
|
||||
@@ -125,7 +109,6 @@ public:
|
||||
height = getdisplay().height(); // Screen height
|
||||
|
||||
// Get config data
|
||||
// lengthformat = commonData->config->getString(commonData->config->lengthFormat);
|
||||
useSimuData = commonData->config->getBool(commonData->config->useSimuData);
|
||||
holdValues = commonData->config->getBool(commonData->config->holdvalues);
|
||||
flashLED = commonData->config->getString(commonData->config->flashLED);
|
||||
@@ -218,9 +201,6 @@ public:
|
||||
String bValFormat = bValue->getFormat(); // Value format
|
||||
|
||||
dataHstryBuf[i] = pageData.hstryBuffers->getBuffer(bValName);
|
||||
// if (dataHstryBuf[i]->getFormat() == "") { // data format might have been unknown at time of buffer creation
|
||||
// dataHstryBuf[i]->setFormat(bValFormat); // in that case, we specify it here, because we need it for printing of buffer data
|
||||
// }
|
||||
|
||||
if (dataHstryBuf[i]) {
|
||||
dataChart[i].reset(new Chart(*dataHstryBuf[i], *commonData, useSimuData));
|
||||
@@ -235,8 +215,6 @@ public:
|
||||
int displayPage(PageData& pageData)
|
||||
{
|
||||
|
||||
// using CD = Chart::ChrtDirection;
|
||||
|
||||
LOG_DEBUG(GwLog::LOG, "Display PageWeather");
|
||||
|
||||
// Get latest boat values for page
|
||||
@@ -272,12 +250,12 @@ public:
|
||||
|
||||
if (pageMode == VAL_CHART) {
|
||||
if (dataChart[0]) {
|
||||
dataChart[0]->showChrt(HORIZONTAL, TWO_THIRD_TOP, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue[0]);
|
||||
dataChart[0]->showChrt(Chart::HORIZONTAL, Chart::TWO_THIRD_TOP, dataIntv, Chart::PRNT_NAME, Chart::PRNT_VALUE, *bValue[0]);
|
||||
}
|
||||
showData(bValue);
|
||||
|
||||
} else if (pageMode == CHART && dataChart[0]) { // show only data chart, but that has to exist
|
||||
dataChart[0]->showChrt(HORIZONTAL, FULL_SIZE, dataIntv, PRNT_NAME, PRNT_VALUE, *bValue[0]);
|
||||
dataChart[0]->showChrt(Chart::HORIZONTAL, Chart::FULL_SIZE, dataIntv, Chart::PRNT_NAME, Chart::PRNT_VALUE, *bValue[0]);
|
||||
}
|
||||
|
||||
return PAGE_UPDATE;
|
||||
|
||||
@@ -11,28 +11,17 @@ class PageWindPlot : public Page {
|
||||
private:
|
||||
GwLog* logger;
|
||||
|
||||
enum ChartMode {
|
||||
enum PageMode {
|
||||
DIRECTION,
|
||||
SPEED,
|
||||
BOTH
|
||||
};
|
||||
|
||||
static constexpr char HORIZONTAL = 'H';
|
||||
static constexpr char VERTICAL = 'V';
|
||||
static constexpr int8_t FULL_SIZE = 0;
|
||||
static constexpr int8_t HALF_SIZE_LEFT = 1;
|
||||
static constexpr int8_t HALF_SIZE_RIGHT = 2;
|
||||
|
||||
static constexpr bool PRNT_NAME = true;
|
||||
static constexpr bool NO_PRNT_NAME = false;
|
||||
static constexpr bool PRNT_VALUE = true;
|
||||
static constexpr bool NO_PRNT_VALUE = false;
|
||||
|
||||
int width; // Screen width
|
||||
int height; // Screen height
|
||||
|
||||
bool keylock = false; // Keylock
|
||||
ChartMode chrtMode = DIRECTION;
|
||||
PageMode chrtMode = DIRECTION;
|
||||
bool showTruW = true; // Show true wind or apparent wind in chart area
|
||||
bool oldShowTruW = false; // remember recent user selection of wind data type
|
||||
|
||||
@@ -226,7 +215,7 @@ public:
|
||||
|
||||
if (chrtMode == DIRECTION) {
|
||||
if (wdChart) {
|
||||
wdChart->showChrt(VERTICAL, FULL_SIZE, dataIntv, PRNT_NAME, PRNT_VALUE, *wdBVal);
|
||||
wdChart->showChrt(Chart::VERTICAL, Chart::FULL_SIZE, dataIntv, Chart::PRNT_NAME, Chart::PRNT_VALUE, *wdBVal);
|
||||
}
|
||||
|
||||
} else if (chrtMode == SPEED) {
|
||||
@@ -234,15 +223,15 @@ public:
|
||||
if (dataIntv == 8) {
|
||||
dataIntv = 1; // horizontal charts show max. 4 x 7 min. only; no factor 8 multiplier
|
||||
}
|
||||
wsChart->showChrt(HORIZONTAL, FULL_SIZE, dataIntv, PRNT_NAME, PRNT_VALUE, *wsBVal);
|
||||
wsChart->showChrt(Chart::HORIZONTAL, Chart::FULL_SIZE, dataIntv, Chart::PRNT_NAME, Chart::PRNT_VALUE, *wsBVal);
|
||||
}
|
||||
|
||||
} else if (chrtMode == BOTH) {
|
||||
if (wdChart) {
|
||||
wdChart->showChrt(VERTICAL, HALF_SIZE_LEFT, dataIntv, PRNT_NAME, PRNT_VALUE, *wdBVal);
|
||||
wdChart->showChrt(Chart::VERTICAL, Chart::HALF_SIZE_LEFT_TOP, dataIntv, Chart::NO_PRNT_NAME, Chart::PRNT_VALUE, *wdBVal);
|
||||
}
|
||||
if (wsChart) {
|
||||
wsChart->showChrt(VERTICAL, HALF_SIZE_RIGHT, dataIntv, PRNT_NAME, PRNT_VALUE, *wsBVal);
|
||||
wsChart->showChrt(Chart::VERTICAL, Chart::HALF_SIZE_RIGHT_BOTTOM, dataIntv, Chart::NO_PRNT_NAME, Chart::PRNT_VALUE, *wsBVal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user