So to answer your question - what is wait() - it was a hack that I knew would one day need to be discussed. Its the bad bit of code below:
// quick hack function wait(ms){ var start = new Date().getTime(); var end = start; while(end < start + ms) { end = new Date().getTime(); } }
What is really needed is a yield(ms) function that gracefully yields but comes back to the same thread in ms time.
So the question is how to code using timers something like this:
function setupPSMOO() { log_debug("setupGPS() PSMOO"); UBX_CFG_RESET(); wait(100); UBX_CFG_PM2(settings.update, settings.search); wait(20); UBX_CFG_RXM(); wait(20); UBX_CFG_SAVE(); wait(20); }
@HughB started
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.
So to answer your question - what is wait() - it was a hack that I knew would one day need to be discussed. Its the bad bit of code below:
What is really needed is a yield(ms) function that gracefully yields but comes back to the same thread in ms time.
So the question is how to code using timers something like this: