:) Just so you know - intervals is just a variable. The idea is that if you call LED1.pwm more than once, it knows that it was already doing PWM on that pin and knows to get rid of the old setInterval...
pos=0.001 is a minor hack - it's because digitalPulse complains if it gets given a value of 0. It just makes more sense to ensure that it is never given that value :)
Can you give an example of which Math.pow(.., 3) doesn't work? I just tried Math.pow(Math.sin(1), 3) and it's fine.
I'm unsure if the speed/complexity would help much... I do already have a page on performance as Espruino has some particularly weird behaviour ;)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
:) Just so you know - intervals is just a variable. The idea is that if you call LED1.pwm more than once, it knows that it was already doing PWM on that pin and knows to get rid of the old setInterval...
pos=0.001
is a minor hack - it's because digitalPulse complains if it gets given a value of 0. It just makes more sense to ensure that it is never given that value :)Can you give an example of which
Math.pow(.., 3)
doesn't work? I just triedMath.pow(Math.sin(1), 3)
and it's fine.I'm unsure if the speed/complexity would help much... I do already have a page on performance as Espruino has some particularly weird behaviour ;)