2022-05-07 20:31:21 +10:00
|
|
|
#include "buzz.h"
|
2022-02-28 21:19:38 +00:00
|
|
|
#include "configuration.h"
|
|
|
|
|
#include "graphics/Screen.h"
|
|
|
|
|
#include "main.h"
|
2022-05-07 20:31:21 +10:00
|
|
|
#include "power.h"
|
2022-02-28 21:19:38 +00:00
|
|
|
|
|
|
|
|
void powerCommandsCheck()
|
|
|
|
|
{
|
|
|
|
|
if (rebootAtMsec && millis() > rebootAtMsec) {
|
2022-12-30 10:27:07 -06:00
|
|
|
LOG_INFO("Rebooting\n");
|
2022-07-31 07:11:47 -05:00
|
|
|
#if defined(ARCH_ESP32)
|
2022-02-28 21:19:38 +00:00
|
|
|
ESP.restart();
|
2022-07-31 07:11:47 -05:00
|
|
|
#elif defined(ARCH_NRF52)
|
2022-04-27 11:00:26 +02:00
|
|
|
NVIC_SystemReset();
|
2023-07-08 18:32:36 +02:00
|
|
|
#elif defined(ARCH_RP2040)
|
|
|
|
|
rp2040.reboot();
|
2022-02-28 21:19:38 +00:00
|
|
|
#else
|
2023-01-21 14:34:29 +01:00
|
|
|
rebootAtMsec = -1;
|
2023-08-07 22:16:56 +02:00
|
|
|
LOG_WARN("FIXME implement reboot for this platform. Note that some settings require a restart to be applied.\n");
|
2022-02-28 21:19:38 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-11 22:40:33 +01:00
|
|
|
#if defined(ARCH_ESP32) || defined(ARCH_NRF52)
|
2022-02-28 21:19:38 +00:00
|
|
|
if (shutdownAtMsec) {
|
|
|
|
|
screen->startShutdownScreen();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (shutdownAtMsec && millis() > shutdownAtMsec) {
|
2022-12-30 10:27:07 -06:00
|
|
|
LOG_INFO("Shutting down from admin command\n");
|
2023-03-11 22:40:33 +01:00
|
|
|
#if defined(ARCH_NRF52) || defined(ARCH_ESP32)
|
2023-06-01 07:14:55 -05:00
|
|
|
playShutdownMelody();
|
2022-02-28 21:19:38 +00:00
|
|
|
power->shutdown();
|
|
|
|
|
#else
|
2022-12-30 10:27:07 -06:00
|
|
|
LOG_WARN("FIXME implement shutdown for this platform");
|
2022-02-28 21:19:38 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
2023-07-08 18:32:36 +02:00
|
|
|
}
|