From db84445a6284db224c66a3ecef6290ce0e17915f Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 21 Jul 2019 16:21:39 -0400 Subject: [PATCH 01/44] WIP: refactor _pixelbuf to use strings instead of classes --- shared-bindings/_pixelbuf/PixelBuf.c | 101 +++++++++++++++++---------- shared-bindings/_pixelbuf/PixelBuf.h | 3 +- shared-bindings/_pixelbuf/__init__.c | 101 ++++++--------------------- shared-bindings/_pixelbuf/__init__.h | 2 - shared-bindings/_pixelbuf/types.h | 6 +- 5 files changed, 88 insertions(+), 125 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 420720e622..0e43b79dd6 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -40,10 +40,42 @@ #include "../../shared-module/_pixelbuf/PixelBuf.h" #include "shared-bindings/digitalio/DigitalInOut.h" -extern const pixelbuf_byteorder_obj_t byteorder_BGR; -extern const mp_obj_type_t pixelbuf_byteorder_type; extern const int32_t colorwheel(float pos); +int parse_byteorder_string(const char *byteorder, pixelbuf_byteorder_details_t details) { + details.bpp = strlen(byteorder); + char *dotstar = strchr(byteorder, 'D'); + char *r = strchr(byteorder, 'R'); + char *g = strchr(byteorder, 'G'); + char *b = strchr(byteorder, 'B'); + char *w = strchr(byteorder, 'W'); + int num_chars = (dotstar ? 1 : 0) + (w ? 1 : 0) + (r ? 1 : 0) + (g ? 1 : 0) + (b ? 1 : 0); + if (num_chars < details.bpp) + mp_raise_ValueError(translate("Unexpected character in byteorder")); + if (!(r && b && g)) + mp_raise_ValueError(translate("Incomplete byteorder string")); + details.is_dotstar = dotstar ? true : false; + details.has_white = w ? true : false; + details.byteorder.r = byteorder - r; + details.byteorder.g = byteorder - g; + details.byteorder.b = byteorder - b; + if (w) + details.byteorder.w = byteorder - w; + // The dotstar brightness byte is always first (as it goes with the pixel start bits) + // if 'D' is found at the end, adjust byte position + // if 'D' is elsewhere, error out + if (dotstar) { + size_t dotstar_pos = dotstar - byteorder; + if (dotstar_pos == 4) { + details.byteorder.b += 1; + details.byteorder.g += 1; + details.byteorder.r += 1; + } else if (dotstar_pos != 0) { + mp_raise_ValueError(translate("Dotstar position invalid")); + } + } +} + //| .. currentmodule:: pixelbuf //| //| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices @@ -51,7 +83,7 @@ extern const int32_t colorwheel(float pos); //| //| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction. //| -//| .. class:: PixelBuf(size, buf, byteorder=BGR, brightness=0, rawbuf=None, offset=0, dotstar=False, auto_write=False, write_function=None, write_args=None) +//| .. class:: PixelBuf(size, buf, byteorder="BGR", brightness=0, rawbuf=None, offset=0, auto_write=False, write_function=None, write_args=None) //| //| Create a PixelBuf object of the specified size, byteorder, and bits per pixel. //| @@ -60,17 +92,15 @@ extern const int32_t colorwheel(float pos); //| //| When only given ``buf``, ``brightness`` applies to the next pixel assignment. //| -//| When ``dotstar`` is True, and ``bpp`` is 4, the 4th value in a tuple/list -//| is the individual pixel brightness (0-1). Not compatible with RGBW Byteorders. -//| Compatible `ByteOrder` classes are bpp=3, or bpp=4 and has_luminosity=True (g LBGR). +//| When ``D`` (dotstar mode) is present in the byteorder configuration, the +//| 4th value in a tuple/list is the individual pixel brightness (0-1). //| //| :param ~int size: Number of pixelsx -//| :param ~bytearray buf: Bytearray to store pixel data in -//| :param ~_pixelbuf.ByteOrder byteorder: Byte order constant from `_pixelbuf` +//| :param ~bytearray buf: Bytearray in which to store pixel data +//| :param ~str byteorder: Byte order string (such as "BGR" or "BGRD") //| :param ~float brightness: Brightness (0 to 1.0, default 1.0) -//| :param ~bytearray rawbuf: Bytearray to store raw pixel colors in +//| :param ~bytearray rawbuf: Bytearray in which to store raw pixel data (before brightness adjustment) //| :param ~int offset: Offset from start of buffer (default 0) -//| :param ~bool dotstar: Dotstar mode (default False) //| :param ~bool auto_write: Whether to automatically write pixels (Default False) //| :param ~callable write_function: (optional) Callable to use to send pixels //| :param ~list write_args: (optional) Tuple or list of args to pass to ``write_function``. The @@ -78,7 +108,7 @@ extern const int32_t colorwheel(float pos); //| STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 2, MP_OBJ_FUN_ARGS_MAX, true); - enum { ARG_size, ARG_buf, ARG_byteorder, ARG_brightness, ARG_rawbuf, ARG_offset, ARG_dotstar, + enum { ARG_size, ARG_buf, ARG_byteorder, ARG_brightness, ARG_rawbuf, ARG_offset, ARG_auto_write, ARG_write_function, ARG_write_args }; static const mp_arg_t allowed_args[] = { { MP_QSTR_size, MP_ARG_REQUIRED | MP_ARG_INT }, @@ -87,7 +117,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_brightness, MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_rawbuf, MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_offset, MP_ARG_INT, { .u_int = 0 } }, - { MP_QSTR_dotstar, MP_ARG_BOOL, { .u_bool = false } }, { MP_QSTR_auto_write, MP_ARG_BOOL, {.u_bool = false} }, { MP_QSTR_write_function, MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_write_args, MP_ARG_OBJ, {.u_obj = mp_const_none} }, @@ -95,15 +124,23 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - if (mp_obj_is_subclass_fast(args[ARG_byteorder].u_obj, &pixelbuf_byteorder_type)) - mp_raise_TypeError_varg(translate("byteorder is not an instance of ByteOrder (got a %s)"), mp_obj_get_type_str(args[ARG_byteorder].u_obj)); + if (!MP_OBJ_IS_STR(args[ARG_byteorder].u_obj)) + mp_raise_TypeError(translate("byteorder is not a string")); - pixelbuf_byteorder_obj_t *byteorder = (args[ARG_byteorder].u_obj == mp_const_none) ? MP_OBJ_FROM_PTR(&byteorder_BGR) : args[ARG_byteorder].u_obj; + const char *byteorder_str = NULL; + pixelbuf_byteorder_details_t byteorder_details; + size_t bo_len; + if (args[ARG_byteorder].u_obj == NULL) + byteorder_str = "BGR"; + else + byteorder_str = mp_obj_str_get_data(byteorder_str, bo_len); - if (byteorder->has_white && args[ARG_dotstar].u_bool) - mp_raise_ValueError_varg(translate("Can not use dotstar with %s"), mp_obj_get_type_str(byteorder)); + parse_byteorder_string(byteorder_str, byteorder_details); - size_t effective_bpp = args[ARG_dotstar].u_bool ? 4 : byteorder->bpp; // Always 4 for DotStar + if (byteorder_details.has_white && byteorder_details.is_dotstar) + mp_raise_ValueError(translate("Can not use dotstar with a white byte")); + + size_t effective_bpp = byteorder_details.is_dotstar ? 4 : byteorder_details.bpp; // Always 4 for DotStar size_t bytes = args[ARG_size].u_int * effective_bpp; size_t offset = args[ARG_offset].u_int; mp_buffer_info_t bufinfo, rawbufinfo; @@ -133,28 +170,16 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a self->base.type = &pixelbuf_pixelbuf_type; self->pixels = args[ARG_size].u_int; self->bytes = bytes; - self->byteorder = *byteorder; // Copied because we modify for dotstar + self->byteorder = byteorder_details; // Copied because we modify for dotstar self->bytearray = args[ARG_buf].u_obj; self->two_buffers = two_buffers; self->rawbytearray = two_buffers ? args[ARG_rawbuf].u_obj : NULL; self->offset = offset; - self->dotstar_mode = args[ARG_dotstar].u_bool; self->buf = (uint8_t *)bufinfo.buf + offset; self->rawbuf = two_buffers ? (uint8_t *)rawbufinfo.buf + offset : NULL; self->pixel_step = effective_bpp; self->auto_write = args[ARG_auto_write].u_bool; - if (self->dotstar_mode) { - // Ensure sane configuration - if (!self->byteorder.has_luminosity) { - self->byteorder.has_luminosity = true; - self->byteorder.byteorder.b += 1; - self->byteorder.byteorder.g += 1; - self->byteorder.byteorder.r += 1; - } - self->byteorder.byteorder.w = 0; - } - // Show/auto-write callbacks self->write_function = args[ARG_write_function].u_obj; mp_obj_t function_args = args[ARG_write_args].u_obj; @@ -187,7 +212,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a self->brightness = 1; } - if (self->dotstar_mode) { + if (self->byteorder.is_dotstar) { // Initialize the buffer with the dotstar start bytes. // Header and end must be setup by caller for (uint i = 0; i < self->pixels * 4; i += 4) { @@ -266,7 +291,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { // Compensate for shifted buffer (bpp=3 dotstar) for (uint i = 0; i < self->bytes; i++) { // Don't adjust per-pixel luminance bytes in dotstar mode - if (!self->dotstar_mode || (i % 4 != 0)) + if (!self->byteorder.is_dotstar || (i % 4 != 0)) buf[i] = rawbuf[i] * self->brightness; } } @@ -321,7 +346,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_buf_obj = { //| .. attribute:: byteorder //| -//| `ByteOrder` class for the buffer (read-only) +//| byteorder string for the buffer (read-only) //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); @@ -397,7 +422,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (value == MP_OBJ_SENTINEL) { // Get size_t len = slice.stop - slice.start; - return pixelbuf_get_pixel_array((uint8_t *) self->buf + slice.start, len, &self->byteorder, self->pixel_step, self->dotstar_mode); + return pixelbuf_get_pixel_array((uint8_t *) self->buf + slice.start, len, &self->byteorder, self->pixel_step, self->byteorder.is_dotstar); } else { // Set #if MICROPY_PY_ARRAY_SLICE_ASSIGN @@ -426,7 +451,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple) || MP_OBJ_IS_INT(value)) { pixelbuf_set_pixel(self->buf + (i * self->pixel_step), self->two_buffers ? self->rawbuf + (i * self->pixel_step) : NULL, - self->brightness, item, &self->byteorder, self->dotstar_mode); + self->brightness, item, &self->byteorder, self->byteorder.is_dotstar); } } if (self->auto_write) @@ -445,10 +470,10 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (value == MP_OBJ_SENTINEL) { // Get uint8_t *pixelstart = (uint8_t *)(self->two_buffers ? self->rawbuf : self->buf) + offset; - return pixelbuf_get_pixel(pixelstart, &self->byteorder, self->dotstar_mode); + return pixelbuf_get_pixel(pixelstart, &self->byteorder, self->byteorder.is_dotstar); } else { // Store pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, - self->brightness, value, &self->byteorder, self->dotstar_mode); + self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) call_write_function(self); return mp_const_none; diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index 0b1e362783..0f5613621a 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -36,13 +36,12 @@ typedef struct { size_t pixels; size_t bytes; size_t pixel_step; - pixelbuf_byteorder_obj_t byteorder; + pixelbuf_byteorder_details_t byteorder; mp_obj_t bytearray; mp_obj_t rawbytearray; mp_float_t brightness; bool two_buffers; size_t offset; - bool dotstar_mode; uint8_t *rawbuf; uint8_t *buf; mp_obj_t write_function; diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 48b9f1cef1..6ff43cb33b 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -42,9 +42,11 @@ //| .. module:: _pixelbuf //| :synopsis: A fast RGB(W) pixel buffer library for like NeoPixel and DotStar. //| -//| The `_pixelbuf` module provides :py:class:`PixelBuf` and :py:class:`ByteOrder` classes to accelerate +//| The `_pixelbuf` module provides the :py:class:`PixelBuf` class to accelerate //| RGB(W) strip/matrix manipulation, such as DotStar and Neopixel. //| +//| Byteorders are configured with strings, such as "RGB" or "RGBD". +//| TODO: Pull in docs from pypixelbuf. //| Libraries //| @@ -53,31 +55,6 @@ //| //| PixelBuf -//| .. class:: ByteOrder() -//| -//| Classes representing byteorders for circuitpython - - -//| .. attribute:: bpp -//| -//| The number of bytes per pixel (read-only) -//| - -//| .. attribute:: has_white -//| -//| Whether the pixel has white (in addition to RGB) -//| - -//| .. attribute:: has_luminosity -//| -//| Whether the pixel has luminosity (in addition to RGB) -//| - -//| .. attribute:: byteorder -//| -//| Tuple of byte order (r, g, b) or (r, g, b, w) or (r, g, b, l) -//| - STATIC void pixelbuf_byteorder_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_byteorder_type)); @@ -113,33 +90,6 @@ STATIC void pixelbuf_byteorder_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) } } -STATIC mp_obj_t pixelbuf_byteorder_unary_op(mp_unary_op_t op, mp_obj_t self_in) { - pixelbuf_byteorder_obj_t *self = MP_OBJ_TO_PTR(self_in); - switch (op) { - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->bpp); - default: return MP_OBJ_NULL; // op not supported - } -} - -const mp_obj_type_t pixelbuf_byteorder_type = { - { &mp_type_type }, - .name = MP_QSTR_ByteOrder, - .print = pixelbuf_byteorder_print, - .unary_op = pixelbuf_byteorder_unary_op, - .attr = pixelbuf_byteorder_attr, -}; - - -// This macro is used to simplify RGB subclass definition -#define PIXELBUF_BYTEORDER(p_name, p_bpp, p_r, p_g, p_b, p_w, p_has_white, p_has_luminosity) \ -const pixelbuf_byteorder_obj_t byteorder_## p_name = { \ - { &pixelbuf_byteorder_type }, \ - .name = MP_QSTR_## p_name, \ - .bpp = p_bpp, \ - .byteorder = { p_r, p_g, p_b, p_w }, \ - .has_white = p_has_white, \ - .has_luminosity = p_has_luminosity, \ -}; //| .. function:: wheel(n) //| @@ -290,36 +240,29 @@ PIXELBUF_BYTEORDER(LBGR, 4, 3, 2, 1, 0, false, true) STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) }, { MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) }, - { MP_ROM_QSTR(MP_QSTR_ByteOrder), MP_ROM_PTR(&pixelbuf_byteorder_type) }, - { MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_PTR(&byteorder_RGB) }, - { MP_ROM_QSTR(MP_QSTR_RBG), MP_ROM_PTR(&byteorder_RBG) }, - { MP_ROM_QSTR(MP_QSTR_GRB), MP_ROM_PTR(&byteorder_GRB) }, - { MP_ROM_QSTR(MP_QSTR_GBR), MP_ROM_PTR(&byteorder_GBR) }, - { MP_ROM_QSTR(MP_QSTR_BRG), MP_ROM_PTR(&byteorder_BRG) }, - { MP_ROM_QSTR(MP_QSTR_BGR), MP_ROM_PTR(&byteorder_BGR) }, - { MP_ROM_QSTR(MP_QSTR_RGBW), MP_ROM_PTR(&byteorder_RGBW) }, - { MP_ROM_QSTR(MP_QSTR_RBGW), MP_ROM_PTR(&byteorder_RBGW) }, - { MP_ROM_QSTR(MP_QSTR_GRBW), MP_ROM_PTR(&byteorder_GRBW) }, - { MP_ROM_QSTR(MP_QSTR_GBRW), MP_ROM_PTR(&byteorder_GBRW) }, - { MP_ROM_QSTR(MP_QSTR_BRGW), MP_ROM_PTR(&byteorder_BRGW) }, - { MP_ROM_QSTR(MP_QSTR_BGRW), MP_ROM_PTR(&byteorder_BGRW) }, - { MP_ROM_QSTR(MP_QSTR_LRGB), MP_ROM_PTR(&byteorder_LRGB) }, - { MP_ROM_QSTR(MP_QSTR_LRBG), MP_ROM_PTR(&byteorder_LRBG) }, - { MP_ROM_QSTR(MP_QSTR_LGRB), MP_ROM_PTR(&byteorder_LGRB) }, - { MP_ROM_QSTR(MP_QSTR_LGBR), MP_ROM_PTR(&byteorder_LGBR) }, - { MP_ROM_QSTR(MP_QSTR_LBRG), MP_ROM_PTR(&byteorder_LBRG) }, - { MP_ROM_QSTR(MP_QSTR_LBGR), MP_ROM_PTR(&byteorder_LBGR) }, - { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, + { MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_QSTR(MP_QSTR_RGB) }, + { MP_ROM_QSTR(MP_QSTR_RBG), MP_ROM_QSTR(MP_QSTR_RBG) }, + { MP_ROM_QSTR(MP_QSTR_GRB), MP_ROM_QSTR(MP_QSTR_GRB) }, + { MP_ROM_QSTR(MP_QSTR_GBR), MP_ROM_QSTR(MP_QSTR_GBR) }, + { MP_ROM_QSTR(MP_QSTR_BRG), MP_ROM_QSTR(MP_QSTR_BRG) }, + { MP_ROM_QSTR(MP_QSTR_BGR), MP_ROM_QSTR(MP_QSTR_BGR) }, + { MP_ROM_QSTR(MP_QSTR_RGBW), MP_ROM_QSTR(MP_QSTR_RGBW) }, + { MP_ROM_QSTR(MP_QSTR_RBGW), MP_ROM_QSTR(MP_QSTR_RBGW) }, + { MP_ROM_QSTR(MP_QSTR_GRBW), MP_ROM_QSTR(MP_QSTR_GRBW) }, + { MP_ROM_QSTR(MP_QSTR_GBRW), MP_ROM_QSTR(MP_QSTR_GBRW) }, + { MP_ROM_QSTR(MP_QSTR_BRGW), MP_ROM_QSTR(MP_QSTR_BRGW) }, + { MP_ROM_QSTR(MP_QSTR_BGRW), MP_ROM_QSTR(MP_QSTR_BGRW) }, + { MP_ROM_QSTR(MP_QSTR_RGBD), MP_ROM_QSTR(MP_QSTR_RGBD) }, + { MP_ROM_QSTR(MP_QSTR_RBGD), MP_ROM_QSTR(MP_QSTR_RBGD) }, + { MP_ROM_QSTR(MP_QSTR_GRBD), MP_ROM_QSTR(MP_QSTR_GRBD) }, + { MP_ROM_QSTR(MP_QSTR_GBRD), MP_ROM_QSTR(MP_QSTR_GBRD) }, + { MP_ROM_QSTR(MP_QSTR_BRGD), MP_ROM_QSTR(MP_QSTR_BRGD) }, + { MP_ROM_QSTR(MP_QSTR_BGRD), MP_ROM_QSTR(MP_QSTR_BGRD) }, + { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_QSTR(&pixelbuf_wheel_obj) }, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_table); -STATIC void pixelbuf_byteorder_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - pixelbuf_byteorder_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_printf(print, "%q.%q", MP_QSTR__pixelbuf, self->name); - return; -} - const mp_obj_module_t pixelbuf_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&pixelbuf_module_globals, diff --git a/shared-bindings/_pixelbuf/__init__.h b/shared-bindings/_pixelbuf/__init__.h index a62d67c4a4..f70ffe5083 100644 --- a/shared-bindings/_pixelbuf/__init__.h +++ b/shared-bindings/_pixelbuf/__init__.h @@ -29,9 +29,7 @@ #include "common-hal/digitalio/DigitalInOut.h" -STATIC void pixelbuf_byteorder_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); const int32_t colorwheel(float pos); -const mp_obj_type_t pixelbuf_byteorder_type; extern void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* gpio, uint8_t *pixels, uint32_t numBytes); #endif //CP_SHARED_BINDINGS_PIXELBUF_INIT_H diff --git a/shared-bindings/_pixelbuf/types.h b/shared-bindings/_pixelbuf/types.h index f7d757791b..7d772dbf53 100644 --- a/shared-bindings/_pixelbuf/types.h +++ b/shared-bindings/_pixelbuf/types.h @@ -37,12 +37,10 @@ typedef struct { } pixelbuf_rgbw_t; typedef struct { - mp_obj_base_t base; - qstr name; uint8_t bpp; pixelbuf_rgbw_t byteorder; bool has_white; - bool has_luminosity; -} pixelbuf_byteorder_obj_t; + bool is_dotstar; +} pixelbuf_byteorder_details_t; #endif // CIRCUITPYTHON_PIXELBUF_TYPES_H From a62a1ae2bd16a4d8e4029b26bd23761da1b12d5f Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 21 Jul 2019 16:30:09 -0400 Subject: [PATCH 02/44] WIP: refactor _pixelbuf to use strings instead of classes --- shared-bindings/_pixelbuf/PixelBuf.c | 2 +- shared-bindings/_pixelbuf/__init__.c | 35 ---------------------------- shared-module/_pixelbuf/PixelBuf.c | 6 ++--- shared-module/_pixelbuf/PixelBuf.h | 8 +++---- 4 files changed, 8 insertions(+), 43 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 0e43b79dd6..2ea40d1de2 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -42,7 +42,7 @@ extern const int32_t colorwheel(float pos); -int parse_byteorder_string(const char *byteorder, pixelbuf_byteorder_details_t details) { +void parse_byteorder_string(const char *byteorder, pixelbuf_byteorder_details_t details) { details.bpp = strlen(byteorder); char *dotstar = strchr(byteorder, 'D'); char *r = strchr(byteorder, 'R'); diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 6ff43cb33b..229c04603c 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -56,41 +56,6 @@ //| PixelBuf -STATIC void pixelbuf_byteorder_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_byteorder_type)); - pixelbuf_byteorder_obj_t *self = MP_OBJ_TO_PTR(self_in); - if (dest[0] == MP_OBJ_NULL) { - // load attribute - mp_obj_t val; - if (attr == MP_QSTR_bpp) { - val = MP_OBJ_NEW_SMALL_INT(self->bpp); - } else if (attr == MP_QSTR_has_white) { - val = mp_obj_new_bool(self->has_white); - } else if (attr == MP_QSTR_has_luminosity) { - val = mp_obj_new_bool(self->has_luminosity); - } else if (attr == MP_QSTR_byteorder) { - mp_obj_t items[4]; - uint8_t n = self->bpp; - if (self->has_luminosity || self->has_white) { - n = 4; - } - uint8_t *values = (uint8_t *)&(self->byteorder); - for (uint8_t i=0; i -void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_obj_t *byteorder) { +void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_details_t *byteorder) { buf[byteorder->byteorder.r] = value >> 16 & 0xff; buf[byteorder->byteorder.g] = (value >> 8) & 0xff; buf[byteorder->byteorder.b] = value & 0xff; @@ -43,7 +43,7 @@ void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_obj } } -void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_obj_t *byteorder, bool dotstar) { +void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_details_t *byteorder, bool dotstar) { if (MP_OBJ_IS_INT(item)) { uint8_t *target = rawbuf ? rawbuf : buf; pixelbuf_set_pixel_int(target, mp_obj_get_int_truncated(item), byteorder); @@ -94,7 +94,7 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_ } } -mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_obj_t *byteorder, uint8_t step, bool dotstar) { +mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, bool dotstar) { mp_obj_t elems[len]; for (uint i = 0; i < len; i++) { elems[i] = pixelbuf_get_pixel(buf + (i * step), byteorder, dotstar); diff --git a/shared-module/_pixelbuf/PixelBuf.h b/shared-module/_pixelbuf/PixelBuf.h index 9e115fe0cf..6b3272e193 100644 --- a/shared-module/_pixelbuf/PixelBuf.h +++ b/shared-module/_pixelbuf/PixelBuf.h @@ -42,9 +42,9 @@ #define DOTSTAR_GET_BRIGHTNESS(value) ((value & 0b00011111) / 31.0) #define DOTSTAR_LED_START_FULL_BRIGHT 0xFF -void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_obj_t *byteorder, bool dotstar); -mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_obj_t *byteorder, bool dotstar); -mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_obj_t *byteorder, uint8_t step, bool dotstar); -void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_obj_t *byteorder); +void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_details_t *byteorder, bool dotstar); +mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_details_t *byteorder, bool dotstar); +mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, bool dotstar); +void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_details_t *byteorder); #endif From 31e4591691891abd92d8e3851cd13fb6dbc9bf64 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 21 Jul 2019 16:37:06 -0400 Subject: [PATCH 03/44] WIP: refactor _pixelbuf to use strings instead of classes --- shared-bindings/_pixelbuf/PixelBuf.c | 2 +- shared-bindings/_pixelbuf/__init__.c | 122 +-------------------------- shared-module/_pixelbuf/PixelBuf.c | 2 +- 3 files changed, 3 insertions(+), 123 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 2ea40d1de2..01ba702c37 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -133,7 +133,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a if (args[ARG_byteorder].u_obj == NULL) byteorder_str = "BGR"; else - byteorder_str = mp_obj_str_get_data(byteorder_str, bo_len); + byteorder_str = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); parse_byteorder_string(byteorder_str, byteorder_details); diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 229c04603c..02d5f49b35 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -82,126 +82,6 @@ const int32_t colorwheel(float pos) { } } - -/// RGB -//| .. data:: RGB -//| -//| * **order** Red, Green, Blue -//| * **bpp** 3 -PIXELBUF_BYTEORDER(RGB, 3, 0, 1, 2, 3, false, false) -//| .. data:: RBG -//| -//| * **order** Red, Blue, Green -//| * **bpp** 3 -PIXELBUF_BYTEORDER(RBG, 3, 0, 2, 1, 3, false, false) -//| .. data:: GRB -//| -//| * **order** Green, Red, Blue -//| * **bpp** 3 -//| -//| Commonly used by NeoPixel. -PIXELBUF_BYTEORDER(GRB, 3, 1, 0, 2, 3, false, false) -//| .. data:: GBR -//| -//| * **order** Green, Blue, Red -//| * **bpp** 3 -PIXELBUF_BYTEORDER(GBR, 3, 1, 2, 0, 3, false, false) -//| .. data:: BRG -//| -//| * **order** Blue, Red, Green -//| * **bpp** 3 -PIXELBUF_BYTEORDER(BRG, 3, 2, 0, 1, 3, false, false) -//| .. data:: BGR -//| -//| * **order** Blue, Green, Red -//| * **bpp** 3 -//| -//| Commonly used by Dotstar. -PIXELBUF_BYTEORDER(BGR, 3, 2, 1, 0, 3, false, false) - -// RGBW -//| .. data:: RGBW -//| -//| * **order** Red, Green, Blue, White -//| * **bpp** 4 -//| * **has_white** True -PIXELBUF_BYTEORDER(RGBW, 4, 0, 1, 2, 3, true, false) -//| .. data:: RBGW -//| -//| * **order** Red, Blue, Green, White -//| * **bpp** 4 -//| * **has_white** True -PIXELBUF_BYTEORDER(RBGW, 4, 0, 2, 1, 3, true, false) -//| .. data:: GRBW -//| -//| * **order** Green, Red, Blue, White -//| * **bpp** 4 -//| * **has_white** True -//| -//| Commonly used by RGBW NeoPixels. -PIXELBUF_BYTEORDER(GRBW, 4, 1, 0, 2, 3, true, false) -//| .. data:: GBRW -//| -//| * **order** Green, Blue, Red, White -//| * **bpp** 4 -//| * **has_white** True -PIXELBUF_BYTEORDER(GBRW, 4, 1, 2, 0, 3, true, false) -//| .. data:: BRGW -//| -//| * **order** Blue, Red, Green, White -//| * **bpp** 4 -//| * **has_white** True -PIXELBUF_BYTEORDER(BRGW, 4, 2, 0, 1, 3, true, false) -//| .. data:: BGRW -//| -//| * **order** Blue, Green, Red, White -//| * **bpp** 4 -//| * **has_white** True -PIXELBUF_BYTEORDER(BGRW, 4, 2, 1, 0, 3, true, false) - -// Luminosity + RGB (eg for Dotstar) -// Luminosity chosen because the luminosity of a Dotstar at full bright -// burns the eyes like looking at the Sun. -// https://www.thesaurus.com/browse/luminosity?s=t -//| .. data:: LRGB -//| -//| * **order** *Luminosity*, Red, Green, Blue -//| * **bpp** 4 -//| * **has_luminosity** True -PIXELBUF_BYTEORDER(LRGB, 4, 1, 2, 3, 0, false, true) -//| .. data:: LRBG -//| -//| * **order** *Luminosity*, Red, Blue, Green -//| * **bpp** 4 -//| * **has_luminosity** True -PIXELBUF_BYTEORDER(LRBG, 4, 1, 3, 2, 0, false, true) -//| .. data:: LGRB -//| -//| * **order** *Luminosity*, Green, Red, Blue -//| * **bpp** 4 -//| * **has_luminosity** True -PIXELBUF_BYTEORDER(LGRB, 4, 2, 1, 3, 0, false, true) -//| .. data:: LGBR -//| -//| * **order** *Luminosity*, Green, Blue, Red -//| * **bpp** 4 -//| * **has_luminosity** True -PIXELBUF_BYTEORDER(LGBR, 4, 2, 3, 1, 0, false, true) -//| .. data:: LBRG -//| -//| * **order** *Luminosity*, Blue, Red, Green -//| * **bpp** 4 -//| * **has_luminosity** True -PIXELBUF_BYTEORDER(LBRG, 4, 3, 1, 2, 0, false, true) -//| .. data:: LBGR -//| -//| * **order** *Luminosity*, Blue, Green, Red -//| * **bpp** 4 -//| * **has_luminosity** True -//| -//| Actual format commonly used by DotStar (5 bit luninance value) -PIXELBUF_BYTEORDER(LBGR, 4, 3, 2, 1, 0, false, true) - STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) }, { MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) }, @@ -223,7 +103,7 @@ STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_GBRD), MP_ROM_QSTR(MP_QSTR_GBRD) }, { MP_ROM_QSTR(MP_QSTR_BRGD), MP_ROM_QSTR(MP_QSTR_BRGD) }, { MP_ROM_QSTR(MP_QSTR_BGRD), MP_ROM_QSTR(MP_QSTR_BGRD) }, - { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_QSTR(&pixelbuf_wheel_obj) }, + { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_table); diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c index 6b222eec85..b7cdef4830 100644 --- a/shared-module/_pixelbuf/PixelBuf.c +++ b/shared-module/_pixelbuf/PixelBuf.c @@ -102,7 +102,7 @@ mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_de return mp_obj_new_tuple(len, elems); } -mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_obj_t *byteorder, bool dotstar) { +mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_details_t *byteorder, bool dotstar) { mp_obj_t elems[byteorder->bpp]; elems[0] = mp_obj_new_int(buf[byteorder->byteorder.r]); From cf3bb7e1181a0e5cc74a5f12c0d3fcc77dadea8f Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 26 Jul 2019 18:52:22 -0400 Subject: [PATCH 04/44] fix bugs and inline the byteorder code --- shared-bindings/_pixelbuf/PixelBuf.c | 77 +++++++++++++--------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 01ba702c37..e508551ae3 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -42,40 +42,6 @@ extern const int32_t colorwheel(float pos); -void parse_byteorder_string(const char *byteorder, pixelbuf_byteorder_details_t details) { - details.bpp = strlen(byteorder); - char *dotstar = strchr(byteorder, 'D'); - char *r = strchr(byteorder, 'R'); - char *g = strchr(byteorder, 'G'); - char *b = strchr(byteorder, 'B'); - char *w = strchr(byteorder, 'W'); - int num_chars = (dotstar ? 1 : 0) + (w ? 1 : 0) + (r ? 1 : 0) + (g ? 1 : 0) + (b ? 1 : 0); - if (num_chars < details.bpp) - mp_raise_ValueError(translate("Unexpected character in byteorder")); - if (!(r && b && g)) - mp_raise_ValueError(translate("Incomplete byteorder string")); - details.is_dotstar = dotstar ? true : false; - details.has_white = w ? true : false; - details.byteorder.r = byteorder - r; - details.byteorder.g = byteorder - g; - details.byteorder.b = byteorder - b; - if (w) - details.byteorder.w = byteorder - w; - // The dotstar brightness byte is always first (as it goes with the pixel start bits) - // if 'D' is found at the end, adjust byte position - // if 'D' is elsewhere, error out - if (dotstar) { - size_t dotstar_pos = dotstar - byteorder; - if (dotstar_pos == 4) { - details.byteorder.b += 1; - details.byteorder.g += 1; - details.byteorder.r += 1; - } else if (dotstar_pos != 0) { - mp_raise_ValueError(translate("Dotstar position invalid")); - } - } -} - //| .. currentmodule:: pixelbuf //| //| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices @@ -123,20 +89,49 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + const char *byteorder = NULL; + pixelbuf_byteorder_details_t byteorder_details; + size_t bo_len; if (!MP_OBJ_IS_STR(args[ARG_byteorder].u_obj)) mp_raise_TypeError(translate("byteorder is not a string")); - const char *byteorder_str = NULL; - pixelbuf_byteorder_details_t byteorder_details; - size_t bo_len; if (args[ARG_byteorder].u_obj == NULL) - byteorder_str = "BGR"; + byteorder = "BGR"; else - byteorder_str = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); - - parse_byteorder_string(byteorder_str, byteorder_details); + byteorder = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); + byteorder_details.bpp = strlen(byteorder); + char *dotstar = strchr(byteorder, 'D'); + char *r = strchr(byteorder, 'R'); + char *g = strchr(byteorder, 'G'); + char *b = strchr(byteorder, 'B'); + char *w = strchr(byteorder, 'W'); + int num_chars = (dotstar ? 1 : 0) + (w ? 1 : 0) + (r ? 1 : 0) + (g ? 1 : 0) + (b ? 1 : 0); + if (num_chars < byteorder_details.bpp) + mp_raise_ValueError(translate("Unexpected character in byteorder")); + if (!(r && b && g)) + mp_raise_ValueError(translate("Incomplete byteorder string")); + byteorder_details.is_dotstar = dotstar ? true : false; + byteorder_details.has_white = w ? true : false; + byteorder_details.byteorder.r = r - byteorder; + byteorder_details.byteorder.g = g - byteorder; + byteorder_details.byteorder.b = b - byteorder; + if (w) + byteorder_details.byteorder.w = w - byteorder; + // The dotstar brightness byte is always first (as it goes with the pixel start bits) + // if 'D' is found at the end, adjust byte position + // if 'D' is elsewhere, error out + if (dotstar) { + size_t dotstar_pos = dotstar - byteorder; + if (dotstar_pos == 4) { + byteorder_details.byteorder.b += 1; + byteorder_details.byteorder.g += 1; + byteorder_details.byteorder.r += 1; + } else if (dotstar_pos != 0) { + mp_raise_ValueError(translate("Dotstar position invalid")); + } + } if (byteorder_details.has_white && byteorder_details.is_dotstar) mp_raise_ValueError(translate("Can not use dotstar with a white byte")); From cff9c9bc950a3d374babfb3c7388f179c3577e51 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 1 Aug 2019 20:24:39 -0400 Subject: [PATCH 05/44] Reuse error message --- shared-bindings/_pixelbuf/PixelBuf.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index e508551ae3..f4f6c83b2c 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -108,10 +108,8 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a char *b = strchr(byteorder, 'B'); char *w = strchr(byteorder, 'W'); int num_chars = (dotstar ? 1 : 0) + (w ? 1 : 0) + (r ? 1 : 0) + (g ? 1 : 0) + (b ? 1 : 0); - if (num_chars < byteorder_details.bpp) - mp_raise_ValueError(translate("Unexpected character in byteorder")); - if (!(r && b && g)) - mp_raise_ValueError(translate("Incomplete byteorder string")); + if ((num_chars < byteorder_details.bpp) || !(r && b && g)) + mp_raise_ValueError(translate("Invalid byteorder string")); byteorder_details.is_dotstar = dotstar ? true : false; byteorder_details.has_white = w ? true : false; byteorder_details.byteorder.r = r - byteorder; @@ -124,16 +122,16 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a // if 'D' is elsewhere, error out if (dotstar) { size_t dotstar_pos = dotstar - byteorder; - if (dotstar_pos == 4) { + if (dotstar_pos == 3) { byteorder_details.byteorder.b += 1; byteorder_details.byteorder.g += 1; byteorder_details.byteorder.r += 1; } else if (dotstar_pos != 0) { - mp_raise_ValueError(translate("Dotstar position invalid")); + mp_raise_ValueError(translate("Invalid byteorder string")); } } if (byteorder_details.has_white && byteorder_details.is_dotstar) - mp_raise_ValueError(translate("Can not use dotstar with a white byte")); + mp_raise_ValueError(translate("Invalid byteorder string")); size_t effective_bpp = byteorder_details.is_dotstar ? 4 : byteorder_details.bpp; // Always 4 for DotStar size_t bytes = args[ARG_size].u_int * effective_bpp; From 5c08182c731a0f341b6ee61b2433f91063552464 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 3 Aug 2019 13:35:11 -0400 Subject: [PATCH 06/44] fix fix the byte order property. --- shared-bindings/_pixelbuf/PixelBuf.c | 16 ++++++++++------ shared-bindings/_pixelbuf/types.h | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index f4f6c83b2c..90210d4f3a 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -101,7 +101,11 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a else byteorder = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); - byteorder_details.bpp = strlen(byteorder); + if (bo_len < 3 || bo_len > 4) + mp_raise_ValueError(translate("Invalid byteorder string")); + strncpy(byteorder_details.order, byteorder, sizeof(byteorder_details.order)); + + byteorder_details.bpp = bo_len; char *dotstar = strchr(byteorder, 'D'); char *r = strchr(byteorder, 'R'); char *g = strchr(byteorder, 'G'); @@ -344,13 +348,13 @@ const mp_obj_property_t pixelbuf_pixelbuf_buf_obj = { STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); - return &self->byteorder; + return mp_obj_new_str(self->byteorder.order, strlen(self->byteorder.order)); } -MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_byteorder_obj, pixelbuf_pixelbuf_obj_get_byteorder); +MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_byteorder_str, pixelbuf_pixelbuf_obj_get_byteorder); -const mp_obj_property_t pixelbuf_pixelbuf_byteorder_obj = { +const mp_obj_property_t pixelbuf_pixelbuf_byteorder_str = { .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_get_byteorder_obj, + .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_get_byteorder_str, (mp_obj_t)&mp_const_none_obj, (mp_obj_t)&mp_const_none_obj}, }; @@ -479,7 +483,7 @@ STATIC const mp_rom_map_elem_t pixelbuf_pixelbuf_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_bpp), MP_ROM_PTR(&pixelbuf_pixelbuf_bpp_obj)}, { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&pixelbuf_pixelbuf_brightness_obj)}, { MP_ROM_QSTR(MP_QSTR_buf), MP_ROM_PTR(&pixelbuf_pixelbuf_buf_obj)}, - { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_PTR(&pixelbuf_pixelbuf_byteorder_obj)}, + { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_PTR(&pixelbuf_pixelbuf_byteorder_str)}, { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&pixelbuf_pixelbuf_show_obj)}, }; diff --git a/shared-bindings/_pixelbuf/types.h b/shared-bindings/_pixelbuf/types.h index 7d772dbf53..39e49935fa 100644 --- a/shared-bindings/_pixelbuf/types.h +++ b/shared-bindings/_pixelbuf/types.h @@ -41,6 +41,7 @@ typedef struct { pixelbuf_rgbw_t byteorder; bool has_white; bool is_dotstar; + char order[5]; } pixelbuf_byteorder_details_t; #endif // CIRCUITPYTHON_PIXELBUF_TYPES_H From 3cf9a475b99090d72b9992816808cbde309dcc40 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 4 Aug 2019 11:02:33 -0400 Subject: [PATCH 07/44] fix 'white' byte for dotstars --- shared-bindings/_pixelbuf/PixelBuf.c | 4 ++-- shared-module/_pixelbuf/PixelBuf.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 90210d4f3a..969d167099 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -119,8 +119,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a byteorder_details.byteorder.r = r - byteorder; byteorder_details.byteorder.g = g - byteorder; byteorder_details.byteorder.b = b - byteorder; - if (w) - byteorder_details.byteorder.w = w - byteorder; + byteorder_details.byteorder.w = w ? w - byteorder : 0; // The dotstar brightness byte is always first (as it goes with the pixel start bits) // if 'D' is found at the end, adjust byte position // if 'D' is elsewhere, error out @@ -130,6 +129,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a byteorder_details.byteorder.b += 1; byteorder_details.byteorder.g += 1; byteorder_details.byteorder.r += 1; + byteorder_details.byteorder.w = 0; } else if (dotstar_pos != 0) { mp_raise_ValueError(translate("Invalid byteorder string")); } diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c index b7cdef4830..e26f05ac3a 100644 --- a/shared-module/_pixelbuf/PixelBuf.c +++ b/shared-module/_pixelbuf/PixelBuf.c @@ -47,11 +47,11 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_ if (MP_OBJ_IS_INT(item)) { uint8_t *target = rawbuf ? rawbuf : buf; pixelbuf_set_pixel_int(target, mp_obj_get_int_truncated(item), byteorder); - if (dotstar) { + if (dotstar) { buf[0] = DOTSTAR_LED_START_FULL_BRIGHT; if (rawbuf) rawbuf[0] = DOTSTAR_LED_START_FULL_BRIGHT; - } + } if (rawbuf) { buf[byteorder->byteorder.r] = rawbuf[byteorder->byteorder.r] * brightness; buf[byteorder->byteorder.g] = rawbuf[byteorder->byteorder.g] * brightness; From 7507b206be4c2c746f78e67ca76ca882070e34e0 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 3 Oct 2019 19:16:36 -0400 Subject: [PATCH 08/44] disable troublesome context dump (Argument list too long) --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c1f46f6ff..629f554ba7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,10 +6,10 @@ jobs: test: runs-on: ubuntu-16.04 steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" + # - name: Dump GitHub context + # env: + # GITHUB_CONTEXT: ${{ toJson(github) }} + # run: echo "$GITHUB_CONTEXT" - name: Fail if not a release publish # workaround has `on` doesn't have this filter run: exit 1 if: github.event_name == 'release' && (github.event.action != 'published' && github.event.action != 'rerequested') From 00032619bd3c0255b3e30e43951ab8222913f8e5 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 3 Oct 2019 19:42:40 -0400 Subject: [PATCH 09/44] Update translation --- locale/ID.po | 20 +++++++------------- locale/circuitpython.pot | 20 +++++++------------- locale/de_DE.po | 27 ++++++++++++++------------- locale/en_US.po | 20 +++++++------------- locale/en_x_pirate.po | 20 +++++++------------- locale/es.po | 35 ++++++++++++++++++++--------------- locale/fil.po | 25 +++++++++++-------------- locale/fr.po | 35 ++++++++++++++++++++--------------- locale/it_IT.po | 29 +++++++++++++++-------------- locale/pl.po | 33 +++++++++++++++++++-------------- locale/pt_BR.po | 25 +++++++++++-------------- locale/zh_Latn_pinyin.po | 33 +++++++++++++++++++-------------- 12 files changed, 157 insertions(+), 165 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 63e3466b6e..1e5e404465 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -370,11 +370,6 @@ msgstr "" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -812,6 +807,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "Ukuran buffer tidak valid" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1526,8 +1525,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2212,7 +2210,7 @@ msgstr "tidak ada modul yang bernama '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2394,10 +2392,6 @@ msgstr "antrian meluap (overflow)" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "relative import" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index d709a69cc9..1e888ad9ef 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -365,11 +365,6 @@ msgstr "" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -797,6 +792,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1492,8 +1491,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2177,7 +2175,7 @@ msgstr "" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2358,10 +2356,6 @@ msgstr "" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index c846b646b7..c39cc653bb 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -369,11 +369,6 @@ msgstr "Ein Bytes kann nur Werte zwischen 0 und 255 annehmen." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "Kann dotstar nicht mit %s verwenden" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -803,6 +798,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "Ungültige Puffergröße" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1532,8 +1531,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2224,7 +2222,7 @@ msgstr "Kein Modul mit dem Namen '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2407,10 +2405,6 @@ msgstr "Warteschlangenüberlauf" msgid "rawbuf is not the same size as buf" msgstr "rawbuf hat nicht die gleiche Größe wie buf" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "Readonly-Attribut" - #: py/builtinimport.c msgid "relative import" msgstr "relativer Import" @@ -2760,6 +2754,10 @@ msgstr "" #~ msgid "C-level assert" #~ msgstr "C-Level Assert" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "Kann dotstar nicht mit %s verwenden" + #~ msgid "Can't add services in Central mode" #~ msgstr "Im Central mode können Dienste nicht hinzugefügt werden" @@ -2978,6 +2976,9 @@ msgstr "" #~ msgid "pin does not have IRQ capabilities" #~ msgstr "Pin hat keine IRQ Fähigkeiten" +#~ msgid "readonly attribute" +#~ msgstr "Readonly-Attribut" + #~ msgid "scan failed" #~ msgstr "Scan fehlgeschlagen" diff --git a/locale/en_US.po b/locale/en_US.po index 652053ee99..a26fd72472 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -365,11 +365,6 @@ msgstr "" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -797,6 +792,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1492,8 +1491,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2177,7 +2175,7 @@ msgstr "" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2358,10 +2356,6 @@ msgstr "" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 1d2fcb659c..0cd7b24643 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -369,11 +369,6 @@ msgstr "" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -801,6 +796,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1496,8 +1495,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2181,7 +2179,7 @@ msgstr "" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2362,10 +2360,6 @@ msgstr "" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" diff --git a/locale/es.po b/locale/es.po index ca8593dcdf..c312565fa8 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -373,11 +373,6 @@ msgstr "Bytes debe estar entre 0 y 255." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "No se puede usar dotstar con %s" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -808,6 +803,10 @@ msgstr "Inválido bits por valor" msgid "Invalid buffer size" msgstr "Tamaño de buffer inválido" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Inválido periodo de captura. Rango válido: 1 - 500" @@ -1539,9 +1538,8 @@ msgid "byte code not implemented" msgstr "codigo byte no implementado" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" -msgstr "byteorder no es instancia de ByteOrder (encontarmos un %s)" +msgid "byteorder is not a string" +msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2234,7 +2232,7 @@ msgstr "ningún módulo se llama '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "no hay tal atributo" @@ -2419,11 +2417,6 @@ msgstr "desbordamiento de cola(queue)" msgid "rawbuf is not the same size as buf" msgstr "rawbuf no es el mismo tamaño que buf" -#: shared-bindings/_pixelbuf/__init__.c -#, fuzzy -msgid "readonly attribute" -msgstr "atributo no legible" - #: py/builtinimport.c msgid "relative import" msgstr "import relativo" @@ -2768,6 +2761,10 @@ msgstr "paso cero" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Direción no es %d bytes largo o esta en el formato incorrecto" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "No se puede usar dotstar con %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "No se pueden agregar servicio en modo Central" @@ -2963,6 +2960,10 @@ msgstr "paso cero" #~ msgid "buffer too long" #~ msgstr "buffer demasiado largo" +#, c-format +#~ msgid "byteorder is not an instance of ByteOrder (got a %s)" +#~ msgstr "byteorder no es instancia de ByteOrder (encontarmos un %s)" + #~ msgid "can query only one param" #~ msgstr "puede consultar solo un param" @@ -3036,6 +3037,10 @@ msgstr "paso cero" #~ msgid "position must be 2-tuple" #~ msgstr "posición debe ser 2-tuple" +#, fuzzy +#~ msgid "readonly attribute" +#~ msgstr "atributo no legible" + #~ msgid "row must be packed and word aligned" #~ msgstr "la fila debe estar empacada y la palabra alineada" diff --git a/locale/fil.po b/locale/fil.po index 6f460c94cf..c252d9c350 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -372,11 +372,6 @@ msgstr "Sa gitna ng 0 o 255 dapat ang bytes." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -817,6 +812,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "Mali ang buffer size" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1546,8 +1545,7 @@ msgid "byte code not implemented" msgstr "byte code hindi pa implemented" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2248,7 +2246,7 @@ msgstr "walang module na '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "walang ganoon na attribute" @@ -2431,11 +2429,6 @@ msgstr "puno na ang pila (overflow)" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -#, fuzzy -msgid "readonly attribute" -msgstr "hindi mabasa ang attribute" - #: py/builtinimport.c msgid "relative import" msgstr "relative import" @@ -3019,6 +3012,10 @@ msgstr "zero step" #~ msgid "position must be 2-tuple" #~ msgstr "position ay dapat 2-tuple" +#, fuzzy +#~ msgid "readonly attribute" +#~ msgstr "hindi mabasa ang attribute" + #~ msgid "row must be packed and word aligned" #~ msgstr "row ay dapat packed at ang word nakahanay" diff --git a/locale/fr.po b/locale/fr.po index c176fd8bcf..3514362305 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -377,11 +377,6 @@ msgstr "Les octets 'bytes' doivent être entre 0 et 255" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "Impossible d'utiliser 'dotstar' avec %s" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -824,6 +819,10 @@ msgstr "Bits par valeur invalides" msgid "Invalid buffer size" msgstr "Longueur de tampon invalide" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Période de capture invalide. Gamme valide: 1 à 500" @@ -1572,9 +1571,8 @@ msgid "byte code not implemented" msgstr "bytecode non implémenté" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" -msgstr "'byteorder' n'est pas une instance de ByteOrder (reçu un %s)" +msgid "byteorder is not a string" +msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2281,7 +2279,7 @@ msgstr "pas de module '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "pas de tel attribut" @@ -2471,11 +2469,6 @@ msgstr "dépassement de file" msgid "rawbuf is not the same size as buf" msgstr "'rawbuf' n'est pas de la même taille que 'buf'" -#: shared-bindings/_pixelbuf/__init__.c -#, fuzzy -msgid "readonly attribute" -msgstr "attribut en lecture seule" - #: py/builtinimport.c msgid "relative import" msgstr "import relatif" @@ -2824,6 +2817,10 @@ msgstr "'step' nul" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "L'adresse n'est pas longue de %d octets ou est d'un format erroné" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "Impossible d'utiliser 'dotstar' avec %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "Impossible d'ajouter des services en mode Central" @@ -3015,6 +3012,10 @@ msgstr "'step' nul" #~ msgid "buffer too long" #~ msgstr "tampon trop long" +#, c-format +#~ msgid "byteorder is not an instance of ByteOrder (got a %s)" +#~ msgstr "'byteorder' n'est pas une instance de ByteOrder (reçu un %s)" + #~ msgid "can query only one param" #~ msgstr "ne peut demander qu'un seul paramètre" @@ -3087,6 +3088,10 @@ msgstr "'step' nul" #~ msgid "position must be 2-tuple" #~ msgstr "position doit être un 2-tuple" +#, fuzzy +#~ msgid "readonly attribute" +#~ msgstr "attribut en lecture seule" + #~ msgid "scan failed" #~ msgstr "échec du scan" diff --git a/locale/it_IT.po b/locale/it_IT.po index 883c65d41f..9376a679b6 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -372,11 +372,6 @@ msgstr "I byte devono essere compresi tra 0 e 255" msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "dotstar non può essere usato con %s" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -817,6 +812,10 @@ msgstr "bits per valore invalido" msgid "Invalid buffer size" msgstr "lunghezza del buffer non valida" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "periodo di cattura invalido. Zona valida: 1 - 500" @@ -1542,8 +1541,7 @@ msgid "byte code not implemented" msgstr "byte code non implementato" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2242,7 +2240,7 @@ msgstr "nessun modulo chiamato '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "attributo inesistente" @@ -2429,11 +2427,6 @@ msgstr "overflow della coda" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -#, fuzzy -msgid "readonly attribute" -msgstr "attributo non leggibile" - #: py/builtinimport.c msgid "relative import" msgstr "importazione relativa" @@ -2779,6 +2772,10 @@ msgstr "zero step" #~ msgid "C-level assert" #~ msgstr "assert a livello C" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "dotstar non può essere usato con %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "non si può aggiungere servizi in Central mode" @@ -3017,6 +3014,10 @@ msgstr "zero step" #~ msgid "position must be 2-tuple" #~ msgstr "position deve essere una 2-tuple" +#, fuzzy +#~ msgid "readonly attribute" +#~ msgstr "attributo non leggibile" + #~ msgid "row must be packed and word aligned" #~ msgstr "la riga deve essere compattata e allineata alla parola" diff --git a/locale/pl.po b/locale/pl.po index 9ed76924b5..8cf69bb37d 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -368,11 +368,6 @@ msgstr "Bytes musi być między 0 a 255." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "Nie można używać dotstar z %s" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -802,6 +797,10 @@ msgstr "Zła liczba bitów wartości" msgid "Invalid buffer size" msgstr "Zła wielkość bufora" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Zły okres. Poprawny zakres to: 1 - 500" @@ -1516,9 +1515,8 @@ msgid "byte code not implemented" msgstr "bajtkod niezaimplemntowany" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" -msgstr "byteorder musi być typu ByteOrder (jest %s)" +msgid "byteorder is not a string" +msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2202,7 +2200,7 @@ msgstr "brak modułu o nazwie '%q'" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "nie ma takiego atrybutu" @@ -2384,10 +2382,6 @@ msgstr "przepełnienie kolejki" msgid "rawbuf is not the same size as buf" msgstr "rawbuf nie jest tej samej wielkości co buf" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "atrybut tylko do odczytu" - #: py/builtinimport.c msgid "relative import" msgstr "relatywny import" @@ -2725,6 +2719,10 @@ msgstr "zerowy krok" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Adres nie ma długości %d bajtów lub zły format" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "Nie można używać dotstar z %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "Nie można dodać serwisów w trybie Central" @@ -2802,6 +2800,10 @@ msgstr "zerowy krok" #~ msgid "bad GATT role" #~ msgstr "zła rola GATT" +#, c-format +#~ msgid "byteorder is not an instance of ByteOrder (got a %s)" +#~ msgstr "byteorder musi być typu ByteOrder (jest %s)" + #~ msgid "characteristics includes an object that is not a Characteristic" #~ msgstr "" #~ "charakterystyki zawierają obiekt, który nie jest typu Characteristic" @@ -2809,6 +2811,9 @@ msgstr "zerowy krok" #~ msgid "interval not in range 0.0020 to 10.24" #~ msgstr "przedział poza zakresem 0.0020 do 10.24" +#~ msgid "readonly attribute" +#~ msgstr "atrybut tylko do odczytu" + #~ msgid "services includes an object that is not a Service" #~ msgstr "obiekt typu innego niż Service w services" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index a17a275390..280cf13cdb 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -369,11 +369,6 @@ msgstr "Os bytes devem estar entre 0 e 255." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -810,6 +805,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "Arquivo inválido" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1516,8 +1515,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2203,7 +2201,7 @@ msgstr "" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2384,11 +2382,6 @@ msgstr "estouro de fila" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -#, fuzzy -msgid "readonly attribute" -msgstr "atributo ilegível" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2927,6 +2920,10 @@ msgstr "passo zero" #~ msgid "pin does not have IRQ capabilities" #~ msgstr "Pino não tem recursos de IRQ" +#, fuzzy +#~ msgid "readonly attribute" +#~ msgstr "atributo ilegível" + #~ msgid "row must be packed and word aligned" #~ msgstr "Linha deve ser comprimida e com as palavras alinhadas" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index d5df0b7b0c..481b98e7bf 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-08 17:30-0500\n" +"POT-Creation-Date: 2019-10-03 19:41-0400\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -369,11 +369,6 @@ msgstr "Zì jié bìxū jiè yú 0 dào 255 zhī jiān." msgid "Call super().__init__() before accessing native object." msgstr "Zài fǎngwèn běn jī wùjiàn zhīqián diàoyòng super().__init__()" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "Wúfǎ yǔ dotstar yīqǐ shǐyòng %s" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -803,6 +798,10 @@ msgstr "Měi gè zhí de wèi wúxiào" msgid "Invalid buffer size" msgstr "Wúxiào de huǎnchōng qū dàxiǎo" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Wúxiào de bǔhuò zhōuqí. Yǒuxiào fànwéi: 1-500" @@ -1525,9 +1524,8 @@ msgid "byte code not implemented" msgstr "zì jié dàimǎ wèi zhíxíng" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" -msgstr "zì jié bùshì zì jié xù shílì (yǒu %s)" +msgid "byteorder is not a string" +msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2215,7 +2213,7 @@ msgstr "méiyǒu mókuài '%q'" msgid "no reset pin available" msgstr "Méiyǒu kěyòng de fùwèi yǐn jiǎo" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "méiyǒu cǐ shǔxìng" @@ -2396,10 +2394,6 @@ msgstr "duìliè yìchū" msgid "rawbuf is not the same size as buf" msgstr "yuánshǐ huǎnchōng qū hé huǎnchōng qū de dàxiǎo bùtóng" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "zhǐ dú shǔxìng" - #: py/builtinimport.c msgid "relative import" msgstr "xiāngduì dǎorù" @@ -2738,6 +2732,10 @@ msgstr "líng bù" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Dìzhǐ bùshì %d zì jié zhǎng, huòzhě géshì cuòwù" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "Wúfǎ yǔ dotstar yīqǐ shǐyòng %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "Wúfǎ zài zhōngyāng móshì xià tiānjiā fúwù" @@ -2831,6 +2829,10 @@ msgstr "líng bù" #~ msgid "bad GATT role" #~ msgstr "zǒng xiédìng de bùliáng juésè" +#, c-format +#~ msgid "byteorder is not an instance of ByteOrder (got a %s)" +#~ msgstr "zì jié bùshì zì jié xù shílì (yǒu %s)" + #~ msgid "characteristics includes an object that is not a Characteristic" #~ msgstr "tèxìng bāokuò bùshì zìfú de wùtǐ" @@ -2840,6 +2842,9 @@ msgstr "líng bù" #~ msgid "interval not in range 0.0020 to 10.24" #~ msgstr "jùlí 0.0020 Zhì 10.24 Zhī jiān de jiàngé shíjiān" +#~ msgid "readonly attribute" +#~ msgstr "zhǐ dú shǔxìng" + #~ msgid "row must be packed and word aligned" #~ msgstr "xíng bìxū dǎbāo bìngqiě zì duìqí" From dfad1352ad98c01da1c61c7575074e87ba65cb72 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 3 Oct 2019 19:49:12 -0400 Subject: [PATCH 10/44] echo github context using python --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 629f554ba7..430623dd77 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,10 +6,10 @@ jobs: test: runs-on: ubuntu-16.04 steps: - # - name: Dump GitHub context - # env: - # GITHUB_CONTEXT: ${{ toJson(github) }} - # run: echo "$GITHUB_CONTEXT" + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: python -c "import os; print os.environ['GITHUB_CONTEXT']" - name: Fail if not a release publish # workaround has `on` doesn't have this filter run: exit 1 if: github.event_name == 'release' && (github.event.action != 'published' && github.event.action != 'rerequested') From 84b8ae13029633d9db2c6a688303aba4a01ccf2e Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 5 Oct 2019 12:53:58 -0400 Subject: [PATCH 11/44] change frozen point on dotstar and neopixel libs --- frozen/Adafruit_CircuitPython_DotStar | 2 +- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index 409e90902a..02758607e2 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit 409e90902ac49720c4add985e8e1a1660bbe63a0 +Subproject commit 02758607e26bedd356a0ff004d0493b1783950dd diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index c0bdd8b103..443626b5e5 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit c0bdd8b10383725ee9293f5d88fb8d47eb1272bd +Subproject commit 443626b5e5df688a5b4cc077c4a2c4fdd8fbb49a From 000ae6bf17ca43486e5cfd261d4cb2eded4c3147 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 5 Oct 2019 13:47:40 -0400 Subject: [PATCH 12/44] support subclasses --- shared-bindings/_pixelbuf/PixelBuf.c | 40 +++++++++++++--------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 969d167099..0ad40c6209 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -26,6 +26,7 @@ #include "py/obj.h" #include "py/objarray.h" +#include "py/objtype.h" #include "py/mphal.h" #include "py/runtime.h" #include "py/binary.h" @@ -223,13 +224,20 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } + +// Helper to ensure we have the native super class instead of a subclass. +static pixelbuf_pixelbuf_obj_t* native_pixelbuf(mp_obj_t pixelbuf_obj) { + mp_obj_t native_pixelbuf = mp_instance_cast_to_native_base(pixelbuf_obj, &pixelbuf_pixelbuf_type); + mp_obj_assert_native_inited(native_pixelbuf); + return MP_OBJ_TO_PTR(native_pixelbuf); +} + //| .. attribute:: bpp //| //| The number of bytes per pixel in the buffer (read-only) //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_bpp(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); return mp_obj_new_int_from_uint(self->byteorder.bpp); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_bpp_obj, pixelbuf_pixelbuf_obj_get_bpp); @@ -252,16 +260,14 @@ const mp_obj_property_t pixelbuf_pixelbuf_bpp_obj = { //| In DotStar mode //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_brightness(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); return mp_obj_new_float(self->brightness); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_brightness_obj, pixelbuf_pixelbuf_obj_get_brightness); STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t value) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); self->brightness = mp_obj_float_get(value); if (self->brightness > 1) self->brightness = 1; @@ -298,16 +304,14 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { //| Whether to automatically write the pixels after each update. //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_auto_write(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); return mp_obj_new_bool(self->auto_write); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_auto_write_obj, pixelbuf_pixelbuf_obj_get_auto_write); STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_auto_write(mp_obj_t self_in, mp_obj_t value) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); self->auto_write = mp_obj_is_true(value); return mp_const_none; } @@ -328,8 +332,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_auto_write_obj = { //| actual pixels. //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_buf(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); return mp_obj_new_bytearray_by_ref(self->bytes, self->buf); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_buf_obj, pixelbuf_pixelbuf_obj_get_buf); @@ -346,8 +349,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_buf_obj = { //| byteorder string for the buffer (read-only) //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); return mp_obj_new_str(self->byteorder.order, strlen(self->byteorder.order)); } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_byteorder_str, pixelbuf_pixelbuf_obj_get_byteorder); @@ -360,8 +362,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_byteorder_str = { }; STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); switch (op) { case MP_UNARY_OP_BOOL: return mp_const_true; case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->pixels); @@ -375,8 +376,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); call_write_function(self); return mp_const_none; } @@ -398,15 +398,13 @@ void call_write_function(pixelbuf_pixelbuf_obj_t *self) { //| Sets the pixel value at the given index. //| STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { - mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type)); - if (value == MP_OBJ_NULL) { // delete item // slice deletion return MP_OBJ_NULL; // op not supported } - pixelbuf_pixelbuf_obj_t *self = MP_OBJ_TO_PTR(self_in); + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); if (0) { #if MICROPY_PY_BUILTINS_SLICE } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { From 55c688cbebc9f4eac3787591f5349c2f4c25e9e4 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 5 Oct 2019 15:53:53 -0400 Subject: [PATCH 13/44] restructure to be subclassable --- shared-bindings/_pixelbuf/PixelBuf.c | 63 +++++++--------------------- shared-bindings/_pixelbuf/PixelBuf.h | 2 +- 2 files changed, 15 insertions(+), 50 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 0ad40c6209..cb6fe55673 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -50,7 +50,7 @@ extern const int32_t colorwheel(float pos); //| //| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction. //| -//| .. class:: PixelBuf(size, buf, byteorder="BGR", brightness=0, rawbuf=None, offset=0, auto_write=False, write_function=None, write_args=None) +//| .. class:: PixelBuf(size, buf, byteorder="BGR", brightness=0, rawbuf=None, offset=0, auto_write=False) //| //| Create a PixelBuf object of the specified size, byteorder, and bits per pixel. //| @@ -69,14 +69,11 @@ extern const int32_t colorwheel(float pos); //| :param ~bytearray rawbuf: Bytearray in which to store raw pixel data (before brightness adjustment) //| :param ~int offset: Offset from start of buffer (default 0) //| :param ~bool auto_write: Whether to automatically write pixels (Default False) -//| :param ~callable write_function: (optional) Callable to use to send pixels -//| :param ~list write_args: (optional) Tuple or list of args to pass to ``write_function``. The -//| PixelBuf instance is appended after these args. //| STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 2, MP_OBJ_FUN_ARGS_MAX, true); enum { ARG_size, ARG_buf, ARG_byteorder, ARG_brightness, ARG_rawbuf, ARG_offset, - ARG_auto_write, ARG_write_function, ARG_write_args }; + ARG_auto_write }; static const mp_arg_t allowed_args[] = { { MP_QSTR_size, MP_ARG_REQUIRED | MP_ARG_INT }, { MP_QSTR_buf, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -85,8 +82,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_rawbuf, MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_offset, MP_ARG_INT, { .u_int = 0 } }, { MP_QSTR_auto_write, MP_ARG_BOOL, {.u_bool = false} }, - { MP_QSTR_write_function, MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_write_args, MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -155,13 +150,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a if (bytes + offset > bufinfo.len) mp_raise_ValueError_varg(translate("buf is too small. need %d bytes"), bytes + offset); - if (!MP_OBJ_IS_TYPE(args[ARG_write_args].u_obj, &mp_type_list) && - !MP_OBJ_IS_TYPE(args[ARG_write_args].u_obj, &mp_type_tuple) && - args[ARG_write_args].u_obj != mp_const_none) - { - mp_raise_ValueError(translate("write_args must be a list, tuple, or None")); - } - // Validation complete, allocate and populate object. pixelbuf_pixelbuf_obj_t *self = m_new_obj(pixelbuf_pixelbuf_obj_t); @@ -178,28 +166,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a self->pixel_step = effective_bpp; self->auto_write = args[ARG_auto_write].u_bool; - // Show/auto-write callbacks - self->write_function = args[ARG_write_function].u_obj; - mp_obj_t function_args = args[ARG_write_args].u_obj; - mp_obj_t *src_objs = (mp_obj_t *)&mp_const_none_obj; - size_t num_items = 0; - if (function_args != mp_const_none) { - if (MP_OBJ_IS_TYPE(function_args, &mp_type_list)) { - mp_obj_list_t *t = MP_OBJ_TO_PTR(function_args); - num_items = t->len; - src_objs = t->items; - } else { - mp_obj_tuple_t *l = MP_OBJ_TO_PTR(function_args); - num_items = l->len; - src_objs = l->items; - } - } - self->write_function_args = mp_obj_new_tuple(num_items + 1, NULL); - for (size_t i = 0; i < num_items; i++) { - self->write_function_args->items[i] = src_objs[i]; - } - self->write_function_args->items[num_items] = self; - if (args[ARG_brightness].u_obj == mp_const_none) { self->brightness = 1.0; } else { @@ -276,7 +242,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t if (self->two_buffers) pixelbuf_recalculate_brightness(self); if (self->auto_write) - call_write_function(self); + call_show(self_in); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_brightness_obj, pixelbuf_pixelbuf_obj_set_brightness); @@ -299,6 +265,14 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { } } +mp_obj_t call_show(mp_obj_t self_in) { + mp_obj_t dest[2]; + mp_load_method(self_in, MP_QSTR_show, dest); + if (dest[0] == MP_OBJ_NULL) + return mp_const_none; + return mp_call_method_self_n_kw(dest[0], self_in, 0, 0, mp_const_none); +} + //| .. attribute:: auto_write //| //| Whether to automatically write the pixels after each update. @@ -372,23 +346,14 @@ STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| .. method:: show() //| -//| Call the associated write function to display the pixels. +//| Does nothing unless subclassed. //| STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - call_write_function(self); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); -void call_write_function(pixelbuf_pixelbuf_obj_t *self) { - // execute function if it's set - if (self->write_function != mp_const_none) { - mp_call_function_n_kw(self->write_function, self->write_function_args->len, 0, self->write_function_args->items); - } -} - //| .. method:: __getitem__(index) //| //| Returns the pixel value at the given index. @@ -450,7 +415,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_write_function(self); + call_show(self_in); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -470,7 +435,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_write_function(self); + call_show(self_in); return mp_const_none; } } diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index 0f5613621a..2a132dda23 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -50,6 +50,6 @@ typedef struct { } pixelbuf_pixelbuf_obj_t; void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self); -void call_write_function(pixelbuf_pixelbuf_obj_t *self); +mp_obj_t call_show(mp_obj_t self_in); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H From dc8c27d1292673f1610f6440fa0de810018995fe Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 6 Oct 2019 22:44:00 -0400 Subject: [PATCH 14/44] make dotstar byteorder constants start with P. fix small bugs. --- shared-bindings/_pixelbuf/PixelBuf.c | 46 ++++++++++------------------ shared-bindings/_pixelbuf/PixelBuf.h | 2 -- shared-bindings/_pixelbuf/__init__.c | 12 ++++---- shared-bindings/_pixelbuf/types.h | 2 +- 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index cb6fe55673..3a2c88ef61 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -59,12 +59,14 @@ extern const int32_t colorwheel(float pos); //| //| When only given ``buf``, ``brightness`` applies to the next pixel assignment. //| -//| When ``D`` (dotstar mode) is present in the byteorder configuration, the -//| 4th value in a tuple/list is the individual pixel brightness (0-1). +//| When ``P`` (pwm duration) is present as the 4th character of the byteorder +//| string, the 4th value in the tuple/list for a pixel is the individual pixel +//| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the +//| output buffer (``buf``). //| //| :param ~int size: Number of pixelsx //| :param ~bytearray buf: Bytearray in which to store pixel data -//| :param ~str byteorder: Byte order string (such as "BGR" or "BGRD") +//| :param ~str byteorder: Byte order string (such as "BGR" or "DBGR") //| :param ~float brightness: Brightness (0 to 1.0, default 1.0) //| :param ~bytearray rawbuf: Bytearray in which to store raw pixel data (before brightness adjustment) //| :param ~int offset: Offset from start of buffer (default 0) @@ -77,7 +79,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a static const mp_arg_t allowed_args[] = { { MP_QSTR_size, MP_ARG_REQUIRED | MP_ARG_INT }, { MP_QSTR_buf, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_byteorder, MP_ARG_OBJ, { .u_obj = mp_const_none } }, + { MP_QSTR_byteorder, MP_ARG_OBJ, { .u_obj = MP_OBJ_NEW_QSTR(MP_QSTR_BGR) } }, { MP_QSTR_brightness, MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_rawbuf, MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_offset, MP_ARG_INT, { .u_int = 0 } }, @@ -92,17 +94,13 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a if (!MP_OBJ_IS_STR(args[ARG_byteorder].u_obj)) mp_raise_TypeError(translate("byteorder is not a string")); - if (args[ARG_byteorder].u_obj == NULL) - byteorder = "BGR"; - else - byteorder = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); - + byteorder = mp_obj_str_get_data(args[ARG_byteorder].u_obj, &bo_len); if (bo_len < 3 || bo_len > 4) mp_raise_ValueError(translate("Invalid byteorder string")); - strncpy(byteorder_details.order, byteorder, sizeof(byteorder_details.order)); + byteorder_details.order = args[ARG_byteorder].u_obj; byteorder_details.bpp = bo_len; - char *dotstar = strchr(byteorder, 'D'); + char *dotstar = strchr(byteorder, 'P'); char *r = strchr(byteorder, 'R'); char *g = strchr(byteorder, 'G'); char *b = strchr(byteorder, 'B'); @@ -117,18 +115,8 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a byteorder_details.byteorder.b = b - byteorder; byteorder_details.byteorder.w = w ? w - byteorder : 0; // The dotstar brightness byte is always first (as it goes with the pixel start bits) - // if 'D' is found at the end, adjust byte position - // if 'D' is elsewhere, error out - if (dotstar) { - size_t dotstar_pos = dotstar - byteorder; - if (dotstar_pos == 3) { - byteorder_details.byteorder.b += 1; - byteorder_details.byteorder.g += 1; - byteorder_details.byteorder.r += 1; - byteorder_details.byteorder.w = 0; - } else if (dotstar_pos != 0) { - mp_raise_ValueError(translate("Invalid byteorder string")); - } + if (dotstar && byteorder[0] != 'P') { + mp_raise_ValueError(translate("Invalid byteorder string")); } if (byteorder_details.has_white && byteorder_details.is_dotstar) mp_raise_ValueError(translate("Invalid byteorder string")); @@ -178,7 +166,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a if (self->byteorder.is_dotstar) { // Initialize the buffer with the dotstar start bytes. - // Header and end must be setup by caller + // Note: Header and end must be setup by caller for (uint i = 0; i < self->pixels * 4; i += 4) { self->buf[i] = DOTSTAR_LED_START_FULL_BRIGHT; if (two_buffers) { @@ -268,9 +256,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { mp_obj_t call_show(mp_obj_t self_in) { mp_obj_t dest[2]; mp_load_method(self_in, MP_QSTR_show, dest); - if (dest[0] == MP_OBJ_NULL) - return mp_const_none; - return mp_call_method_self_n_kw(dest[0], self_in, 0, 0, mp_const_none); + return mp_call_method_n_kw(0, 0, dest); } //| .. attribute:: auto_write @@ -324,7 +310,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_buf_obj = { //| STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - return mp_obj_new_str(self->byteorder.order, strlen(self->byteorder.order)); + return self->byteorder.order; } MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_get_byteorder_str, pixelbuf_pixelbuf_obj_get_byteorder); @@ -376,13 +362,15 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(self->bytes, index_in, &slice)) + // TODO support stepping!!! mp_raise_NotImplementedError(translate("Only slices with step=1 (aka None) are supported")); if ((slice.stop * self->pixel_step) > self->bytes) mp_raise_IndexError(translate("Range out of bounds")); if (value == MP_OBJ_SENTINEL) { // Get size_t len = slice.stop - slice.start; - return pixelbuf_get_pixel_array((uint8_t *) self->buf + slice.start, len, &self->byteorder, self->pixel_step, self->byteorder.is_dotstar); + uint8_t *readbuf = self->two_buffers ? self->rawbuf : self->buf; + return pixelbuf_get_pixel_array(readbuf + slice.start, len, &self->byteorder, self->pixel_step, self->byteorder.is_dotstar); } else { // Set #if MICROPY_PY_ARRAY_SLICE_ASSIGN diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index 2a132dda23..aa09e92613 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -44,8 +44,6 @@ typedef struct { size_t offset; uint8_t *rawbuf; uint8_t *buf; - mp_obj_t write_function; - mp_obj_tuple_t *write_function_args; bool auto_write; } pixelbuf_pixelbuf_obj_t; diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 02d5f49b35..e5cb652672 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -97,12 +97,12 @@ STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_GBRW), MP_ROM_QSTR(MP_QSTR_GBRW) }, { MP_ROM_QSTR(MP_QSTR_BRGW), MP_ROM_QSTR(MP_QSTR_BRGW) }, { MP_ROM_QSTR(MP_QSTR_BGRW), MP_ROM_QSTR(MP_QSTR_BGRW) }, - { MP_ROM_QSTR(MP_QSTR_RGBD), MP_ROM_QSTR(MP_QSTR_RGBD) }, - { MP_ROM_QSTR(MP_QSTR_RBGD), MP_ROM_QSTR(MP_QSTR_RBGD) }, - { MP_ROM_QSTR(MP_QSTR_GRBD), MP_ROM_QSTR(MP_QSTR_GRBD) }, - { MP_ROM_QSTR(MP_QSTR_GBRD), MP_ROM_QSTR(MP_QSTR_GBRD) }, - { MP_ROM_QSTR(MP_QSTR_BRGD), MP_ROM_QSTR(MP_QSTR_BRGD) }, - { MP_ROM_QSTR(MP_QSTR_BGRD), MP_ROM_QSTR(MP_QSTR_BGRD) }, + { MP_ROM_QSTR(MP_QSTR_PRGB), MP_ROM_QSTR(MP_QSTR_PRGB) }, + { MP_ROM_QSTR(MP_QSTR_PRBG), MP_ROM_QSTR(MP_QSTR_PRBG) }, + { MP_ROM_QSTR(MP_QSTR_PGRB), MP_ROM_QSTR(MP_QSTR_PGRB) }, + { MP_ROM_QSTR(MP_QSTR_PGBR), MP_ROM_QSTR(MP_QSTR_PGBR) }, + { MP_ROM_QSTR(MP_QSTR_PBRG), MP_ROM_QSTR(MP_QSTR_PBRG) }, + { MP_ROM_QSTR(MP_QSTR_PBGR), MP_ROM_QSTR(MP_QSTR_PBGR) }, { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, }; diff --git a/shared-bindings/_pixelbuf/types.h b/shared-bindings/_pixelbuf/types.h index 39e49935fa..f7dc1a1092 100644 --- a/shared-bindings/_pixelbuf/types.h +++ b/shared-bindings/_pixelbuf/types.h @@ -41,7 +41,7 @@ typedef struct { pixelbuf_rgbw_t byteorder; bool has_white; bool is_dotstar; - char order[5]; + mp_obj_t *order; } pixelbuf_byteorder_details_t; #endif // CIRCUITPYTHON_PIXELBUF_TYPES_H From 2970680e6af663200b35227bfbca5240542a4c47 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 20 Oct 2019 19:54:25 -0400 Subject: [PATCH 15/44] fix show and fix step > 1 --- py/obj.c | 9 ++++++-- py/objtype.c | 3 ++- shared-bindings/_pixelbuf/PixelBuf.c | 31 +++++++++++++++++----------- shared-bindings/_pixelbuf/PixelBuf.h | 2 +- shared-module/_pixelbuf/PixelBuf.c | 7 +++++-- shared-module/_pixelbuf/PixelBuf.h | 2 +- 6 files changed, 35 insertions(+), 19 deletions(-) diff --git a/py/obj.c b/py/obj.c index bd2aaf9d26..f91b00a648 100644 --- a/py/obj.c +++ b/py/obj.c @@ -489,14 +489,19 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(base); + mp_obj_t instance = base; + // If we got an MP_OBJ_SENTINEL as the type, then we got called by instance_subscr + if (type == MP_OBJ_SENTINEL) { + instance = ((mp_obj_t *)base)[1]; + type = mp_obj_get_type(((mp_obj_t *)base)[2]); + } if (type->subscr != NULL) { - mp_obj_t ret = type->subscr(base, index, value); + mp_obj_t ret = type->subscr(instance, index, value); // May have called port specific C code. Make sure it didn't mess up the heap. assert_heap_ok(); if (ret != MP_OBJ_NULL) { return ret; } - // TODO: call base classes here? } if (value == MP_OBJ_NULL) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { diff --git a/py/objtype.c b/py/objtype.c index 5133d849fc..7d41b86560 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -850,7 +850,8 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value meth_args = 3; } if (member[0] == MP_OBJ_SENTINEL) { - return mp_obj_subscr(self->subobj[0], index, value); + mp_obj_t args[3] = {MP_OBJ_SENTINEL, self_in, self->subobj[0]}; + return mp_obj_subscr(args, index, value); } else if (member[0] != MP_OBJ_NULL) { mp_obj_t args[3] = {self_in, index, value}; // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 3a2c88ef61..aeed6f5043 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -230,7 +230,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t if (self->two_buffers) pixelbuf_recalculate_brightness(self); if (self->auto_write) - call_show(self_in); + call_show(self_in, 'b'); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_brightness_obj, pixelbuf_pixelbuf_obj_set_brightness); @@ -253,7 +253,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { } } -mp_obj_t call_show(mp_obj_t self_in) { +mp_obj_t call_show(mp_obj_t self_in, char origin) { mp_obj_t dest[2]; mp_load_method(self_in, MP_QSTR_show, dest); return mp_call_method_n_kw(0, 0, dest); @@ -356,29 +356,35 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); + if (0) { #if MICROPY_PY_BUILTINS_SLICE } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { mp_bound_slice_t slice; - if (!mp_seq_get_fast_slice_indexes(self->bytes, index_in, &slice)) - // TODO support stepping!!! - mp_raise_NotImplementedError(translate("Only slices with step=1 (aka None) are supported")); + mp_seq_get_fast_slice_indexes(self->bytes, index_in, &slice); + if ((slice.stop * self->pixel_step) > self->bytes) mp_raise_IndexError(translate("Range out of bounds")); + if (slice.step < 0) + mp_raise_IndexError(translate("Negative step not supported")); if (value == MP_OBJ_SENTINEL) { // Get size_t len = slice.stop - slice.start; uint8_t *readbuf = self->two_buffers ? self->rawbuf : self->buf; - return pixelbuf_get_pixel_array(readbuf + slice.start, len, &self->byteorder, self->pixel_step, self->byteorder.is_dotstar); + return pixelbuf_get_pixel_array(readbuf + slice.start, len, &self->byteorder, self->pixel_step, slice.step, self->byteorder.is_dotstar); } else { // Set #if MICROPY_PY_ARRAY_SLICE_ASSIGN if (!(MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple))) mp_raise_ValueError(translate("tuple/list required on RHS")); - size_t dst_len = slice.stop - slice.start; - + size_t dst_len = (slice.stop - slice.start); + dst_len = (slice.stop - slice.start) / slice.step; + if (slice.step > 1) { + if ((slice.stop - slice.start) % slice.step) + dst_len ++; + } mp_obj_t *src_objs; size_t num_items; if (MP_OBJ_IS_TYPE(value, &mp_type_list)) { @@ -394,16 +400,17 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp mp_raise_ValueError_varg(translate("Unmatched number of items on RHS (expected %d, got %d)."), dst_len, num_items); - for (size_t i = slice.start; i < slice.stop; i++) { + size_t target_i = slice.start; + for (size_t i = slice.start; target_i < slice.stop; i++, target_i += slice.step) { mp_obj_t *item = src_objs[i-slice.start]; if (MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple) || MP_OBJ_IS_INT(value)) { - pixelbuf_set_pixel(self->buf + (i * self->pixel_step), + pixelbuf_set_pixel(self->buf + (target_i * self->pixel_step), self->two_buffers ? self->rawbuf + (i * self->pixel_step) : NULL, self->brightness, item, &self->byteorder, self->byteorder.is_dotstar); } } if (self->auto_write) - call_show(self_in); + call_show(self_in, 's'); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -423,7 +430,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(self_in); + call_show(self_in, 'i'); return mp_const_none; } } diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index aa09e92613..18caa9219a 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -48,6 +48,6 @@ typedef struct { } pixelbuf_pixelbuf_obj_t; void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self); -mp_obj_t call_show(mp_obj_t self_in); +mp_obj_t call_show(mp_obj_t self_in, char origin); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c index e26f05ac3a..a0071903a9 100644 --- a/shared-module/_pixelbuf/PixelBuf.c +++ b/shared-module/_pixelbuf/PixelBuf.c @@ -94,10 +94,13 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_ } } -mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, bool dotstar) { +mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, mp_int_t slice_step, bool dotstar) { mp_obj_t elems[len]; + if (slice_step > 1) { + len = len / slice_step; + } for (uint i = 0; i < len; i++) { - elems[i] = pixelbuf_get_pixel(buf + (i * step), byteorder, dotstar); + elems[i] = pixelbuf_get_pixel(buf + ((i * slice_step) * step), byteorder, dotstar); } return mp_obj_new_tuple(len, elems); } diff --git a/shared-module/_pixelbuf/PixelBuf.h b/shared-module/_pixelbuf/PixelBuf.h index 6b3272e193..173ce61a83 100644 --- a/shared-module/_pixelbuf/PixelBuf.h +++ b/shared-module/_pixelbuf/PixelBuf.h @@ -44,7 +44,7 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_details_t *byteorder, bool dotstar); mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_details_t *byteorder, bool dotstar); -mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, bool dotstar); +mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, mp_int_t slice_step, bool dotstar); void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_details_t *byteorder); #endif From fa57de06886f3ec6785ec74676da0b08758c81c7 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 16 Nov 2019 14:04:12 -0500 Subject: [PATCH 16/44] use instance for verbose errors --- py/obj.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/obj.c b/py/obj.c index f91b00a648..6177f74b55 100644 --- a/py/obj.c +++ b/py/obj.c @@ -508,21 +508,21 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { mp_raise_TypeError(translate("object does not support item deletion")); } else { mp_raise_TypeError_varg( - translate("'%s' object does not support item deletion"), mp_obj_get_type_str(base)); + translate("'%s' object does not support item deletion"), mp_obj_get_type_str(instance)); } } else if (value == MP_OBJ_SENTINEL) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_TypeError(translate("object is not subscriptable")); } else { mp_raise_TypeError_varg( - translate("'%s' object is not subscriptable"), mp_obj_get_type_str(base)); + translate("'%s' object is not subscriptable"), mp_obj_get_type_str(instance)); } } else { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_TypeError(translate("object does not support item assignment")); } else { mp_raise_TypeError_varg( - translate("'%s' object does not support item assignment"), mp_obj_get_type_str(base)); + translate("'%s' object does not support item assignment"), mp_obj_get_type_str(instance)); } } } From c770ccd93917cf46a7b8cef7613ff389d7c3d18d Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 12:09:26 -0500 Subject: [PATCH 17/44] make ->subscr take an instance to pass when instance_subscr is called from subscr. --- extmod/machine_mem.c | 2 +- extmod/modbtree.c | 2 +- extmod/moductypes.c | 2 +- ports/unix/modjni.c | 2 +- py/obj.c | 15 +++++++-------- py/obj.h | 3 ++- py/objarray.c | 2 +- py/objdict.c | 2 +- py/objlist.c | 2 +- py/objrange.c | 2 +- py/objstr.c | 2 +- py/objstrunicode.c | 2 +- py/objtuple.c | 2 +- py/objtuple.h | 2 +- py/objtype.c | 5 ++--- py/opmethods.c | 6 +++--- shared-bindings/_pixelbuf/PixelBuf.c | 6 +++--- shared-bindings/displayio/Bitmap.c | 2 +- shared-bindings/displayio/Group.c | 2 +- shared-bindings/displayio/Palette.c | 2 +- shared-bindings/displayio/TileGrid.c | 2 +- shared-bindings/nvm/ByteArray.c | 2 +- shared-bindings/pulseio/PulseIn.c | 2 +- 23 files changed, 35 insertions(+), 36 deletions(-) diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c index e0649290ef..b80eaea998 100644 --- a/extmod/machine_mem.c +++ b/extmod/machine_mem.c @@ -60,7 +60,7 @@ STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_prin mp_printf(print, "<%u-bit memory>", 8 * self->elem_size); } -STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { // TODO support slice index to read/write multiple values at once machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { diff --git a/extmod/modbtree.c b/extmod/modbtree.c index 8b76885809..cfc614c137 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -246,7 +246,7 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { } } -STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { // delete diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 9eea30bf3e..2165152eaf 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -518,7 +518,7 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { +STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 8ec5ae54d9..4aefb2476f 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -241,7 +241,7 @@ STATIC void get_jclass_name(jobject obj, char *buf) { check_exception(); } -STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_jobject_t *self = self_in; mp_uint_t idx = mp_obj_get_int(index); char class_name[64]; diff --git a/py/obj.c b/py/obj.c index 6177f74b55..94c509be65 100644 --- a/py/obj.c +++ b/py/obj.c @@ -488,15 +488,14 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { } mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { + return mp_obj_subscr_impl(base, index, value, base); +} + +mp_obj_t mp_obj_subscr_impl(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(base); - mp_obj_t instance = base; - // If we got an MP_OBJ_SENTINEL as the type, then we got called by instance_subscr - if (type == MP_OBJ_SENTINEL) { - instance = ((mp_obj_t *)base)[1]; - type = mp_obj_get_type(((mp_obj_t *)base)[2]); - } + if (type->subscr != NULL) { - mp_obj_t ret = type->subscr(instance, index, value); + mp_obj_t ret = type->subscr(base, index, value, instance); // May have called port specific C code. Make sure it didn't mess up the heap. assert_heap_ok(); if (ret != MP_OBJ_NULL) { @@ -551,7 +550,7 @@ STATIC mp_obj_t generic_it_iternext(mp_obj_t self_in) { mp_obj_type_t *type = mp_obj_get_type(self->obj); mp_obj_t current_length = type->unary_op(MP_UNARY_OP_LEN, self->obj); if (self->cur < MP_OBJ_SMALL_INT_VALUE(current_length)) { - mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL); + mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL, self->obj); self->cur += 1; return o_out; } else { diff --git a/py/obj.h b/py/obj.h index cf4216d02f..edeeb2a4b5 100644 --- a/py/obj.h +++ b/py/obj.h @@ -444,7 +444,7 @@ typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, cons typedef mp_obj_t (*mp_unary_op_fun_t)(mp_unary_op_t op, mp_obj_t); typedef mp_obj_t (*mp_binary_op_fun_t)(mp_binary_op_t op, mp_obj_t, mp_obj_t); typedef void (*mp_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest); -typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); +typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance); typedef mp_obj_t (*mp_getiter_fun_t)(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf); // Buffer protocol @@ -708,6 +708,7 @@ mp_obj_t mp_obj_id(mp_obj_t o_in); mp_obj_t mp_obj_len(mp_obj_t o_in); mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val); +mp_obj_t mp_obj_subscr_impl(mp_obj_t base, mp_obj_t index, mp_obj_t val, mp_obj_t instance); mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in); // cell diff --git a/py/objarray.c b/py/objarray.c index 9114a63c5a..70e57f1901 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -396,7 +396,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend); #endif -STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { +STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item // TODO implement diff --git a/py/objdict.c b/py/objdict.c index 683fcb748e..c13ad88e5d 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -174,7 +174,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { } } -STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete mp_obj_dict_delete(self_in, index); diff --git a/py/objlist.c b/py/objlist.c index ea38e64e55..b0c62a6ee6 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -158,7 +158,7 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } -STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete #if MICROPY_PY_BUILTINS_SLICE diff --git a/py/objrange.c b/py/objrange.c index 30d55c56cd..f8b960900b 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -158,7 +158,7 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs } #endif -STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/py/objstr.c b/py/objstr.c index 6ef9a15b5e..3d2cb338fe 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -431,7 +431,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s #endif // This is used for both bytes and 8-bit strings. This is not used for unicode strings. -STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(self_in); GET_STR_DATA_LEN(self_in, self_data, self_len); if (value == MP_OBJ_SENTINEL) { diff --git a/py/objstrunicode.c b/py/objstrunicode.c index 30000a51e7..e299266831 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -197,7 +197,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s return s; } -STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(self_in); assert(type == &mp_type_str); GET_STR_DATA_LEN(self_in, self_data, self_len); diff --git a/py/objtuple.c b/py/objtuple.c index ed13cdcef2..625c53bdd3 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -177,7 +177,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } -mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/py/objtuple.h b/py/objtuple.h index 7f20ab7b6f..4df3aeded9 100644 --- a/py/objtuple.h +++ b/py/objtuple.h @@ -45,7 +45,7 @@ extern const mp_obj_type_t mp_type_tuple; void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); mp_obj_t mp_obj_tuple_unary_op(mp_unary_op_t op, mp_obj_t self_in); mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs); -mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value); +mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance); mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf); extern const mp_obj_type_t mp_type_attrtuple; diff --git a/py/objtype.c b/py/objtype.c index 7d41b86560..41ebe7b61e 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -823,7 +823,7 @@ STATIC void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { +STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_t member[2] = {MP_OBJ_NULL}; struct class_lookup_data lookup = { @@ -850,8 +850,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value meth_args = 3; } if (member[0] == MP_OBJ_SENTINEL) { - mp_obj_t args[3] = {MP_OBJ_SENTINEL, self_in, self->subobj[0]}; - return mp_obj_subscr(args, index, value); + return mp_obj_subscr_impl(self->subobj[0], index, value, instance); } else if (member[0] != MP_OBJ_NULL) { mp_obj_t args[3] = {self_in, index, value}; // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw diff --git a/py/opmethods.c b/py/opmethods.c index 247fa5bbc8..d906ddb6a3 100644 --- a/py/opmethods.c +++ b/py/opmethods.c @@ -29,19 +29,19 @@ STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_SENTINEL); + return type->subscr(self_in, key_in, MP_OBJ_SENTINEL, self_in); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_getitem_obj, op_getitem); STATIC mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, value_in); + return type->subscr(self_in, key_in, value_in, self_in); } MP_DEFINE_CONST_FUN_OBJ_3(mp_op_setitem_obj, op_setitem); STATIC mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_NULL); + return type->subscr(self_in, key_in, MP_OBJ_NULL, self_in); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_delitem_obj, op_delitem); diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index aeed6f5043..851c3a2762 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -348,7 +348,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_s //| //| Sets the pixel value at the given index. //| -STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { +STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item // slice deletion @@ -410,7 +410,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_show(self_in, 's'); + call_show(instance, 's'); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -430,7 +430,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(self_in, 'i'); + call_show(instance, 'i'); return mp_const_none; } } diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 91c17f2d13..764313e1ec 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -133,7 +133,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| //| bitmap[0,1] = 3 //| -STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { +STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { if (value_obj == mp_const_none) { // delete item mp_raise_AttributeError(translate("Cannot delete values")); diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index dd7600eb9c..2288026dcd 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -310,7 +310,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| //| del group[0] //| -STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { +STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { displayio_group_t *self = native_group(self_in); if (MP_OBJ_IS_TYPE(index_obj, &mp_type_slice)) { diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index dda58e3c53..491f9343b5 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -95,7 +95,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[2] = b'\xff\xff\x00\x00' # set using 4 bytes //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes //| -STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { +STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item return MP_OBJ_NULL; // op not supported diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 288eb4b236..5acf8496f8 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -349,7 +349,7 @@ const mp_obj_property_t displayio_tilegrid_pixel_shader_obj = { //| //| grid[0,0] = 10 //| -STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { +STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { displayio_tilegrid_t *self = native_tilegrid(self_in); diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 31bedeacc0..5ac46b260c 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -70,7 +70,7 @@ STATIC const mp_rom_map_elem_t nvm_bytearray_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(nvm_bytearray_locals_dict, nvm_bytearray_locals_dict_table); -STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { +STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item // slice deletion diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 8b69109f04..5947329a54 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -272,7 +272,7 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| pulses = pulseio.PulseIn(pin) //| print(pulses[0]) //| -STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { +STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { if (value == mp_const_none) { // delete item mp_raise_AttributeError(translate("Cannot delete values")); From 27979f51ace467215d5d823e0ce9f4f2ef690369 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 12:15:12 -0500 Subject: [PATCH 18/44] use base for errors --- py/obj.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/obj.c b/py/obj.c index 94c509be65..54822c9771 100644 --- a/py/obj.c +++ b/py/obj.c @@ -507,21 +507,21 @@ mp_obj_t mp_obj_subscr_impl(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_ob mp_raise_TypeError(translate("object does not support item deletion")); } else { mp_raise_TypeError_varg( - translate("'%s' object does not support item deletion"), mp_obj_get_type_str(instance)); + translate("'%s' object does not support item deletion"), mp_obj_get_type_str(base)); } } else if (value == MP_OBJ_SENTINEL) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_TypeError(translate("object is not subscriptable")); } else { mp_raise_TypeError_varg( - translate("'%s' object is not subscriptable"), mp_obj_get_type_str(instance)); + translate("'%s' object is not subscriptable"), mp_obj_get_type_str(base)); } } else { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_TypeError(translate("object does not support item assignment")); } else { mp_raise_TypeError_varg( - translate("'%s' object does not support item assignment"), mp_obj_get_type_str(instance)); + translate("'%s' object does not support item assignment"), mp_obj_get_type_str(base)); } } } From 03b892379ad9f427e4f3381ce4c572a27392a7f6 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 13:38:51 -0500 Subject: [PATCH 19/44] Try to fix frozen to fix CI --- frozen/Adafruit_CircuitPython_DotStar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index 02758607e2..01e89a8437 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit 02758607e26bedd356a0ff004d0493b1783950dd +Subproject commit 01e89a8437c78b62d4d655c745ded57e26dc747a From 75e1e7da4b2cae6adae2b3e12ec4fb6de628598d Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 13:40:03 -0500 Subject: [PATCH 20/44] Try to fix frozen to fix CI --- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index 443626b5e5..b94f06d85c 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit 443626b5e5df688a5b4cc077c4a2c4fdd8fbb49a +Subproject commit b94f06d85c2678d608d904c23e9c0c4172c76b15 From a9baa441c94bf4ba9fe676a34e8a47fee6001559 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 13:52:14 -0500 Subject: [PATCH 21/44] disable -Wunused-parameter on subscr functions --- extmod/machine_mem.c | 1 + extmod/modbtree.c | 1 + extmod/moductypes.c | 1 + ports/unix/modjni.c | 1 + py/objarray.c | 1 + py/objdict.c | 1 + py/objlist.c | 1 + py/objrange.c | 1 + py/objstr.c | 1 + py/objstrunicode.c | 1 + py/objtuple.c | 1 + shared-bindings/displayio/Bitmap.c | 1 + shared-bindings/displayio/Group.c | 1 + shared-bindings/displayio/Palette.c | 1 + 14 files changed, 14 insertions(+) diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c index b80eaea998..826c59d0f0 100644 --- a/extmod/machine_mem.c +++ b/extmod/machine_mem.c @@ -60,6 +60,7 @@ STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_prin mp_printf(print, "<%u-bit memory>", 8 * self->elem_size); } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { // TODO support slice index to read/write multiple values at once machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/extmod/modbtree.c b/extmod/modbtree.c index cfc614c137..97a4de3d5b 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -246,6 +246,7 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { } } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 2165152eaf..722f4bb872 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -518,6 +518,7 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 4aefb2476f..50dd10dd25 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -241,6 +241,7 @@ STATIC void get_jclass_name(jobject obj, char *buf) { check_exception(); } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_jobject_t *self = self_in; mp_uint_t idx = mp_obj_get_int(index); diff --git a/py/objarray.c b/py/objarray.c index 70e57f1901..6fffa84125 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -396,6 +396,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend); #endif +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item diff --git a/py/objdict.c b/py/objdict.c index c13ad88e5d..2c07331e7c 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -174,6 +174,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { } } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete diff --git a/py/objlist.c b/py/objlist.c index b0c62a6ee6..c544c27f05 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -158,6 +158,7 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete diff --git a/py/objrange.c b/py/objrange.c index f8b960900b..328416303d 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -158,6 +158,7 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs } #endif +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_SENTINEL) { // load diff --git a/py/objstr.c b/py/objstr.c index 4e17153226..fd802fe852 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -439,6 +439,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s #endif // This is used for both bytes and 8-bit strings. This is not used for unicode strings. +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(self_in); GET_STR_DATA_LEN(self_in, self_data, self_len); diff --git a/py/objstrunicode.c b/py/objstrunicode.c index e299266831..dc8c0743d3 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -197,6 +197,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s return s; } +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(self_in); assert(type == &mp_type_str); diff --git a/py/objtuple.c b/py/objtuple.c index 625c53bdd3..b6640def51 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -177,6 +177,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } +#pragma GCC diagnostic ignored "-Wunused-parameter" mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_SENTINEL) { // load diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 764313e1ec..7c77d05eda 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -133,6 +133,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| //| bitmap[0,1] = 3 //| +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { if (value_obj == mp_const_none) { // delete item diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 2288026dcd..40f2704c05 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -310,6 +310,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| //| del group[0] //| +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { displayio_group_t *self = native_group(self_in); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 491f9343b5..2fa65867aa 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -95,6 +95,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[2] = b'\xff\xff\x00\x00' # set using 4 bytes //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes //| +#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { if (value == MP_OBJ_NULL) { // delete item From 7422f430b2e2f398c8d0eac72fb84d188866cf04 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 23 Nov 2019 13:59:44 -0500 Subject: [PATCH 22/44] update translations --- locale/ID.po | 14 +++++--------- locale/circuitpython.pot | 14 +++++--------- locale/de_DE.po | 26 ++++++++++++++------------ locale/en_US.po | 14 +++++--------- locale/en_x_pirate.po | 14 +++++--------- locale/es.po | 19 +++++++++---------- locale/fil.po | 20 ++++++++++---------- locale/fr.po | 22 ++++++++++++---------- locale/it_IT.po | 19 +++++++++---------- locale/ko.po | 32 +++++++++++--------------------- locale/pl.po | 20 +++++++++++--------- locale/pt_BR.po | 14 +++++--------- locale/zh_Latn_pinyin.po | 20 +++++++++++--------- 13 files changed, 112 insertions(+), 136 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 58ba02f0f8..ece73442ba 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -843,6 +843,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -938,10 +942,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -2614,10 +2614,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 9b71b722da..da189a7178 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -832,6 +832,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -926,10 +930,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -2582,10 +2582,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index c87f0de82e..58cf8c1535 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -847,6 +847,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "Muss eine %q Unterklasse sein." +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Kein CCCD für diese Charakteristik" @@ -947,10 +951,6 @@ msgstr "" "Nur monochrome, indizierte 4bpp oder 8bpp, und 16bpp oder größere BMPs " "unterstützt: %d bpp wurden gegeben" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "Oversample muss ein Vielfaches von 8 sein." @@ -1464,9 +1464,8 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" -msgstr "byteorder ist keine Instanz von ByteOrder (%s erhalten)" +msgid "byteorder is not a string" +msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "bytes > 8 bits not supported" @@ -2648,10 +2647,6 @@ msgstr "value_count muss größer als 0 sein" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "write_args muss eine Liste, ein Tupel oder None sein" - #: py/objstr.c msgid "wrong number of arguments" msgstr "falsche Anzahl an Argumenten" @@ -2941,6 +2936,10 @@ msgstr "" #~ msgid "buffer too long" #~ msgstr "Buffer zu lang" +#, c-format +#~ msgid "byteorder is not an instance of ByteOrder (got a %s)" +#~ msgstr "byteorder ist keine Instanz von ByteOrder (%s erhalten)" + #~ msgid "expected a DigitalInOut" #~ msgstr "erwarte DigitalInOut" @@ -3007,3 +3006,6 @@ msgstr "" #~ msgid "wifi_set_ip_info() failed" #~ msgstr "wifi_set_ip_info() fehlgeschlagen" + +#~ msgid "write_args must be a list, tuple, or None" +#~ msgstr "write_args muss eine Liste, ein Tupel oder None sein" diff --git a/locale/en_US.po b/locale/en_US.po index 7d0eaca6e3..07c7a42f97 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -832,6 +832,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -926,10 +930,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -2582,10 +2582,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 3a88493111..2018f47bdc 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -836,6 +836,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -930,10 +934,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -2586,10 +2586,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/es.po b/locale/es.po index 7b955923b6..6e93dc5f60 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -846,6 +846,10 @@ msgstr "Micrófono demora de inicio debe estar en el rango 0.0 a 1.0" msgid "Must be a %q subclass." msgstr "Debe de ser una subclase de %q" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -944,11 +948,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "solo se admiten segmentos con step=1 (alias None)" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "El sobremuestreo debe ser un múltiplo de 8" @@ -2645,10 +2644,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "numero erroneo de argumentos" @@ -2890,6 +2885,10 @@ msgstr "paso cero" #~ "Solo se admiten BMP monocromos, indexados de 8bpp y 16bpp o superiores:% " #~ "d bppdado" +#, fuzzy +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "solo se admiten segmentos con step=1 (alias None)" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Solo color verdadero (24 bpp o superior) BMP admitido %x" diff --git a/locale/fil.po b/locale/fil.po index 75229b48f6..a506d5dbdd 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -852,6 +852,10 @@ msgstr "Ang delay ng startup ng mikropono ay dapat na nasa 0.0 hanggang 1.0" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -949,11 +953,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "ang mga slices lamang na may hakbang = 1 (aka None) ang sinusuportahan" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "Oversample ay dapat multiple ng 8." @@ -2654,10 +2653,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "mali ang bilang ng argumento" @@ -2873,6 +2868,11 @@ msgstr "zero step" #~ msgid "Only bit maps of 8 bit color or less are supported" #~ msgstr "Tanging bit maps na may 8 bit color o mas mababa ang supportado" +#, fuzzy +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "" +#~ "ang mga slices lamang na may hakbang = 1 (aka None) ang sinusuportahan" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Dapat true color (24 bpp o mas mataas) BMP lamang ang supportado %x" diff --git a/locale/fr.po b/locale/fr.po index 560007d5f2..04452a64b1 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -860,6 +860,10 @@ msgstr "Le délais au démarrage du micro doit être entre 0.0 et 1.0" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -960,11 +964,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "seuls les slices avec 'step=1' (cad 'None') sont supportées" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "Le sur-échantillonage doit être un multiple de 8." @@ -2695,10 +2694,6 @@ msgstr "'value_count' doit être > 0" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "'write_args' doit être une liste, un tuple ou 'None'" - #: py/objstr.c msgid "wrong number of arguments" msgstr "mauvais nombres d'arguments" @@ -2945,6 +2940,10 @@ msgstr "'step' nul" #~ "Seul les BMP monochromes, 8bit indexé et 16bit sont supportés: %d bpp " #~ "fourni" +#, fuzzy +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "seuls les slices avec 'step=1' (cad 'None') sont supportées" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Seul les BMP 24bits ou plus sont supportés %x" @@ -3107,3 +3106,6 @@ msgstr "'step' nul" #~ msgid "wifi_set_ip_info() failed" #~ msgstr "wifi_set_ip_info() a échoué" + +#~ msgid "write_args must be a list, tuple, or None" +#~ msgstr "'write_args' doit être une liste, un tuple ou 'None'" diff --git a/locale/it_IT.po b/locale/it_IT.po index 50b4dea8e6..87784829db 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -852,6 +852,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -950,11 +954,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "solo slice con step=1 (aka None) sono supportate" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "L'oversampling deve essere multiplo di 8." @@ -2653,10 +2652,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "numero di argomenti errato" @@ -2883,6 +2878,10 @@ msgstr "zero step" #~ msgid "Only bit maps of 8 bit color or less are supported" #~ msgstr "Sono supportate solo bitmap con colori a 8 bit o meno" +#, fuzzy +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "solo slice con step=1 (aka None) sono supportate" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Solo BMP true color (24 bpp o superiore) sono supportati %x" diff --git a/locale/ko.po b/locale/ko.po index 1452bd7e70..dfe49efe6c 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -378,11 +378,6 @@ msgstr "바이트는 0에서 255 사이 여야합니다." msgid "Call super().__init__() before accessing native object." msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "Can not use dotstar with %s" -msgstr "" - #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -703,6 +698,10 @@ msgstr "" msgid "Invalid buffer size" msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -837,6 +836,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -931,10 +934,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -1422,8 +1421,7 @@ msgid "byte code not implemented" msgstr "" #: shared-bindings/_pixelbuf/PixelBuf.c -#, c-format -msgid "byteorder is not an instance of ByteOrder (got a %s)" +msgid "byteorder is not a string" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c @@ -2103,7 +2101,7 @@ msgstr "" msgid "no reset pin available" msgstr "" -#: py/runtime.c shared-bindings/_pixelbuf/__init__.c +#: py/runtime.c msgid "no such attribute" msgstr "" @@ -2284,10 +2282,6 @@ msgstr "" msgid "rawbuf is not the same size as buf" msgstr "" -#: shared-bindings/_pixelbuf/__init__.c -msgid "readonly attribute" -msgstr "" - #: py/builtinimport.c msgid "relative import" msgstr "" @@ -2593,10 +2587,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index e024c2d4ec..cabeb5ed7b 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -842,6 +842,10 @@ msgstr "Opóźnienie włączenia mikrofonu musi być w zakresie od 0.0 do 1.0" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -936,10 +940,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "Wspierane są tylko fragmenty z step=1 (albo None)" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "Nadpróbkowanie musi być wielokrotnością 8." @@ -2609,10 +2609,6 @@ msgstr "value_count musi być > 0" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "write_args musi być listą, krotką lub None" - #: py/objstr.c msgid "wrong number of arguments" msgstr "zła liczba argumentów" @@ -2773,6 +2769,9 @@ msgstr "zerowy krok" #~ "bpp given" #~ msgstr "Wspierane są tylko pliki BMP czarno-białe, 8bpp i 16bpp: %d bpp " +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "Wspierane są tylko fragmenty z step=1 (albo None)" + #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Soft device assert, id: 0x%08lX, pc: 0x%08lX" @@ -2807,3 +2806,6 @@ msgstr "zerowy krok" #~ msgid "tile index out of bounds" #~ msgstr "indeks kafelka poza zakresem" + +#~ msgid "write_args must be a list, tuple, or None" +#~ msgstr "write_args musi być listą, krotką lub None" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 51189f8145..ffa7e72905 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -844,6 +844,10 @@ msgstr "" msgid "Must be a %q subclass." msgstr "" +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -941,10 +945,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "" @@ -2606,10 +2606,6 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "" - #: py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index fe2622c383..c2303f8e22 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-21 16:50-0800\n" +"POT-Creation-Date: 2019-11-23 13:58-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -842,6 +842,10 @@ msgstr "Màikèfēng qǐdòng yánchí bìxū zài 0.0 Dào 1.0 De fànwéi nèi msgid "Must be a %q subclass." msgstr "Bìxū shì %q zi lèi." +#: shared-bindings/_pixelbuf/PixelBuf.c +msgid "Negative step not supported" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Zhège tèzhēng méiyǒu CCCD" @@ -939,10 +943,6 @@ msgid "" "%d bpp given" msgstr "" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "Only slices with step=1 (aka None) are supported" -msgstr "Jǐn zhīchí 1 bù qiēpiàn" - #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." msgstr "Guò cǎiyàng bìxū shì 8 de bèishù." @@ -2622,10 +2622,6 @@ msgstr "zhí jìshù bìxū wèi > 0" msgid "window must be <= interval" msgstr "Chuāngkǒu bìxū shì <= jiàngé" -#: shared-bindings/_pixelbuf/PixelBuf.c -msgid "write_args must be a list, tuple, or None" -msgstr "xiě cānshù bìxū shì yuán zǔ, lièbiǎo huò None" - #: py/objstr.c msgid "wrong number of arguments" msgstr "cānshù shù cuòwù" @@ -2828,6 +2824,9 @@ msgstr "líng bù" #~ msgstr "" #~ "Jǐn zhīchí dān sè, suǒyǐn 8bpp hé 16bpp huò gèng dà de BMP: %d bpp tígōng" +#~ msgid "Only slices with step=1 (aka None) are supported" +#~ msgstr "Jǐn zhīchí 1 bù qiēpiàn" + #~ msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX" #~ msgstr "Ruǎn shèbèi wéihù, id: 0X%08lX, pc: 0X%08lX" @@ -2873,3 +2872,6 @@ msgstr "líng bù" #~ msgid "unsupported bitmap type" #~ msgstr "bù zhīchí de bitmap lèixíng" + +#~ msgid "write_args must be a list, tuple, or None" +#~ msgstr "xiě cānshù bìxū shì yuán zǔ, lièbiǎo huò None" From d4ed258b74ccf526ebd2a206b5d8ef035380c535 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 25 Nov 2019 20:20:51 -0500 Subject: [PATCH 23/44] remove unnecessary qstrs --- shared-bindings/_pixelbuf/__init__.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index e5cb652672..75482cbc26 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -85,24 +85,6 @@ const int32_t colorwheel(float pos) { STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) }, { MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) }, - { MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_QSTR(MP_QSTR_RGB) }, - { MP_ROM_QSTR(MP_QSTR_RBG), MP_ROM_QSTR(MP_QSTR_RBG) }, - { MP_ROM_QSTR(MP_QSTR_GRB), MP_ROM_QSTR(MP_QSTR_GRB) }, - { MP_ROM_QSTR(MP_QSTR_GBR), MP_ROM_QSTR(MP_QSTR_GBR) }, - { MP_ROM_QSTR(MP_QSTR_BRG), MP_ROM_QSTR(MP_QSTR_BRG) }, - { MP_ROM_QSTR(MP_QSTR_BGR), MP_ROM_QSTR(MP_QSTR_BGR) }, - { MP_ROM_QSTR(MP_QSTR_RGBW), MP_ROM_QSTR(MP_QSTR_RGBW) }, - { MP_ROM_QSTR(MP_QSTR_RBGW), MP_ROM_QSTR(MP_QSTR_RBGW) }, - { MP_ROM_QSTR(MP_QSTR_GRBW), MP_ROM_QSTR(MP_QSTR_GRBW) }, - { MP_ROM_QSTR(MP_QSTR_GBRW), MP_ROM_QSTR(MP_QSTR_GBRW) }, - { MP_ROM_QSTR(MP_QSTR_BRGW), MP_ROM_QSTR(MP_QSTR_BRGW) }, - { MP_ROM_QSTR(MP_QSTR_BGRW), MP_ROM_QSTR(MP_QSTR_BGRW) }, - { MP_ROM_QSTR(MP_QSTR_PRGB), MP_ROM_QSTR(MP_QSTR_PRGB) }, - { MP_ROM_QSTR(MP_QSTR_PRBG), MP_ROM_QSTR(MP_QSTR_PRBG) }, - { MP_ROM_QSTR(MP_QSTR_PGRB), MP_ROM_QSTR(MP_QSTR_PGRB) }, - { MP_ROM_QSTR(MP_QSTR_PGBR), MP_ROM_QSTR(MP_QSTR_PGBR) }, - { MP_ROM_QSTR(MP_QSTR_PBRG), MP_ROM_QSTR(MP_QSTR_PBRG) }, - { MP_ROM_QSTR(MP_QSTR_PBGR), MP_ROM_QSTR(MP_QSTR_PBGR) }, { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, }; From 0ef9344c17343aa01aadc5a261eba21012325132 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 25 Nov 2019 20:21:00 -0500 Subject: [PATCH 24/44] make pixelbuf iterable --- shared-bindings/_pixelbuf/PixelBuf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 851c3a2762..0b1bd3e897 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -454,6 +454,7 @@ const mp_obj_type_t pixelbuf_pixelbuf_type = { .subscr = pixelbuf_pixelbuf_subscr, .make_new = pixelbuf_pixelbuf_make_new, .unary_op = pixelbuf_pixelbuf_unary_op, + .getiter = mp_obj_new_generic_iterator, .print = NULL, .locals_dict = (mp_obj_t)&pixelbuf_pixelbuf_locals_dict, }; From 0b0aa5c5cf69189a619c6888fdd62c3eee063480 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 26 Nov 2019 18:12:46 -0500 Subject: [PATCH 25/44] Undo github workflow workaround --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7da73cb2de..1d5793573f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,10 +15,7 @@ jobs: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJson(github) }} - run: python -c "import os; print os.environ['GITHUB_CONTEXT']" - - name: Fail if not a release publish # workaround has `on` doesn't have this filter - run: exit 1 - if: github.event_name == 'release' && (github.event.action != 'published' && github.event.action != 'rerequested') + run: echo "$GITHUB_CONTEXT" - name: Set up Python 3.5 uses: actions/setup-python@v1 with: From 56720eae0a9eb6fe8845cf20eb1298c3fb68a373 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 26 Nov 2019 18:39:08 -0500 Subject: [PATCH 26/44] remove unnecessary intermediate mp_obj_subscr wrapper --- extmod/modurandom.c | 2 +- extmod/vfs.c | 2 +- ports/unix/modjni.c | 2 +- py/obj.c | 6 +----- py/obj.h | 3 +-- py/objreversed.c | 2 +- py/objtype.c | 2 +- py/vm.c | 4 ++-- shared-bindings/random/__init__.c | 2 +- shared-module/os/__init__.c | 2 +- 10 files changed, 11 insertions(+), 16 deletions(-) diff --git a/extmod/modurandom.c b/extmod/modurandom.c index 1512a3fd4a..101c80cf8a 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -150,7 +150,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_randint_obj, mod_urandom_randint); STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) { mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); if (len > 0) { - return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL); + return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL, seq); } else { nlr_raise(mp_obj_new_exception(&mp_type_IndexError)); } diff --git a/extmod/vfs.c b/extmod/vfs.c index 7d6e6999bd..7599739e0c 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -373,7 +373,7 @@ mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) { mp_obj_t dir_list = mp_obj_new_list(0, NULL); mp_obj_t next; while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL)); + mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, next)); } return dir_list; } diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 50dd10dd25..8f0eac5a9d 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -311,7 +311,7 @@ STATIC mp_obj_t jobject_unary_op(mp_unary_op_t op, mp_obj_t self_in) { // TODO: subscr_load_adaptor & subscr_getiter convenience functions // should be moved to common location for reuse. STATIC mp_obj_t subscr_load_adaptor(mp_obj_t self_in, mp_obj_t index_in) { - return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL); + return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL, self_in); } MP_DEFINE_CONST_FUN_OBJ_2(subscr_load_adaptor_obj, subscr_load_adaptor); diff --git a/py/obj.c b/py/obj.c index 54822c9771..47aa1aebfc 100644 --- a/py/obj.c +++ b/py/obj.c @@ -487,11 +487,7 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { } } -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { - return mp_obj_subscr_impl(base, index, value, base); -} - -mp_obj_t mp_obj_subscr_impl(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { mp_obj_type_t *type = mp_obj_get_type(base); if (type->subscr != NULL) { diff --git a/py/obj.h b/py/obj.h index edeeb2a4b5..ff97b34d83 100644 --- a/py/obj.h +++ b/py/obj.h @@ -707,8 +707,7 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool mp_obj_t mp_obj_id(mp_obj_t o_in); mp_obj_t mp_obj_len(mp_obj_t o_in); mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val); -mp_obj_t mp_obj_subscr_impl(mp_obj_t base, mp_obj_t index, mp_obj_t val, mp_obj_t instance); +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val, mp_obj_t instance); mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in); // cell diff --git a/py/objreversed.c b/py/objreversed.c index 4937d08189..0b21e69380 100644 --- a/py/objreversed.c +++ b/py/objreversed.c @@ -66,7 +66,7 @@ STATIC mp_obj_t reversed_iternext(mp_obj_t self_in) { // pre-decrement and index sequence self->cur_index -= 1; - return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL); + return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL, self->seq); } const mp_obj_type_t mp_type_reversed = { diff --git a/py/objtype.c b/py/objtype.c index 7d0760a106..9608a9242d 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -852,7 +852,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value meth_args = 3; } if (member[0] == MP_OBJ_SENTINEL) { - return mp_obj_subscr_impl(self->subobj[0], index, value, instance); + return mp_obj_subscr(self->subobj[0], index, value, instance); } else if (member[0] != MP_OBJ_NULL) { mp_obj_t args[3] = {self_in, index, value}; // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw diff --git a/py/vm.c b/py/vm.c index 353fc88100..2fe8d32370 100644 --- a/py/vm.c +++ b/py/vm.c @@ -386,7 +386,7 @@ dispatch_loop: ENTRY(MP_BC_LOAD_SUBSCR): { MARK_EXC_IP_SELECTIVE(); mp_obj_t index = POP(); - SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL)); + SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL, TOP())); DISPATCH(); } @@ -464,7 +464,7 @@ dispatch_loop: ENTRY(MP_BC_STORE_SUBSCR): MARK_EXC_IP_SELECTIVE(); - mp_obj_subscr(sp[-1], sp[0], sp[-2]); + mp_obj_subscr(sp[-1], sp[0], sp[-2], sp[-1]); sp -= 3; DISPATCH(); diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index 83698eac57..fdef914438 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -145,7 +145,7 @@ STATIC mp_obj_t random_choice(mp_obj_t seq) { if (len == 0) { mp_raise_IndexError(translate("empty sequence")); } - return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL); + return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL, seq); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_choice_obj, random_choice); diff --git a/shared-module/os/__init__.c b/shared-module/os/__init__.c index 8060eec4f3..ad76251c81 100644 --- a/shared-module/os/__init__.c +++ b/shared-module/os/__init__.c @@ -127,7 +127,7 @@ mp_obj_t common_hal_os_listdir(const char* path) { mp_obj_t next; while ((next = mp_iternext(iter_obj)) != MP_OBJ_STOP_ITERATION) { // next[0] is the filename. - mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL)); + mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, dir_list)); RUN_BACKGROUND_TASKS; } return dir_list; From a9624fff253a33c6c71e992ab438bf0c63ed3a5f Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 26 Nov 2019 21:28:41 -0500 Subject: [PATCH 27/44] add show --- shared-bindings/_pixelbuf/PixelBuf.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 0b1bd3e897..8ddcf6648a 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -230,7 +230,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t if (self->two_buffers) pixelbuf_recalculate_brightness(self); if (self->auto_write) - call_show(self_in, 'b'); + call_show(self_in); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_brightness_obj, pixelbuf_pixelbuf_obj_set_brightness); @@ -253,7 +253,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { } } -mp_obj_t call_show(mp_obj_t self_in, char origin) { +mp_obj_t call_show(mp_obj_t self_in) { mp_obj_t dest[2]; mp_load_method(self_in, MP_QSTR_show, dest); return mp_call_method_n_kw(0, 0, dest); @@ -340,6 +340,25 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); + +//| .. method:: fill(color) +//| +//| Fills the entire buffer with the given color. +//| + +STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); + + for (size_t offset = 0; offset < self->pixels; offset++) { + pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, + self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); + if (self->auto_write) + call_show(self_in); + } +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_fill); + + //| .. method:: __getitem__(index) //| //| Returns the pixel value at the given index. @@ -410,7 +429,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_show(instance, 's'); + call_show(instance); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -430,7 +449,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(instance, 'i'); + call_show(instance); return mp_const_none; } } @@ -443,6 +462,7 @@ STATIC const mp_rom_map_elem_t pixelbuf_pixelbuf_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_buf), MP_ROM_PTR(&pixelbuf_pixelbuf_buf_obj)}, { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_PTR(&pixelbuf_pixelbuf_byteorder_str)}, { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&pixelbuf_pixelbuf_show_obj)}, + { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&pixelbuf_pixelbuf_fill_obj)}, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_pixelbuf_locals_dict, pixelbuf_pixelbuf_locals_dict_table); From 659dcce635a0302625fd1f702843f1c793191e76 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 2 Dec 2019 14:07:46 -0500 Subject: [PATCH 28/44] run translate --- locale/circuitpython.pot | 2 +- locale/pl.po | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index d93ebb3bee..1d2b8ad867 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-02 14:06-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/locale/pl.po b/locale/pl.po index 73b08a8a73..f13bed53b9 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-11-27 14:54-0500\n" +"POT-Creation-Date: 2019-12-02 14:06-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -2794,11 +2794,11 @@ msgstr "zerowy krok" #~ msgid "tile index out of bounds" #~ msgstr "indeks kafelka poza zakresem" -#~ msgid "write_args must be a list, tuple, or None" -#~ msgstr "write_args musi być listą, krotką lub None" - #~ msgid "time.struct_time() takes exactly 1 argument" #~ msgstr "time.struct_time() wymaga jednego argumentu" #~ msgid "timeout >100 (units are now seconds, not msecs)" #~ msgstr "timeout > 100 (jednostkami są sekundy)" + +#~ msgid "write_args must be a list, tuple, or None" +#~ msgstr "write_args musi być listą, krotką lub None" From 0d267eaee13ec2e4f5a48947974fb612cdab6b96 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 2 Dec 2019 14:25:57 -0500 Subject: [PATCH 29/44] fix compile fails --- shared-bindings/_pixelbuf/PixelBuf.c | 3 ++- shared-bindings/_pixelbuf/PixelBuf.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 8ddcf6648a..d0be2b61df 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -355,8 +355,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { if (self->auto_write) call_show(self_in); } + return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_fill); +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); //| .. method:: __getitem__(index) diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index 18caa9219a..aa09e92613 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -48,6 +48,6 @@ typedef struct { } pixelbuf_pixelbuf_obj_t; void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self); -mp_obj_t call_show(mp_obj_t self_in, char origin); +mp_obj_t call_show(mp_obj_t self_in); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H From dd7ac68fb0a1d1327dbeddf1786480a977d41e96 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sun, 8 Dec 2019 16:53:08 -0500 Subject: [PATCH 30/44] fix slice anf fill bugs --- shared-bindings/_pixelbuf/PixelBuf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index d0be2b61df..dabc23d359 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -349,8 +349,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_s STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - for (size_t offset = 0; offset < self->pixels; offset++) { - pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, + for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { + pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) call_show(self_in); @@ -382,7 +382,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { mp_bound_slice_t slice; - mp_seq_get_fast_slice_indexes(self->bytes, index_in, &slice); + mp_seq_get_fast_slice_indexes(self->pixels, index_in, &slice); if ((slice.stop * self->pixel_step) > self->bytes) mp_raise_IndexError(translate("Range out of bounds")); @@ -399,8 +399,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (!(MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple))) mp_raise_ValueError(translate("tuple/list required on RHS")); - size_t dst_len = (slice.stop - slice.start); - dst_len = (slice.stop - slice.start) / slice.step; + size_t dst_len = (slice.stop - slice.start) / slice.step; if (slice.step > 1) { if ((slice.stop - slice.start) % slice.step) dst_len ++; From 222dd29a142a530b43fdf4d1ea01e276962b9886 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 10 Dec 2019 20:42:39 -0500 Subject: [PATCH 31/44] Fix slice step. --- shared-bindings/_pixelbuf/PixelBuf.c | 8 +++++--- shared-module/_pixelbuf/PixelBuf.c | 3 --- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index dabc23d359..feda2c573a 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -391,6 +391,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (value == MP_OBJ_SENTINEL) { // Get size_t len = slice.stop - slice.start; + if (slice.step > 1) { + len = (len / slice.step) + (len % slice.step ? 1 : 0); + } uint8_t *readbuf = self->two_buffers ? self->rawbuf : self->buf; return pixelbuf_get_pixel_array(readbuf + slice.start, len, &self->byteorder, self->pixel_step, slice.step, self->byteorder.is_dotstar); } else { // Set @@ -399,10 +402,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp if (!(MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple))) mp_raise_ValueError(translate("tuple/list required on RHS")); - size_t dst_len = (slice.stop - slice.start) / slice.step; + size_t dst_len = (slice.stop - slice.start); if (slice.step > 1) { - if ((slice.stop - slice.start) % slice.step) - dst_len ++; + dst_len = (dst_len / slice.step) + (dst_len % slice.step ? 1 : 0); } mp_obj_t *src_objs; size_t num_items; diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c index a0071903a9..020151bc31 100644 --- a/shared-module/_pixelbuf/PixelBuf.c +++ b/shared-module/_pixelbuf/PixelBuf.c @@ -96,9 +96,6 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_ mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, mp_int_t slice_step, bool dotstar) { mp_obj_t elems[len]; - if (slice_step > 1) { - len = len / slice_step; - } for (uint i = 0; i < len; i++) { elems[i] = pixelbuf_get_pixel(buf + ((i * slice_step) * step), byteorder, dotstar); } From cc31f2d10fd6cf0b96110c7b390e514dc0c3dbc1 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 13 Dec 2019 13:46:37 -0500 Subject: [PATCH 32/44] update translations --- locale/circuitpython.pot | 2 +- locale/es.po | 10 +++++----- locale/fr.po | 10 +++++----- locale/pl.po | 8 ++++---- locale/zh_Latn_pinyin.po | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 8b9b240a0e..7adde9ba85 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2019-12-13 13:44-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/locale/es.po b/locale/es.po index 6430ab3fb8..331c1a3edd 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2019-12-13 13:44-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -2673,15 +2673,15 @@ msgstr "paso cero" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Direción no es %d bytes largo o esta en el formato incorrecto" -#, c-format -#~ msgid "Can not use dotstar with %s" -#~ msgstr "No se puede usar dotstar con %s" - #~ msgid "Attempted heap allocation when MicroPython VM not running.\n" #~ msgstr "" #~ "Intento de allocation de heap cuando la VM de MicroPython no estaba " #~ "corriendo.\n" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "No se puede usar dotstar con %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "No se pueden agregar servicio en modo Central" diff --git a/locale/fr.po b/locale/fr.po index 5e355b8798..22e3b5b5bc 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2019-12-13 13:44-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -2724,14 +2724,14 @@ msgstr "'step' nul" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "L'adresse n'est pas longue de %d octets ou est d'un format erroné" -#, c-format -#~ msgid "Can not use dotstar with %s" -#~ msgstr "Impossible d'utiliser 'dotstar' avec %s" - #~ msgid "Attempted heap allocation when MicroPython VM not running.\n" #~ msgstr "" #~ "Tentative d'allocation de tas alors que la VM MicroPython ne tourne pas.\n" +#, c-format +#~ msgid "Can not use dotstar with %s" +#~ msgstr "Impossible d'utiliser 'dotstar' avec %s" + #~ msgid "Can't add services in Central mode" #~ msgstr "Impossible d'ajouter des services en mode Central" diff --git a/locale/pl.po b/locale/pl.po index c9c5bb36a7..9b2208849b 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2019-12-13 13:44-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -2637,13 +2637,13 @@ msgstr "zerowy krok" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Adres nie ma długości %d bajtów lub zły format" +#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" +#~ msgstr "Próba alokacji pamięci na stercie gdy VM nie działa.\n" + #, c-format #~ msgid "Can not use dotstar with %s" #~ msgstr "Nie można używać dotstar z %s" -#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" -#~ msgstr "Próba alokacji pamięci na stercie gdy VM nie działa.\n" - #~ msgid "Can't add services in Central mode" #~ msgstr "Nie można dodać serwisów w trybie Central" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 0ab65599d7..5b636ff606 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2019-12-13 13:44-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -2650,13 +2650,13 @@ msgstr "líng bù" #~ msgid "Address is not %d bytes long or is in wrong format" #~ msgstr "Dìzhǐ bùshì %d zì jié zhǎng, huòzhě géshì cuòwù" +#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" +#~ msgstr "MicroPython VM wèi yùnxíng shí chángshì duī fēnpèi.\n" + #, c-format #~ msgid "Can not use dotstar with %s" #~ msgstr "Wúfǎ yǔ dotstar yīqǐ shǐyòng %s" -#~ msgid "Attempted heap allocation when MicroPython VM not running.\n" -#~ msgstr "MicroPython VM wèi yùnxíng shí chángshì duī fēnpèi.\n" - #~ msgid "Can't add services in Central mode" #~ msgstr "Wúfǎ zài zhōngyāng móshì xià tiānjiā fúwù" From 15072c69c9e940fa5cb0239fc821d2c0353f918e Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 13 Dec 2019 13:32:58 -0500 Subject: [PATCH 33/44] push changes --- extmod/modbtree.c | 3 ++- extmod/moductypes.c | 4 ++-- py/objlist.c | 8 +++----- py/objtype.c | 10 ++++++++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/extmod/modbtree.c b/extmod/modbtree.c index 97a4de3d5b..939ab813e4 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -248,7 +248,8 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { #pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { - mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + //mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type); if (value == MP_OBJ_NULL) { // delete DBT key; diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 722f4bb872..145b348874 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -519,8 +519,8 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { - mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { + mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type); if (value == MP_OBJ_NULL) { // delete diff --git a/py/objlist.c b/py/objlist.c index c544c27f05..0c0d60aa83 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -160,11 +160,11 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { #pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { + mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); if (value == MP_OBJ_NULL) { // delete #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { mp_raise_NotImplementedError(NULL); @@ -180,12 +180,11 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp return mp_const_none; } #endif - mp_obj_t args[2] = {self_in, index}; + mp_obj_t args[2] = {self, index}; list_pop(2, args); return mp_const_none; } else if (value == MP_OBJ_SENTINEL) { // load - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; @@ -202,7 +201,6 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp } else { #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { - mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in); size_t value_len; mp_obj_t *value_items; mp_obj_get_array(value, &value_len, &value_items); mp_bound_slice_t slice_out; @@ -231,7 +229,7 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp return mp_const_none; } #endif - mp_obj_list_store(self_in, index, value); + mp_obj_list_store(self, index, value); return mp_const_none; } } diff --git a/py/objtype.c b/py/objtype.c index 9608a9242d..c7dc2ae78f 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -34,6 +34,7 @@ #include "py/objtype.h" #include "py/runtime.h" +#include "supervisor/shared/stack.h" #include "supervisor/shared/translate.h" #if MICROPY_DEBUG_VERBOSE // print debugging info @@ -851,8 +852,13 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value mp_obj_class_lookup(&lookup, self->base.type); meth_args = 3; } - if (member[0] == MP_OBJ_SENTINEL) { - return mp_obj_subscr(self->subobj[0], index, value, instance); + if (member[0] == MP_OBJ_SENTINEL) { // native base subscr exists + mp_obj_type_t *subobj_type = mp_obj_get_type(self->subobj[0]); + // return mp_obj_subscr(self->subobj[0], index, value, instance); + mp_obj_t ret = subobj_type->subscr(self_in, index, value, instance); + // May have called port specific C code. Make sure it didn't mess up the heap. + assert_heap_ok(); + return ret; } else if (member[0] != MP_OBJ_NULL) { mp_obj_t args[3] = {self_in, index, value}; // TODO probably need to call mp_convert_member_lookup, and use mp_call_method_n_kw From dc8dd6df20f4904917169f4ec1172c8f3827e822 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 13 Dec 2019 14:29:15 -0500 Subject: [PATCH 34/44] Revert subscr signature change --- extmod/machine_mem.c | 2 +- extmod/modbtree.c | 2 +- extmod/moductypes.c | 2 +- extmod/modurandom.c | 2 +- extmod/vfs.c | 2 +- ports/unix/modjni.c | 4 ++-- py/obj.c | 6 +++--- py/obj.h | 4 ++-- py/objarray.c | 3 +-- py/objdict.c | 2 +- py/objlist.c | 2 +- py/objrange.c | 2 +- py/objreversed.c | 2 +- py/objstr.c | 2 +- py/objstrunicode.c | 2 +- py/objtuple.c | 2 +- py/objtuple.h | 2 +- py/objtype.c | 4 ++-- py/opmethods.c | 6 +++--- py/vm.c | 4 ++-- shared-bindings/_pixelbuf/PixelBuf.c | 6 +++--- shared-bindings/displayio/Bitmap.c | 2 +- shared-bindings/displayio/Group.c | 2 +- shared-bindings/displayio/Palette.c | 2 +- shared-bindings/displayio/TileGrid.c | 2 +- shared-bindings/nvm/ByteArray.c | 2 +- shared-bindings/pulseio/PulseIn.c | 2 +- shared-bindings/random/__init__.c | 2 +- shared-module/os/__init__.c | 2 +- 29 files changed, 39 insertions(+), 40 deletions(-) diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c index 826c59d0f0..75496c6b5f 100644 --- a/extmod/machine_mem.c +++ b/extmod/machine_mem.c @@ -61,7 +61,7 @@ STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_prin } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { // TODO support slice index to read/write multiple values at once machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { diff --git a/extmod/modbtree.c b/extmod/modbtree.c index 939ab813e4..ad845163d6 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -247,7 +247,7 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { //mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type); if (value == MP_OBJ_NULL) { diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 145b348874..bf5f1cef73 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -519,7 +519,7 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value) { mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type); if (value == MP_OBJ_NULL) { diff --git a/extmod/modurandom.c b/extmod/modurandom.c index 101c80cf8a..1512a3fd4a 100644 --- a/extmod/modurandom.c +++ b/extmod/modurandom.c @@ -150,7 +150,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_urandom_randint_obj, mod_urandom_randint); STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) { mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); if (len > 0) { - return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL, seq); + return mp_obj_subscr(seq, mp_obj_new_int(yasmarang_randbelow(len)), MP_OBJ_SENTINEL); } else { nlr_raise(mp_obj_new_exception(&mp_type_IndexError)); } diff --git a/extmod/vfs.c b/extmod/vfs.c index 4d344095a6..2bb4057e7e 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -373,7 +373,7 @@ mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) { mp_obj_t dir_list = mp_obj_new_list(0, NULL); mp_obj_t next; while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { - mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, next)); + mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL)); } return dir_list; } diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 8f0eac5a9d..e18a26f3c6 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -242,7 +242,7 @@ STATIC void get_jclass_name(jobject obj, char *buf) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_jobject_t *self = self_in; mp_uint_t idx = mp_obj_get_int(index); char class_name[64]; @@ -311,7 +311,7 @@ STATIC mp_obj_t jobject_unary_op(mp_unary_op_t op, mp_obj_t self_in) { // TODO: subscr_load_adaptor & subscr_getiter convenience functions // should be moved to common location for reuse. STATIC mp_obj_t subscr_load_adaptor(mp_obj_t self_in, mp_obj_t index_in) { - return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL, self_in); + return mp_obj_subscr(self_in, index_in, MP_OBJ_SENTINEL); } MP_DEFINE_CONST_FUN_OBJ_2(subscr_load_adaptor_obj, subscr_load_adaptor); diff --git a/py/obj.c b/py/obj.c index 47aa1aebfc..09e71be4d6 100644 --- a/py/obj.c +++ b/py/obj.c @@ -487,11 +487,11 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) { } } -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(base); if (type->subscr != NULL) { - mp_obj_t ret = type->subscr(base, index, value, instance); + mp_obj_t ret = type->subscr(base, index, value); // May have called port specific C code. Make sure it didn't mess up the heap. assert_heap_ok(); if (ret != MP_OBJ_NULL) { @@ -546,7 +546,7 @@ STATIC mp_obj_t generic_it_iternext(mp_obj_t self_in) { mp_obj_type_t *type = mp_obj_get_type(self->obj); mp_obj_t current_length = type->unary_op(MP_UNARY_OP_LEN, self->obj); if (self->cur < MP_OBJ_SMALL_INT_VALUE(current_length)) { - mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL, self->obj); + mp_obj_t o_out = type->subscr(self->obj, MP_OBJ_NEW_SMALL_INT(self->cur), MP_OBJ_SENTINEL); self->cur += 1; return o_out; } else { diff --git a/py/obj.h b/py/obj.h index ff97b34d83..cf4216d02f 100644 --- a/py/obj.h +++ b/py/obj.h @@ -444,7 +444,7 @@ typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, cons typedef mp_obj_t (*mp_unary_op_fun_t)(mp_unary_op_t op, mp_obj_t); typedef mp_obj_t (*mp_binary_op_fun_t)(mp_binary_op_t op, mp_obj_t, mp_obj_t); typedef void (*mp_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest); -typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance); +typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); typedef mp_obj_t (*mp_getiter_fun_t)(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf); // Buffer protocol @@ -707,7 +707,7 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool mp_obj_t mp_obj_id(mp_obj_t o_in); mp_obj_t mp_obj_len(mp_obj_t o_in); mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL -mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val, mp_obj_t instance); +mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val); mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in); // cell diff --git a/py/objarray.c b/py/objarray.c index 6fffa84125..9114a63c5a 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -396,8 +396,7 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend); #endif -#pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item // TODO implement diff --git a/py/objdict.c b/py/objdict.c index 2c07331e7c..5bbe939b1d 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -175,7 +175,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete mp_obj_dict_delete(self_in, index); diff --git a/py/objlist.c b/py/objlist.c index 0c0d60aa83..64381bc706 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -159,7 +159,7 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); if (value == MP_OBJ_NULL) { // delete diff --git a/py/objrange.c b/py/objrange.c index 328416303d..6f14bcc9f9 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -159,7 +159,7 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs #endif #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/py/objreversed.c b/py/objreversed.c index 0b21e69380..4937d08189 100644 --- a/py/objreversed.c +++ b/py/objreversed.c @@ -66,7 +66,7 @@ STATIC mp_obj_t reversed_iternext(mp_obj_t self_in) { // pre-decrement and index sequence self->cur_index -= 1; - return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL, self->seq); + return mp_obj_subscr(self->seq, MP_OBJ_NEW_SMALL_INT(self->cur_index), MP_OBJ_SENTINEL); } const mp_obj_type_t mp_type_reversed = { diff --git a/py/objstr.c b/py/objstr.c index fd802fe852..567e734442 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -440,7 +440,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s // This is used for both bytes and 8-bit strings. This is not used for unicode strings. #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(self_in); GET_STR_DATA_LEN(self_in, self_data, self_len); if (value == MP_OBJ_SENTINEL) { diff --git a/py/objstrunicode.c b/py/objstrunicode.c index dc8c0743d3..2540a1d7b6 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -198,7 +198,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s } #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(self_in); assert(type == &mp_type_str); GET_STR_DATA_LEN(self_in, self_data, self_len); diff --git a/py/objtuple.c b/py/objtuple.c index b6640def51..7a4c09ab70 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -178,7 +178,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } #pragma GCC diagnostic ignored "-Wunused-parameter" -mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/py/objtuple.h b/py/objtuple.h index 4df3aeded9..7f20ab7b6f 100644 --- a/py/objtuple.h +++ b/py/objtuple.h @@ -45,7 +45,7 @@ extern const mp_obj_type_t mp_type_tuple; void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); mp_obj_t mp_obj_tuple_unary_op(mp_unary_op_t op, mp_obj_t self_in); mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs); -mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value, mp_obj_t instance); +mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value); mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf); extern const mp_obj_type_t mp_type_attrtuple; diff --git a/py/objtype.c b/py/objtype.c index c7dc2ae78f..a5e733208c 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -826,7 +826,7 @@ STATIC void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_t member[2] = {MP_OBJ_NULL}; struct class_lookup_data lookup = { @@ -855,7 +855,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value if (member[0] == MP_OBJ_SENTINEL) { // native base subscr exists mp_obj_type_t *subobj_type = mp_obj_get_type(self->subobj[0]); // return mp_obj_subscr(self->subobj[0], index, value, instance); - mp_obj_t ret = subobj_type->subscr(self_in, index, value, instance); + mp_obj_t ret = subobj_type->subscr(self_in, index, value); // May have called port specific C code. Make sure it didn't mess up the heap. assert_heap_ok(); return ret; diff --git a/py/opmethods.c b/py/opmethods.c index d906ddb6a3..247fa5bbc8 100644 --- a/py/opmethods.c +++ b/py/opmethods.c @@ -29,19 +29,19 @@ STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_SENTINEL, self_in); + return type->subscr(self_in, key_in, MP_OBJ_SENTINEL); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_getitem_obj, op_getitem); STATIC mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, value_in, self_in); + return type->subscr(self_in, key_in, value_in); } MP_DEFINE_CONST_FUN_OBJ_3(mp_op_setitem_obj, op_setitem); STATIC mp_obj_t op_delitem(mp_obj_t self_in, mp_obj_t key_in) { mp_obj_type_t *type = mp_obj_get_type(self_in); - return type->subscr(self_in, key_in, MP_OBJ_NULL, self_in); + return type->subscr(self_in, key_in, MP_OBJ_NULL); } MP_DEFINE_CONST_FUN_OBJ_2(mp_op_delitem_obj, op_delitem); diff --git a/py/vm.c b/py/vm.c index 2fe8d32370..353fc88100 100644 --- a/py/vm.c +++ b/py/vm.c @@ -386,7 +386,7 @@ dispatch_loop: ENTRY(MP_BC_LOAD_SUBSCR): { MARK_EXC_IP_SELECTIVE(); mp_obj_t index = POP(); - SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL, TOP())); + SET_TOP(mp_obj_subscr(TOP(), index, MP_OBJ_SENTINEL)); DISPATCH(); } @@ -464,7 +464,7 @@ dispatch_loop: ENTRY(MP_BC_STORE_SUBSCR): MARK_EXC_IP_SELECTIVE(); - mp_obj_subscr(sp[-1], sp[0], sp[-2], sp[-1]); + mp_obj_subscr(sp[-1], sp[0], sp[-2]); sp -= 3; DISPATCH(); diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index feda2c573a..a3579c92c0 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -368,7 +368,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_f //| //| Sets the pixel value at the given index. //| -STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item // slice deletion @@ -431,7 +431,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_show(instance); + call_show(self_in); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -451,7 +451,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(instance); + call_show(self_in); return mp_const_none; } } diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 7c77d05eda..ca9484a408 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -134,7 +134,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| bitmap[0,1] = 3 //| #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { +STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { if (value_obj == mp_const_none) { // delete item mp_raise_AttributeError(translate("Cannot delete values")); diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 40f2704c05..f5e3c22634 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -311,7 +311,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| del group[0] //| #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { displayio_group_t *self = native_group(self_in); if (MP_OBJ_IS_TYPE(index_obj, &mp_type_slice)) { diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 2fa65867aa..903338abb2 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -96,7 +96,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes //| #pragma GCC diagnostic ignored "-Wunused-parameter" -STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item return MP_OBJ_NULL; // op not supported diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 5acf8496f8..288eb4b236 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -349,7 +349,7 @@ const mp_obj_property_t displayio_tilegrid_pixel_shader_obj = { //| //| grid[0,0] = 10 //| -STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj, mp_obj_t instance) { +STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { displayio_tilegrid_t *self = native_tilegrid(self_in); diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 5ac46b260c..31bedeacc0 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -70,7 +70,7 @@ STATIC const mp_rom_map_elem_t nvm_bytearray_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(nvm_bytearray_locals_dict, nvm_bytearray_locals_dict_table); -STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item // slice deletion diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 5947329a54..8b69109f04 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -272,7 +272,7 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| pulses = pulseio.PulseIn(pin) //| print(pulses[0]) //| -STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value, mp_obj_t instance) { +STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { if (value == mp_const_none) { // delete item mp_raise_AttributeError(translate("Cannot delete values")); diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index fdef914438..83698eac57 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -145,7 +145,7 @@ STATIC mp_obj_t random_choice(mp_obj_t seq) { if (len == 0) { mp_raise_IndexError(translate("empty sequence")); } - return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL, seq); + return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_choice_obj, random_choice); diff --git a/shared-module/os/__init__.c b/shared-module/os/__init__.c index ad76251c81..8060eec4f3 100644 --- a/shared-module/os/__init__.c +++ b/shared-module/os/__init__.c @@ -127,7 +127,7 @@ mp_obj_t common_hal_os_listdir(const char* path) { mp_obj_t next; while ((next = mp_iternext(iter_obj)) != MP_OBJ_STOP_ITERATION) { // next[0] is the filename. - mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL, dir_list)); + mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL)); RUN_BACKGROUND_TASKS; } return dir_list; From 7f7105d36d5775e6b7842a24f06604a229b2aae3 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 13 Dec 2019 14:52:04 -0800 Subject: [PATCH 35/44] Fix tuple test --- py/objtuple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/objtuple.c b/py/objtuple.c index 7a4c09ab70..cc69f5469c 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -181,7 +181,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load - mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_tuple_t *self = mp_instance_cast_to_native_base(self_in, MP_OBJ_FROM_PTR(&mp_type_tuple)); #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; From d8e66a5f32749f29f5274432c616b2bd001dc7b3 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 13 Dec 2019 16:00:04 -0800 Subject: [PATCH 36/44] try 2. make namedtuple types handle subclasses --- py/objnamedtuple.c | 12 +++++++++++- py/objnamedtuple.h | 1 + py/objtuple.c | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index a044fe3ff8..a0a64f9b25 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -31,6 +31,7 @@ #include "py/runtime.h" #include "py/objstr.h" #include "py/objnamedtuple.h" +#include "py/objtype.h" #include "supervisor/shared/translate.h" @@ -70,6 +71,15 @@ void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t ki mp_obj_attrtuple_print_helper(print, fields, &o->tuple); } +mp_obj_t namedtuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + mp_obj_type_t *type = mp_obj_get_type(self_in); + // Check for subclasses of namedtuple and unpack if needed. + if (type->parent != &mp_type_tuple) { + self_in = ((mp_obj_instance_t*) self_in)->subobj[0]; + } + return mp_obj_tuple_subscr(self_in, index, value); +} + void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { if (dest[0] == MP_OBJ_NULL) { // load attribute @@ -167,7 +177,7 @@ STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, size_t n_fields, mp_obj_t o->base.unary_op = mp_obj_tuple_unary_op; o->base.binary_op = mp_obj_tuple_binary_op; o->base.attr = namedtuple_attr; - o->base.subscr = mp_obj_tuple_subscr; + o->base.subscr = namedtuple_subscr; o->base.getiter = mp_obj_tuple_getiter; o->base.parent = &mp_type_tuple; return MP_OBJ_FROM_PTR(o); diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h index 0ea0d28622..5a7512e3a6 100644 --- a/py/objnamedtuple.h +++ b/py/objnamedtuple.h @@ -49,6 +49,7 @@ typedef struct _mp_obj_namedtuple_t { void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr name); +mp_obj_t namedtuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *fields); mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); diff --git a/py/objtuple.c b/py/objtuple.c index cc69f5469c..b7f50d3b2c 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -179,9 +179,10 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { #pragma GCC diagnostic ignored "-Wunused-parameter" mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { + if (value == MP_OBJ_SENTINEL) { // load - mp_obj_tuple_t *self = mp_instance_cast_to_native_base(self_in, MP_OBJ_FROM_PTR(&mp_type_tuple)); + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); #if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; From ef2a8906ddd1b21c37d31fe7098fe6b7d5b5940d Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 16 Dec 2019 15:05:09 -0500 Subject: [PATCH 37/44] move call to show outside loop --- shared-bindings/_pixelbuf/PixelBuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index feda2c573a..1ed6f7baf8 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -352,9 +352,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); - if (self->auto_write) - call_show(self_in); } + if (self->auto_write) + call_show(self_in); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); From ca5b2770cf30f30946991faeaab16263bce435e9 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 16:10:01 -0500 Subject: [PATCH 38/44] try a property with a callable static class --- shared-bindings/_pixelbuf/PixelBuf.c | 64 ++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 7c624a8fdf..75f1b21882 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -346,8 +346,26 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_s //| Fills the entire buffer with the given color. //| -STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); + +// Pixelbuf Fill callable class + +typedef struct _pixelbuf_fill_t { + mp_obj_base_t base; +} pixelbuf_fill_t; + + +STATIC mp_obj_t pixelbuf_fill_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + pixelbuf_fill_t *o = m_new_obj(pixelbuf_fill_t); + o->base.type = type; + return MP_OBJ_FROM_PTR(o); +} + +// calls show +STATIC mp_obj_t pixelbuf_fill_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num_kw_array(n_args, n_kw, 2, 2, false); + mp_obj_t object = args[0]; + mp_obj_t value = args[1]; + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(object); for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, @@ -357,7 +375,47 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { call_show(self_in); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); + +const mp_obj_type_t pixelbuf_fill_type = { + { &mp_type_type }, + .name = MP_QSTR_PixelBufFill, + .make_new = pixelbuf_fill_make_new, + .call = pixelbuf_fill_call, +}; + +STATIC const pixelbuf_fill_t pixelbuf_fill_singleton = { + .base = { &pixelbuf_fill_type }, +}; + + +// STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { +// pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); + +// for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { +// pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, +// self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); +// } +// if (self->auto_write) +// call_show(self_in); +// return mp_const_none; +// } +// STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); + + +STATIC mp_obj_t pixelbuf_pixelbuf_obj_fill_get(mp_obj_t self_in) { + // pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); + return MP_OBJ_FROM_PTR(&pixelbuf_fill_singleton); +} +MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_obj_fill_get_obj, pixelbuf_pixelbuf_obj_fill_get); + +const mp_obj_property_t pixelbuf_pixelbuf_fill_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_obj_fill_get_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + //| .. method:: __getitem__(index) From 8129a8503a25bdffd00ce679ee98e940d1b6b04d Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 16:10:22 -0500 Subject: [PATCH 39/44] Revert "try a property with a callable static class" This reverts commit ca5b2770cf30f30946991faeaab16263bce435e9. --- shared-bindings/_pixelbuf/PixelBuf.c | 64 ++-------------------------- 1 file changed, 3 insertions(+), 61 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 75f1b21882..7c624a8fdf 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -346,26 +346,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_s //| Fills the entire buffer with the given color. //| - -// Pixelbuf Fill callable class - -typedef struct _pixelbuf_fill_t { - mp_obj_base_t base; -} pixelbuf_fill_t; - - -STATIC mp_obj_t pixelbuf_fill_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - pixelbuf_fill_t *o = m_new_obj(pixelbuf_fill_t); - o->base.type = type; - return MP_OBJ_FROM_PTR(o); -} - -// calls show -STATIC mp_obj_t pixelbuf_fill_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num_kw_array(n_args, n_kw, 2, 2, false); - mp_obj_t object = args[0]; - mp_obj_t value = args[1]; - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(object); +STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { + pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, @@ -375,47 +357,7 @@ STATIC mp_obj_t pixelbuf_fill_call(mp_obj_t self_in, size_t n_args, size_t n_kw, call_show(self_in); return mp_const_none; } - -const mp_obj_type_t pixelbuf_fill_type = { - { &mp_type_type }, - .name = MP_QSTR_PixelBufFill, - .make_new = pixelbuf_fill_make_new, - .call = pixelbuf_fill_call, -}; - -STATIC const pixelbuf_fill_t pixelbuf_fill_singleton = { - .base = { &pixelbuf_fill_type }, -}; - - -// STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { -// pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - -// for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { -// pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, -// self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); -// } -// if (self->auto_write) -// call_show(self_in); -// return mp_const_none; -// } -// STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); - - -STATIC mp_obj_t pixelbuf_pixelbuf_obj_fill_get(mp_obj_t self_in) { - // pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - return MP_OBJ_FROM_PTR(&pixelbuf_fill_singleton); -} -MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_obj_fill_get_obj, pixelbuf_pixelbuf_obj_fill_get); - -const mp_obj_property_t pixelbuf_pixelbuf_fill_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&pixelbuf_pixelbuf_obj_fill_get_obj, - (mp_obj_t)&mp_const_none_obj, - (mp_obj_t)&mp_const_none_obj}, -}; - - +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); //| .. method:: __getitem__(index) From 12193913a802e3b9c72079a93cb40c97d95cc683 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 17:30:17 -0500 Subject: [PATCH 40/44] move native fill to a helper to work around being unable to call a subclass show method from the native superclass --- locale/ID.po | 7 +++++-- locale/circuitpython.pot | 7 +++++-- locale/de_DE.po | 7 +++++-- locale/en_US.po | 7 +++++-- locale/en_x_pirate.po | 7 +++++-- locale/es.po | 7 +++++-- locale/fil.po | 7 +++++-- locale/fr.po | 7 +++++-- locale/it_IT.po | 7 +++++-- locale/ko.po | 7 +++++-- locale/pl.po | 7 +++++-- locale/pt_BR.po | 7 +++++-- locale/zh_Latn_pinyin.po | 7 +++++-- shared-bindings/_pixelbuf/PixelBuf.c | 20 -------------------- shared-bindings/_pixelbuf/__init__.c | 24 ++++++++++++++++++++++++ 15 files changed, 89 insertions(+), 46 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 4808727066..20662ae9db 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -600,6 +600,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1078,7 +1082,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Nilai sampel terlalu tinggi. Nilai harus kurang dari %d" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 7adde9ba85..5cf44cc356 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -589,6 +589,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1062,7 +1066,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 4a2bc89947..17f2e38280 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -593,6 +593,10 @@ msgstr "Erwartet ein(e) %q" msgid "Expected a Characteristic" msgstr "Characteristic wird erwartet" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "Ein Service wird erwartet" @@ -1079,7 +1083,6 @@ msgid "Sample rate must be positive" msgstr "Abtastrate muss positiv sein" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Abtastrate zu hoch. Wert muss unter %d liegen" diff --git a/locale/en_US.po b/locale/en_US.po index 135aeda172..e6fbfc471b 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -589,6 +589,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1062,7 +1066,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 5ac17778af..5635102301 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -593,6 +593,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1066,7 +1070,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/es.po b/locale/es.po index 331c1a3edd..c9688a41b1 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -595,6 +595,10 @@ msgstr "Se espera un %q" msgid "Expected a Characteristic" msgstr "Se esperaba una Característica." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1080,7 +1084,6 @@ msgid "Sample rate must be positive" msgstr "Sample rate debe ser positivo" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d" diff --git a/locale/fil.po b/locale/fil.po index a867e2a4f8..94f39f4064 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -602,6 +602,10 @@ msgstr "Umasa ng %q" msgid "Expected a Characteristic" msgstr "Hindi mabasa and Characteristic." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1086,7 +1090,6 @@ msgid "Sample rate must be positive" msgstr "Sample rate ay dapat positibo" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Sample rate ay masyadong mataas. Ito ay dapat hindi hiigit sa %d" diff --git a/locale/fr.po b/locale/fr.po index 22e3b5b5bc..42209a045e 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -605,6 +605,10 @@ msgstr "Attendu un %q" msgid "Expected a Characteristic" msgstr "Une 'Characteristic' est attendue" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1100,7 +1104,6 @@ msgid "Sample rate must be positive" msgstr "Le taux d'échantillonage doit être positif" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Taux d'échantillonage trop élevé. Doit être inf. à %d" diff --git a/locale/it_IT.po b/locale/it_IT.po index 575263b4be..684e2a90b9 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -602,6 +602,10 @@ msgstr "Atteso un %q" msgid "Expected a Characteristic" msgstr "Non è possibile aggiungere Characteristic." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1096,7 +1100,6 @@ msgid "Sample rate must be positive" msgstr "STA deve essere attiva" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 51544984ed..7b4240800b 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -593,6 +593,10 @@ msgstr "%q 이 예상되었습니다." msgid "Expected a Characteristic" msgstr "특성(Characteristic)이 예상되었습니다." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1066,7 +1070,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 9b2208849b..1ef686e451 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -592,6 +592,10 @@ msgstr "Oczekiwano %q" msgid "Expected a Characteristic" msgstr "Oczekiwano charakterystyki" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1067,7 +1071,6 @@ msgid "Sample rate must be positive" msgstr "Częstotliwość próbkowania musi być dodatnia" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Zbyt wysoka częstotliwość próbkowania. Musi być mniejsza niż %d" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index a2ccd2625d..9d36696ce7 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -597,6 +597,10 @@ msgstr "Esperado um" msgid "Expected a Characteristic" msgstr "Não é possível adicionar Característica." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1079,7 +1083,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Taxa de amostragem muito alta. Deve ser menor que %d" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 5b636ff606..cb907e0a1f 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -593,6 +593,10 @@ msgstr "Yùqí %q" msgid "Expected a Characteristic" msgstr "Yùqí de tèdiǎn" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "Yùqí fúwù" @@ -1072,7 +1076,6 @@ msgid "Sample rate must be positive" msgstr "Cǎiyàng lǜ bìxū wèi zhèng shù" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Cǎiyàng lǜ tài gāo. Tā bìxū xiǎoyú %d" diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 7c624a8fdf..e422818546 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -341,25 +341,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); -//| .. method:: fill(color) -//| -//| Fills the entire buffer with the given color. -//| - -STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - - for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { - pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, - self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); - } - if (self->auto_write) - call_show(self_in); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); - - //| .. method:: __getitem__(index) //| //| Returns the pixel value at the given index. @@ -464,7 +445,6 @@ STATIC const mp_rom_map_elem_t pixelbuf_pixelbuf_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_buf), MP_ROM_PTR(&pixelbuf_pixelbuf_buf_obj)}, { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_PTR(&pixelbuf_pixelbuf_byteorder_str)}, { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&pixelbuf_pixelbuf_show_obj)}, - { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&pixelbuf_pixelbuf_fill_obj)}, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_pixelbuf_locals_dict, pixelbuf_pixelbuf_locals_dict_table); diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 75482cbc26..433f1d97b8 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -82,10 +82,34 @@ const int32_t colorwheel(float pos) { } } + +//| .. function:: fill(pixelbuf, color) +//| +//| Fills the given pixelbuf with the given color. +//| + +STATIC mp_obj_t pixelbuf_fill(mp_obj_t pixelbuf_in, mp_obj_t value) { + mp_obj_t obj = mp_instance_cast_to_native_base(pixelbuf_in, &pixelbuf_pixelbuf_type); + if (obj == MP_OBJ_NULL) + mp_raise_TypeError(translate("Expected a PixelBuf instance")); + pixelbuf_pixelbuf_obj_t *pixelbuf = MP_OBJ_TO_PTR(obj); + + for (size_t offset = 0; offset < pixelbuf->bytes; offset+= pixelbuf->pixel_step) { + pixelbuf_set_pixel(pixelbuf->buf + offset, pixelbuf->two_buffers ? (pixelbuf->rawbuf + offset) : NULL, + pixelbuf->brightness, value, &pixelbuf->byteorder, pixelbuf->byteorder.is_dotstar); + } + if (pixelbuf->auto_write) + call_show(pixelbuf_in); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_fill_obj, pixelbuf_fill); + + STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) }, { MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) }, { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, + { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&pixelbuf_fill_obj) }, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_table); From 4e1996856f15bb1ada52651ce6b9e7571c1d52bc Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 19:25:44 -0500 Subject: [PATCH 41/44] Fix docstring for byteorder --- shared-bindings/_pixelbuf/PixelBuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index e422818546..465b5cbb86 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -66,7 +66,7 @@ extern const int32_t colorwheel(float pos); //| //| :param ~int size: Number of pixelsx //| :param ~bytearray buf: Bytearray in which to store pixel data -//| :param ~str byteorder: Byte order string (such as "BGR" or "DBGR") +//| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR") //| :param ~float brightness: Brightness (0 to 1.0, default 1.0) //| :param ~bytearray rawbuf: Bytearray in which to store raw pixel data (before brightness adjustment) //| :param ~int offset: Offset from start of buffer (default 0) From fdddb54db41fce45abaa9d4254f44de4dab4b631 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 2 Jan 2020 17:56:04 -0500 Subject: [PATCH 42/44] rename call_show to pixelbuf_call_show --- shared-bindings/_pixelbuf/PixelBuf.c | 8 ++++---- shared-bindings/_pixelbuf/PixelBuf.h | 2 +- shared-bindings/_pixelbuf/__init__.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 465b5cbb86..6eb35c51ad 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -230,7 +230,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_obj_set_brightness(mp_obj_t self_in, mp_obj_t if (self->two_buffers) pixelbuf_recalculate_brightness(self); if (self->auto_write) - call_show(self_in); + pixelbuf_call_show(self_in); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_set_brightness_obj, pixelbuf_pixelbuf_obj_set_brightness); @@ -253,7 +253,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) { } } -mp_obj_t call_show(mp_obj_t self_in) { +mp_obj_t pixelbuf_call_show(mp_obj_t self_in) { mp_obj_t dest[2]; mp_load_method(self_in, MP_QSTR_show, dest); return mp_call_method_n_kw(0, 0, dest); @@ -412,7 +412,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } } if (self->auto_write) - call_show(self_in); + pixelbuf_call_show(self_in); return mp_const_none; #else return MP_OBJ_NULL; // op not supported @@ -432,7 +432,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL, self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); if (self->auto_write) - call_show(self_in); + pixelbuf_call_show(self_in); return mp_const_none; } } diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index aa09e92613..691da3cd33 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -48,6 +48,6 @@ typedef struct { } pixelbuf_pixelbuf_obj_t; void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self); -mp_obj_t call_show(mp_obj_t self_in); +mp_obj_t pixelbuf_call_show(mp_obj_t self_in); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 433f1d97b8..ed264f3bb4 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -99,7 +99,7 @@ STATIC mp_obj_t pixelbuf_fill(mp_obj_t pixelbuf_in, mp_obj_t value) { pixelbuf->brightness, value, &pixelbuf->byteorder, pixelbuf->byteorder.is_dotstar); } if (pixelbuf->auto_write) - call_show(pixelbuf_in); + pixelbuf_call_show(pixelbuf_in); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_fill_obj, pixelbuf_fill); From ccf158b03009d3de7ec8d70584044cd7f7bc1dd3 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 2 Jan 2020 18:00:36 -0500 Subject: [PATCH 43/44] raise mp_raise_NotImplementedError --- extmod/modbtree.c | 2 -- shared-bindings/_pixelbuf/PixelBuf.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/extmod/modbtree.c b/extmod/modbtree.c index ad845163d6..7cfa9c6afb 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -246,9 +246,7 @@ STATIC mp_obj_t btree_iternext(mp_obj_t self_in) { } } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { - //mp_obj_btree_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_btree_t *self = mp_instance_cast_to_native_base(self_in, &btree_type); if (value == MP_OBJ_NULL) { // delete diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 6eb35c51ad..3e93190470 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -332,11 +332,11 @@ STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| .. method:: show() //| -//| Does nothing unless subclassed. +//| Must be implemented in subclasses. //| STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { - return mp_const_none; + mp_raise_NotImplementedError(NULL); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); From 767ce1cdf8c56ed00f2b88c4babcd92b91b51755 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 2 Jan 2020 18:03:18 -0500 Subject: [PATCH 44/44] remove unnecessary GCC pragmas --- extmod/machine_mem.c | 1 - extmod/moductypes.c | 1 - ports/unix/modjni.c | 1 - py/objdict.c | 1 - py/objlist.c | 1 - py/objrange.c | 1 - py/objstr.c | 1 - py/objstrunicode.c | 1 - py/objtuple.c | 1 - shared-bindings/displayio/Bitmap.c | 1 - shared-bindings/displayio/Group.c | 1 - shared-bindings/displayio/Palette.c | 1 - 12 files changed, 12 deletions(-) diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c index 75496c6b5f..e0649290ef 100644 --- a/extmod/machine_mem.c +++ b/extmod/machine_mem.c @@ -60,7 +60,6 @@ STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_prin mp_printf(print, "<%u-bit memory>", 8 * self->elem_size); } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { // TODO support slice index to read/write multiple values at once machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/extmod/moductypes.c b/extmod/moductypes.c index bf5f1cef73..451dc29ed9 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -518,7 +518,6 @@ STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_obj_t value) { mp_obj_uctypes_struct_t *self = mp_instance_cast_to_native_base(base_in, &uctypes_struct_type); diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index e18a26f3c6..8ec5ae54d9 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -241,7 +241,6 @@ STATIC void get_jclass_name(jobject obj, char *buf) { check_exception(); } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_jobject_t *self = self_in; mp_uint_t idx = mp_obj_get_int(index); diff --git a/py/objdict.c b/py/objdict.c index 5bbe939b1d..683fcb748e 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -174,7 +174,6 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { } } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete diff --git a/py/objlist.c b/py/objlist.c index 64381bc706..b32f82085e 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -158,7 +158,6 @@ STATIC mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_list_t *self = mp_instance_cast_to_native_base(self_in, &mp_type_list); if (value == MP_OBJ_NULL) { diff --git a/py/objrange.c b/py/objrange.c index 6f14bcc9f9..30d55c56cd 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -158,7 +158,6 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs } #endif -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load diff --git a/py/objstr.c b/py/objstr.c index 567e734442..fde2646815 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -439,7 +439,6 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s #endif // This is used for both bytes and 8-bit strings. This is not used for unicode strings. -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(self_in); GET_STR_DATA_LEN(self_in, self_data, self_len); diff --git a/py/objstrunicode.c b/py/objstrunicode.c index 2540a1d7b6..30000a51e7 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -197,7 +197,6 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s return s; } -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(self_in); assert(type == &mp_type_str); diff --git a/py/objtuple.c b/py/objtuple.c index b7f50d3b2c..2b483f8b83 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -177,7 +177,6 @@ mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { } } -#pragma GCC diagnostic ignored "-Wunused-parameter" mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index ca9484a408..91c17f2d13 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -133,7 +133,6 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| //| bitmap[0,1] = 3 //| -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { if (value_obj == mp_const_none) { // delete item diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index f5e3c22634..dd7600eb9c 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -310,7 +310,6 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| //| del group[0] //| -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { displayio_group_t *self = native_group(self_in); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 903338abb2..dda58e3c53 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -95,7 +95,6 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[2] = b'\xff\xff\x00\x00' # set using 4 bytes //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes //| -#pragma GCC diagnostic ignored "-Wunused-parameter" STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item