File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5757#include "supervisor/shared/status_leds.h"
5858#include "supervisor/shared/stack.h"
5959#include "supervisor/serial.h"
60+ #include "supervisor/usb.h"
61+
62+ #include "shared-bindings/microcontroller/__init__.h"
6063
6164#include "boards/board.h"
6265
@@ -300,6 +303,19 @@ bool run_code_py(safe_mode_t safe_mode) {
300303 }
301304 }
302305
306+ for (uint8_t i = 0 ; i <=100 ; i ++ ) {
307+ if (!usb_msc_ejected ()) {
308+ //Go into light sleep
309+ break ;
310+ }
311+ mp_hal_delay_ms (10 );
312+ }
313+
314+ if (usb_msc_ejected ()) {
315+ //Go into deep sleep
316+ common_hal_mcu_deep_sleep ();
317+ }
318+
303319 // Display a different completion message if the user has no USB attached (cannot save files)
304320 if (!serial_connected_at_start ) {
305321 serial_write_compressed (translate ("\nCode done running. Waiting for reload.\n" ));
You can’t perform that action at this time.
0 commit comments