diff --git a/ch32v/ch32v003fun b/ch32v/ch32v003fun
index 119924c..b987542 160000
--- a/ch32v/ch32v003fun
+++ b/ch32v/ch32v003fun
@@ -1 +1 @@
-Subproject commit 119924c0d9ee02b8c069254d37d2a89921820689
+Subproject commit b987542621b715eacca818dcf3ef6856777d7d75
diff --git a/ch32v/ch32v203-goertzel/README.md b/ch32v/ch32v203-goertzel/README.md
index 0513839..a26f283 100644
--- a/ch32v/ch32v203-goertzel/README.md
+++ b/ch32v/ch32v203-goertzel/README.md
@@ -27,3 +27,6 @@ TODO: TODO: Test HTML values.
TODO: TODO: g_goertzel_omega_per_sample lokos WRONG.
+
+Extra notes:
+ .87996033 = 880 AM, why?
diff --git a/ch32v/ch32v203-goertzel/adcgoertzel.c b/ch32v/ch32v203-goertzel/adcgoertzel.c
index be2a2d5..2e05330 100644
--- a/ch32v/ch32v203-goertzel/adcgoertzel.c
+++ b/ch32v/ch32v203-goertzel/adcgoertzel.c
@@ -201,7 +201,8 @@ void SetupADC()
// ADC_SCAN: Allow scanning.
ADC1->CTLR1 =
//ADC_SCAN;
- ADC_Pga_16 | ADC_SCAN;
+ ADC_SCAN | ADC_BUFEN ;
+ //ADC_Pga_16 | ADC_SCAN | ADC_BUFEN ;
//ADC_Pga_64 | ADC_SCAN;
@@ -753,6 +754,23 @@ void HandleHidUserReportOutComplete( struct _USBState * ctx )
if( numconfigs > 5) g_exactcompute = configs[7];
if( numconfigs > 6) g_goertzel_advance_r = configs[8];
if( numconfigs > 7) g_goertzel_advance_i = configs[9];
+ if( numconfigs > 8)
+ {
+ int adc_buffer = configs[10];
+ if( adc_buffer )
+ {
+ // Consider using PGA.
+ //ADC_Pga_16 | ADC_SCAN | ADC_BUFEN ;
+ //ADC_Pga_64 | ADC_SCAN;
+ ADC1->CTLR1 =
+ ADC_SCAN | ADC_BUFEN;
+ }
+ else
+ {
+ ADC1->CTLR1 =
+ ADC_SCAN;
+ }
+ }
// Need to reset so we don't blast by.
g_goertzel_samples = 0;
diff --git a/ch32v/lib/calculator.html b/ch32v/lib/calculator.html
index a95292a..d140329 100644
--- a/ch32v/lib/calculator.html
+++ b/ch32v/lib/calculator.html
@@ -22,8 +22,30 @@ function DrawSpan( rowspan, colspan, freq, target, docolor, extrastr = "" )
return ret;
}
+var lastGn;
+var lastGmhz;
+var lastGfr;
+var lastGbrf;
+var lastGexact;
+
function Goertz( n, mhz, fr, brf, exact_compute )
{
+ lastGn = n;
+ lastGmhz = mhz;
+ lastGfr = fr;
+ lastGbrf = brf;
+ lastGexact = exact_compute;
+ SendGoertz();
+}
+
+function SendGoertz()
+{
+ var n = lastGn;
+ var mhz = lastGmhz;
+ var fr = lastGfr;
+ var brf = lastGbrf;
+ var exact_compute = lastGexact;
+
let tau = 3.1415926535*2.0;
let omega = fr * tau;
var textarea = document.getElementById("goertzeloutput");
@@ -64,7 +86,76 @@ function Goertz( n, mhz, fr, brf, exact_compute )
exact_compute|0,
g_goertzel_advance_r|0,
g_goertzel_advance_i|0,
+ document.getElementById( "toggle_adc_buffer").checked ? 1 : 0,
] );
+
+ // Update toggle control
+ let target = Number(document.getElementById("targetmhz").value );
+ var tz = (target * 10000000.0);
+ for( var i = 0|0; i < 10; i++ )
+ {
+ var tc = (tz / 1000000000.0) % 10;
+ document.getElementById( "mhzm" + i ).value = tc|0;
+ tz *= 10;
+ }
+}
+
+function toggleBuffer( ths )
+{
+ SendGoertz();
+}
+
+function mhzm( event, ths )
+{
+ event.preventDefault();
+ let dy = event.deltaY > 0 ? -1 : 1;
+ var thss = Number(ths.id.substr(4));
+
+ var hz = 0; // actually tents of hertz
+ for( var i = 0|0; i < 10; i++ )
+ {
+ var dig = Number(document.getElementById( "mhzm" + i ).value);
+ hz += Math.pow( 10, 9-i ) * dig;
+ }
+
+ hz += dy * Math.pow( 10, 9-thss );
+
+ lastGmhz = hz/10000000.0;
+ document.getElementById("targetmhz").value = lastGmhz;
+
+
+ let xtal = Number(document.getElementById("crystalmhz").value );
+ let target = Number(document.getElementById("targetmhz").value );
+ let quadrature = document.getElementById("QUADRATURE").checked;
+ let goertzels = document.getElementById("GOERTZELS").checked;
+ let goertzel2 = document.getElementById("GOERTZEL2").checked;
+ let quanta = Math.round(Number(document.getElementById("quanta").value));
+ let quantasearch = Math.round(Number(document.getElementById("quantasearch").value));
+
+ let n = lastGn;
+ let freq = ( xtal / n );
+ let goertzelpoint = 0;
+ let goertzelpointinv = 0;
+ let tgoertzelp = 0;
+ let tgoertzelpi = 0;
+ let quantaA = 0;
+ let quantaINV = 0;
+
+ let h = 1;
+
+ let tquanta = (quanta&0xffffc);
+ let base = freq * h;
+ let next = freq * (h+1);
+
+
+ let tgoertzelpoint = tquanta;
+ tgoertzelpoint = ( target - base ) / ( next - base );
+ tgoertzelpoint = ((tgoertzelpoint%1)+1)%1;
+
+ quantaA = tquanta;
+ tgoertzelp = h;
+ Goertz( n, freq * (h+tgoertzelpoint), (tgoertzelpoint), quantaA , 1);
+ return false;
}
function computeTable()
@@ -214,8 +305,23 @@ function computeTable()
}
else if( goertzel2 )
{
- contents += "
";
- contents += "
";
+
+ // Add widget to control various things, realtime.
+ contents += " Scroll Wheel Control: "; + contents += ""; + contents += ""; + contents += "."; + contents += ""; + contents += ""; + contents += ","; + contents += ""; + contents += ""; + contents += ","; + contents += ""; + contents += " |
| d\\h | '; for( let h = 0|min_harmonics; h <= max_harmonics+1; h++ ) {
|---|