feat: add `PowerMetrics` data to nodes telemetry

closes #994
pull/1277/head
andrekir 2024-10-01 19:20:18 -03:00
rodzic 7eca16caeb
commit cca06784fc
1 zmienionych plików z 9 dodań i 1 usunięć

Wyświetl plik

@ -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(" ")
}