mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 17:27:32 +00:00
Add configurable VFO frequency range with GHz support
- Settings > Display: new "VFO Display" control to select max frequency range (999 MHz / 9.999 GHz / 99.999 GHz), persisted as freq_mhz_digits - FreqDisplay: extend digit map [0..10] to support up to 11 digit positions; keyboard navigation adapts to MinMhzDigits dynamically - MainForm/LayoutTopVfoBlock: VFO panel width scales automatically with selected digit count using dynamic text measurement - Web VFO: fix broken HTML (class attr not closed before data-s — wheel and hover were completely non-functional); rewrite fmtVfo to use variable MHz digit count synced from server state; fix missing </span> for .vfo-hz - WebServer: publish freq_mhz_digits in state JSON; updated from ApplyFreqMhzDigits so desktop and web stay in sync - Fix Int32 overflow on frequencies above ~2.15 GHz: CATEngine.Pad V param Int64, FormatFreq/FormatFreqSV Mhz var Int64 (Mhz*1000000 overflowed) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+18
-11
@@ -323,22 +323,28 @@ begin
|
||||
'q("muteIc").onclick=()=>{cur.mute=!cur.mute;q("muteIc").textContent=cur.mute?"\uD83D\uDD07":"\uD83D\uDD0A";cmd("set_mute",cur.mute);};' +
|
||||
|
||||
'let stA=0,stAmem=100,stB=0,stBmem=100;' +
|
||||
'let freqMhzDigits=3,freqMaxHz=999999999;' +
|
||||
'function fmtVfo(hz,step){' +
|
||||
'const s=String(Math.max(0,Math.round(hz||0))).padStart(9,"0");' +
|
||||
'const N=freqMhzDigits+6;' +
|
||||
'const s=String(Math.max(0,Math.round(hz||0))).padStart(N,"0");' +
|
||||
'let h="",seenNZ=false;' +
|
||||
'for(let i=0;i<6;i++){' +
|
||||
'const st=Math.pow(10,8-i);' +
|
||||
'for(let i=0;i<freqMhzDigits;i++){' +
|
||||
'const st=Math.pow(10,freqMhzDigits+5-i);' +
|
||||
'if(s[i]!=="0")seenNZ=true;' +
|
||||
'const lead=(!seenNZ)?" lead":"";' +
|
||||
'const sel=(step>0&&st===step)?" sel":"";' +
|
||||
'h+="<span class=\"dg"+lead+sel+" data-s=\""+st+"\">"+s[i]+"</span>";' +
|
||||
'if(i===2)h+="<span class=\"sp\">.</span>";}' +
|
||||
'h+="<span class=\"dg"+lead+sel+"\" data-s=\""+st+"\">"+s[i]+"</span>";}' +
|
||||
'h+="<span class=\"sp\">.</span>";' +
|
||||
'h+="<span class=\"vfo-hz\">";' +
|
||||
'for(let i=6;i<9;i++){const st=Math.pow(10,8-i);' +
|
||||
'for(let i=freqMhzDigits;i<freqMhzDigits+3;i++){' +
|
||||
'const st=Math.pow(10,freqMhzDigits+5-i);' +
|
||||
'const sel=(step>0&&st===step)?" sel":"";' +
|
||||
'h+="<span class=\"dg"+sel+" data-s=\""+st+"\">"+s[i]+"</span>";}' +
|
||||
'return h;}' +
|
||||
'h+="<span class=\"dg"+sel+"\" data-s=\""+st+"\">"+s[i]+"</span>";}' +
|
||||
'h+="<span class=\"sp\">.</span><span class=\"vfo-hz\">";' +
|
||||
'for(let i=freqMhzDigits+3;i<N;i++){' +
|
||||
'const st=Math.pow(10,freqMhzDigits+5-i);' +
|
||||
'const sel=(step>0&&st===step)?" sel":"";' +
|
||||
'h+="<span class=\"dg"+sel+"\" data-s=\""+st+"\">"+s[i]+"</span>";}' +
|
||||
'h+="</span>";return h;}' +
|
||||
'function renderVfos(){q("vDispA").innerHTML=fmtVfo(vfoA,stA);q("vDispB").innerHTML=fmtVfo(vfoB,stB);}' +
|
||||
|
||||
'function bindVfo(dispId,getHz,setHz,getSt,setSt,getMem,setMem,onSend){' +
|
||||
@@ -348,12 +354,12 @@ begin
|
||||
'el.addEventListener("mouseleave",()=>{if(getSt()!==0){setSt(0);renderVfos();}});' +
|
||||
'el.addEventListener("wheel",e=>{e.preventDefault();e.stopPropagation();audioKick();' +
|
||||
'const dir=e.deltaY<0?1:-1,st=getSt()||getMem()||100;' +
|
||||
'const nf=cl(Math.round(getHz())+st*dir,30000,60000000);' +
|
||||
'const nf=cl(Math.round(getHz())+st*dir,30000,freqMaxHz);' +
|
||||
'setHz(nf);onSend(nf);},{passive:false});' +
|
||||
'el.addEventListener("dblclick",()=>{' +
|
||||
'const s=prompt("Set Hz",String(Math.round(getHz())));if(!s)return;' +
|
||||
'const f=parseInt(s.replace(/[^0-9]/g,""),10);if(!isFinite(f))return;' +
|
||||
'const nf=cl(f,30000,60000000);setHz(nf);renderVfos();onSend(nf);' +
|
||||
'const nf=cl(f,30000,freqMaxHz);setHz(nf);renderVfos();onSend(nf);' +
|
||||
'});}' +
|
||||
'bindVfo("vDispA",()=>vfoA,v=>{vfoA=v;},()=>stA,v=>{stA=v;},()=>stAmem,v=>{stAmem=v;},' +
|
||||
'function(nf){renderVfos();pend("freq");if(activeVfo==="A"){localCenter=nf;ws2({cmd:"freq",hz:nf});}else ws2({cmd:"freq_b",hz:nf});});' +
|
||||
@@ -483,6 +489,7 @@ begin
|
||||
'}' +
|
||||
'if(!isPending("freq")){vfoA=cur.vfo_a_hz||vfoA;}' +
|
||||
'if(msg.vfo_b_hz!=null)vfoB=msg.vfo_b_hz;' +
|
||||
'if(msg.freq_mhz_digits!=null){freqMhzDigits=Math.max(3,Math.min(5,msg.freq_mhz_digits|0));freqMaxHz=Math.pow(10,freqMhzDigits+6)-1;}' +
|
||||
'if(msg.active_vfo!=null&&!isPending("freq")){' +
|
||||
'const sv=msg.active_vfo===0?"A":"B";' +
|
||||
'if(sv!==activeVfo){activeVfo=sv;' +
|
||||
|
||||
Reference in New Issue
Block a user