summaryrefslogtreecommitdiff
path: root/supervisor/shared
diff options
context:
space:
mode:
authorScott Shawcroft <scott@adafruit.com>2020-12-08 16:30:41 -0800
committerGitHub <noreply@github.com>2020-12-08 16:30:41 -0800
commit57101d7da6151bbbb8417850bea191d21d9be123 (patch)
tree04f571b716c4b28ecba424525bbc48b8d8fd97bd /supervisor/shared
parent93fade24efb964a049e2fcbcfe5cda51008ab079 (diff)
parent0b4bcd9599cc07ff85d6a70297ae86ff3b02cdec (diff)
Merge pull request #3807 from tannewt/sleep_tweaks
Add `board_deinit` for use with sleep
Diffstat (limited to 'supervisor/shared')
-rw-r--r--supervisor/shared/board.c19
-rw-r--r--supervisor/shared/board.h14
-rw-r--r--supervisor/shared/tick.c4
3 files changed, 17 insertions, 20 deletions
diff --git a/supervisor/shared/board.c b/supervisor/shared/board.c
index e3eb8fd0d..30603aa66 100644
--- a/supervisor/shared/board.c
+++ b/supervisor/shared/board.c
@@ -26,23 +26,22 @@
#include "supervisor/shared/board.h"
-#include "shared-bindings/digitalio/DigitalInOut.h"
-#include "shared-bindings/neopixel_write/__init__.h"
+#if CIRCUITPY_DIGITALIO && CIRCUITPY_NEOPIXEL_WRITE
-#ifdef USER_NEOPIXELS_PIN
+#include <string.h>
-// The maximum number of user neopixels right now is 10, on Circuit Playgrounds.
-// PyBadge and PyGamer have max 5
-#define USER_NEOPIXELS_MAX_COUNT 10
+#include "shared-bindings/digitalio/DigitalInOut.h"
+#include "shared-bindings/neopixel_write/__init__.h"
-void board_reset_user_neopixels(void) {
+void board_reset_user_neopixels(const mcu_pin_obj_t* pin, size_t count) {
// Turn off on-board NeoPixel string
- uint8_t empty[USER_NEOPIXELS_MAX_COUNT * 3] = { 0 };
+ uint8_t empty[count * 3];
+ memset(empty, 0, count);
digitalio_digitalinout_obj_t neopixel_pin;
- common_hal_digitalio_digitalinout_construct(&neopixel_pin, USER_NEOPIXELS_PIN);
+ common_hal_digitalio_digitalinout_construct(&neopixel_pin, pin);
common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false,
DRIVE_MODE_PUSH_PULL);
- common_hal_neopixel_write(&neopixel_pin, empty, USER_NEOPIXELS_MAX_COUNT * 3);
+ common_hal_neopixel_write(&neopixel_pin, empty, count * 3);
common_hal_digitalio_digitalinout_deinit(&neopixel_pin);
}
diff --git a/supervisor/shared/board.h b/supervisor/shared/board.h
index 0e4d73455..fe887a933 100644
--- a/supervisor/shared/board.h
+++ b/supervisor/shared/board.h
@@ -24,15 +24,13 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_SUPERVISOR_BOARD_H
-#define MICROPY_INCLUDED_SUPERVISOR_BOARD_H
+#ifndef MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H
+#define MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H
-#include "py/mpconfig.h"
+#include <stddef.h>
-#ifdef USER_NEOPIXELS_PIN
+#include "shared-bindings/microcontroller/Pin.h"
-void board_reset_user_neopixels(void);
+void board_reset_user_neopixels(const mcu_pin_obj_t* pin, size_t count);
-#endif
-
-#endif // MICROPY_INCLUDED_SUPERVISOR_BOARD_H
+#endif // MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H
diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c
index a2855a570..d37a585eb 100644
--- a/supervisor/shared/tick.c
+++ b/supervisor/shared/tick.c
@@ -156,8 +156,8 @@ void mp_hal_delay_ms(mp_uint_t delay) {
break;
}
port_interrupt_after_ticks(remaining);
- // Sleep until an interrupt happens.
- port_sleep_until_interrupt();
+ // Idle until an interrupt happens.
+ port_idle_until_interrupt();
remaining = end_tick - port_get_raw_ticks(NULL);
}
}