firmware/src/shutdown.h

51 lines
1.1 KiB
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) {
2022-04-27 09:00:26 +00:00
DEBUG_MSG("Rebooting\n");
#if defined(ARCH_ESP32)
ESP.restart();
#elif defined(ARCH_NRF52)
2022-04-27 09:00:26 +00:00
NVIC_SystemReset();
#else
DEBUG_MSG("FIXME implement reboot for this platform");
#endif
}
#if defined(ARCH_NRF52)
if (shutdownAtMsec) {
screen->startShutdownScreen();
playBeep();
2022-07-28 07:37:16 +00:00
#ifdef PIN_LED1
ledOff(PIN_LED1);
2022-07-28 07:37:16 +00:00
#endif
#ifdef PIN_LED2
ledOff(PIN_LED2);
2022-07-28 07:37:16 +00:00
#endif
#ifdef PIN_LED3
ledOff(PIN_LED3);
#endif
}
#endif
if (shutdownAtMsec && millis() > shutdownAtMsec) {
DEBUG_MSG("Shutting down from admin command\n");
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
if (axp192_found == true) {
2022-06-06 16:48:22 +00:00
playShutdownMelody();
power->shutdown();
}
#elif defined(ARCH_NRF52)
playShutdownMelody();
power->shutdown();
#else
DEBUG_MSG("FIXME implement shutdown for this platform");
#endif
}
}