Watch display shows if glasses are charging or silent mode

This commit is contained in:
James Babcock committed 2026-08-28 18:36:35 -07:00
1 parent ed8302bc6b
commit 6cd7d5fff9
10 files changed
+122 -20

No files matched your search

+5 -1
View File
@@ -49,7 +49,7 @@ dashboard state, re-sent whenever it changes (and at least every 30 s):
"protocol": 1, "version": "…",
"phase": "connected", "status": "…", "connected": true,
"screenOn": true, "locked": false, "worn": true, "listening": false,
"battery": 78, "charging": false,
"battery": 78, "charging": false, "silentMode": false,
"foreground": {"appId": "music", "title": "Music"},
"windows": [{"windowId": "…", "title": "…", "appId": "…", "focused": true, "closeable": true, "acceptsText": false}],
"apps": [{"appId": "timer", "title": "Timer"}],
@@ -60,6 +60,10 @@ dashboard state, re-sent whenever it changes (and at least every 30 s):
}
```
`battery` is the current or last-known G2 percentage. `charging` and
`silentMode` identify the two states in which the glasses display is not
visible even though the BLE session remains available.
`protocol` is reserved for incompatible revisions of this format (nothing
checks it yet); `displayMode` mirrors the phone's Display > Display mode and
is what the `display-mode` command changes. `crownClockwiseNext` mirrors the
@@ -100,9 +100,10 @@ data class PhoneState(
val listening: Boolean,
/** Display mode wire value ("576x288" | "576x480" | "640x480"). */
val displayMode: String,
// The state item also carries "battery"; the watch doesn't show it (the
// glasses' own top bar does), so it is left unparsed.
/** Current or last-known G2 charge percentage. */
val battery: Int?,
val charging: Boolean,
val silentMode: Boolean,
val foreground: AppEntry?,
val windows: List<WindowEntry>,
val apps: List<AppEntry>,
@@ -129,7 +130,9 @@ data class PhoneState(
worn = if (o.isNull("worn")) null else o.optBoolean("worn"),
listening = o.optBoolean("listening", false),
displayMode = o.optString("displayMode", "576x288"),
battery = if (o.isNull("battery")) null else o.optInt("battery", -1).takeIf { it in 0..100 },
charging = o.optBoolean("charging", false),
silentMode = o.optBoolean("silentMode", false),
foreground = foreground?.let {
AppEntry(it.optString("appId", ""), it.optString("title", ""))
},
@@ -63,6 +63,8 @@ fun padLine(state: PhoneState?, link: LinkStatus): StatusLine = when {
state == null -> StatusLine("Waiting for phone", StatusTone.BUSY)
state.remoteEnabled == false -> StatusLine("Watch control off", StatusTone.PROBLEM)
state.connected -> when {
state.charging || state.phase == "charging" -> StatusLine(chargingLine(state.battery), StatusTone.BUSY)
state.silentMode -> StatusLine("Silent mode", StatusTone.OFF)
state.locked -> StatusLine("Locked", StatusTone.OFF)
!state.screenOn -> StatusLine("●● Wake", StatusTone.OFF)
state.listening -> StatusLine("Listening…", StatusTone.BUSY)
@@ -73,6 +75,9 @@ fun padLine(state: PhoneState?, link: LinkStatus): StatusLine = when {
else -> StatusLine("Glasses disconnected", StatusTone.OFF)
}
private fun chargingLine(battery: Int?): String =
if (battery != null) "Charging · G2 $battery%" else "Charging"
fun StatusTone.color(): Color = when (this) {
StatusTone.GOOD -> Color(0xFF7BD88F)
StatusTone.BUSY -> Color(0xFFF2C14E)
@@ -42,10 +42,13 @@ fun StatusScreen(link: PhoneLink, haptics: Haptics, onOpenSettings: () -> Unit)
ScalingLazyColumn(state = listState, modifier = Modifier.fillMaxSize()) {
item { ListHeader { Text("Glasses") } }
item {
// No battery figure here: the glasses' own top bar shows it.
// Ordinarily the glasses' own top bar shows battery. While
// charging that screen is inside the case, so show it here.
val phaseLabel = when {
state == null -> "No status yet"
connected -> "Connected" + if (state?.charging == true) " · charging" else ""
state?.charging == true || state?.phase == "charging" ->
state?.battery?.let { "Charging · G2 $it%" } ?: "Charging"
connected -> "Connected"
state?.phase == "connecting" -> "Connecting…"
state?.phase == "disconnecting" -> "Disconnecting…"
else -> "Disconnected"