From cca06784fc4835972ec8cbfaee7f419c2f4a8357 Mon Sep 17 00:00:00 2001 From: andrekir Date: Tue, 1 Oct 2024 19:20:18 -0300 Subject: [PATCH] feat: add `PowerMetrics` data to nodes telemetry closes #994 --- .../com/geeksville/mesh/database/entity/NodeEntity.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/geeksville/mesh/database/entity/NodeEntity.kt b/app/src/main/java/com/geeksville/mesh/database/entity/NodeEntity.kt index c80cea7a..10d99b88 100644 --- a/app/src/main/java/com/geeksville/mesh/database/entity/NodeEntity.kt +++ b/app/src/main/java/com/geeksville/mesh/database/entity/NodeEntity.kt @@ -135,13 +135,21 @@ data class NodeEntity( ).joinToString(" ") } + private fun TelemetryProtos.PowerMetrics.getDisplayString(): String = listOfNotNull( + "%.2fV".format(ch2Voltage).takeIf { hasCh2Voltage() }, + "%.1fmA".format(ch2Current).takeIf { hasCh2Current() }, + "%.2fV".format(ch3Voltage).takeIf { hasCh3Voltage() }, + "%.1fmA".format(ch3Current).takeIf { hasCh3Current() }, + ).joinToString(" ") + private fun PaxcountProtos.Paxcount.getDisplayString() = "PAX: ${ble + wifi} (B:$ble/W:$wifi)".takeIf { ble != 0 && wifi != 0 } fun getTelemetryString(isFahrenheit: Boolean = false): String { return listOfNotNull( paxcounter.getDisplayString(), - environmentMetrics.getDisplayString(isFahrenheit) + environmentMetrics.getDisplayString(isFahrenheit), + powerMetrics.getDisplayString(), ).joinToString(" ") }