mirror of
https://github.com/cnlohr/lolra.git
synced 2026-06-21 18:29:28 +00:00
Compare commits
2 Commits
933a3d4347
...
c1bdfe0acf
| Author | SHA1 | Date | |
|---|---|---|---|
| c1bdfe0acf | |||
| 147fdc514d |
@@ -251,13 +251,18 @@ static void SetupTimer1()
|
||||
|
||||
#ifdef ENABLE_OLED_SCOPE
|
||||
|
||||
#ifdef PLOTGUARD
|
||||
// Command-mode, Set X, Disable Timer, Set Y, Enable Timer
|
||||
// Done this way to prevent streaking.
|
||||
uint8_t cmdxy[] = { 0x00, 0xd3, 0x30, 0xd5, 0xff, 0x00, 0xdc, 0x30, 0xd5, 0xf0 };
|
||||
// There doesn't seem to be a way of truly pausing the scanout.
|
||||
// GENERAL NOTE: This doesn't actually seem to help reduce streaking.
|
||||
uint8_t cmdxy[] = { 0x00, 0xd3, 0x30, 0xd5, 0xff, 0xdc, 0x30, 0xd5, 0xf0 };
|
||||
#else
|
||||
// Only set xy plot, and make sure clock is cranked.
|
||||
uint8_t cmdxy[] = { 0x00, 0xd3, 0x30, 0xdc, 0x30, 0xd5, 0xf0 };
|
||||
#endif
|
||||
|
||||
void config_turbo_scope()
|
||||
{
|
||||
|
||||
DMA1_Channel3->PADDR = (uint32_t)&SPI1->DATAR;
|
||||
DMA1_Channel3->MADDR = (uint32_t)cmdxy;
|
||||
DMA1_Channel3->CNTR = sizeof(cmdxy);
|
||||
@@ -270,39 +275,23 @@ void config_turbo_scope()
|
||||
DMA_Mode_Normal |
|
||||
DMA_DIR_PeripheralDST;
|
||||
|
||||
// Turn on DMA channel 3
|
||||
// Turn on DMA channel 3 (For SPI output)
|
||||
DMA1_Channel3->CFGR |= DMA_CFGR1_EN;
|
||||
|
||||
|
||||
// All display controls from here on out are made using DC = 0.
|
||||
funDigitalWrite( SSD1306_DC_PIN, FUN_LOW );
|
||||
|
||||
SPI1->CTLR2 |= SPI_CTLR2_TXDMAEN;
|
||||
}
|
||||
|
||||
void ssd1306_send_turbo(uint8_t *data, uint8_t sz)
|
||||
{
|
||||
funDigitalWrite( SSD1306_DC_PIN, FUN_LOW );
|
||||
funDigitalWrite( SSD1306_CS_PIN, FUN_LOW );
|
||||
|
||||
// send data
|
||||
while(sz--)
|
||||
{
|
||||
// wait for TXE
|
||||
while(!(SPI1->STATR & SPI_STATR_TXE));
|
||||
|
||||
// Send byte
|
||||
SPI1->DATAR = *data++;
|
||||
}
|
||||
|
||||
// wait for not busy before exiting
|
||||
while(SPI1->STATR & SPI_STATR_BSY);
|
||||
|
||||
funDigitalWrite( SSD1306_CS_PIN, FUN_HIGH );
|
||||
}
|
||||
|
||||
static void PlotPoint( int x, int y )
|
||||
{
|
||||
funDigitalWrite( SSD1306_CS_PIN, FUN_HIGH );
|
||||
cmdxy[2] = x; cmdxy[7] = y;
|
||||
#ifdef PLOTGUARD
|
||||
cmdxy[2] = x; cmdxy[6] = y;
|
||||
#else
|
||||
cmdxy[2] = x; cmdxy[4] = y;
|
||||
#endif
|
||||
DMA1_Channel3->CNTR = sizeof(cmdxy);
|
||||
funDigitalWrite( SSD1306_CS_PIN, FUN_LOW );
|
||||
DMA1_Channel3->CFGR |= DMA_CFGR1_EN;
|
||||
@@ -546,66 +535,6 @@ static inline uint32_t gets2()
|
||||
return ret;
|
||||
}
|
||||
|
||||
void InnerLoop()
|
||||
{
|
||||
while(1){
|
||||
#if 0
|
||||
int adcz = adc_buffer[0];
|
||||
for( k = 0; k < 128; k++ )
|
||||
{
|
||||
int y = adc_buffer[k]-adcz + 64;
|
||||
if( y < 0 ) y = 0;
|
||||
if( y > 127 ) y = 127;
|
||||
ssd1306_drawPixel( k, y, 1 );
|
||||
}
|
||||
#endif
|
||||
|
||||
// Only display half of the list so the other half could
|
||||
// be updated by the ISR.
|
||||
|
||||
#ifdef ENABLE_OLED
|
||||
int pxa = 0;
|
||||
int glread = qibaselogs_head;
|
||||
|
||||
for( pxa = 0; pxa < LOG_GOERTZEL_LIST; pxa++ )
|
||||
{
|
||||
uint32_t combiq = qibaselogs[glread];
|
||||
glread = ( glread + 1 ) & ( LOG_GOERTZEL_LIST -1 );
|
||||
|
||||
int16_t rr = combiq & 0xffff;
|
||||
int16_t ri = combiq >> 16;
|
||||
|
||||
rr = rr * 512 / (intensity_average);
|
||||
ri = ri * 512 / (intensity_average);
|
||||
|
||||
rr += 64;
|
||||
ri += 64;
|
||||
|
||||
if( rr < 0 ) rr = 0;
|
||||
if( ri < 0 ) ri = 0;
|
||||
if( rr > 127 ) rr = 127;
|
||||
if( ri > 127 ) ri = 127;
|
||||
|
||||
ssd1306_drawPixel( rr, ri, 1 );
|
||||
}
|
||||
//char cts[32];
|
||||
//snprintf( cts, 32, "%d", intensity_average );
|
||||
//ssd1306_drawstr( 0, 0, cts, 1 );
|
||||
|
||||
ssd1306_refresh();
|
||||
//static int ik = 0;
|
||||
//printf( "%d %08x\n", ik, ssd1306_buffer[ik++] );
|
||||
//if( ik == sizeof(ssd1306_buffer) ) ik = 0;
|
||||
|
||||
ssd1306_setbuf(0);
|
||||
#endif
|
||||
|
||||
// Do nothing.
|
||||
Delay_Ms(17);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint8_t i2c_send_buffer[16];
|
||||
void setup_i2c_dma(void)
|
||||
{
|
||||
@@ -630,8 +559,6 @@ void setup_i2c_dma(void)
|
||||
DMA1_Channel6->CFGR |= DMA_CFGR1_EN;
|
||||
|
||||
NVIC_DisableIRQ(I2C1_EV_IRQn);
|
||||
|
||||
printf( "INTO\n" );
|
||||
}
|
||||
|
||||
|
||||
@@ -742,7 +669,56 @@ int main()
|
||||
USBOTGSetup();
|
||||
|
||||
|
||||
InnerLoop();
|
||||
while(1){
|
||||
#if 0
|
||||
// To draw a sinewave...
|
||||
int adcz = adc_buffer[0];
|
||||
for( k = 0; k < 128; k++ )
|
||||
{
|
||||
int y = adc_buffer[k]-adcz + 64;
|
||||
if( y < 0 ) y = 0;
|
||||
if( y > 127 ) y = 127;
|
||||
ssd1306_drawPixel( k, y, 1 );
|
||||
}
|
||||
#endif
|
||||
|
||||
// Only display half of the list so the other half could
|
||||
// be updated by the ISR.
|
||||
|
||||
#ifdef ENABLE_OLED
|
||||
int pxa = 0;
|
||||
int glread = qibaselogs_head;
|
||||
|
||||
for( pxa = 0; pxa < LOG_GOERTZEL_LIST; pxa++ )
|
||||
{
|
||||
uint32_t combiq = qibaselogs[glread];
|
||||
glread = ( glread + 1 ) & ( LOG_GOERTZEL_LIST -1 );
|
||||
|
||||
int16_t rr = combiq & 0xffff;
|
||||
int16_t ri = combiq >> 16;
|
||||
|
||||
rr = rr * 512 / (intensity_average);
|
||||
ri = ri * 512 / (intensity_average);
|
||||
|
||||
rr += 64;
|
||||
ri += 64;
|
||||
|
||||
if( rr < 0 ) rr = 0;
|
||||
if( ri < 0 ) ri = 0;
|
||||
if( rr > 127 ) rr = 127;
|
||||
if( ri > 127 ) ri = 127;
|
||||
|
||||
ssd1306_drawPixel( rr, ri, 1 );
|
||||
}
|
||||
|
||||
ssd1306_refresh();
|
||||
|
||||
ssd1306_setbuf(0);
|
||||
#endif
|
||||
|
||||
// Do nothing.
|
||||
Delay_Ms(17);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+22
-12
@@ -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 += "<input type=checkbox ID=toggle_adc_buffer onchange='toggleBuffer(this)'><label for=toggle_buffer>ADC Buffer Enable</label><BR>Scroll Wheel Control:<BR>";
|
||||
contents += "<BR>Scroll Wheel Control:<BR>";
|
||||
contents += "<TABLE BORDER=1>";
|
||||
contents += '<TR><TH>d\\h</div></TH>';
|
||||
for( let h = 0|min_harmonics; h <= max_harmonics; h++ )
|
||||
@@ -284,7 +286,7 @@ function computeTable()
|
||||
if( mode == 0 )
|
||||
{
|
||||
contents += "<TD COLSPAN=2>"
|
||||
if( tgoertzelp == h ) contents += "<INPUT TYPE=SUBMIT ONCLICK='Goertz(" + n + ", " + freq * (h+goertzelpoint) + ", " + (goertzelpoint) + ", " + quantaA + ", 0)' VALUE='↑" + (goertzelpoint).toFixed(6) + "'/>";
|
||||
if( tgoertzelp == h ) contents += "<INPUT TYPE=SUBMIT ONCLICK='Goertz(" + n + ", " + freq * (h+goertzelpoint) + ", " + (goertzelpoint) + ", " + quantaA + ", 0, " + freq + ")' VALUE='↑" + (goertzelpoint).toFixed(6) + "'/>";
|
||||
contents += "</TD>";
|
||||
}
|
||||
else if( mode == 1 )
|
||||
@@ -294,7 +296,7 @@ function computeTable()
|
||||
else if( mode == 2 )
|
||||
{
|
||||
contents += "<TD COLSPAN=2>"
|
||||
if( tgoertzelpi == h-1 ) contents += "<INPUT TYPE=SUBMIT ONCLICK='Goertz(" + n + ", " + freq * (h-goertzelpointinv) + ", " + goertzelpointinv + ", " + quantaINV + ", 0)' VALUE='↓" + goertzelpointinv.toFixed(6) + "'/>";
|
||||
if( tgoertzelpi == h-1 ) contents += "<INPUT TYPE=SUBMIT ONCLICK='Goertz(" + n + ", " + freq * (h-goertzelpointinv) + ", " + goertzelpointinv + ", " + quantaINV + ", 0, " + freq + ")' VALUE='↓" + goertzelpointinv.toFixed(6) + "'/>";
|
||||
contents += "</TD>";
|
||||
}
|
||||
else if( mode == 3 )
|
||||
@@ -314,7 +316,7 @@ function computeTable()
|
||||
contents += "<TABLE><TR><TD><TEXTAREA ROWS=6 COLS=120 ID=goertzeloutput></TEXTAREA></TD><TD><DIV>";
|
||||
|
||||
// Add widget to control various things, realtime.
|
||||
contents += "<input type=checkbox ID=toggle_adc_buffer onchange='toggleBuffer(this)'><label for=toggle_buffer>ADC Buffer Enable</label><BR>Scroll Wheel Control:<BR>";
|
||||
contents += "<BR>Scroll Wheel Control:<BR>";
|
||||
contents += "<input id=mhzm0 onwheel='mhzm(event, this)' size=1>";
|
||||
contents += "<input id=mhzm1 onwheel='mhzm(event, this)' size=1>";
|
||||
contents += "<input id=mhzm2 onwheel='mhzm(event, this)' size=1>.";
|
||||
@@ -363,7 +365,7 @@ function computeTable()
|
||||
if( rid == 0 )
|
||||
{
|
||||
contents += "<TD COLSPAN=1 ROWSPAN=2>"
|
||||
contents += "<INPUT TYPE=SUBMIT ONCLICK='Goertz(" + n + ", " + freq * (h+tgoertzelpoint) + ", " + (tgoertzelpoint) + ", " + quantaA + ", 1)' VALUE='↑" + n + "'/>";
|
||||
contents += "<INPUT TYPE=SUBMIT ONCLICK='Goertz(" + n + ", " + freq * (h+tgoertzelpoint) + ", " + (tgoertzelpoint) + ", " + quantaA + ", 1, " + target + " )' VALUE='↑" + n + "'/>";
|
||||
contents += "</TD>"
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<input type=checkbox ID=toggle_adc_buffer onchange='toggleBuffer(this)'><label for=toggle_buffer>ADC Buffer Enable</label>
|
||||
|
||||
<DIV ID=TABLE></DIV>
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -330,7 +330,7 @@ async function sendLoop()
|
||||
document.getElementById( "StatusPerf" ).innerHTML =
|
||||
(kBsecAvg).toFixed(2) + " kBytes/s<br>" +
|
||||
(xActionSecAvg).toFixed(2) + "transactions/sec<br>" +
|
||||
"Count: " + goodCount + " / " + badCount;
|
||||
"Count: " + goodCount + " / " + badCount + "<br>Inten: " + ((Math.log( lastIntensity * lastIntensity )/Math.log(10)) * 10-130).toFixed(2) + "db";
|
||||
lastTime = thisTime;
|
||||
}
|
||||
else if( frameNo % updateStatsPerfPer == 2 )
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user