In case you still struggle with MainCodeMenu.js code, no surprise to me: upload invokes at the end setup(). This means that before the upload can complete, things get executed... setup() is also called in E.on("init",...);.
Even though I cannot validate the following change, give it a try: put setup() at the end of the code into a setTimeout(setup,1000);.
What I generally suggest and do is just using function onInit() { setup(); } at the end of the code. While I'm still developing it is cumbersome to every time enter setup() in the console after code upload, I add an extra line containing setTimeout(onInit,1000); and remove it after I'm done with developing. I then upload the code with this last line removed and save it. That way I have a plain vanilla code on the chip and on power on it will do what I'm expecting: run the complete setup();. Level 0 code gets right away interpreted/executed while in upload... see the (often) referenced conversation about simple explanation how to save code that espruino run on start?.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
In case you still struggle with
MainCodeMenu.js
code, no surprise to me: upload invokes at the endsetup()
. This means that before the upload can complete, things get executed...setup()
is also called inE.on("init",...);
.Even though I cannot validate the following change, give it a try: put
setup()
at the end of the code into asetTimeout(setup,1000);
.What I generally suggest and do is just using
function onInit() { setup(); }
at the end of the code. While I'm still developing it is cumbersome to every time entersetup()
in the console after code upload, I add an extra line containingsetTimeout(onInit,1000);
and remove it after I'm done with developing. I then upload the code with this last line removed and save it. That way I have a plain vanilla code on the chip and on power on it will do what I'm expecting: run the completesetup();
. Level 0 code gets right away interpreted/executed while in upload... see the (often) referenced conversation about simple explanation how to save code that espruino run on start?.