Files
firmware/src/shutdown.h

52 lines
1.1 KiB
C
Raw Normal View History

2022-05-07 20:31:21 +10:00
#include "buzz.h"
#include "configuration.h"
#include "graphics/Screen.h"
#include "main.h"
2022-05-07 20:31:21 +10: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 11:00:26 +02:00
NVIC_SystemReset();
#else
2023-01-21 14:34:29 +01:00
rebootAtMsec = -1;
LOG_WARN("FIXME implement reboot for this platform. Skipping for now.\n");
#endif
}
#if defined(ARCH_NRF52) || defined(HAS_PMU)
if (shutdownAtMsec) {
screen->startShutdownScreen();
playBeep();
2022-07-28 09:37:16 +02:00
#ifdef PIN_LED1
ledOff(PIN_LED1);
2022-07-28 09:37:16 +02:00
#endif
2023-01-21 14:34:29 +01:00
#ifdef PIN_LED2
ledOff(PIN_LED2);
2022-07-28 09:37:16 +02:00
#endif
2023-01-21 14:34:29 +01:00
#ifdef PIN_LED3
2022-07-28 09:37:16 +02:00
ledOff(PIN_LED3);
#endif
}
#endif
if (shutdownAtMsec && millis() > shutdownAtMsec) {
LOG_INFO("Shutting down from admin command\n");
2022-09-08 10:36:53 +08:00
#ifdef HAS_PMU
if (pmu_found == true) {
2022-06-06 18:48:22 +02:00
playShutdownMelody();
power->shutdown();
}
#elif defined(ARCH_NRF52)
playShutdownMelody();
power->shutdown();
#else
LOG_WARN("FIXME implement shutdown for this platform");
#endif
}
}