From 147fdc514d08c26249069ad31fe882707c58d2b6 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Wed, 9 Oct 2024 02:16:14 -0700 Subject: [PATCH] Niceities when working with the webpage. --- ch32v/lib/calculator.html | 34 ++++++++++++++++++++++------------ ch32v/lib/webhidcontrol.js | 4 ++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ch32v/lib/calculator.html b/ch32v/lib/calculator.html index dcce01e..420d29c 100644 --- a/ch32v/lib/calculator.html +++ b/ch32v/lib/calculator.html @@ -28,14 +28,16 @@ var lastGmhz; var lastGfr; var lastGbrf; var lastGexact; +var lastTargetMHz; -function Goertz( n, mhz, fr, brf, exact_compute ) +function Goertz( n, mhz, fr, brf, exact_compute, targetmhz ) { lastGn = n; lastGmhz = mhz; lastGfr = fr; lastGbrf = brf; lastGexact = exact_compute; + lastTargetMHz = targetmhz; SendGoertz(); } @@ -91,8 +93,8 @@ function SendGoertz() ] ); // Update toggle control - let target = Number(document.getElementById("targetmhz").value ); - var tz = (target * 10000000.0); + let target = lastTargetMHz; + var tz = (target * 10000000.0) + 0.05; for( var i = 0|0; i < 10; i++ ) { var tc = (tz / 1000000000.0) % 10; @@ -158,7 +160,7 @@ function mhzm( event, ths ) quantaA = tquanta; tgoertzelp = h; - Goertz( n, freq * (h+tgoertzelpoint), (tgoertzelpoint), quantaA , 1); + Goertz( n, freq * (h+tgoertzelpoint), (tgoertzelpoint), quantaA , 1, target); return false; } @@ -210,7 +212,7 @@ function computeTable() if( goertzels || quadrature ) { - contents += "
Scroll Wheel Control:
"; + contents += "
Scroll Wheel Control:
"; contents += ""; contents += ''; for( let h = 0|min_harmonics; h <= max_harmonics; h++ ) @@ -284,7 +286,7 @@ function computeTable() if( mode == 0 ) { contents += ""; } else if( mode == 1 ) @@ -294,7 +296,7 @@ function computeTable() else if( mode == 2 ) { contents += ""; } else if( mode == 3 ) @@ -314,7 +316,7 @@ function computeTable() contents += "
d\\h" - if( tgoertzelp == h ) contents += ""; + if( tgoertzelp == h ) contents += ""; contents += "" - if( tgoertzelpi == h-1 ) contents += ""; + if( tgoertzelpi == h-1 ) contents += ""; contents += "
" } } @@ -391,7 +393,7 @@ function computeTable() document.getElementById( "TABLE" ).innerHTML = contents; } -const savedFields = ["crystalmhz", "targetmhz", "QUADRATURE", "GOERTZELS", "GOERTZELS2", "quanta", "quantasearch"]; +const savedFields = ["crystalmhz", "targetmhz", "quanta", "quantasearch", "toggle_adc_buffer"]; function SaveDefaults() { @@ -412,9 +414,16 @@ function LoadDefaults() { let f = savedFields[i]; let e = document.getElementById(f); - if( e && localStorage.getItem( f ) ) + let v = localStorage.getItem( f ); + console.log( `Loading: ${e} ${f} ${v}`); + if( e && v ) { - e.value = localStorage.getItem( f ); + if( v == 'on' ) + e.checked = true; + else if( v == 'off' ) + e.checked = false; + else + e.value = v; } } } @@ -467,6 +476,7 @@ Live Control:
"; // Add widget to control various things, realtime. - contents += "
Scroll Wheel Control:
"; + contents += "
Scroll Wheel Control:
"; contents += ""; contents += ""; contents += "."; @@ -363,7 +365,7 @@ function computeTable() if( rid == 0 ) { contents += "
" - contents += ""; + contents += ""; contents += "
+
diff --git a/ch32v/lib/webhidcontrol.js b/ch32v/lib/webhidcontrol.js index 60154d9..5eadb57 100644 --- a/ch32v/lib/webhidcontrol.js +++ b/ch32v/lib/webhidcontrol.js @@ -187,7 +187,7 @@ async function toggleAudio() gainParam.setValueAtTime( 0, audioContext.currentTime ); } - var newVal = 0.5 - targetGain; + var newVal = 1.0 - targetGain; console.log( "Setting gain to: " + newVal ); let gainParam = playingAudioProcessor.parameters.get("gain"); gainParam.setValueAtTime( newVal, audioContext.currentTime); @@ -441,7 +441,7 @@ async function sendLoop() var po = FMphaseout = FMphaseout * 0.993 + diffphase; if( po < 0.0 ) po += 1.0; if( po > 1.0 ) po -= 1.0; - demodbuffer[i] = po; + demodbuffer[i] = po * .3; // Turn down FM it's really loud. } IQHistoryHead = (IQHistoryHead+1)%IQHistoryLen;