From 64cb33ba677e4d92875a0ecb4c0a0c4c7ff9b919 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Mon, 4 Nov 2024 20:00:45 +0100 Subject: [PATCH 1/3] Fix autobahn segment display and calculation --- lib/obp60task/PageAutobahn.cpp | 47 +++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/lib/obp60task/PageAutobahn.cpp b/lib/obp60task/PageAutobahn.cpp index bb3f36a..18c4b72 100644 --- a/lib/obp60task/PageAutobahn.cpp +++ b/lib/obp60task/PageAutobahn.cpp @@ -46,7 +46,7 @@ class PageAutobahn : public Page{ // draw outline getdisplay().drawLine(x0, y0, x1, y1, color); getdisplay().drawLine(x1, y1, x2, y2, color); - getdisplay().drawLine(x2, y2, x3, y3, color); + getdisplay().drawLine(x2, y2, x3, y3, color); getdisplay().drawLine(x3, y3, x0, y0, color); } } @@ -69,7 +69,7 @@ class PageAutobahn : public Page{ String backlightMode = config->getString(config->backlight); String trackStep = config->getString(config->trackStep); - double seg_deg = trackStep.toFloat(); // degrees per display segment + double seg_step = trackStep.toFloat() * PI / 180; // Optical warning by limit violation (unused) if(String(flashLED) == "Limit Violation"){ @@ -136,20 +136,26 @@ class PageAutobahn : public Page{ getdisplay().setCursor(360-w, 257); getdisplay().print(sval_btw); + bool valid = bv_cog->valid && bv_btw->valid; + // autobahn view // draw ship symbol (as bitmap) getdisplay().drawXBitmap(184, 68, ship_bits, ship_width, ship_height, pixelcolor); // draw next waypoint name - String sval_wpname = "Tonne 122"; + String sval_wpname = "no data"; + + if (valid) { + sval_wpname = "Tonne 122"; + } + getdisplay().setFont(&Ubuntu_Bold10pt7b); getdisplay().getTextBounds(sval_wpname, 0, 150, &x, &y, &w, &h); // TODO if text don't fix use smaller font size. // if smallest size does not fit use 2 lines // last resort: clip with ellipsis getdisplay().setCursor(200 - w / 2, 60); - getdisplay().print(sval_wpname); // draw course segments @@ -161,21 +167,26 @@ class PageAutobahn : public Page{ diff -= 360; } - // default all segments activated - bool seg[6] = {true, true, true, true, true, true}; + // as default all segments activated if valid calculation + // values are available + bool seg[6]; // segment layout: [2][1][0] | [3][4][5] + for (int i=0; i<6; i++) { + seg[i] = valid; + } + // number of inactive segments - int nseg = std::min(static_cast(std::floor(std::abs(diff) / seg_deg)), 5); + int nseg = std::min(static_cast(std::floor(std::abs(diff) / seg_step)), 5); int order[6]; - if (diff < 0) { + if (diff > 0) { // right - order[0] = 6; order[1] = 5; order[2] = 4; - order[3] = 1; order[4] = 2; order[5] = 3; - } - else if (diff > 0) { + order[0] = 3; order[1] = 4; order[2] = 5; + order[3] = 0; order[4] = 1; order[5] = 2; + } + else if (diff < 0) { // left - order[0] = 3; order[1] = 2; order[2] = 1; - order[3] = 4; order[4] = 5; order[5] = 6; + order[0] = 0; order[1] = 1; order[2] = 2; + order[3] = 3; order[4] = 4; order[5] = 5; } int i = 0; while (nseg > 0) { @@ -185,13 +196,13 @@ class PageAutobahn : public Page{ } // left segments - drawSegment(0, 54, 46, 24, 75, 24, 0, 90, pixelcolor, seg[0]); + drawSegment(0, 54, 46, 24, 75, 24, 0, 90, pixelcolor, seg[2]); drawSegment(0, 100, 82, 24, 112, 24, 50, 100, pixelcolor, seg[1]); - drawSegment(60, 100, 117, 24, 147, 24, 110, 100, pixelcolor,seg[2]); + drawSegment(60, 100, 117, 24, 147, 24, 110, 100, pixelcolor,seg[0]); // right segments - drawSegment(399, 54, 354, 24, 325, 24, 399, 90, pixelcolor, seg[3]); + drawSegment(340, 100, 283, 24, 253, 24, 290, 100, pixelcolor, seg[3]); drawSegment(399, 100, 318, 24, 289, 24, 350, 100, pixelcolor, seg[4]); - drawSegment(340, 100, 283, 24, 253, 24, 290, 100, pixelcolor, seg[5]); + drawSegment(399, 54, 354, 24, 325, 24, 399, 90, pixelcolor, seg[5]); // Key Layout getdisplay().setFont(&Ubuntu_Bold8pt7b); From 87f7579c8e5fe058ff08bb3d768fcbcaa5b65f22 Mon Sep 17 00:00:00 2001 From: Tobias E Date: Wed, 20 Nov 2024 07:19:07 +0000 Subject: [PATCH 2/3] modified: lib/obp60task/PageRollPitch.cpp update svalue1old, to fix Issure 114 --- lib/obp60task/PageRollPitch.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/obp60task/PageRollPitch.cpp b/lib/obp60task/PageRollPitch.cpp index 9bc9b49..0674e2b 100644 --- a/lib/obp60task/PageRollPitch.cpp +++ b/lib/obp60task/PageRollPitch.cpp @@ -70,7 +70,9 @@ public: else{ svalue1 = String(value1/(2*PI)*360,0); } - + if(valid1 == true){ + svalue1old = svalue1; // Save the old value + } // Get boat values for pitch GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (xdrPitch) String name2 = xdrDelete(bvalue2->getName()); // Value name @@ -93,6 +95,9 @@ public: else{ svalue2 = String(value2/(2*PI)*360,0); } + if(valid2 == true){ + svalue2old = svalue2; // Save the old value + } // Optical warning by limit violation if(String(flashLED) == "Limit Violation"){ @@ -135,6 +140,8 @@ public: getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b); getdisplay().setCursor(10, 65); getdisplay().print(rolllimit); // Value + //getdisplay().print(svalue1); // Value + getdisplay().setFont(&Ubuntu_Bold12pt7b); getdisplay().setCursor(10, 95); getdisplay().print("Limit"); // Name @@ -353,6 +360,7 @@ PageDescription registerPageRollPitch( "RollPitch", // Page name createPage, // Action 0, // Number of bus values depends on selection in Web configuration + // {"xdrROLL", "xdrPTCH"},// Bus values we need in the page {"xdrRoll", "xdrPitch"},// Bus values we need in the page true // Show display header on/off ); From a75ea95694ad4d3e3693664fb13b08747dffdbd1 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Wed, 20 Nov 2024 10:42:38 +0100 Subject: [PATCH 3/3] Fix warnings --- lib/obp60task/PageVoltage.cpp | 2 +- lib/obp60task/RTClib.cpp | 4 ++-- lib/obp60task/RTClib.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/obp60task/PageVoltage.cpp b/lib/obp60task/PageVoltage.cpp index 77af4ca..cc1f9bb 100644 --- a/lib/obp60task/PageVoltage.cpp +++ b/lib/obp60task/PageVoltage.cpp @@ -127,7 +127,7 @@ public: } // Logging voltage value - if (raw == NULL) return; + if (raw == 0) return; LOG_DEBUG(GwLog::LOG,"Drawing at PageVoltage, Type:%s %s:=%f", batType, name1.c_str(), raw); // Draw page diff --git a/lib/obp60task/RTClib.cpp b/lib/obp60task/RTClib.cpp index 8c5429c..ebc989f 100644 --- a/lib/obp60task/RTClib.cpp +++ b/lib/obp60task/RTClib.cpp @@ -486,7 +486,7 @@ uint8_t RTC_BQ32000::readRegister(uint8_t address) { return Wire.read(); } -uint8_t RTC_BQ32000::writeRegister(uint8_t address, uint8_t value) { +void RTC_BQ32000::writeRegister(uint8_t address, uint8_t value) { /* Write the given value to the register at the given address. */ Wire.beginTransmission(BQ32000_ADDRESS); @@ -513,4 +513,4 @@ DateTime RTC_Millis::now() { return offset + millis() / 1000; } -//////////////////////////////////////////////////////////////////////////////// \ No newline at end of file +//////////////////////////////////////////////////////////////////////////////// diff --git a/lib/obp60task/RTClib.h b/lib/obp60task/RTClib.h index a99e791..137c51f 100644 --- a/lib/obp60task/RTClib.h +++ b/lib/obp60task/RTClib.h @@ -182,7 +182,7 @@ public: // utility functions: static uint8_t readRegister(uint8_t address); - static uint8_t writeRegister(uint8_t address, uint8_t value); + static void writeRegister(uint8_t address, uint8_t value); static uint8_t bcd2bin (uint8_t val) { return val - 6 * (val >> 4); } static uint8_t bin2bcd (uint8_t val) { return val + 6 * (val / 10); } };