You are reading a single comment by @Gordon and its replies.
Click here to read the full conversation.
-
@Gordon the Waveform that you recommended will come in handy. I was looking for away to trigger the other sensor readings once the espruino receives the temp. The temp is needed first before I request the other sensor readings.
I will respond back hopefully in a couple days with my results/issues.
To make it easier to upload your code, it might be an idea to put all the calls to
setInterval
orsetTimeout
into anonInit
function. They'll then only be called after you've typedsave()
.You could also really speed up your median code I reckon. For starters you could use Float32Array (which is a bit more memory efficient too), and you could then use the 'views' and built-in
sum
- also the default compare function for sorting does what you want I think, so you can just callsort
with no arguments:I've not tested it though...
As a way to make Espruino respond a lot faster, you might also want to look at Waveforms.
You could do something like:
Waveforms allow you to do analog readings at a fixed frequency in the background - it'll then only call your JavaScript code when it has filled up a buffer full of data. All the rest of the time it'll be able to do other things.
Only thing to note is it puts the data into a 16 bit value, so you can do exactly the same stuff but you have to divide by 2^16 (65536) at the end.