• @Levon, I suggest the following:

    1) Remove the clearXyz(...) in E.onInit().
    2) Remove the save() from your code you upload.

    Optional (in addition to above):
    a) make a named function out of the anonymous function in E.on(...), for exaple: function initTimeControl() { ... }
    b) drop the E.on("init",...); alltogether
    c) add a simple onInit(){ ... } function, in which you call as 'first order of business' initTimeControl();.

    TL;DR:

    Assuming you use the upload function in the the IDE to get (all) the code (in post #1) onto the board, this happens:

    You are connected and upload the the code (into the RAM). Because you have save() as last statement, the code is saved (into FLASH). Because save() includes as last item to run the saved code, the code is (reloaded into RAM and) executed all to the end, including the save()... you get the point.

    I assume further, that you tried to fix this issue by adding all these clearXyz(...)... to no avail, because that messes even more with things, last but not leas because you added in an E.on("init",...). At first this looks like a good idea, butE.on(...)is position dependent: the sequence of encounter ofE.on(...)on upload will also be the sequence of execution at runtime. By pulling in modules that may also have "E.on(...)", you have no real control over the execution sequence and theseclearXYZ(...)``` may destroy things you just established or even Espruino in its firmware has established before even your code runs.

    You may read this post and then the whole conversation further this TL;DR: simple explanation how to save code that Espruino run on start? Even though some aspects have changed since this conversation took place, it points out the major difference between Espruino IoT platform and others, such as Arduino,...

About

Avatar for allObjects @allObjects started