Skip to content

Current row: moment value with windowed average, stable visibility (#173)#175

Merged
almothafar merged 4 commits into
masterfrom
feat/173-current-avg-display
Jul 17, 2026
Merged

Current row: moment value with windowed average, stable visibility (#173)#175
almothafar merged 4 commits into
masterfrom
feat/173-current-avg-display

Conversation

@almothafar

@almothafar almothafar commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Follow-up to the #152 fixes, from on-device testing on the Mate 10 Pro. Base is master (#169/#170 merged; branch rebased).

The Current row blinked in and out whenever the instantaneous reading dipped below the 10 mA display floor, and each surface showed its own instant. Maintainer direction: keep the moment value as the headline (no smoothing it away, no show/hide flapping, no "—" placeholder) and show the windowed average alongside.

What it looks like now

Current : −208 mA
          avg: −245 mA      ← second line, 0.8× size, label colour
  • The average gets its own smaller, dimmer line under the moment value (the earlier inline (avg: −245) wrapped mid-parenthesis in narrow columns, larger font scales, and Arabic).
  • The avg value goes through the same formatCurrentValue as the instant, so sign style, mA unit, and the Western-digit guarantee (Battery details table: fix RTL alignment + use Western digits for numbers #96) can't drift.
  • Arabic deliberately keeps the Latin "avg" label (maintainer decision): the line is Latin-heavy already (sign + mA), and a lone Arabic word would break the text direction. Wording may be revisited later.

Behavior

  • Average: the same rolling 10-minute window the %/h rate uses (≥ 3 plausible readings over ≥ 45 s, extracted into a shared averagedCurrentMicroAmps helper so rate source A and the displayed average can't disagree). Resets on plug/unplug like the rate; until it's ready the row shows the instant alone.
  • Stable visibility: the 10 mA floor gate runs on the average when available, instant-only while the window is fresh. The average moves slowly → the row's presence is stable; a momentary dip no longer hides it, while sustained garbage (pre-calibration Kirin ~1 mA averages) stays hidden as before.
  • Notification: mA fallback unchanged (instant only — the line is already long); it inherits the stable gate via hasCurrent.
  • BatteryRate gains hasAvgCurrent/avgCurrentMilliAmps; table cells accept CharSequence so the styled value flows through; new string battery_current_avg_line.

Tests

Dip-below-floor stays shown via the avg gate; sustained sub-floor average hidden; fresh window gates on the instant without the avg line; averagedCurrentMicroAmps boundaries (mean, implausible-skip, short span, too few); formatAverageCurrentLine under en + ar. testDebugUnitTest + lintDebug green.

On-device

Watch the Current row through a normal session — it should tick but never blink out, with the avg line appearing ~45 s into a steady window and tracking the sustained draw.

Closes #173

🤖 Generated with Claude Code

Base automatically changed from fix/152-current-unit-calibration-v2 to master July 17, 2026 12:51
almothafar and others added 2 commits July 17, 2026 15:56
…erage (#173)

The Current row flickered in and out when the instantaneous reading
dipped below the 10 mA display floor, and each surface showed its own
instant. Keep the moment value as the headline but display the
windowed average next to it ("-208 mA (avg: -245)"), and let the
average carry the floor gate when available: the average moves slowly,
so the row's visibility is stable, while sustained garbage (whose
average also sits below the floor) stays hidden exactly as before.

The average reuses source A's smoothing criteria, extracted into a
shared averagedCurrentMicroAmps helper so the rate source and the
displayed average cannot disagree. The notification's mA fallback
stays instant-only (the line is already long) and inherits the stable
gate for free.

Arabic drafted for the new string, pending maintainer review.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The inline "-208 mA (avg: -245)" wrapped mid-parenthesis in narrow
columns, larger font scales, and Arabic (maintainer on-device
feedback). Move the average to a second line under the moment value,
rendered at 0.8x size in the label colour so it reads as a quiet
anchor rather than competing with the instant. Table cells accept a
CharSequence now so the styled value flows through unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@almothafar
almothafar force-pushed the feat/173-current-avg-display branch from 4c1acc8 to 0e84a40 Compare July 17, 2026 12:58
@almothafar

Copy link
Copy Markdown
Owner Author

Updated after on-device feedback + the #169/#170 merges:

🤖 Generated with Claude Code

almothafar and others added 2 commits July 17, 2026 16:01
The unitless "avg: -245" was a leftover of the abandoned inline
layout's width squeeze; on its own line the unit costs nothing and
reads clearer. Route the value through formatCurrentValue so sign,
unit, and Western-digit handling can't drift from the instant above.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Maintainer decision: the line is Latin-heavy already (sign + mA), so a
lone Arabic word would just break the text direction. Wording to be
revisited later.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@almothafar
almothafar merged commit 31d0d9b into master Jul 17, 2026
2 checks passed
@almothafar
almothafar deleted the feat/173-current-avg-display branch July 17, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Current row flickers and disagrees between surfaces — show moment value with windowed average, gate visibility on the average

1 participant