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';
BtnMute.Invalidate;
end;
rfNR: UpdateNRButton;
rfNB: UpdateNBButton;
rfSNB: UpdateSNBButton;
rfANF: UpdateANFButton;
end;
finally
FSyncingFromController := False;
@@ -5912,30 +5916,26 @@ end;
procedure TMainForm.BtnNRClick(Sender: TObject);
begin
FController.FNRMode := (FController.FNRMode + 1) mod 5;
UpdateNRButton;
if FController.FWDSPReady then FController.FDSPEngine.SetNRMode(FController.FNRMode);
if FSyncingFromController then Exit;
FController.SetNR((FController.FNRMode + 1) mod 5);
end;
procedure TMainForm.BtnNBClick(Sender: TObject);
begin
FController.FNBMode := (FController.FNBMode + 1) mod 3;
UpdateNBButton;
if FController.FWDSPReady then FController.FDSPEngine.SetNBMode(FController.FNBMode);
if FSyncingFromController then Exit;
FController.SetNB((FController.FNBMode + 1) mod 3);
end;
procedure TMainForm.BtnSNBClick(Sender: TObject);
begin
FController.FSNB := not FController.FSNB;
UpdateSNBButton;
if FController.FWDSPReady then FController.FDSPEngine.SetSNB(FController.FSNB);
if FSyncingFromController then Exit;
FController.SetSNB(not FController.FSNB);
end;
procedure TMainForm.BtnANFClick(Sender: TObject);
begin
FController.FANF := not FController.FANF;
UpdateANFButton;
if FController.FWDSPReady then FController.FDSPEngine.SetANF(FController.FANF);
if FSyncingFromController then Exit;
FController.SetANF(not FController.FANF);
end;
@@ -6078,11 +6078,11 @@ end;
procedure TMainForm.OnVfoOverlayDSPChange(NRMode, NBMode: Integer; SNBOn, ANFOn: Boolean);
begin
FController.FNRMode := NRMode; UpdateNRButton;
FController.FNBMode := NBMode; UpdateNBButton;
FController.FSNB := SNBOn; UpdateSNBButton;
FController.FANF := ANFOn; UpdateANFButton;
ApplyNoiseFilterButtonsToDSP;
// Команды контроллера применяют к DSP и через OnControllerState обновляют кнопки.
FController.SetNR(NRMode);
FController.SetNB(NBMode);
FController.SetSNB(SNBOn);
FController.SetANF(ANFOn);
end;
procedure TMainForm.OnVfoOverlayAGCChange(AGCMode: Integer);
@@ -6483,14 +6483,7 @@ end;
procedure TMainForm.SyncWebNR;
begin
if FWebSyncInt < 0 then FWebSyncInt := 0;
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;
FController.SetNR(FWebSyncInt); // клампит и применяет; OnControllerState обновит кнопку
end;
// ── NB ────────────────────────────────────────────────────────────────────
@@ -6504,14 +6497,7 @@ end;
procedure TMainForm.SyncWebNB;
begin
if FWebSyncInt < 0 then FWebSyncInt := 0;
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;
FController.SetNB(FWebSyncInt); // клампит и применяет; OnControllerState обновит кнопку
end;
procedure TMainForm.WebOnSNB(On_: Boolean);
@@ -6523,8 +6509,7 @@ end;
procedure TMainForm.SyncWebSNB;
begin
if FWebSyncBool <> (FController.FSNB) then
BtnSNBClick(BtnSNB);
FController.SetSNB(FWebSyncBool);
end;
// ── ANF ───────────────────────────────────────────────────────────────────
@@ -6538,8 +6523,7 @@ end;
procedure TMainForm.SyncWebANF;
begin
if FWebSyncBool <> (FController.FANF) then
BtnANFClick(BtnANF);
FController.SetANF(FWebSyncBool);
end;
// ── VFO-B freq (из веба) ─────────────────────────────────────────────────
+22 -4
View File
@@ -446,16 +446,34 @@ procedure TRadioController.SetWfNF(On_: Boolean);
begin FWfNFEnabled := On_; Changed(rfWfNF); end;
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);
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);
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);
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);
begin FTransmitting := On_; Changed(rfTransmitting); { TODO wiring: ApplyMOX } end;