Phase 3 (batch 1): route NR/NB/SNB/ANF through controller commands

Apply the slice pattern to the noise-filter controls:
- TRadioController.SetNR/SetNB/SetSNB/SetANF now clamp and apply to the DSP
  engine, then fire OnStateChanged.
- OnControllerState refreshes the matching button (UpdateNR/NB/SNB/ANF).
- Click handlers, SyncWebNR/NB/SNB/ANF, and OnVfoOverlayDSPChange all call
  the commands instead of poking fields/widgets and the DSP directly.

UI clicks, the web client, and the VFO overlay now share one path; the
web client already renders these fields in applyState, so UI->web syncs.
Builds clean (cocoa); behavior unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-04 11:20:40 +03:00
co-authored by Claude Opus 4.8
parent a85f196c97
commit ff42889fa1
2 changed files with 43 additions and 41 deletions
+21 -37
View File
@@ -1431,6 +1431,10 @@ begin
else BtnMute.Caption := 'MUTE'; else BtnMute.Caption := 'MUTE';
BtnMute.Invalidate; BtnMute.Invalidate;
end; end;
rfNR: UpdateNRButton;
rfNB: UpdateNBButton;
rfSNB: UpdateSNBButton;
rfANF: UpdateANFButton;
end; end;
finally finally
FSyncingFromController := False; FSyncingFromController := False;
@@ -5912,30 +5916,26 @@ end;
procedure TMainForm.BtnNRClick(Sender: TObject); procedure TMainForm.BtnNRClick(Sender: TObject);
begin begin
FController.FNRMode := (FController.FNRMode + 1) mod 5; if FSyncingFromController then Exit;
UpdateNRButton; FController.SetNR((FController.FNRMode + 1) mod 5);
if FController.FWDSPReady then FController.FDSPEngine.SetNRMode(FController.FNRMode);
end; end;
procedure TMainForm.BtnNBClick(Sender: TObject); procedure TMainForm.BtnNBClick(Sender: TObject);
begin begin
FController.FNBMode := (FController.FNBMode + 1) mod 3; if FSyncingFromController then Exit;
UpdateNBButton; FController.SetNB((FController.FNBMode + 1) mod 3);
if FController.FWDSPReady then FController.FDSPEngine.SetNBMode(FController.FNBMode);
end; end;
procedure TMainForm.BtnSNBClick(Sender: TObject); procedure TMainForm.BtnSNBClick(Sender: TObject);
begin begin
FController.FSNB := not FController.FSNB; if FSyncingFromController then Exit;
UpdateSNBButton; FController.SetSNB(not FController.FSNB);
if FController.FWDSPReady then FController.FDSPEngine.SetSNB(FController.FSNB);
end; end;
procedure TMainForm.BtnANFClick(Sender: TObject); procedure TMainForm.BtnANFClick(Sender: TObject);
begin begin
FController.FANF := not FController.FANF; if FSyncingFromController then Exit;
UpdateANFButton; FController.SetANF(not FController.FANF);
if FController.FWDSPReady then FController.FDSPEngine.SetANF(FController.FANF);
end; end;
@@ -6078,11 +6078,11 @@ end;
procedure TMainForm.OnVfoOverlayDSPChange(NRMode, NBMode: Integer; SNBOn, ANFOn: Boolean); procedure TMainForm.OnVfoOverlayDSPChange(NRMode, NBMode: Integer; SNBOn, ANFOn: Boolean);
begin begin
FController.FNRMode := NRMode; UpdateNRButton; // Команды контроллера применяют к DSP и через OnControllerState обновляют кнопки.
FController.FNBMode := NBMode; UpdateNBButton; FController.SetNR(NRMode);
FController.FSNB := SNBOn; UpdateSNBButton; FController.SetNB(NBMode);
FController.FANF := ANFOn; UpdateANFButton; FController.SetSNB(SNBOn);
ApplyNoiseFilterButtonsToDSP; FController.SetANF(ANFOn);
end; end;
procedure TMainForm.OnVfoOverlayAGCChange(AGCMode: Integer); procedure TMainForm.OnVfoOverlayAGCChange(AGCMode: Integer);
@@ -6483,14 +6483,7 @@ end;
procedure TMainForm.SyncWebNR; procedure TMainForm.SyncWebNR;
begin begin
if FWebSyncInt < 0 then FWebSyncInt := 0; FController.SetNR(FWebSyncInt); // клампит и применяет; OnControllerState обновит кнопку
if FWebSyncInt > 4 then FWebSyncInt := 4;
if FController.FNRMode <> FWebSyncInt then
begin
FController.FNRMode := FWebSyncInt;
UpdateNRButton;
if FController.FWDSPReady then FController.FDSPEngine.SetNRMode(FController.FNRMode);
end;
end; end;
// ── NB ──────────────────────────────────────────────────────────────────── // ── NB ────────────────────────────────────────────────────────────────────
@@ -6504,14 +6497,7 @@ end;
procedure TMainForm.SyncWebNB; procedure TMainForm.SyncWebNB;
begin begin
if FWebSyncInt < 0 then FWebSyncInt := 0; FController.SetNB(FWebSyncInt); // клампит и применяет; OnControllerState обновит кнопку
if FWebSyncInt > 2 then FWebSyncInt := 2;
if FController.FNBMode <> FWebSyncInt then
begin
FController.FNBMode := FWebSyncInt;
UpdateNBButton;
if FController.FWDSPReady then FController.FDSPEngine.SetNBMode(FController.FNBMode);
end;
end; end;
procedure TMainForm.WebOnSNB(On_: Boolean); procedure TMainForm.WebOnSNB(On_: Boolean);
@@ -6523,8 +6509,7 @@ end;
procedure TMainForm.SyncWebSNB; procedure TMainForm.SyncWebSNB;
begin begin
if FWebSyncBool <> (FController.FSNB) then FController.SetSNB(FWebSyncBool);
BtnSNBClick(BtnSNB);
end; end;
// ── ANF ─────────────────────────────────────────────────────────────────── // ── ANF ───────────────────────────────────────────────────────────────────
@@ -6538,8 +6523,7 @@ end;
procedure TMainForm.SyncWebANF; procedure TMainForm.SyncWebANF;
begin begin
if FWebSyncBool <> (FController.FANF) then FController.SetANF(FWebSyncBool);
BtnANFClick(BtnANF);
end; end;
// ── VFO-B freq (из веба) ───────────────────────────────────────────────── // ── VFO-B freq (из веба) ─────────────────────────────────────────────────
+22 -4
View File
@@ -446,16 +446,34 @@ procedure TRadioController.SetWfNF(On_: Boolean);
begin FWfNFEnabled := On_; Changed(rfWfNF); end; begin FWfNFEnabled := On_; Changed(rfWfNF); end;
procedure TRadioController.SetNR(Mode: Integer); procedure TRadioController.SetNR(Mode: Integer);
begin FNRMode := Mode; Changed(rfNR); { TODO wiring: FDSPEngine.SetNRMode } end; begin
if Mode < 0 then Mode := 0 else if Mode > 4 then Mode := 4;
FNRMode := Mode;
if FWDSPReady and Assigned(FDSPEngine) then FDSPEngine.SetNRMode(FNRMode);
Changed(rfNR);
end;
procedure TRadioController.SetNB(Mode: Integer); procedure TRadioController.SetNB(Mode: Integer);
begin FNBMode := Mode; Changed(rfNB); { TODO wiring } end; begin
if Mode < 0 then Mode := 0 else if Mode > 2 then Mode := 2;
FNBMode := Mode;
if FWDSPReady and Assigned(FDSPEngine) then FDSPEngine.SetNBMode(FNBMode);
Changed(rfNB);
end;
procedure TRadioController.SetSNB(On_: Boolean); procedure TRadioController.SetSNB(On_: Boolean);
begin FSNB := On_; Changed(rfSNB); { TODO wiring } end; begin
FSNB := On_;
if FWDSPReady and Assigned(FDSPEngine) then FDSPEngine.SetSNB(FSNB);
Changed(rfSNB);
end;
procedure TRadioController.SetANF(On_: Boolean); procedure TRadioController.SetANF(On_: Boolean);
begin FANF := On_; Changed(rfANF); { TODO wiring } end; begin
FANF := On_;
if FWDSPReady and Assigned(FDSPEngine) then FDSPEngine.SetANF(FANF);
Changed(rfANF);
end;
procedure TRadioController.SetMOX(On_: Boolean); procedure TRadioController.SetMOX(On_: Boolean);
begin FTransmitting := On_; Changed(rfTransmitting); { TODO wiring: ApplyMOX } end; begin FTransmitting := On_; Changed(rfTransmitting); { TODO wiring: ApplyMOX } end;