Throw an error when we cannot allocate PWM pixel buffer
This commit is contained in:
parent
6afb8dadbc
commit
f6ec1ea172
@ -130,7 +130,17 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
|
||||
if (pattern_size <= sizeof(one_pixel)) {
|
||||
pixels_pattern = (uint16_t *) one_pixel;
|
||||
} else {
|
||||
pixels_pattern = (uint16_t *) m_malloc_maybe(pattern_size, false);
|
||||
uint8_t sd_en = 0;
|
||||
(void) sd_softdevice_is_enabled(&sd_en);
|
||||
if (sd_en) {
|
||||
// If the soft device is enabled then we must use PWM to
|
||||
// transmit. This takes a bunch of memory to do so raise an
|
||||
// exception if we can't.
|
||||
pixels_pattern = (uint16_t *) m_malloc(pattern_size, false);
|
||||
} else {
|
||||
pixels_pattern = (uint16_t *) m_malloc_maybe(pattern_size, false);
|
||||
}
|
||||
|
||||
pattern_on_heap = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user