fix(spectrum): smarter Floor: auto-adjust (smoothing + transient rejection)#2653
Merged
Conversation
…ansient rejection + pan instead of zoom The Display → Floor: noise-floor auto-adjust previously used a 20th-percentile / every-10-frames / zoom-the-span algorithm. Symptoms: - Visible stepping as the range changed in 10-frame jumps. - Span varied with the floor, which made signal visual heights jump. - Lightning crashes and key-up edge clicks pulled the lock immediately. Cherry-picks rfoust's algorithm work from PR #2643 ("Lock Spectrum Position") into this existing feature path instead of adding a second parallel UX: - Per-frame baseline update with asymmetric smoothing — τ = 0.08–0.12 s on drops (track noise reductions fast), τ = 1.2–8 s on rises (don't chase upward transients). - Candidate-state transient filter — ≥4 dB upward shifts must persist 16 frames / 1.2 s before being adopted; downward 2 frames / 70 ms. - Pan instead of zoom: m_refLevel slides to keep the smoothed floor at m_noiseFloorPosition; m_dynamicRange (span) stays fixed. Signals no longer change visual height when the floor drifts. - Smooth m_refLevel motion (τ = 0.10–0.24 s) instead of stepping. - Command throttling — ≥150 ms / ≥0.75 dB between dbmRangeChangeRequested emits so the radio isn't flooded. - Two-pass trimmed-mean noise-floor estimator extracted into a shared estimateNoiseFloorDbm() helper (was duplicated between the floor overlay line and the auto-adjust path). - Reset triggers in zoom / band-change / dBm-drag / pan-recenter paths so the baseline re-acquires after disruptions (5 fresh frames force the baseline rather than smoothing from a stale value). Driven by the existing m_noiseFloorEnable toggle (Display → Floor) and m_noiseFloorPosition slider (0=top, 100=bottom). No new menu entries, no new toggles — the existing UX gets the upgraded algorithm. PR #2643 (the "Lock Spectrum Position" right-click toggle that this work is derived from) is closed in favour of this consolidation: two implementations of the same feature would have been confusing for users and a maintenance burden. Co-Authored-By: rfoust <rfoust@users.noreply.github.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Consolidates rfoust's "Lock Spectrum Position" algorithm work from #2643 into the existing Display → Floor: noise-floor auto-adjust feature instead of adding a second parallel UX entry point.
The existing Floor: toggle used a 20th-percentile / every-10-frames / zoom-the-span approach that produced:
This PR replaces the algorithm with the smoothing + transient rejection logic from #2643 (with permission and attribution preserved via co-author), driving it through the existing toggle + slider so users get the upgrade without learning a new UI surface.
What's in the new algorithm
UX
No new menu entries, no new toggles. The existing Display → Floor: button drives the new algorithm. The position slider behaves the same. The dBm-scale drag is now also captured as a new target position (consistent with rfoust's original design).
Validation
Closes
Co-authored with rfoust (algorithm) and Claude.
73, Jeremy KK7GWY & Claude (AI dev partner)