diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index d097f96e3f..cf1b367057 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -97,6 +97,16 @@ static NRF_PWM_Type* find_free_pwm (void) { return NULL; } +static uint16_t* pixels_pattern_heap = NULL; +static size_t pixels_pattern_heap_size = 0; +static bool pattern_on_heap = false; +// Called during reset_port() to free the pattern buffer +void neopixel_write_reset(void) { + pixels_pattern_heap = NULL; + pixels_pattern_heap_size = 0; + pattern_on_heap = false; +} + uint64_t next_start_tick_ms = 0; uint32_t next_start_tick_us = 1000; @@ -113,12 +123,8 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout // using DWT #define PATTERN_SIZE(numBytes) (numBytes * 8 * sizeof(uint16_t) + 2 * sizeof(uint16_t)) - uint32_t pattern_size = PATTERN_SIZE(numBytes); uint16_t* pixels_pattern = NULL; - static uint16_t* pixels_pattern_heap = NULL; - static size_t pixels_pattern_heap_size = 0; - bool pattern_on_heap = false; // Use the stack to store 1 pixels worth of PWM data for the status led. uint32_t to ensure alignment. // Make it at least as big as PATTERN_SIZE(3), for one pixel of RGB data. diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index af858aa4a1..d240e3be0d 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -47,6 +47,7 @@ #include "common-hal/pulseio/PulseOut.h" #include "common-hal/pulseio/PulseIn.h" #include "common-hal/rtc/RTC.h" +#include "common-hal/neopixel_write/__init__.h" #include "tick.h" #include "shared-bindings/rtc/__init__.h" @@ -106,6 +107,7 @@ void reset_port(void) { i2c_reset(); spi_reset(); uart_reset(); + neopixel_write_reset(); #if CIRCUITPY_AUDIOBUSIO i2s_reset();