From 0f50b614eb510e1abb1e49d42daefcb1274386f3 Mon Sep 17 00:00:00 2001 From: Ulrich Meine Date: Fri, 5 Dec 2025 00:10:31 +0100 Subject: [PATCH] Add lower chart line for horizontal half chart; write current value after chart lines --- lib/obp60task/OBPcharts.cpp | 23 +++++++++++++---------- lib/obp60task/OBPcharts.h | 3 ++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/obp60task/OBPcharts.cpp b/lib/obp60task/OBPcharts.cpp index 6ba5a83..17caf75 100644 --- a/lib/obp60task/OBPcharts.cpp +++ b/lib/obp60task/OBPcharts.cpp @@ -107,6 +107,15 @@ void Chart::showChrt(int8_t chrtIntv, GwApi::BoatValue currValue) drawChrt(chrtIntv, currValue); drawChrtTimeAxis(chrtIntv); drawChrtValAxis(); + + if (bufDataValid) { + // uses BoatValue temp variable to format latest buffer value + // doesn't work unfortunately when 'simulation data' is active, because OBP60Formatter generates own simulation value in that case + currValue.value = dataBuf.getLast(); + currValue.valid = currValue.value != dbMAX_VAL; + Chart::prntCurrValue(currValue); + LOG_DEBUG(GwLog::DEBUG, "Chart drawChrt: currValue-value: %.1f, Valid: %d, Name: %s, Address: %p", currValue.value, currValue.valid, currValue.getName(), (void*)&currValue); + } } // draw chart @@ -116,7 +125,7 @@ void Chart::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue) double chrtVal; // Current data value double chrtScl; // Scale for data values in pixels per value static double chrtPrevVal; // Last data value in chart area - bool bufDataValid = false; // Flag to indicate if buffer data is valid + // bool bufDataValid = false; // Flag to indicate if buffer data is valid static int numNoData; // Counter for multiple invalid data values in a row int x, y; // x and y coordinates for drawing @@ -248,13 +257,6 @@ void Chart::drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue) } } - // uses BoatValue temp variable to format latest buffer value - // doesn't work unfortunately when 'simulation data' is active, because OBP60Formatter generates own simulation value in that case - currValue.value = dataBuf.getLast(); - currValue.valid = currValue.value != dbMAX_VAL; - Chart::prntCurrValue(currValue); - LOG_DEBUG(GwLog::DEBUG, "Chart drawChrt: currValue-value: %.1f, Valid: %d, Name: %s, Address: %p", currValue.value, currValue.valid, currValue.getName(), (void*)&currValue); - } else { // No valid data available getdisplay().setFont(&Ubuntu_Bold10pt8b); @@ -527,6 +529,7 @@ void Chart::drawChrtValAxis() getdisplay().fillRect(cStart.x, cStart.y + valAxis - 16, 42, 16, bgColor); // Clear small area to remove potential chart lines getdisplay().setCursor(cStart.x + ((3 - sLen) * 10), cStart.y + valAxis - 1); getdisplay().printf("%s", sVal); // Range high end + getdisplay().drawLine(cStart.x + 43, cStart.y + valAxis, cStart.x + timAxis, cStart.y + valAxis, fgColor); } getdisplay().setFont(&Ubuntu_Bold12pt8b); @@ -582,8 +585,8 @@ void Chart::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, // testdbValue, currValue.getFormat(), dbUnit, currValue.valid, currValue.getName(), currValue); - getdisplay().fillRect(xPosVal - 1, yPosVal - 34, 125, 42, bgColor); // Clear area for TWS value - getdisplay().drawRect(xPosVal, yPosVal - 33, 123, 40, fgColor); // Draw box for TWS value + getdisplay().fillRect(xPosVal - 1, yPosVal - 34, 125, 41, bgColor); // Clear area for TWS value + getdisplay().drawRect(xPosVal, yPosVal - 33, 123, 39, fgColor); // Draw box for TWS value getdisplay().setFont(&DSEG7Classic_BoldItalic16pt7b); getdisplay().setCursor(xPosVal + 1, yPosVal); if (useSimuData) { diff --git a/lib/obp60task/OBPcharts.h b/lib/obp60task/OBPcharts.h index 677be04..db298a5 100644 --- a/lib/obp60task/OBPcharts.h +++ b/lib/obp60task/OBPcharts.h @@ -25,7 +25,7 @@ protected: int top = 48; // display top header lines int bottom = 22; // display bottom lines - int hGap = 10; // gap between 2 horizontal charts; actual gap is 2x + int hGap = 11; // gap between 2 horizontal charts; actual gap is 2x int vGap = 20; // gap between 2 vertical charts; actual gap is 2x int xOffset = 33; // offset for horizontal axis (time/value), because of space for left vertical axis labeling int yOffset = 10; // offset for vertical axis (time/value), because of space for top horizontal axis labeling @@ -52,6 +52,7 @@ protected: size_t currIdx; // Current index in TWD history buffer size_t lastIdx; // Last index of TWD history buffer size_t lastAddedIdx = 0; // Last index of TWD history buffer when new data was added + bool bufDataValid = false; // Flag to indicate if buffer data is valid int oldChrtIntv = 0; // remember recent user selection of data interval void drawChrt(int8_t chrtIntv, GwApi::BoatValue& currValue); // Draw chart line