diff --git a/libraries/badger2040/badger2040.cpp b/libraries/badger2040/badger2040.cpp index 252c4342..6edd2ce3 100644 --- a/libraries/badger2040/badger2040.cpp +++ b/libraries/badger2040/badger2040.cpp @@ -2,6 +2,7 @@ #include #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) {