Reboot on button press when halted but still have power

pull/285/head
Mike Bell 2022-03-09 23:32:52 +00:00
rodzic da14ec870f
commit bbb995a062
1 zmienionych plików z 5 dodań i 2 usunięć

Wyświetl plik

@ -2,6 +2,7 @@
#include <math.h>
#include "hardware/pwm.h"
#include "hardware/watchdog.h"
#include "badger2040.hpp"
@ -79,8 +80,10 @@ namespace pimoroni {
void Badger2040::halt() {
gpio_put(ENABLE_3V3, 0);
// don't allow any more code to execute while power rail drops
while(true) {}
// If running on USB we will not actually power down, so emulate the behaviour
// of battery powered badge by listening for a button press and then resetting
wait_for_press();
watchdog_reboot(0, 0, 0);
}
uint8_t _dither_value(int32_t x, int32_t y, uint8_t p) {