From 685370c91f9eb17148473fbf40a040fcee39df60 Mon Sep 17 00:00:00 2001 From: Uladzimir Karpenka Date: Mon, 25 May 2026 12:45:43 +0300 Subject: [PATCH] Snap frequency to FM step on spectrum/waterfall click when Step is enabled Co-Authored-By: Claude Sonnet 4.6 --- MainForm.pas | 5 ++++- WebPageHtml.pas | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MainForm.pas b/MainForm.pas index 5ca3a0c..29a17a0 100644 --- a/MainForm.pas +++ b/MainForm.pas @@ -4659,7 +4659,10 @@ var BandIdx: Integer; begin if PanelWidth <= 0 then Exit; - StepHz := 100; + if (FMode = MODE_FM) and FFMStepOn then + StepHz := FM_STEP_HZ[FFMStepIdx] + else + StepHz := 100; ClickFreq := Round(FCenterFreq + (PixelX / PanelWidth - 0.5) * FSpanHz); ClickFreq := (ClickFreq div StepHz) * StepHz; if FActiveVfo = 0 then diff --git a/WebPageHtml.pas b/WebPageHtml.pas index aedd028..033c23d 100644 --- a/WebPageHtml.pas +++ b/WebPageHtml.pas @@ -768,7 +768,8 @@ begin 'if(dragging&&Math.abs(e.offsetX-dragX0)<4){' + // клик — не трогаем localCenter: фильтр встаёт точно туда куда кликнули. // Спектр остаётся на месте, сервер пришлёт center_hz через ~200ms и всё перецентрируется. - 'const nf=cl(Math.round(xToHz(e.offsetX,cv.clientWidth)/100)*100,vfoMin(),vfoMax());' + + 'const snap=(cur.mode===5&&inFMStep)?FM_STEP_HZ[fmStepIdx]:100;' + + 'const nf=cl(Math.round(xToHz(e.offsetX,cv.clientWidth)/snap)*snap,vfoMin(),vfoMax());' + 'setActiveVfoHz(nf);' + 'if(activeVfo==="A")cur.vfo_a_hz=nf;else cur.vfo_b_hz=nf;' + 'renderVfos();pend("freq");ws2({cmd:"freq",hz:nf});' +