-
• #2
Ahh crap, my code isn't formatted correct in the forum. Sorry! Im
using my cell phone to post. I have no idea how to fix the
formatting......Nvm l, I fixed the formatting problem....
-
• #3
Ahh - that's interesting. Looks like there are 2 issues (Which I should have checked!)
- If you make a
Uint16Array
with everything the same value and then sort it, sort crashes(!)Uint8Array
works fine though, and strangely it also works on a Pico! I've just filed a bug for this. We need to set a longer interval. As we do all out calculations first, and then kick off the Waveform, the waveform isn't finished by the time the interval fires again. I've just increased the interval to 200ms and that's fixed it.
var w = new Waveform(128/* your buffer size */,{doubleBuffer:false, bits:16}); var first = true; setInterval(function() { if (!first) { var myarr = w.buffer; myarr.sort(); // cut off first and last 2 elements var view = new Uint16Array(myarr.buffer, 2/*sizeof(uint16)*/*2, myarr.length-4); var vOut = E.getAnalogVRef() * E.sum(view)/(view.length*65536); // if you attached VOUT to Ao var vZero = 0.4; var tCoeff = 19.5 / 1000; var tempinc = (vOut - vZero) / tCoeff; var tempinf = tempinc * (9 / 5) + 32; console.log("Temp in C: " + tempinc); console.log("Temp in F: " + tempinf); //console.log(E.sum(view)/(view.length*65536)); } else first = false; // start it again w.startInput(A0,2000 /* Samples per second */); }, 200);
- If you make a
I've been demoing out different ways to use waveform and come across an issue when using both setInterval and Waveform. the issue is: I am not seeing my temp output in the console.
Code:
I tried setting the time higher, but I am still getting the same issue. I did, however, place a console.log ("start!") Inside of the startInterval as the first line and start! was sent to the Console successfully.