fix(power): reset LPF when adc_multiplier_override changes at runtime #9509
+9
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
power.adc_multiplier_overridechanges at runtimeinitial_read_doneflag when it changesProblem
When changing
power.adc_multiplier_overrideat runtime, the new value is saved but has no visible effect on battery voltage readings for 1-2 minutes due to the LPF slowly converging to the new value.The LPF uses a cached
last_read_valuecalculated with the old multiplier, and theinitial_read_doneflag (set on first reading) prevents immediate application of the new multiplier.Solution
Add a member variable to track the last used multiplier. When the multiplier changes, reset
initial_read_donetofalse, causing the next ADC reading to initialize the filter directly with the new scaled value.Test plan
power.adc_multiplier_overridevia CLIFixes #9508