1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-28 21:23:07 +01:00

Fixed OBP60Formatter issue with speeds of 9.9999 knots

This commit is contained in:
Ulrich Meine
2025-11-29 01:21:45 +01:00
parent 3fa7ca5e99
commit 625f9c087e

View File

@@ -305,10 +305,13 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
snprintf(buffer, bsize, "%2.0f", speed);
}
else{
if (speed < 10){
speed = std::round(speed * 100) / 100; // in rare cases, speed could be 9.9999 kn instead of 10.0 kn
LOG_DEBUG(GwLog::DEBUG,"OBPFormatter-formatValue: value->value: %.3f speed: %.15f speed<10: %d", value->value, speed, speed < 10.0);
if (speed < 10.0){
snprintf(buffer, bsize, fmt_dec_1, speed);
}
else if (speed < 100){
else if (speed < 100.0){
snprintf(buffer, bsize, fmt_dec_10, speed);
}
else {