Throw an error when we cannot allocate PWM pixel buffer
This commit is contained in:
parent
6afb8dadbc
commit
f6ec1ea172
|
@ -129,8 +129,18 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
|
||||||
if ( pwm != NULL ) {
|
if ( pwm != NULL ) {
|
||||||
if (pattern_size <= sizeof(one_pixel)) {
|
if (pattern_size <= sizeof(one_pixel)) {
|
||||||
pixels_pattern = (uint16_t *) one_pixel;
|
pixels_pattern = (uint16_t *) one_pixel;
|
||||||
|
} else {
|
||||||
|
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 {
|
} else {
|
||||||
pixels_pattern = (uint16_t *) m_malloc_maybe(pattern_size, false);
|
pixels_pattern = (uint16_t *) m_malloc_maybe(pattern_size, false);
|
||||||
|
}
|
||||||
|
|
||||||
pattern_on_heap = true;
|
pattern_on_heap = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue