You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Hi MikeD,

    The timer Espruino uses at the moment is the 32kHz RTC, so while theoretically you could do that, you're limited by the speed of execution. You can test with:

    counter = 0;
    var i = setInterval(function() { counter++; },10);
    setInterval(function() { console.log(counter);counter=0; },1000);
    // then...
    changeInterval(i,5);
    changeInterval(i,2);
    changeInterval(i,1);
    changeInterval(i,0.5);
    

    and it'll show you how many times per second it's actually been able to manage.

    At the moment you're limited to about 4.5kHz = 0.22ms for simple functions like that example. The more complicated the function the slower it is though.

About

Avatar for Gordon @Gordon started