-
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); });
@allObjects thanks for the tip. Any sample code I can look at?
My code is here
https://github.com/piofthings/BangleApps/blob/master/apps/fitclck/fit-clock.js
It is just a copy of the
morph-clock.js
app with some minor mods.