From e60ead0455b1c772ad1469a369bf167d1c8c47b3 Mon Sep 17 00:00:00 2001 From: Ulrich Meine <145987006+Scorgan01@users.noreply.github.com> Date: Sun, 9 Aug 2026 22:44:00 +0200 Subject: [PATCH] Fix potential CTW under-/overflow; has to be [0..2PI] --- lib/obp60task/PageCurrent.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/obp60task/PageCurrent.cpp b/lib/obp60task/PageCurrent.cpp index 15820af..96f9e37 100644 --- a/lib/obp60task/PageCurrent.cpp +++ b/lib/obp60task/PageCurrent.cpp @@ -16,7 +16,7 @@ static const std::unordered_map leeKMap = { { "Multihull Fixed Keel [16]", 16 } }; -enum bValIdx { +enum bValueIdx { ROLL = 0, SET, DFT, @@ -30,7 +30,7 @@ enum bValIdx { NUM_VALS }; -// Screen coordinates for boat values +// Screen coordinates for boat value, name, unit struct Points { int16_t x1, y1; int16_t x2, y2; @@ -126,9 +126,9 @@ private: double ctw; // course through water (rad true) if (awa >= M_PI) { // apparent wind > 180° -> comes from port - ctw = hdt + lay; + ctw = WindUtils::to2PI(hdt + lay); } else { // wind comes from starboard - ctw = hdt - lay; + ctw = WindUtils::to2PI(hdt - lay); } return ctw; @@ -231,7 +231,9 @@ private: float direction // angle the arrow is pointing to [0..2PI] ) { - if (size < 0.05) { // no arrow for current set below 0.05 m/s + static constexpr double MINSIZE = 0.05; // minimum current set (size) (m/s) for arrow size + + if (size < MINSIZE) { // no arrow for current set below 0.05 m/s return; }