• 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

  • indeed, that's all my code - I just wanted to "quickly" test a servo (but nothing works quickly if I am touching it - I tend to break everything)

    Amendment: I also just checked the firmware state (just to be sure): and, yes, it is 2v10

    Amendment 2: just to be sure, I flashed 2v10 one more time and tried my code again - with the same result.

  • 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 the time 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)

About

Avatar for Gordon @Gordon started