mirror of
https://github.com/cnlohr/lolra.git
synced 2026-06-17 00:09:31 +00:00
Making good progress.
This commit is contained in:
@@ -33,18 +33,24 @@ function Goertz( n, mhz, fr, brf )
|
||||
{
|
||||
let omega = fr * 3.1415926535*2.0;
|
||||
var textarea = document.getElementById("goertzeloutput");
|
||||
|
||||
var g_goertzel_omega_per_sample = Math.round( ( omega*2*(1<<29)) );
|
||||
var g_goertzel_coefficient = Math.round( (2 * Math.cos( omega ) * (1<<30)) );
|
||||
var g_goertzel_coefficient_s = Math.round( (2 * Math.sin( omega ) * (1<<30)) );
|
||||
textarea.value =
|
||||
"int g_pwm_period = ("+n+"-1);\n" +
|
||||
"int g_goertzel_buffer = ("+brf+");\n" +
|
||||
"int32_t g_goertzel_omega_per_sample = " + ( omega*2*(1<<29)).toFixed(0) + "; // " + ( omega / (3.1415926535*2.0)).toFixed(6) + " of whole per step / " + mhz.toFixed(6) + "MHz\n" +
|
||||
"int32_t g_goertzel_coefficient = " + (2 * Math.cos( omega ) * (1<<30)).toFixed(0) + ";\n" +
|
||||
"int32_t g_goertzel_coefficient_s = "+ (2 * Math.sin( omega ) * (1<<30)).toFixed(0) + ";\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";
|
||||
|
||||
// Highlight its content
|
||||
textarea.select();
|
||||
// Highlight its content
|
||||
textarea.select();
|
||||
|
||||
// Copy the highlighted text
|
||||
document.execCommand("copy");
|
||||
// Copy the highlighted text
|
||||
document.execCommand("copy");
|
||||
|
||||
updateWebHidDeviceWithParameters( [ (n-1)|0, brf|0, g_goertzel_omega_per_sample|0, g_goertzel_coefficient|0, g_goertzel_coefficient_s|0 ] );
|
||||
}
|
||||
|
||||
function computeTable()
|
||||
|
||||
@@ -136,10 +136,30 @@ async function sendLoopError( e )
|
||||
setStatusError( e );
|
||||
}
|
||||
|
||||
function updateWebHidDeviceWithParameters( paramlist )
|
||||
{
|
||||
var i = 0|0;
|
||||
var arraySend = new Uint8Array(63);
|
||||
for( var i = 0|0; i < paramlist.length|0; i++ )
|
||||
{
|
||||
var vv = paramlist[i] | 0;
|
||||
arraySend[i*4+7] = (vv>>0)&0xff;
|
||||
arraySend[i*4+8] = (vv>>8)&0xff;
|
||||
arraySend[i*4+9] = (vv>>16)&0xff;
|
||||
arraySend[i*4+10] = (vv>>24)&0xff;
|
||||
}
|
||||
arraySend[3] = paramlist.length | 0;
|
||||
|
||||
console.log( arraySend );
|
||||
|
||||
sendReport = dev.sendFeatureReport( 0xAC, arraySend ).catch( sendLoopError );
|
||||
if( !sendReport ) sendLoopError( "error creating sendFeatureReport" );
|
||||
}
|
||||
|
||||
|
||||
async function sendLoop()
|
||||
{
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||
//var arraySend = new Uint8Array(255);
|
||||
var frameNo = 0|0;
|
||||
var lastTime = performance.now();
|
||||
let goodCount = 0;
|
||||
@@ -151,13 +171,6 @@ async function sendLoop()
|
||||
{
|
||||
if( dev && !loopAbort )
|
||||
{
|
||||
//var i = 0|0;
|
||||
//for( var i = 0|0; i < 255|0; i++ )
|
||||
// arraySend[i] = (Math.random()*256)|0;
|
||||
|
||||
//sendReport = dev.sendFeatureReport( 0xAA, arraySend ).catch( sendLoopError );
|
||||
//if( !sendReport ) sendLoopError( "error creating sendFeatureReport" );
|
||||
|
||||
receiveReport = dev.receiveFeatureReport( 0xAD ).catch( sendLoopError );
|
||||
if( !receiveReport ) sendLoopError( "error creating receiveReport" );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user