• Sat 2019.12.21

    Hi @PiOfThings,

    While I haven't seen much use of IIFE (Immediately Invoked Function Expression) for microcontrollers, if it's working for you, Bravo! (see the structure in the example of the code file you referenced)

    As that entire IIFE code block will execute as it is uploaded to your Espruino device, as @allObjects points out, the setWatch()'s may occur before everything settles.

    Place something like this as the very last section with a call to your constructor function within the timeout.

    example

    // Note: save() must be entered at least once before this will take effect
    
    E.on('init',function() {
    //  setWatch(kill, BTN, { repeat: true, edge:'falling' });
      setTimeout( function() {
        console.log("Hello World!");
    //    st();
    //    console.log("Receiving\n");
    //    rx();
        
      }, 1500);
    });
    
About

Avatar for Robin @Robin started