Skip to content

Commit dc07493

Browse files
eriedclaude
andcommitted
Watch PWM bar + number: safe-zone follows accent (tiers still win at >=60/>=80)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ba08776 commit dc07493

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

  • wear/src/main/java/com/eried/eucplanet/wear/ui

wear/src/main/java/com/eried/eucplanet/wear/ui/WatchApp.kt

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,27 +244,28 @@ private fun MainScreen(state: WatchState, accent: Color) {
244244
verticalAlignment = Alignment.CenterVertically,
245245
modifier = Modifier.offset(y = -(sw * 0.020f).coerceIn(6f, 12f).dp)
246246
) {
247+
// PWM safe-zone colour matches the phone dashboard: accent
248+
// when a non-default accent is picked, else safe green. The
249+
// ≥60 / ≥80 tiers always override with orange / red so the
250+
// danger signal can't be hidden by the accent.
251+
val pwmAccent = state.accentKey != "default"
252+
val pwmSafeColor = if (pwmAccent) accent else GaugeAccentGreen
247253
if (showBar) {
248254
LoadBar(
249255
percent = state.pwmPercent,
256+
safeColor = pwmSafeColor,
250257
modifier = Modifier
251258
.width(loadBarWidth * barWidthShrink)
252259
.height(loadBarHeight)
253260
)
254261
}
255262
if (showBar && showPwmNumber) Spacer(Modifier.width(6.dp))
256263
if (showPwmNumber) {
257-
// Tier scale matches the phone dashboard's LOAD card:
258-
// ≥ 80% red, ≥ 60% orange, else green (or accent for
259-
// custom accents). Disconnected -> safe-tier green so
260-
// the dash reads continuous with the speed glyph.
261-
val pwmAccent = state.accentKey != "default"
262264
val pwmNumberColor = when {
263-
pwmAccent -> accent
264-
!state.connected -> GaugeAccentGreen
265+
!state.connected -> pwmSafeColor
265266
state.pwmPercent >= 80f -> GaugeAccentRed
266267
state.pwmPercent >= 60f -> GaugeAccentOrange
267-
else -> GaugeAccentGreen
268+
else -> pwmSafeColor
268269
}
269270
val numberText = if (state.connected) "%.0f%%".format(state.pwmPercent) else DASH
270271
if (showBar) {
@@ -370,12 +371,19 @@ private fun speedTierColor(speedKmh: Float, maxSpeedKmh: Float): Color =
370371
* tells you how hard the motor is working.
371372
*/
372373
@Composable
373-
private fun LoadBar(percent: Float, modifier: Modifier = Modifier) {
374+
private fun LoadBar(
375+
percent: Float,
376+
/** Safe-zone fill colour. Matches the phone's PWM rule: accent (if a
377+
* non-default accent is picked) or green; the >=60/>=80 tiers always
378+
* override with orange/red. */
379+
safeColor: Color = Color(0xFF66BB6A),
380+
modifier: Modifier = Modifier
381+
) {
374382
val pct = percent.coerceIn(0f, 100f)
375383
val fillColor = when {
376384
pct >= 80f -> Color(0xFFEF5350)
377385
pct >= 60f -> Color(0xFFFFA726)
378-
else -> Color(0xFF66BB6A)
386+
else -> safeColor
379387
}
380388
val trackColor = Color(0xFF333333)
381389
Canvas(modifier = modifier) {

0 commit comments

Comments
 (0)