You are reading a single comment by @allObjects and its replies.
Click here to read the full conversation.
-
Thank you for your help! It's the first time I code for Espruino and I still need to get used to it. I had concern about the loop functions, since I thought that the way they work is quite different from the environment I used to work in (especially Arduino). I will try to change my code according to your suggestions, thank you!
Your issue is that all your code runs within the upload cycle and that messes most of the time with the actual upload and things just do not what they should do.
Simplest thing, put your
doStart()
into theonInit(){}
function. After upload, you enteronInit()
in the console and your code will either just work straight from the start or reveal issues it has. For convenience while you get the code to get its act together and not having to type into the console for starting it after every upload, add this as a last line - which you remove for final upload for save():Adding the
onInit(){...}
gives you two birds w/ one stone:PS: JS is executed while uploaded. For the last thing you have
doStart()
which sets everything in motion before the upload has completed (except you have save on send checked in the IDE... which is not the point of (original) Espruino... it was first added to help to overcome Arduinism, and later, to increase memory saving by writing things directly into Flash and execute (most of) it from there.