...it is always the same issue: Active executing code in level 0 messes with the upload completion detection from editor as well as console, and in your case it is even worse: your console.log() goes directly after that upload process. Reason: the (default, regular) console connection is used to upload... and because arriving code is executed as soon as it is a complete JavaScript statement or expression. The upload uses a timeout to check for a 'completion prompt' from Espruino. It does not get it but rather gets stuff from your application.
Put your function invocation code into a function (which you call within) onInit() function. This has other advantages: you will be able to save() your code in flash (enter save() in the console after upload), and the code will run on power on.
PS: without the convenience of last code line (setTimeout(onInit,...), you have to start your code every time after upload by entering onInit(); in the console... Helpful read up on these subjects is the conversation about simple explanation how to save code that espruino run on start?.
var temp = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
var send = function(times, i) {
console.log('foobar', i);
if (i < times.length) {
send(times, i + 1);
}
};
function onInit() {
send(temp, 1);
}
setTimeout(onInit, 1000); // DEVELOPMENT CONVENIENCE - REMOVE BEFORE SAVING
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.
...it is always the same issue: Active executing code in level 0 messes with the upload completion detection from editor as well as console, and in your case it is even worse: your
console.log()
goes directly after that upload process. Reason: the (default, regular) console connection is used to upload... and because arriving code is executed as soon as it is a complete JavaScript statement or expression. The upload uses a timeout to check for a 'completion prompt' from Espruino. It does not get it but rather gets stuff from your application.Put your function invocation code into a function (which you call within)
onInit()
function. This has other advantages: you will be able tosave()
your code in flash (entersave()
in the console after upload), and the code will run on power on.PS: without the convenience of last code line (
setTimeout(onInit,...
), you have to start your code every time after upload by enteringonInit();
in the console... Helpful read up on these subjects is the conversation about simple explanation how to save code that espruino run on start?.