DigitalPulse() on 1V66

Posted on
  • Am I doing something wrong here.

    var thePin = LED1;
    var theDummy = LED2;
    // Both turn on at the same time, then LED2 off, and then LED1 off.
    // This is normal.
    // First turn LED1 on, then LED2 on, and off almost simultaneously.
    // Something wrong here
    /* _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
     1v66 Copyright 2014 G.Williams
    Uncaught [object Object]
     at line 1 col 26
  • Isn't it supposed to be:


    to wait for the current pulse to finish?
    That's what the reference shows, at least.

    Not sure if that's the issue here - if you caught the exception and printed it out, it might give you more information.

  • It does not matter whether it is 0.0 or 1.0, it gives the same error as seen in the bottom of the list.

    Uncaught [object Object]
    at line 1 col 26

  • Strangely, after testing other pieces of software, I tried again and now it works without error.

  • Thanks. I've managed to reproduce this so I'll try and fix it...

  • 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:

     setTimeout(function() {
     }, 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

    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!

  • That explains, why the fault disappeared, that was because I have set my timing to <= 300.
    Thank you for looking into it.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

DigitalPulse() on 1V66

Posted by Avatar for Frida @Frida