don't burn so much cpu spinning in loop()

This commit is contained in:
geeksville
2020-02-07 16:12:55 -08:00
parent 6f592fbb6b
commit 039f18c80d
3 changed files with 19 additions and 6 deletions

View File

@@ -371,8 +371,10 @@ void setup()
void loop()
{
uint32_t msecstosleep = 1000 * 30; // How long can we sleep before we again need to service the main loop?
gps.loop();
screen_loop();
msecstosleep = min(screen_loop(), msecstosleep);
service.loop();
loopBLE();
@@ -428,5 +430,6 @@ void loop()
// No GPS lock yet, let the OS put the main CPU in low power mode for 100ms (or until another interrupt comes in)
// i.e. don't just keep spinning in loop as fast as we can.
//delay(100);
DEBUG_MSG("msecs %d\n", msecstosleep);
delay(msecstosleep);
}