mirror of
https://github.com/cnlohr/lolra.git
synced 2026-06-17 00:09:31 +00:00
Improve usability of various things
This commit is contained in:
@@ -75,7 +75,6 @@ int g_volume_pwm = 127; // 0 - 127 (100%) (but you can go over 100) (For when us
|
|||||||
|
|
||||||
#define SAMPLETIME 1 // 0: 1.5 cycles; 1: 7.5 cycles; 2: 13.5 cycles; (0 would go fastest and is important in single-ADC mode, but 1 seems slightly better in 2-ADC mode)
|
#define SAMPLETIME 1 // 0: 1.5 cycles; 1: 7.5 cycles; 2: 13.5 cycles; (0 would go fastest and is important in single-ADC mode, but 1 seems slightly better in 2-ADC mode)
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_OLED_SCOPE
|
#ifdef ENABLE_OLED_SCOPE
|
||||||
#define SH1107_128x128
|
#define SH1107_128x128
|
||||||
#define SSD1306_RST_PIN PA3
|
#define SSD1306_RST_PIN PA3
|
||||||
@@ -111,7 +110,7 @@ volatile uint16_t adc_buffer[ADC_BUFFSIZE];
|
|||||||
|
|
||||||
int32_t g_goertzel_phasor_r = 32768;
|
int32_t g_goertzel_phasor_r = 32768;
|
||||||
int32_t g_goertzel_phasor_i = 0;
|
int32_t g_goertzel_phasor_i = 0;
|
||||||
|
int32_t g_attenuation_pow2 = 4;
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// Very basic setup, for tuning to 880AM
|
// Very basic setup, for tuning to 880AM
|
||||||
@@ -423,8 +422,8 @@ void DMA1_Channel1_IRQHandler( void )
|
|||||||
|
|
||||||
int32_t zp = g_goertzelp_store;
|
int32_t zp = g_goertzelp_store;
|
||||||
int32_t zp2 = g_goertzelp2_store;
|
int32_t zp2 = g_goertzelp2_store;
|
||||||
int32_t rr = (((int64_t)(g_goertzel_coefficient ) * (int64_t)zp<<1)>>32) - (zp2);
|
int32_t rr = (((int64_t)(g_goertzel_coefficient ) * (int64_t)zp<<1)>>(32+g_attenuation_pow2)) - (zp2>>g_attenuation_pow2);
|
||||||
int32_t ri = (((int64_t)(g_goertzel_coefficient_s) * (int64_t)zp<<1)>>32);
|
int32_t ri = (((int64_t)(g_goertzel_coefficient_s) * (int64_t)zp<<1)>>(32+g_attenuation_pow2));
|
||||||
|
|
||||||
// Advanced the current goertzel advance
|
// Advanced the current goertzel advance
|
||||||
// phasor = phasor * advance;
|
// phasor = phasor * advance;
|
||||||
@@ -451,8 +450,8 @@ void DMA1_Channel1_IRQHandler( void )
|
|||||||
|
|
||||||
// Now, rotate rr, ri by that phasor.
|
// Now, rotate rr, ri by that phasor.
|
||||||
// To get it in line >> 15, but we also want to divide by 8 (>>3) because that makes the rest of the math easier.
|
// To get it in line >> 15, but we also want to divide by 8 (>>3) because that makes the rest of the math easier.
|
||||||
temp = (g_goertzel_phasor_r * ri + g_goertzel_phasor_i * rr) >> (15+3);
|
temp = (g_goertzel_phasor_r * ri + g_goertzel_phasor_i * rr) >> (15);
|
||||||
rr = (g_goertzel_phasor_r * rr - g_goertzel_phasor_i * ri) >> (15+3);
|
rr = (g_goertzel_phasor_r * rr - g_goertzel_phasor_i * ri) >> (15);
|
||||||
ri = temp;
|
ri = temp;
|
||||||
|
|
||||||
// rr, ri are now in the correct frame of reference. Continue computing.
|
// rr, ri are now in the correct frame of reference. Continue computing.
|
||||||
@@ -474,6 +473,8 @@ void DMA1_Channel1_IRQHandler( void )
|
|||||||
|
|
||||||
// This performs a low-pass IIR without exploding intensity_average.
|
// This performs a low-pass IIR without exploding intensity_average.
|
||||||
intensity_average = intensity_average - (intensity_average>>12) + (intensity>>6);
|
intensity_average = intensity_average - (intensity_average>>12) + (intensity>>6);
|
||||||
|
if( ((int32_t)intensity_average) >= 1<<23 ) intensity_average = (1<<23)-1;
|
||||||
|
if( ((int32_t)intensity_average) < 2048 ) intensity_average = 2048;
|
||||||
|
|
||||||
#ifdef PWM_OUTPUT
|
#ifdef PWM_OUTPUT
|
||||||
intensity = intensity * g_volume_pwm * g_pwm_period / (intensity_average>>(10-12));
|
intensity = intensity * g_volume_pwm * g_pwm_period / (intensity_average>>(10-12));
|
||||||
@@ -767,7 +768,11 @@ int HandleHidUserGetReportSetup( struct _USBState * ctx, tusb_control_request_t
|
|||||||
int samps_to_send = (qibaselogs_head - last_baselog + LOG_GOERTZEL_LIST * 2 - 1) & (LOG_GOERTZEL_LIST-1);
|
int samps_to_send = (qibaselogs_head - last_baselog + LOG_GOERTZEL_LIST * 2 - 1) & (LOG_GOERTZEL_LIST-1);
|
||||||
if( samps_to_send > 120 ) samps_to_send = 120;
|
if( samps_to_send > 120 ) samps_to_send = 120;
|
||||||
|
|
||||||
((uint32_t*)scratchpad)[0] = (intensity_average<<12) | samps_to_send;
|
int intensity_send = intensity_average;
|
||||||
|
|
||||||
|
if( intensity_send >= (1<<24) )
|
||||||
|
intensity_send = (1<<24)-1;
|
||||||
|
((uint32_t*)scratchpad)[0] = (((uint32_t)intensity_send)<<8) | samps_to_send;
|
||||||
((uint32_t*)scratchpad)[1] = (g_lastper<<16) | g_lastlen;
|
((uint32_t*)scratchpad)[1] = (g_lastper<<16) | g_lastlen;
|
||||||
((uint32_t*)scratchpad)[2] = (0<<16) | (((g_pwm_period+1)*g_goertzel_buffer)); //LSW = 144MHz / X
|
((uint32_t*)scratchpad)[2] = (0<<16) | (((g_pwm_period+1)*g_goertzel_buffer)); //LSW = 144MHz / X
|
||||||
|
|
||||||
@@ -835,6 +840,7 @@ void HandleHidUserReportOutComplete( struct _USBState * ctx )
|
|||||||
ADC2->CTLR1 &= (~ADC_BUFEN);
|
ADC2->CTLR1 &= (~ADC_BUFEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( numconfigs > 9) g_attenuation_pow2 = configs[11];
|
||||||
|
|
||||||
// Need to reset so we don't blast by.
|
// Need to reset so we don't blast by.
|
||||||
g_goertzel_samples = 0;
|
g_goertzel_samples = 0;
|
||||||
|
|||||||
+50
-25
@@ -52,6 +52,7 @@ function SendGoertz()
|
|||||||
let tau = 3.1415926535*2.0;
|
let tau = 3.1415926535*2.0;
|
||||||
let omega = fr * tau;
|
let omega = fr * tau;
|
||||||
var textarea = document.getElementById("goertzeloutput");
|
var textarea = document.getElementById("goertzeloutput");
|
||||||
|
var g_attenuation_pow2 = Number( document.getElementById( "g_attenuation_pow2" ).value );
|
||||||
|
|
||||||
var goertzel_omega_per_sample_real = ( omega*2*(1<<29));
|
var goertzel_omega_per_sample_real = ( omega*2*(1<<29));
|
||||||
var g_goertzel_omega_per_sample = Math.round( goertzel_omega_per_sample_real );
|
var g_goertzel_omega_per_sample = Math.round( goertzel_omega_per_sample_real );
|
||||||
@@ -64,21 +65,27 @@ function SendGoertz()
|
|||||||
var g_goertzel_advance_i = Math.sin( goertzel_phasor_advance_radians_per_sample ) * 32768;
|
var g_goertzel_advance_i = Math.sin( goertzel_phasor_advance_radians_per_sample ) * 32768;
|
||||||
|
|
||||||
var g_exactcompute = exact_compute;
|
var g_exactcompute = exact_compute;
|
||||||
textarea.value =
|
|
||||||
"int g_pwm_period = ("+n+"-1); // " + system_rate/lastGn/1000000. + " MHz Samplerate\n" +
|
|
||||||
"int g_exactcompute = ("+exact_compute+");\n" +
|
|
||||||
"int g_goertzel_buffer = ("+brf+");\n" +
|
|
||||||
"int32_t g_goertzel_omega_per_sample = " + g_goertzel_coefficient.toFixed(0) + "; // " + ( omega / (3.1415926535*2.0)).toFixed(6) + " of whole per step / " + mhz.toFixed(6) + "MHz\n" +
|
|
||||||
"int32_t g_goertzel_coefficient = " + g_goertzel_coefficient.toFixed(0) + ";\n" +
|
|
||||||
"int32_t g_goertzel_coefficient_s = " + g_goertzel_coefficient_s.toFixed(0) + ";\n" +
|
|
||||||
"int32_t g_goertzel_advance_r = " + g_goertzel_advance_r.toFixed(0) + ";\n" +
|
|
||||||
"int32_t g_goertzel_advance_i = " + g_goertzel_advance_i.toFixed(0) + ";\n";
|
|
||||||
|
|
||||||
// Highlight its content
|
if( textarea )
|
||||||
textarea.select();
|
{
|
||||||
|
textarea.value =
|
||||||
|
"int g_pwm_period = ("+n+"-1); // " + system_rate/lastGn/1000000. + " MHz Samplerate\n" +
|
||||||
|
"int g_exactcompute = ("+exact_compute+");\n" +
|
||||||
|
"int g_goertzel_buffer = ("+brf+");\n" +
|
||||||
|
"int32_t g_goertzel_omega_per_sample = " + g_goertzel_coefficient.toFixed(0) + "; // " + ( omega / (3.1415926535*2.0)).toFixed(6) + " of whole per step / " + mhz.toFixed(6) + "MHz\n" +
|
||||||
|
"int32_t g_goertzel_coefficient = " + g_goertzel_coefficient.toFixed(0) + ";\n" +
|
||||||
|
"int32_t g_goertzel_coefficient_s = " + g_goertzel_coefficient_s.toFixed(0) + ";\n" +
|
||||||
|
"int32_t g_goertzel_advance_r = " + g_goertzel_advance_r.toFixed(0) + ";\n" +
|
||||||
|
"int32_t g_goertzel_advance_i = " + g_goertzel_advance_i.toFixed(0) + ";\n";
|
||||||
|
"int32_t g_attenuation_pow2 = " + g_attenuation_pow2.toFixed(0) + ";\n";
|
||||||
|
|
||||||
// Copy the highlighted text
|
// Highlight its content
|
||||||
document.execCommand("copy");
|
textarea.select();
|
||||||
|
|
||||||
|
// Copy the highlighted text
|
||||||
|
document.execCommand("copy");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
updateWebHidDeviceWithParameters( [
|
updateWebHidDeviceWithParameters( [
|
||||||
(n-1)|0,
|
(n-1)|0,
|
||||||
@@ -90,6 +97,7 @@ function SendGoertz()
|
|||||||
g_goertzel_advance_r|0,
|
g_goertzel_advance_r|0,
|
||||||
g_goertzel_advance_i|0,
|
g_goertzel_advance_i|0,
|
||||||
document.getElementById( "toggle_adc_buffer").checked ? 1 : 0,
|
document.getElementById( "toggle_adc_buffer").checked ? 1 : 0,
|
||||||
|
g_attenuation_pow2,
|
||||||
] );
|
] );
|
||||||
|
|
||||||
// Update toggle control
|
// Update toggle control
|
||||||
@@ -109,6 +117,17 @@ function toggleBuffer( ths )
|
|||||||
SendGoertz();
|
SendGoertz();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function attenuationpow2wheel( event, ths )
|
||||||
|
{
|
||||||
|
event.preventDefault();
|
||||||
|
let dy = event.deltaY > 0 ? -1 : 1;
|
||||||
|
var thss = Number(ths.value) + dy;
|
||||||
|
if( thss < -9 ) thss = -9;
|
||||||
|
if( thss > 9 ) thss = 9;
|
||||||
|
ths.value = thss;
|
||||||
|
UpdateQuickSettings();
|
||||||
|
}
|
||||||
|
|
||||||
function mhzm( event, ths )
|
function mhzm( event, ths )
|
||||||
{
|
{
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -126,8 +145,11 @@ function mhzm( event, ths )
|
|||||||
|
|
||||||
lastGmhz = hz/10000000.0;
|
lastGmhz = hz/10000000.0;
|
||||||
document.getElementById("targetmhz").value = lastGmhz;
|
document.getElementById("targetmhz").value = lastGmhz;
|
||||||
|
UpdateQuickSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
function UpdateQuickSettings()
|
||||||
|
{
|
||||||
let xtal = Number(document.getElementById("crystalmhz").value );
|
let xtal = Number(document.getElementById("crystalmhz").value );
|
||||||
let target = Number(document.getElementById("targetmhz").value );
|
let target = Number(document.getElementById("targetmhz").value );
|
||||||
let quadrature = document.getElementById("QUADRATURE").checked;
|
let quadrature = document.getElementById("QUADRATURE").checked;
|
||||||
@@ -317,16 +339,16 @@ function computeTable()
|
|||||||
|
|
||||||
// Add widget to control various things, realtime.
|
// Add widget to control various things, realtime.
|
||||||
contents += "<BR>Scroll Wheel Control:<BR>";
|
contents += "<BR>Scroll Wheel Control:<BR>";
|
||||||
contents += "<input id=mhzm0 onwheel='mhzm(event, this)' size=1>";
|
contents += "<input id=mhzm0 onwheel='mhzm(event, this)' size=1 type=number min=0 max=9 style='width:2em'>";
|
||||||
contents += "<input id=mhzm1 onwheel='mhzm(event, this)' size=1>";
|
contents += "<input id=mhzm1 onwheel='mhzm(event, this)' size=1 type=number min=0 max=9 style='width:2em'>";
|
||||||
contents += "<input id=mhzm2 onwheel='mhzm(event, this)' size=1>.";
|
contents += "<input id=mhzm2 onwheel='mhzm(event, this)' size=1 type=number min=0 max=9 style='width:2em'>.";
|
||||||
contents += "<input id=mhzm3 onwheel='mhzm(event, this)' size=1>";
|
contents += "<input id=mhzm3 onwheel='mhzm(event, this)' size=1 type=number min=0 max=9 style='width:2em'>";
|
||||||
contents += "<input id=mhzm4 onwheel='mhzm(event, this)' size=1>";
|
contents += "<input id=mhzm4 onwheel='mhzm(event, this)' size=1 type=number min=0 max=9 style='width:2em'>";
|
||||||
contents += "<input id=mhzm5 onwheel='mhzm(event, this)' size=1>,";
|
contents += "<input id=mhzm5 onwheel='mhzm(event, this)' size=1 type=number min=0 max=9 style='width:2em'>,";
|
||||||
contents += "<input id=mhzm6 onwheel='mhzm(event, this)' size=1>";
|
contents += "<input id=mhzm6 onwheel='mhzm(event, this)' size=1 type=number min=0 max=9 style='width:2em'>";
|
||||||
contents += "<input id=mhzm7 onwheel='mhzm(event, this)' size=1>";
|
contents += "<input id=mhzm7 onwheel='mhzm(event, this)' size=1 type=number min=0 max=9 style='width:2em'>";
|
||||||
contents += "<input id=mhzm8 onwheel='mhzm(event, this)' size=1>,";
|
contents += "<input id=mhzm8 onwheel='mhzm(event, this)' size=1 type=number min=0 max=9 style='width:2em'>,";
|
||||||
contents += "<input id=mhzm9 onwheel='mhzm(event, this)' size=1>";
|
contents += "<input id=mhzm9 onwheel='mhzm(event, this)' size=1 type=number min=0 max=9 style='width:2em'>";
|
||||||
contents += "</DIV></TD></TR></TABLE><BR>";
|
contents += "</DIV></TD></TR></TABLE><BR>";
|
||||||
contents += "v Click in this row; <TABLE BORDER=1>";
|
contents += "v Click in this row; <TABLE BORDER=1>";
|
||||||
contents += '<TR><TH>d\\h</div></TH>';
|
contents += '<TR><TH>d\\h</div></TH>';
|
||||||
@@ -393,7 +415,7 @@ function computeTable()
|
|||||||
document.getElementById( "TABLE" ).innerHTML = contents;
|
document.getElementById( "TABLE" ).innerHTML = contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
const savedFields = ["crystalmhz", "targetmhz", "quanta", "quantasearch", "toggle_adc_buffer"];
|
const savedFields = ["crystalmhz", "targetmhz", "quanta", "quantasearch", "toggle_adc_buffer", "g_attenuation_pow2"];
|
||||||
|
|
||||||
function SaveDefaults()
|
function SaveDefaults()
|
||||||
{
|
{
|
||||||
@@ -476,7 +498,10 @@ Live Control:
|
|||||||
</TD>
|
</TD>
|
||||||
</TR>
|
</TR>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
|
<div id=GeneralData></DIV>
|
||||||
<input type=checkbox ID=toggle_adc_buffer onchange='toggleBuffer(this)'><label for=toggle_buffer>ADC Buffer Enable</label>
|
<input type=checkbox ID=toggle_adc_buffer onchange='toggleBuffer(this)'><label for=toggle_buffer>ADC Buffer Enable</label>
|
||||||
|
<BR>Pow2 Attenuation:
|
||||||
|
<input id=g_attenuation_pow2 onwheel='attenuationpow2wheel(event, this)' size=3 type=number style="width:3em" value=3><br>
|
||||||
|
|
||||||
<DIV ID=TABLE></DIV>
|
<DIV ID=TABLE></DIV>
|
||||||
|
|
||||||
|
|||||||
@@ -329,8 +329,9 @@ async function sendLoop()
|
|||||||
|
|
||||||
document.getElementById( "StatusPerf" ).innerHTML =
|
document.getElementById( "StatusPerf" ).innerHTML =
|
||||||
(kBsecAvg).toFixed(2) + " kBytes/s<br>" +
|
(kBsecAvg).toFixed(2) + " kBytes/s<br>" +
|
||||||
(xActionSecAvg).toFixed(2) + "transactions/sec<br>" +
|
(xActionSecAvg).toFixed(2) + "transactions/sec<br>";
|
||||||
"Count: " + goodCount + " / " + badCount + "<br>Inten: " + ((Math.log( lastIntensity * lastIntensity )/Math.log(10)) * 10-130).toFixed(2) + "db";
|
document.getElementById( "GeneralData" ).innerHTML =
|
||||||
|
"Count: " + goodCount + " / " + badCount + "<br>Inten: " + ((Math.log( lastIntensity * lastIntensity )/Math.log(10)) * 10-120).toFixed(2) + "db (" + lastIntensity + ")";
|
||||||
lastTime = thisTime;
|
lastTime = thisTime;
|
||||||
}
|
}
|
||||||
else if( frameNo % updateStatsPerfPer == 2 )
|
else if( frameNo % updateStatsPerfPer == 2 )
|
||||||
@@ -356,8 +357,7 @@ async function sendLoop()
|
|||||||
|
|
||||||
ctx.fillStyle = `rgb( 255 255 255 )`;
|
ctx.fillStyle = `rgb( 255 255 255 )`;
|
||||||
|
|
||||||
let mulcoeff = 30000.0 / lastIntensity;
|
let mulcoeff = 2500.0 / lastIntensity;
|
||||||
|
|
||||||
var lot = 1.2;
|
var lot = 1.2;
|
||||||
var x = 253;
|
var x = 253;
|
||||||
for( var i = (IQHistoryHead-1) & (IQHistoryLen-1); i != IQHistoryHead|0; i = (i - 1 + IQHistoryLen) & (IQHistoryLen-1) )
|
for( var i = (IQHistoryHead-1) & (IQHistoryLen-1); i != IQHistoryHead|0; i = (i - 1 + IQHistoryLen) & (IQHistoryLen-1) )
|
||||||
@@ -412,7 +412,7 @@ async function sendLoop()
|
|||||||
let time_used = data[1]&0xffff;
|
let time_used = data[1]&0xffff;
|
||||||
let sample_divisor = data[2]&0xffff;
|
let sample_divisor = data[2]&0xffff;
|
||||||
let demodbuffer = new Float32Array(numq);
|
let demodbuffer = new Float32Array(numq);
|
||||||
let mulcoeff = 100.0 / lastIntensity;
|
let mulcoeff = 16.0 / lastIntensity;
|
||||||
for( var i = 0|0; i < numq; i++ )
|
for( var i = 0|0; i < numq; i++ )
|
||||||
{
|
{
|
||||||
let vv = IQHistoryArray[IQHistoryHead] = data[i+3];
|
let vv = IQHistoryArray[IQHistoryHead] = data[i+3];
|
||||||
|
|||||||
Reference in New Issue
Block a user