Skip to content

refactor(v2): rename SensorSnapshot, move EMAFilter to util class#92

Merged
kawinie merged 2 commits into
mainfrom
refactor/v2-load-reading
May 16, 2026
Merged

refactor(v2): rename SensorSnapshot, move EMAFilter to util class#92
kawinie merged 2 commits into
mainfrom
refactor/v2-load-reading

Conversation

@kawinie
Copy link
Copy Markdown
Collaborator

@kawinie kawinie commented May 16, 2026

Summary

Rename SensorSnapshot to LoadReading (the struct only carries vbus and current measured at the load) and adds a LoadReading overload to Filter::ema. NormalStage and EnergyStage were each running (prev*(den-1) + sample) / den for both fields. Now each stage calls Filter::ema(prev, sample, den) once. SensorEvent.snapshot becomes SensorEvent.load.

Linked issues

Hardware tested

  • None (no hardware change)

How tested: pio test -e native (130/130 passing).

Breaking change / migration

Details:

Notes

kawinie added 2 commits May 16, 2026 13:09
Both NormalStage and EnergyStage carried the same `(prev*(den-1) + sample) / den`
inline arithmetic. Lifted into `Filter::ema` so the call site reads its intent.
NormalStage and EnergyStage were each filtering vbus_mv and current_ma by hand. Folded the per-field EMA into a Filter::ema(LoadReading, ...) overload so both call sites read like single-shot smoothing. Rename frames the data as a load-side measurement, not a generic sensor blob.
@kawinie kawinie changed the title refactor(v2): rename SensorSnapshot, move EMA into Filter refactor(v2): rename SensorSnapshot, move EMAFilter to util class May 16, 2026
@kawinie kawinie requested a review from centydev May 16, 2026 20:23
@kawinie kawinie marked this pull request as ready for review May 16, 2026 20:23
@kawinie kawinie merged commit ffa3e0a into main May 16, 2026
1 check passed
@kawinie kawinie deleted the refactor/v2-load-reading branch May 18, 2026 03:57
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