You are reading a single comment by @Unreality and its replies. Click here to read the full conversation.
  • the current 'wait x seconds' for Espruino blockly doesn't always work as intended.

    for example, if a while(true) loop containing a wait x seconds block, for javascript, it doesn't really wait for the setTimeout function and will just immediately execute the next iteration.

    e.g. the attached image will be converted to:

    while (true) {
        setTimeout(function() {
            digitalWrite(LED, 0);
            setTimeout(function() {}, 1000*1);
        }, 1000*1);
    }
    

    Which is pretty confusing for the blockly user

    So I implement a sleep function as stated in https://stackoverflow.com/a/16624104/632­26

    var sleep = function (miliseconds) {
       var currentTime = new Date().getTime();
    
       while (currentTime + miliseconds >= new Date().getTime()) {
       }
    }
    

    It works when I execute like sleep(1000) or sleep(2000), but for sleep(3000) the nodeMCU resets itself.

    Is there a max execution time that forced the nodeMCU to reset? if yes, then how to increase it?

    Thanks


    1 Attachment

    • Screenshot 2019-06-18 at 11.32.22 AM.png
About

Avatar for Unreality @Unreality started