Skip to content

Implement sending typical steps to the watch#192

Open
aveao wants to merge 5 commits into
coredevices:masterfrom
aveao:fix/typical-steps
Open

Implement sending typical steps to the watch#192
aveao wants to merge 5 commits into
coredevices:masterfrom
aveao:fix/typical-steps

Conversation

@aveao
Copy link
Copy Markdown
Contributor

@aveao aveao commented May 16, 2026

See #78

should fix step insights at the end of the day not showing typical values, plus the typical number under health app.

image

doesn't have the typical sleep one yet, that's at #194

aveao added 5 commits May 19, 2026 12:26
Adds file-private constants (bin count, bin width, history window,
minimum-history threshold, unknown sentinel) and the weekday→key map
that the upcoming typical-step writer will use. No behavior change yet.
Adds the helper signature and empty-input fast path. Subsequent commits
will fill in the binning algorithm test-by-test.
Implements buildWeekdayTypicalsFromData: single-pass binning of
HealthDataEntity rows into 7×96 (weekday × 15-min slot) aggregates,
with per-slot day-count tracking so a slot that was uncovered on
some matching days isn't underweighted. Weekdays below the 2-day
minimum-history threshold are omitted; per-slot gaps emit the
0xFFFF sentinel the watch firmware sum-skips.

Tests cover empty input, below-threshold skip, sentinel emission,
and the per-slot-vs-per-day averaging distinction.
Wires computeAllWeekdayTypicalSteps into updateHealthStatsInDatabase
so monday_steps..sunday_steps rows land in BlobDatabase.HealthStats
alongside the existing *_movementData / *_sleepData rows. The
@GenerateRoomEntity infrastructure on HealthStat pushes them to the
watch on next sync.

This fixes the missing percentage in the end-of-day activity summary
notification on PebbleOS watches (firmware activity_insights.c
prv_calc_percent_tier returns OnAverage when the typical sums to 0,
and the corresponding copy variants have no "%d%%" placeholder).
Surfaces the seven <weekday>_steps typical totals computed by
computeAllWeekdayTypicalSteps in the Health Debug Stats dialog so
the values pushed to the watch can be sanity-checked from the phone.
Each row sums the 96 15-min bins of that weekday's payload
(matching the firmware's prv_cur_step_avg sum semantics), or
shows "--" for weekdays below the 2-day minimum-history threshold.

New decodeTypicalStepTotal helper in HealthStatsSync encapsulates the
wire-format knowledge; HealthDebugStats gains a weekdayTypicalSteps
field; Health.getHealthDebugStats and FakeLibPebble.getHealthDebugStats
populate it; the iOS healthDebugStatsToJson includes it.
@aveao aveao force-pushed the fix/typical-steps branch from a34a035 to 4cadcf5 Compare May 19, 2026 10:26
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.

1 participant