-
I just looked into the code you referenced - and I found a potential problem:
if (callback) callback();
Shouldn't you always
return callback()
?Amendment: I found the mistake - if a callback is given,
time
must be specified as well, otherwise the callback function is taken as thetime
argument.If you like, you may change the beginning of your
move
function like so:return {move:function(pos, time, callback) { if (typeof time === 'function') { callback = time; time = undefined; } if (typeof time !== 'number') time = 1000;
At least, you should protect the
time
argument better (an error message would be fine, but you may not have enough resources on the device for such an approach)
I think likely what happens is the digitalPulse in servo causes an exception which stops the next command executing which in turn causes the interval to keep on being called.
Unminified source is at : http://www.espruino.com/modules/servo.js
Is that literally all the code you have there? because I'd only expect that error if you were calling
move
with something outside the 0..1 range