mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-10-03 00:54:34 -04:00
fix(ui): give rx_snr real presence semantics end to end (#6523)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4846425ff1
commit
2d20cd8a47
46 files changed
+2194
-148
No files matched your search
+6
-1
@@ -45,7 +45,12 @@ object MetricFormatter {
|
||||
|
||||
fun pressure(hPa: Float, decimalPlaces: Int = 1): String = "${NumberFormatter.format(hPa, decimalPlaces)} hPa"
|
||||
|
||||
fun snr(value: Float, decimalPlaces: Int = 1): String = "${NumberFormatter.format(value, decimalPlaces)} dB"
|
||||
/**
|
||||
* Formats a signal-to-noise ratio, or [UNKNOWN_VALUE] when the packet carried no measurement. 0 dB is a legitimate
|
||||
* reading, so it must never stand in for a missing one.
|
||||
*/
|
||||
fun snr(value: Float?, decimalPlaces: Int = 1): String =
|
||||
if (value == null) UNKNOWN_VALUE else "${NumberFormatter.format(value, decimalPlaces)} dB"
|
||||
|
||||
/**
|
||||
* Formats a received signal strength, or [UNKNOWN_VALUE] when the radio reported none. 0 dBm is a legitimate
|
||||
|
||||
+12
@@ -74,6 +74,18 @@ class MetricFormatterTest {
|
||||
@Test
|
||||
fun snr() {
|
||||
assertEquals("5.5 dB", MetricFormatter.snr(5.5f))
|
||||
assertEquals("-12.5 dB", MetricFormatter.snr(-12.5f))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun snrAbsentIsUnknown() {
|
||||
assertEquals("—", MetricFormatter.snr(null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun snrZeroIsARealReading() {
|
||||
// Must not render as unknown: 0 dB is a signal at the noise floor, not a missing measurement.
|
||||
assertEquals("0.0 dB", MetricFormatter.snr(0f))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user