You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • 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);
    }
    
About

Avatar for Gordon @Gordon started