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;
|
chrtRng = dfltRng;
|
||||||
recalcRngMid = true; // initialize <chrtMid> and chart borders on first chart display call
|
recalcRngMid = true; // initialize <chrtMid> and chart borders on first chart display call
|
||||||
|
|
||||||
if (dbFormat.isEmpty()) {
|
if (dbFormat.isEmpty()) { // data buffer may not exist yet, because boat data object is not available yet
|
||||||
// data buffer may not exist yet, because boat data object is not available yet
|
|
||||||
initValid = false; // chart object will get invalid data during initialization
|
initValid = false; // chart object will get invalid data during initialization
|
||||||
} else {
|
} else {
|
||||||
initValid = true;
|
initValid = true;
|
||||||
@@ -122,8 +121,7 @@ bool Chart::init()
|
|||||||
// <prntName>; print data name on horizontal half chart [true|false]
|
// <prntName>; print data name on horizontal half chart [true|false]
|
||||||
// <showCurrValue>: print current boat data value [true|false]
|
// <showCurrValue>: print current boat data value [true|false]
|
||||||
// <currValue>: current boat data value; used only for test on valid data
|
// <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 ChrtDir chrtDir, ChrtSize chrtSz, 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)
|
|
||||||
{
|
{
|
||||||
if (!setChartDimensions(chrtDir, chrtSz)) {
|
if (!setChartDimensions(chrtDir, chrtSz)) {
|
||||||
return; // wrong chart dimension parameters
|
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
|
// define dimensions and start points for chart
|
||||||
// bool Chart::setChartDimensions(const ChrtDirection direction, const ChrtSize size)
|
bool Chart::setChartDimensions(const ChrtDir chrtDir, const ChrtSize chrtSz)
|
||||||
bool Chart::setChartDimensions(const char direction, const int8_t size)
|
|
||||||
{
|
{
|
||||||
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());
|
LOG_DEBUG(GwLog::ERROR, "obp60:setChartDimensions %s: wrong parameters", dataBuf.getName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction == HORIZONTAL) {
|
if (chrtDir == HORIZONTAL) {
|
||||||
// horizontal chart timeline direction
|
// horizontal chart timeline direction
|
||||||
timAxis = dWidth - 1;
|
timAxis = dWidth - 1;
|
||||||
switch (size) {
|
switch (chrtSz) {
|
||||||
case 0:
|
case ChrtSize::FULL_SIZE:
|
||||||
valAxis = dHeight - top - bottom;
|
valAxis = dHeight - top - bottom;
|
||||||
cRoot = { 0, top - 1 };
|
cRoot = { 0, top - 1 };
|
||||||
break;
|
break;
|
||||||
case 1:
|
case HALF_SIZE_LEFT_TOP:
|
||||||
valAxis = (dHeight - top - bottom) / 2 - hGap;
|
valAxis = (dHeight - top - bottom) / 2 - hGap;
|
||||||
cRoot = { 0, top - 1 };
|
cRoot = { 0, top - 1 };
|
||||||
break;
|
break;
|
||||||
case 2:
|
case HALF_SIZE_RIGHT_BOTTOM:
|
||||||
valAxis = (dHeight - top - bottom) / 2 - hGap;
|
valAxis = (dHeight - top - bottom) / 2 - hGap;
|
||||||
cRoot = { 0, top + (valAxis + hGap) + hGap - 1 };
|
cRoot = { 0, top + (valAxis + hGap) + hGap - 1 };
|
||||||
break;
|
break;
|
||||||
case 3:
|
case TWO_THIRD_TOP:
|
||||||
valAxis = (dHeight - top - bottom) * 0.667 - hGap;
|
valAxis = (dHeight - top - bottom) * 0.667 - hGap;
|
||||||
cRoot = { 0, top - 1 };
|
cRoot = { 0, top - 1 };
|
||||||
break;
|
break;
|
||||||
@@ -179,19 +176,19 @@ bool Chart::setChartDimensions(const char direction, const int8_t size)
|
|||||||
cRoot = { 0, top - 1 };
|
cRoot = { 0, top - 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (direction == VERTICAL) {
|
} else if (chrtDir == VERTICAL) {
|
||||||
// vertical chart timeline direction
|
// vertical chart timeline direction
|
||||||
timAxis = dHeight - top - bottom;
|
timAxis = dHeight - top - bottom;
|
||||||
switch (size) {
|
switch (chrtSz) {
|
||||||
case 0:
|
case FULL_SIZE:
|
||||||
valAxis = dWidth - 1;
|
valAxis = dWidth - 1;
|
||||||
cRoot = { 0, top - 1 };
|
cRoot = { 0, top - 1 };
|
||||||
break;
|
break;
|
||||||
case 1:
|
case HALF_SIZE_LEFT_TOP:
|
||||||
valAxis = dWidth / 2 - vGap;
|
valAxis = dWidth / 2 - vGap;
|
||||||
cRoot = { 0, top - 1 };
|
cRoot = { 0, top - 1 };
|
||||||
break;
|
break;
|
||||||
case 2:
|
case HALF_SIZE_RIGHT_BOTTOM:
|
||||||
valAxis = dWidth / 2 - vGap;
|
valAxis = dWidth / 2 - vGap;
|
||||||
cRoot = { dWidth / 2 + vGap - 1, top - 1 };
|
cRoot = { dWidth / 2 + vGap - 1, top - 1 };
|
||||||
break;
|
break;
|
||||||
@@ -200,13 +197,13 @@ bool Chart::setChartDimensions(const char direction, const int8_t size)
|
|||||||
cRoot = { 0, top - 1 };
|
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",
|
// 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(), direction, size, dWidth, dHeight, timAxis, valAxis, cRoot.x, cRoot.y, top, bottom, hGap, vGap);
|
// dataBuf.getName(), chrtDir, size, dWidth, dHeight, timAxis, valAxis, cRoot.x, cRoot.y, top, bottom, hGap, vGap);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw chart
|
// 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
|
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++;
|
numNoData++;
|
||||||
bufDataValid = true;
|
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
|
if (numNoData > THRESHOLD_NO_DATA * (dataBuf.getUpdFreq() / 1000)) { // If more than <THRESHOLD> invalid values in a row, flag for invalid data
|
||||||
bufDataValid = false;
|
bufDataValid = false;
|
||||||
return;
|
return;
|
||||||
@@ -371,7 +367,7 @@ void Chart::calcChrtBorders(double& rngMin, double& rngMid, double& rngMax, doub
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw chart graph
|
// 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
|
double chrtVal; // Current data value
|
||||||
Pos point, prevPoint; // current and previous chart point
|
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);
|
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)
|
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);
|
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);
|
// 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
|
bool wrappingFromHighToLow = normCurrVal < normPrevVal; // Determine which edge we're crossing
|
||||||
|
|
||||||
if (direction == HORIZONTAL) {
|
if (chrtDir == HORIZONTAL) {
|
||||||
int ySplit = wrappingFromHighToLow ? (cRoot.y + valAxis) : cRoot.y;
|
int ySplit = wrappingFromHighToLow ? (cRoot.y + valAxis) : cRoot.y;
|
||||||
drawBoldLine(prevPoint.x, prevPoint.y, point.x, ySplit);
|
drawBoldLine(prevPoint.x, prevPoint.y, point.x, ySplit);
|
||||||
prevPoint.y = wrappingFromHighToLow ? cRoot.y : (cRoot.y + valAxis);
|
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 (chrtDataFmt == DEPTH) {
|
||||||
if (direction == HORIZONTAL) { // horizontal chart
|
if (chrtDir == HORIZONTAL) { // horizontal chart
|
||||||
drawBoldLine(point.x, point.y, point.x, cRoot.y + valAxis);
|
drawBoldLine(point.x, point.y, point.x, cRoot.y + valAxis);
|
||||||
} else { // vertical chart
|
} else { // vertical chart
|
||||||
drawBoldLine(point.x, point.y, cRoot.x + valAxis, point.y);
|
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
|
// 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;
|
Pos currentPoint;
|
||||||
|
|
||||||
if (direction == HORIZONTAL) {
|
if (chrtDir == HORIZONTAL) {
|
||||||
currentPoint.x = cRoot.x + i; // Position in chart area
|
currentPoint.x = cRoot.x + i; // Position in chart area
|
||||||
|
|
||||||
if (chrtDataFmt == WIND || chrtDataFmt == ROTATION) { // degree type value
|
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
|
// 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;
|
int axSlots, intv, i, timeRng;
|
||||||
char sTime[6];
|
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().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().setCursor((4 - strlen(sTime)) * 7, cRoot.y + j + 3); // time value; print left screen; value right-formated
|
||||||
getdisplay().printf("%s", sTime); // time value
|
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
|
drawTextCenter(dWidth / 2, cRoot.y + j, sTime); // time value; print mid screen
|
||||||
}
|
}
|
||||||
i -= chrtIntv;
|
i -= chrtIntv;
|
||||||
@@ -548,11 +544,11 @@ void Chart::drawChrtTimeAxis(const char chrtDir, const int8_t chrtSz, const int8
|
|||||||
}
|
}
|
||||||
|
|
||||||
// chart value axis labels + lines
|
// 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;
|
const GFXfont* font;
|
||||||
constexpr bool NO_LABEL = false;
|
// constexpr bool NO_LABEL = false;
|
||||||
constexpr bool LABEL = true;
|
// constexpr bool LABEL = true;
|
||||||
|
|
||||||
getdisplay().setTextColor(fgColor);
|
getdisplay().setTextColor(fgColor);
|
||||||
|
|
||||||
@@ -560,13 +556,14 @@ void Chart::drawChrtValAxis(const char chrtDir, const int8_t chrtSz, bool prntNa
|
|||||||
|
|
||||||
if (chrtSz == FULL_SIZE) {
|
if (chrtSz == FULL_SIZE) {
|
||||||
|
|
||||||
// print buffer data name on left hand side of time axis (max. size 5 characters)
|
if (prntName) {
|
||||||
font = &Ubuntu_Bold12pt8b;
|
// print buffer data name on left hand side of time axis (max. size 5 characters)
|
||||||
getdisplay().setFont(font);
|
font = &Ubuntu_Bold12pt8b;
|
||||||
getdisplay().fillRect(cRoot.x + timAxis - 57, cRoot.y + 2, 58, 20, bgColor); // clear small area to remove potential chart lines
|
getdisplay().setFont(font);
|
||||||
String name = xdrDelete(dbName); // Value name
|
getdisplay().fillRect(cRoot.x + timAxis - 57, cRoot.y + 2, 58, 20, bgColor); // clear small area to remove potential chart lines
|
||||||
drawTextRalign(cRoot.x + timAxis - 1, cRoot.y + 19, name.substring(0, 5));
|
String name = xdrDelete(dbName); // Value name
|
||||||
|
drawTextRalign(cRoot.x + timAxis - 1, cRoot.y + 19, name.substring(0, 5));
|
||||||
|
}
|
||||||
if (chrtDataFmt == WIND) {
|
if (chrtDataFmt == WIND) {
|
||||||
prntHorizChartThreeValueAxisLabel(font);
|
prntHorizChartThreeValueAxisLabel(font);
|
||||||
return;
|
return;
|
||||||
@@ -594,9 +591,13 @@ void Chart::drawChrtValAxis(const char chrtDir, const int8_t chrtSz, bool prntNa
|
|||||||
|
|
||||||
} else { // vertical chart
|
} else { // vertical chart
|
||||||
|
|
||||||
if (chrtSz == FULL_SIZE) {
|
if (prntName) {
|
||||||
font = &Ubuntu_Bold12pt8b;
|
if (chrtSz == FULL_SIZE) {
|
||||||
getdisplay().setFont(font); // use larger font
|
font = &Ubuntu_Bold12pt8b;
|
||||||
|
} else {
|
||||||
|
font = &Ubuntu_Bold10pt8b;
|
||||||
|
}
|
||||||
|
getdisplay().setFont(font);
|
||||||
String name = xdrDelete(dbName); // Value name
|
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)
|
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
|
// 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 xPosVal = (chrtDir == HORIZONTAL) ? cRoot.x + (timAxis / 2) - 74 : cRoot.x + 31;
|
||||||
const int yPosVal = (direction == HORIZONTAL) ? cRoot.y + valAxis : cRoot.y + timAxis;
|
const int yPosVal = (chrtDir == HORIZONTAL) ? cRoot.y + valAxis : cRoot.y + timAxis;
|
||||||
|
|
||||||
FormattedData frmtDbData = formatValue(&currValue, *commonData, NO_SIMUDATA);
|
FormattedData frmtDbData = formatValue(&currValue, *commonData, NO_SIMUDATA);
|
||||||
String sdbValue = frmtDbData.svalue; // value as formatted string
|
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>
|
// print message for no valid data availabletemplate <typename T>
|
||||||
void Chart::prntNoValidData(const char direction)
|
void Chart::prntNoValidData(const ChrtDir chrtDir)
|
||||||
{
|
{
|
||||||
Pos p;
|
Pos p;
|
||||||
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold10pt8b);
|
getdisplay().setFont(&Ubuntu_Bold10pt8b);
|
||||||
|
|
||||||
if (direction == HORIZONTAL) {
|
if (chrtDir == HORIZONTAL) {
|
||||||
p.x = cRoot.x + (timAxis / 2);
|
p.x = cRoot.x + (timAxis / 2);
|
||||||
p.y = cRoot.y + (valAxis / 2) - 10;
|
p.y = cRoot.y + (valAxis / 2) - 10;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+24
-28
@@ -20,24 +20,28 @@ class GwLog;
|
|||||||
|
|
||||||
class Chart {
|
class Chart {
|
||||||
public:
|
public:
|
||||||
/* enum class ChrtDirection {
|
enum ChrtDir {
|
||||||
HORIZONTALE,
|
HORIZONTAL,
|
||||||
VERTICALE
|
VERTICAL
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ChrtSize {
|
enum ChrtSize {
|
||||||
FULL_SIZEE,
|
FULL_SIZE,
|
||||||
HALF_SIZE_LEFTE,
|
HALF_SIZE_LEFT_TOP,
|
||||||
HALF_SIZE_RIGHTE,
|
HALF_SIZE_RIGHT_BOTTOM,
|
||||||
TWO_THIRD_TOPE
|
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(RingBuffer<uint16_t>& dataBuf, CommonData& common, bool useSimuData); // Chart object of data chart
|
||||||
~Chart();
|
~Chart();
|
||||||
bool init(); // initialize chart object parameters
|
bool init(); // initialize chart object parameters
|
||||||
bool isValid() { return initValid; }; // Checks if chart object has been fully initialized
|
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(const ChrtDir chrtDir, const ChrtSize 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
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CommonData* commonData;
|
CommonData* commonData;
|
||||||
@@ -54,13 +58,6 @@ protected:
|
|||||||
OTHER
|
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 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 THRESHOLD_NO_DATA = 3; // max. seconds of invalid values in a row
|
||||||
static constexpr int8_t VALAXIS_SLOTS = 5; // no. of value axis labels
|
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
|
{ "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 ChrtDir direction, const ChrtSize chrtSz); // 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 ChrtDir chrtDir, const int8_t chrtIntv, GwApi::BoatValue& currValue); // Draw chart line
|
||||||
void drawChrt(const char 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 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 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
|
void drawChartLines(const ChrtDir 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
|
Pos setCurrentChartPoint(const int i, const ChrtDir chrtDir, 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 drawChrtTimeAxis(const ChrtDir chrtDir, const ChrtSize 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 drawChrtValAxis(const ChrtDir chrtDir, const ChrtSize chrtSz, const 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 prntCurrValue(const ChrtDir chrtDir, GwApi::BoatValue& currValue); // Add current boat data value to chart
|
||||||
void prntNoValidData(const char chrtDir); // print message for no valid data available
|
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
|
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 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
|
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
|
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 width; // Screen width
|
||||||
int height; // Screen height
|
int height; // Screen height
|
||||||
|
|
||||||
@@ -286,13 +275,13 @@ public:
|
|||||||
|
|
||||||
} else if (pageMode == CHART) { // show only data chart
|
} else if (pageMode == CHART) { // show only data chart
|
||||||
if (dataChart) {
|
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
|
} else if (pageMode == BOTH) { // show data value and chart
|
||||||
showData(bValue1, HALF);
|
showData(bValue1, HALF);
|
||||||
if (dataChart) {
|
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
|
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
|
static constexpr int YOFFSET = 130; // y offset for display of 2nd boat value
|
||||||
|
|
||||||
int width; // Screen width
|
int width; // Screen width
|
||||||
@@ -296,28 +285,28 @@ public:
|
|||||||
} else if (pageMode == VAL1_CHART) { // show data value 1 and chart
|
} else if (pageMode == VAL1_CHART) { // show data value 1 and chart
|
||||||
showData({ bValue[0] }, HALF);
|
showData({ bValue[0] }, HALF);
|
||||||
if (dataChart[0]) {
|
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
|
} else if (pageMode == VAL2_CHART) { // show data value 2 and chart
|
||||||
showData({ bValue[1] }, HALF);
|
showData({ bValue[1] }, HALF);
|
||||||
if (dataChart[1]) {
|
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
|
} else if (pageMode == CHARTS) { // show both data charts
|
||||||
if (dataChart[0]) {
|
if (dataChart[0]) {
|
||||||
if (dataChart[1]) {
|
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 {
|
} 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[1]) {
|
||||||
if (dataChart[0]) {
|
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 {
|
} 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,
|
VAL_CHART,
|
||||||
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
|
static constexpr int XOFFSET = 133; // x offset for display of boat values
|
||||||
|
|
||||||
@@ -125,7 +109,6 @@ public:
|
|||||||
height = getdisplay().height(); // Screen height
|
height = getdisplay().height(); // Screen height
|
||||||
|
|
||||||
// Get config data
|
// Get config data
|
||||||
// lengthformat = commonData->config->getString(commonData->config->lengthFormat);
|
|
||||||
useSimuData = commonData->config->getBool(commonData->config->useSimuData);
|
useSimuData = commonData->config->getBool(commonData->config->useSimuData);
|
||||||
holdValues = commonData->config->getBool(commonData->config->holdvalues);
|
holdValues = commonData->config->getBool(commonData->config->holdvalues);
|
||||||
flashLED = commonData->config->getString(commonData->config->flashLED);
|
flashLED = commonData->config->getString(commonData->config->flashLED);
|
||||||
@@ -218,9 +201,6 @@ public:
|
|||||||
String bValFormat = bValue->getFormat(); // Value format
|
String bValFormat = bValue->getFormat(); // Value format
|
||||||
|
|
||||||
dataHstryBuf[i] = pageData.hstryBuffers->getBuffer(bValName);
|
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]) {
|
if (dataHstryBuf[i]) {
|
||||||
dataChart[i].reset(new Chart(*dataHstryBuf[i], *commonData, useSimuData));
|
dataChart[i].reset(new Chart(*dataHstryBuf[i], *commonData, useSimuData));
|
||||||
@@ -235,8 +215,6 @@ public:
|
|||||||
int displayPage(PageData& pageData)
|
int displayPage(PageData& pageData)
|
||||||
{
|
{
|
||||||
|
|
||||||
// using CD = Chart::ChrtDirection;
|
|
||||||
|
|
||||||
LOG_DEBUG(GwLog::LOG, "Display PageWeather");
|
LOG_DEBUG(GwLog::LOG, "Display PageWeather");
|
||||||
|
|
||||||
// Get latest boat values for page
|
// Get latest boat values for page
|
||||||
@@ -272,12 +250,12 @@ public:
|
|||||||
|
|
||||||
if (pageMode == VAL_CHART) {
|
if (pageMode == VAL_CHART) {
|
||||||
if (dataChart[0]) {
|
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);
|
showData(bValue);
|
||||||
|
|
||||||
} else if (pageMode == CHART && dataChart[0]) { // show only data chart, but that has to exist
|
} 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;
|
return PAGE_UPDATE;
|
||||||
|
|||||||
@@ -11,28 +11,17 @@ class PageWindPlot : public Page {
|
|||||||
private:
|
private:
|
||||||
GwLog* logger;
|
GwLog* logger;
|
||||||
|
|
||||||
enum ChartMode {
|
enum PageMode {
|
||||||
DIRECTION,
|
DIRECTION,
|
||||||
SPEED,
|
SPEED,
|
||||||
BOTH
|
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 width; // Screen width
|
||||||
int height; // Screen height
|
int height; // Screen height
|
||||||
|
|
||||||
bool keylock = false; // Keylock
|
bool keylock = false; // Keylock
|
||||||
ChartMode chrtMode = DIRECTION;
|
PageMode chrtMode = DIRECTION;
|
||||||
bool showTruW = true; // Show true wind or apparent wind in chart area
|
bool showTruW = true; // Show true wind or apparent wind in chart area
|
||||||
bool oldShowTruW = false; // remember recent user selection of wind data type
|
bool oldShowTruW = false; // remember recent user selection of wind data type
|
||||||
|
|
||||||
@@ -226,7 +215,7 @@ public:
|
|||||||
|
|
||||||
if (chrtMode == DIRECTION) {
|
if (chrtMode == DIRECTION) {
|
||||||
if (wdChart) {
|
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) {
|
} else if (chrtMode == SPEED) {
|
||||||
@@ -234,15 +223,15 @@ public:
|
|||||||
if (dataIntv == 8) {
|
if (dataIntv == 8) {
|
||||||
dataIntv = 1; // horizontal charts show max. 4 x 7 min. only; no factor 8 multiplier
|
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) {
|
} else if (chrtMode == BOTH) {
|
||||||
if (wdChart) {
|
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) {
|
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