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:
James RichandClaude Opus 5 authored and GitHub committed 2026-07-30 16:40:41 +00:00
1 parent 4846425ff1
commit 2d20cd8a47
46 files changed
+2194 -148

No files matched your search

@@ -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
@@ -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