-
• #2
p.s. I have done both a) most of the logic/programming/timers in the puck.js code and b) the logic/program/timers in Node-Red.
This code version is where nearly all of the logic is one in Node-Red.
can make a new thread if it gets meaty. Pros/cons?
-
• #3
Henry, a good/save/robust practice is to have an
onInit() { ... }
function that gets everything going on power cycle... Having active code - in level 0 - is executed on upload and can be challenging. Take a look at simple explanation how to save code that espruino run on start?.Furthermore, below things give me a bit the chill... because this can actually mess with the Espruino platform which may already include running JS (boot code that uses watches, and timers). To avoid having to go with the crow bar but still want to be able to 'cleanup after me-code' or have in the application the need to stop or pause these hw and sw events/hooks, ,I use variables to hold on to the watch, timeout and interval handles and then use them in the clear functions.
clearWatch(); clearTimeout(); clearInterval();
What code distribution topology to chose? ...it all depends. The pendulum is always swinging and a hybrid approach feels to me right. Question is: what and where are 'your' pain points? There is allways pain - never no pain - but minimizing it by optimizing is the virtue.
-
• #4
If I save a "program" to flash, will it execute again to reload the functions and watches if the battery is changed?
Yes, if you upload this code to flash via WebIDE it is permanently saved in Storage as ".bootcde" file and gets executed from top to bottom at boot time. If this suits you, it is as simple as that, you don't need anything else.
-
• #5
Not sure, but this might help give some explanation of what happens: http://www.espruino.com/Saving
This seems pretty basic.
If I save a "program" to flash, will it execute again to reload the functions and watches if the battery is changed?
Thanks