mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Merge pull request #335 from seagull9000/RTTTL-tone-for-shutdown
Connect RTTTL shutdown melody to shutdown procedure
This commit is contained in:
commit
9ba1d8262f
2 changed files with 26 additions and 2 deletions
|
|
@ -266,7 +266,7 @@ void UITask::buttonHandler() {
|
||||||
digitalWrite(PIN_STATUS_LED, LOW);
|
digitalWrite(PIN_STATUS_LED, LOW);
|
||||||
delay(10);
|
delay(10);
|
||||||
#endif
|
#endif
|
||||||
_board->powerOff();
|
shutdown(); // without restart
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
btn_state_change_time = millis();
|
btn_state_change_time = millis();
|
||||||
|
|
@ -278,6 +278,30 @@ void UITask::buttonHandler() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* hardware-agnostic pre-shutdown activity should be done here
|
||||||
|
*/
|
||||||
|
void UITask::shutdown(bool restart){
|
||||||
|
|
||||||
|
#ifdef PIN_BUZZER
|
||||||
|
/* note: we have a choice here -
|
||||||
|
we can do a blocking buzzer.loop() with non-deterministic consequences
|
||||||
|
or we can set a flag and delay the shutdown for a couple of seconds
|
||||||
|
while a non-blocking buzzer.loop() plays out in UITask::loop()
|
||||||
|
*/
|
||||||
|
buzzer.shutdown();
|
||||||
|
uint32_t buzzer_timer = millis(); // fail-safe shutdown
|
||||||
|
while (buzzer.isPlaying() && (millis() - 2500) < buzzer_timer)
|
||||||
|
buzzer.loop();
|
||||||
|
|
||||||
|
#endif // PIN_BUZZER
|
||||||
|
|
||||||
|
if (restart)
|
||||||
|
_board->reboot();
|
||||||
|
else
|
||||||
|
_board->powerOff();
|
||||||
|
}
|
||||||
|
|
||||||
void UITask::loop() {
|
void UITask::loop() {
|
||||||
buttonHandler();
|
buttonHandler();
|
||||||
userLedHandler();
|
userLedHandler();
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ class UITask {
|
||||||
void buttonHandler();
|
void buttonHandler();
|
||||||
void userLedHandler();
|
void userLedHandler();
|
||||||
void renderBatteryIndicator(uint16_t batteryMilliVolts);
|
void renderBatteryIndicator(uint16_t batteryMilliVolts);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -55,5 +54,6 @@ public:
|
||||||
void msgRead(int msgcount);
|
void msgRead(int msgcount);
|
||||||
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount);
|
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount);
|
||||||
void soundBuzzer(UIEventType bet = UIEventType::none);
|
void soundBuzzer(UIEventType bet = UIEventType::none);
|
||||||
|
void shutdown(bool restart = false);
|
||||||
void loop();
|
void loop();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue