mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
add EnvironmentMetrics to nodes tab
This commit is contained in:
parent
fd0c8ef9b8
commit
7be67ec2d4
3 changed files with 30 additions and 2 deletions
|
|
@ -156,6 +156,17 @@ data class NodeInfo(
|
|||
val voltage get() = deviceMetrics?.voltage
|
||||
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 ""
|
||||
|
||||
val envMetricStr
|
||||
get() = envFormat("%.1f", "°C ", environmentMetrics?.temperature) +
|
||||
envFormat("%.0f", "%% ", environmentMetrics?.relativeHumidity) +
|
||||
envFormat("%.1f", "hPa ", environmentMetrics?.barometricPressure) +
|
||||
envFormat("%.0f", "KΩ ", environmentMetrics?.gasResistance) +
|
||||
envFormat("%.2f", "V ", environmentMetrics?.voltage) +
|
||||
envFormat("%.1f", "mA", environmentMetrics?.current)
|
||||
|
||||
/**
|
||||
* true if the device was heard from recently
|
||||
*
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
|||
val lastTime = itemView.lastConnectionView
|
||||
val powerIcon = itemView.batteryIcon
|
||||
val signalView = itemView.signalView
|
||||
val envMetrics = itemView.envMetrics
|
||||
}
|
||||
|
||||
private val nodesAdapter = object : RecyclerView.Adapter<ViewHolder>() {
|
||||
|
|
@ -136,6 +137,13 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
|||
|
||||
holder.lastTime.text = formatAgo(n.lastHeard)
|
||||
|
||||
if (n.envMetricStr.isNotEmpty()) {
|
||||
holder.envMetrics.text = n.envMetricStr
|
||||
holder.envMetrics.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.envMetrics.visibility = View.GONE
|
||||
}
|
||||
|
||||
if (n.num == ourNodeInfo?.num) {
|
||||
val info = model.myNodeInfo.value
|
||||
if (info != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue