To be honest I think a minor rewrite would fix it. I think it currently looks like:
jsiIdle() { // ... jshSleep(sleepTime); } jsiLoop() { jsiIdle(); } main() { while (1) jsiLoop(); }
But we could do:
jsiIdle() { // ... return sleepTime; } jsiLoop() { return jsiIdle(); } main() { while (1) jshSleep(jsiLoop()); }
In which case suddenly in ESP8266 you've got the sleep time available at the end, so you can reschedule the callback at the right time?
You could hack it in right now just by doing the following though?
function jshSleep(time) { sleepTime = time; } function idleCallback() { sleepTime = as_soon_as_possible; jsiLoop(); reschedule(idleCallback, sleepTime); }
@Gordon 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.
To be honest I think a minor rewrite would fix it. I think it currently looks like:
But we could do:
In which case suddenly in ESP8266 you've got the sleep time available at the end, so you can reschedule the callback at the right time?
You could hack it in right now just by doing the following though?