Merge pull request #5946 from tammymakesthings/pr4218-neopixel-show-after-deinit
Fixes neopixel show() after deinit() not raising an exception
This commit is contained in:
commit
93a60eecab
@ -20,6 +20,7 @@ ifeq ($(CHIP_FAMILY),samd21)
|
||||
# fit in 256kB of flash
|
||||
|
||||
CIRCUITPY_AESIO ?= 0
|
||||
CIRCUITPY_ATEXIT ?= 0
|
||||
CIRCUITPY_AUDIOMIXER ?= 0
|
||||
CIRCUITPY_BINASCII ?= 0
|
||||
CIRCUITPY_BITBANGIO ?= 0
|
||||
@ -33,6 +34,7 @@ CIRCUITPY_COUNTIO ?= 0
|
||||
# Not enough RAM for framebuffers
|
||||
CIRCUITPY_FRAMEBUFFERIO ?= 0
|
||||
CIRCUITPY_FREQUENCYIO ?= 0
|
||||
CIRCUITPY_GETPASS ?= 0
|
||||
CIRCUITPY_GIFIO ?= 0
|
||||
CIRCUITPY_I2CPERIPHERAL ?= 0
|
||||
CIRCUITPY_JSON ?= 0
|
||||
|
@ -29,8 +29,15 @@
|
||||
#include "py/mphal.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
#include "shared-bindings/util.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) {
|
||||
if (common_hal_digitalio_digitalinout_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| """Low-level neopixel implementation
|
||||
//|
|
||||
//| The `neopixel_write` module contains a helper method to write out bytes in
|
||||
@ -60,8 +67,13 @@ STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj
|
||||
if (!mp_obj_is_type(digitalinout_obj, &digitalio_digitalinout_type)) {
|
||||
mp_raise_TypeError_varg(translate("Expected a %q"), digitalio_digitalinout_type.name);
|
||||
}
|
||||
|
||||
// Convert parameters into expected types.
|
||||
const digitalio_digitalinout_obj_t *digitalinout = MP_OBJ_TO_PTR(digitalinout_obj);
|
||||
|
||||
// Check to see if the NeoPixel has been deinited before writing to it.
|
||||
check_for_deinit(digitalinout_obj);
|
||||
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ);
|
||||
// Call platform's neopixel write function with provided buffer and options.
|
||||
|
@ -22,7 +22,7 @@ print(sha1.digest())
|
||||
|
||||
sha1 = hashlib.sha1(b"hello")
|
||||
try:
|
||||
sha1.update(u"world")
|
||||
sha1.update("world")
|
||||
except TypeError as e:
|
||||
print("TypeError")
|
||||
print(sha1.digest())
|
||||
|
@ -28,7 +28,7 @@ print(hashlib.sha256(b"\xff" * 56).digest())
|
||||
|
||||
sha256 = hashlib.sha256(b"hello")
|
||||
try:
|
||||
sha256.update(u"world")
|
||||
sha256.update("world")
|
||||
except TypeError as e:
|
||||
print("TypeError")
|
||||
print(sha256.digest())
|
||||
|
Loading…
x
Reference in New Issue
Block a user