Skip to content

Conversation

@lexfrei
Copy link

@lexfrei lexfrei commented Feb 2, 2026

Summary

  • Reset the Low Pass Filter when power.adc_multiplier_override changes at runtime
  • Track last used ADC multiplier value and reset initial_read_done flag when it changes
  • Allows runtime calibration to take effect immediately instead of waiting for slow LPF convergence

Problem

When changing power.adc_multiplier_override at 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_value calculated with the old multiplier, and the initial_read_done flag (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_done to false, causing the next ADC reading to initialize the filter directly with the new scaled value.

Test plan

  • Set power.adc_multiplier_override via CLI
  • Verify voltage reading updates immediately (within one ADC read cycle, ~5 seconds)
  • Change multiplier again, verify immediate effect
  • Reboot device, verify multiplier is still applied correctly

Fixes #9508

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

@lexfrei, Welcome to Meshtastic!

Thanks for opening your first pull request. We really appreciate it.

We discuss work as a team in discord, please join us in the #firmware channel.
There's a big backlog of patches at the moment. If you have time,
please help us with some code review and testing of other PRs!

Welcome to the team 😄

@github-actions github-actions bot added first-contribution bugfix Pull request that fixes bugs labels Feb 2, 2026
@lexfrei lexfrei marked this pull request as ready for review February 2, 2026 13:35
The Low Pass Filter for battery voltage readings was not resetting when
power.adc_multiplier_override was changed at runtime. This caused the
new multiplier value to take effect only after slow LPF convergence
(~1-2 minutes) instead of immediately.

Add tracking of the last used ADC multiplier and reset initial_read_done
flag when the multiplier changes, allowing runtime calibration to take
effect on the next ADC reading.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where runtime changes to power.adc_multiplier_override configuration had no immediate effect on battery voltage readings due to the Low Pass Filter (LPF) slowly converging to the new value over 1-2 minutes.

Changes:

  • Added tracking of the last used ADC multiplier value via a new member variable last_adc_multiplier
  • Reset the LPF initialization state (initial_read_done) when the multiplier changes at runtime
  • Ensures immediate application of new multiplier values instead of slow LPF convergence

@HarukiToreda HarukiToreda self-requested a review February 4, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs first-contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

power.adc_multiplier_override runtime changes have no immediate effect

1 participant