1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2026-02-11 07:03:07 +01:00

use 9.95 as the limit for formatting numbers below and above 10

This commit is contained in:
TobiasE-github
2026-01-15 17:56:52 +01:00
parent 0b79b7e2ef
commit 02c611ead0

View File

@@ -243,7 +243,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
speed = speed; // Unit conversion form m/s to m/s
result.unit = "m/s";
}
if(speed < 10) {
if(speed < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, speed);
}
else if (speed < 100) {
@@ -323,8 +323,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
snprintf(buffer, bsize, "%2.0f", speed);
}
else{
speed = std::round(speed * 100) / 100; // in rare cases, speed could be 9.9999 kn instead of 10.0 kn
if (speed < 10.0){
if (speed < 9.95){
snprintf(buffer, bsize, fmt_dec_1, speed);
}
else if (speed < 100.0){
@@ -378,7 +377,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
if (dop > 99.9){
dop = 99.9;
}
if (dop < 10){
if (dop < 9.95){
snprintf(buffer, bsize, fmt_dec_1, dop);
}
else if(dop < 100){
@@ -457,7 +456,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
else{
result.unit = "m";
}
if (depth < 10) {
if (depth < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, depth);
}
else if (depth < 100){
@@ -523,7 +522,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
else{
result.unit = "K";
}
if(temp < 10) {
if(temp < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, temp);
}
else if (temp < 100) {
@@ -556,7 +555,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
else {
result.unit = "m";
}
if (distance < 10){
if (distance < 9.95){
snprintf(buffer, bsize, fmt_dec_1, distance);
}
else if (distance < 100){
@@ -613,7 +612,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 12 + float(random(0, 30)) / 10.0;
voltage = rawvalue;
}
if (voltage < 10) {
if (voltage < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, voltage);
}
else {
@@ -633,7 +632,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 8.2 + float(random(0, 50)) / 10.0;
current = rawvalue;
}
if (current < 10) {
if (current < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, current);
}
else if(current < 100) {
@@ -656,7 +655,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 21.8 + float(random(0, 50)) / 10.0;
temperature = rawvalue;
}
if (temperature < 10) {
if (temperature < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, temperature);
}
else if (temperature < 100) {
@@ -679,7 +678,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 21.8 + float(random(0, 50)) / 10.0;
temperature = rawvalue;
}
if (temperature < 10) {
if (temperature < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, temperature);
}
else if(temperature < 100) {
@@ -702,7 +701,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 41.3 + float(random(0, 50)) / 10.0;
humidity = rawvalue;
}
if (humidity < 10) {
if (humidity < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, humidity);
}
else if(humidity < 100) {
@@ -725,7 +724,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 85.8 + float(random(0, 50)) / 10.0;
volume = rawvalue;
}
if (volume < 10) {
if (volume < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, volume);
}
else if (volume < 100) {
@@ -748,7 +747,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 75.2 + float(random(0, 50)) / 10.0;
volume = rawvalue;
}
if (volume < 10) {
if (volume < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, volume);
}
else if (volume < 100) {
@@ -771,7 +770,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 7.5 + float(random(0, 20)) / 10.0;
flow = rawvalue;
}
if (flow < 10) {
if (flow < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, flow);
}
else if (flow < 100) {
@@ -794,7 +793,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 18.5 + float(random(0, 20)) / 10.0;
generic = rawvalue;
}
if (generic < 10) {
if (generic < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, generic);
}
else if (generic < 100) {
@@ -817,7 +816,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 55.3 + float(random(0, 20)) / 10.0;
dplace = rawvalue;
}
if (dplace < 10) {
if (dplace < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, dplace);
}
else if (dplace < 100) {
@@ -861,7 +860,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
rawvalue = 2505 + random(0, 20);
rpm = rawvalue;
}
if (rpm < 10) {
if (rpm < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, rpm);
}
else if (rpm < 100) {
@@ -877,7 +876,7 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata, bool
// Default format
//########################################################
else {
if (value->value < 10) {
if (value->value < 9.95) {
snprintf(buffer, bsize, fmt_dec_1, value->value);
}
else if (value->value < 100) {