You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Ok, looks like the error should have been reported as Timeout on Utility Timer. There were some bugs that meant that InternalError wasn't converted to a string properly.

    It's because Espruino will only block for ~0.5 seconds waiting for the timer before it gives up. You'd be better off writing the code as:

     digitalPulse(thePin,1,800);
     setTimeout(function() {
       digitalPulse(thePin,0,0);
       digitalPulse(theDummy,1,400);
     }, 700);
    

    That way at least Espruino can be doing other stuff for 700 of the 800 ms.

    There's also the slightly hidden 'writeAtTime' method, which allows you to queue stuff up without blocking at all:

    var t = getTime();
    LED1.write(0); // set as output
    LED1.writeAtTime(1,t+1);
    LED1.writeAtTime(0,t+2);
    LED1.writeAtTime(1,t+3);
    LED1.writeAtTime(0,t+4);
    

    Thanks for pointing it out - while debugging I found out that 1v67 had a huge regression that totally broke digitalPulse, so it's good that it got found before I made a release!

About

Avatar for Gordon @Gordon started