Skip to content

Share computeContiguousRegions walker between ATU pre-tune and SWR sweep (discrete-channel band handling) #2822

Description

@ten9876

Context

Two band-plan-aware features walk BandPlanManager::segments() to figure out where to TX within a band:

  1. ATU pre-tune (src/gui/AtuPreTuneDialog.cpp, lines 80-105) — uses a computeContiguousRegions() helper that splits the band into contiguous regions, so discrete-channel bands like US 60 m (5 separate channels with kHz-scale gaps) get walked per-region. Each channel becomes its own region; the pre-tune does NOT try to TX in the inter-channel gaps.

  2. Antenna SWR sweep (src/gui/MainWindow.cpp::startSwrSweep, post-Respect active band plan in Antenna SWR sweep (#2800). Principle IV. #2817) — uses a simpler min(lowMhz) / max(highMhz) walk across matching segments. Gives a single contiguous range, which is correct for continuous bands like 40 m / 20 m but misses the inter-channel gaps on US 60 m / Belgian 30 m etc.

For the user-reported bug in #2800 (IARU R1 40 m trip), the simpler approach is fully sufficient. But for discrete-channel bands the SWR sweep will still try to TX in inter-channel gaps and trip the interlock.

What to do

Extract computeContiguousRegions from AtuPreTuneDialog.cpp into a shared BandPlanManager helper:

// BandPlanManager.h
struct BandRegion {
    double lowMhz;
    double highMhz;
};
QVector<BandRegion> contiguousRegionsForBand(double bandLowMhz, double bandHighMhz) const;

Then:

  • AtuPreTuneDialog::recomputeBands calls the manager method instead of its private helper.
  • MainWindow::startSwrSweep calls the same method and walks ALL returned regions, sweeping each one (or pops a "This band has N discrete channels — sweep each individually?" confirm modal).

Pickup

AetherClaude-eligible. Mechanical refactor — pull a private function up into a shared module, update both call sites. The existing test for AtuPreTuneDialog already covers the region-walking math (#2648); just add a test for the SWR sweep's use of the same helper.

Principle IV — region-aware data comes from BandPlanManager. The helper belongs in the manager, not duplicated in each consumer.

73, Jeremy KK7GWY & Claude (AI dev partner)

Metadata

Metadata

Assignees

No one assigned

    Labels

    GUIUser interfaceenhancementImprovement to existing featuremaintainer-reviewRequires maintainer review before any action is takenrefactorCode cleanup, restructuring, or consolidation — no user-visible behavior changesafetyEquipment protection concern

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions