firmware/src/shutdown.h

37 lines
881 B
C
Raw Normal View History

2022-05-07 10:31:21 +00:00
#include "buzz.h"
#include "configuration.h"
#include "graphics/Screen.h"
#include "main.h"
2022-05-07 10:31:21 +00:00
#include "power.h"
void powerCommandsCheck()
{
if (rebootAtMsec && millis() > rebootAtMsec) {
LOG_INFO("Rebooting\n");
#if defined(ARCH_ESP32)
ESP.restart();
#elif defined(ARCH_NRF52)
2022-04-27 09:00:26 +00:00
NVIC_SystemReset();
#else
2023-01-21 13:34:29 +00:00
rebootAtMsec = -1;
LOG_WARN("FIXME implement reboot for this platform. Skipping for now.\n");
#endif
}
#if defined(ARCH_ESP32) || defined(ARCH_NRF52)
if (shutdownAtMsec) {
screen->startShutdownScreen();
}
#endif
if (shutdownAtMsec && millis() > shutdownAtMsec) {
LOG_INFO("Shutting down from admin command\n");
#if defined(ARCH_NRF52) || defined(ARCH_ESP32)
playShutdownMelody();
power->shutdown();
#else
LOG_WARN("FIXME implement shutdown for this platform");
#endif
}
}