diff options
Diffstat (limited to 'shared-bindings/nvm/ByteArray.c')
| -rw-r--r-- | shared-bindings/nvm/ByteArray.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 22cd838b1..326f719a8 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -31,29 +31,27 @@ #include "shared-bindings/nvm/ByteArray.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: nvm +//| class ByteArray: +//| """Presents a stretch of non-volatile memory as a bytearray. //| -//| :class:`ByteArray` -- Presents a stretch of non-volatile memory as a bytearray. -//| ================================================================================ +//| Non-volatile memory is available as a byte array that persists over reloads +//| and power cycles. Each assignment causes an erase and write cycle so its recommended to assign +//| all values to change at once. //| -//| Non-volatile memory is available as a byte array that persists over reloads -//| and power cycles. Each assignment causes an erase and write cycle so its recommended to assign -//| all values to change at once. +//| Usage:: //| -//| Usage:: -//| -//| import microcontroller -//| microcontroller.nvm[0:3] = b"\xcc\x10\x00" +//| import microcontroller +//| microcontroller.nvm[0:3] = b\"\xcc\x10\x00\"""" //| -//| .. class:: ByteArray() -//| -//| Not currently dynamically supported. Access the sole instance through `microcontroller.nvm`. +//| def __init__(self, ): +//| """Not currently dynamically supported. Access the sole instance through `microcontroller.nvm`.""" +//| ... //| -//| .. method:: __len__() -//| -//| Return the length. This is used by (`len`) +//| def __len__(self, ) -> Any: +//| """Return the length. This is used by (`len`)""" +//| ... //| STATIC mp_obj_t nvm_bytearray_unary_op(mp_unary_op_t op, mp_obj_t self_in) { nvm_bytearray_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -124,7 +122,8 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj #endif } else { // Single index rather than slice. - size_t index = mp_get_index(self->base.type, self->len, index_in, false); + size_t index = mp_get_index(self->base.type, common_hal_nvm_bytearray_get_length(self), + index_in, false); if (value == MP_OBJ_SENTINEL) { // load uint8_t value_out; |
