diff options
| author | microDev <70126934+microDev1@users.noreply.github.com> | 2020-09-30 11:15:02 +0530 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2020-10-27 16:17:29 -0700 |
| commit | 0e444f0de8dd4db8b5be1c41b4c8062364e4fd94 (patch) | |
| tree | 8354a38260a3ae6b57757b7355885ae4ad510346 | |
| parent | 930cf14dcef3e3552a0e7d7476fd89b873738c2d (diff) | |
Implement sleep on code.py exit
| -rwxr-xr-x | main.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -57,6 +57,9 @@ #include "supervisor/shared/status_leds.h" #include "supervisor/shared/stack.h" #include "supervisor/serial.h" +#include "supervisor/usb.h" + +#include "shared-bindings/microcontroller/__init__.h" #include "boards/board.h" @@ -300,6 +303,19 @@ bool run_code_py(safe_mode_t safe_mode) { } } + for (uint8_t i = 0; i<=100; i++) { + if (!usb_msc_ejected()) { + //Go into light sleep + break; + } + mp_hal_delay_ms(10); + } + + if (usb_msc_ejected()) { + //Go into deep sleep + common_hal_mcu_deep_sleep(); + } + // Display a different completion message if the user has no USB attached (cannot save files) if (!serial_connected_at_start) { serial_write_compressed(translate("\nCode done running. Waiting for reload.\n")); |
