Account for negative metric values in telemetry (#532)

This commit is contained in:
Ben Meadors
2022-12-03 15:53:20 -06:00
committed by GitHub
parent 88fabab750
commit dcc03be484

View File

@@ -158,7 +158,7 @@ data class NodeInfo(
val batteryStr get() = if (batteryLevel in 1..100) String.format("%d%%", batteryLevel) else ""
private fun envFormat(f: String, unit: String, env: Float?): String =
if (env != null && env > 0f) String.format(f + unit, env) else ""
if (env != null && env != 0f) String.format(f + unit, env) else ""
val envMetricStr
get() = envFormat("%.1f", "°C ", environmentMetrics?.temperature) +
@@ -211,4 +211,4 @@ data class NodeInfo(
else -> "%.1f km".format(dist / 1000.0)
}
}
}
}