From a8f3fbb34d19d1f21ddc74f8d89217c8156d37ef Mon Sep 17 00:00:00 2001 From: norbert-walter Date: Mon, 18 Aug 2025 10:22:09 +0200 Subject: [PATCH] Fix for XTE page --- lib/obp60task/OBP60Formatter.cpp | 33 ++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/obp60task/OBP60Formatter.cpp b/lib/obp60task/OBP60Formatter.cpp index b1d6888..cfdcc96 100644 --- a/lib/obp60task/OBP60Formatter.cpp +++ b/lib/obp60task/OBP60Formatter.cpp @@ -439,21 +439,34 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ //######################################################## else if (value->getFormat() == "formatXte"){ double xte = 0; - if (!usesimudata) { - xte = abs(value->value); + if(usesimudata == false) { + xte = value->value; rawvalue = value->value; - } else { + } + else{ rawvalue = 6.0 + float(random(0, 4)); xte = rawvalue; } - if (xte >= 100) { - snprintf(buffer, bsize, fmt_dec_100, value->value); - } else if (xte >= 10) { - snprintf(buffer, bsize, fmt_dec_10, value->value); - } else { - snprintf(buffer, bsize, fmt_dec_1, value->value); + if(String(distanceFormat) == "km"){ + xte = xte * 0.001; + result.unit = "km"; + } + else if(String(distanceFormat) == "nm"){ + xte = xte * 0.000539957; + result.unit = "nm"; + } + else{; + result.unit = "m"; + } + if(xte < 10){ + snprintf(buffer,bsize,"%3.2f",xte); + } + if(xte >= 10 && xte < 100){ + snprintf(buffer,bsize,"%3.1f",xte); + } + if(xte >= 100){ + snprintf(buffer,bsize,"%3.0f",xte); } - result.unit = "nm"; } //######################################################## else if (value->getFormat() == "kelvinToC"){