sforkowany z mirror/meshtastic-firmware
don't burn so much cpu spinning in loop()
rodzic
6f592fbb6b
commit
039f18c80d
|
@ -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);
|
||||
}
|
|
@ -259,10 +259,10 @@ void screen_setup()
|
|||
#endif
|
||||
}
|
||||
|
||||
void screen_loop()
|
||||
uint32_t screen_loop()
|
||||
{
|
||||
if (!disp)
|
||||
return;
|
||||
return 30 * 1000;
|
||||
|
||||
#ifdef T_BEAM_V10
|
||||
if (axp192_found && pmu_irq)
|
||||
|
@ -295,11 +295,17 @@ void screen_loop()
|
|||
#endif
|
||||
static bool showingBootScreen = true;
|
||||
|
||||
ui.update();
|
||||
|
||||
|
||||
|
||||
uint32_t msecstosleep = ui.update();
|
||||
|
||||
// Once we finish showing the bootscreen, remove it from the loop
|
||||
if (showingBootScreen && ui.getUiState()->currentFrame == 1)
|
||||
{
|
||||
ui.setFrames(nonBootFrames, frameCount - 1);
|
||||
}
|
||||
|
||||
// If we are scrolling do 30fps, otherwise just 1 fps (to save CPU)
|
||||
return (ui.getUiState()->frameState == IN_TRANSITION ? 10 : 500);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
void screen_print(const char * text);
|
||||
void screen_loop(), screen_setup(), screen_on(), screen_off(), screen_show_logo();
|
||||
|
||||
/// @return how many msecs can we sleep before we want service again
|
||||
uint32_t screen_loop();
|
||||
|
||||
void screen_setup(), screen_on(), screen_off(), screen_show_logo();
|
Ładowanie…
Reference in New Issue