From 7fd1a6c8a80780e227a0f4a7bdd6fda57853814b Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Thu, 25 Jul 2019 15:04:55 -0400 Subject: [PATCH 01/19] Expose array_new and array_subscr --- py/objarray.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/objarray.c b/py/objarray.c index 9114a63c5a..61d55f2559 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -92,7 +92,7 @@ STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t #endif #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY -STATIC mp_obj_array_t *array_new(char typecode, size_t n) { +mp_obj_array_t *array_new(char typecode, size_t n) { int typecode_size = mp_binary_get_size('@', typecode, NULL); mp_obj_array_t *o = m_new_obj(mp_obj_array_t); #if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_PY_ARRAY @@ -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) { +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 From b6178c9d85876c771b08188373df568da0acda87 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Thu, 25 Jul 2019 15:05:30 -0400 Subject: [PATCH 02/19] WIP on exposing fill_area --- shared-bindings/displayio/Display.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 361a37ece1..2b9c740666 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -348,10 +348,125 @@ const mp_obj_property_t displayio_display_bus_obj = { }; +//| .. attribute:: screenshot +//| +//| Take a screenshot. +//| +//| +/* STATIC mp_obj_t displayio_display_obj_get_screenshot(mp_obj_t self_in) { */ +/* displayio_display_obj_t *self = native_display(self_in); */ +/* return mp_const_none; */ +/* } */ +/* MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_screenshot_obj, displayio_display_obj_get_screenshot); */ + +/* const mp_obj_property_t displayio_display_screenshot_obj = { */ +/* .base.type = &mp_type_property, */ +/* .proxy = {(mp_obj_t)&displayio_display_get_screenshot_obj, */ +/* (mp_obj_t)&mp_const_none_obj, */ +/* (mp_obj_t)&mp_const_none_obj}, */ +/* }; */ + + +#include "py/objarray.h" +mp_obj_array_t *array_new(char typecode, size_t n); +mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value); + +//| .. method:: fill_area(x, y, w, h) +//| +//| Switches to displaying the given group of layers. When group is None, the default +//| CircuitPython terminal will be shown. +//| +//| :param int x: The left edge of the area +//| :param int y: The top edge of the area +//| :param int w: The width of the area +//| :param int h: The height of the area +STATIC mp_obj_t displayio_display_obj_fill_area(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_x, ARG_y, ARG_width, ARG_height }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_x, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, + { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, + { MP_QSTR_width, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, + { MP_QSTR_height, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + displayio_display_obj_t *self = native_display(pos_args[0]); + mp_int_t x = args[ARG_x].u_int; + mp_int_t y = args[ARG_y].u_int; + mp_int_t w = args[ARG_width].u_int; + mp_int_t h = args[ARG_height].u_int; + + uint16_t buffer_size = 128; // In uint32_ts + displayio_area_t area = { + .x1 = x, + .y1 = y, + .x2 = x + w, + .y2 = y + h + }; + displayio_area_t clipped; + // Clip the area to the display by overlapping the areas. If there is no overlap then we're done. + if (!displayio_display_clip_area(self, &area, &clipped)) { + return mp_const_none; + } + uint16_t subrectangles = 1; + uint16_t rows_per_buffer = displayio_area_height(&clipped); + uint8_t pixels_per_word = (sizeof(uint32_t) * 8) / self->colorspace.depth; + uint16_t pixels_per_buffer = displayio_area_size(&clipped); + if (displayio_area_size(&clipped) > buffer_size * pixels_per_word) { + rows_per_buffer = buffer_size * pixels_per_word / displayio_area_width(&clipped); + if (rows_per_buffer == 0) { + rows_per_buffer = 1; + } + // If pixels are packed by column then ensure rows_per_buffer is on a byte boundary. + if (self->colorspace.depth < 8 && !self->colorspace.pixels_in_byte_share_row) { + uint8_t pixels_per_byte = 8 / self->colorspace.depth; + if (rows_per_buffer % pixels_per_byte != 0) { + rows_per_buffer -= rows_per_buffer % pixels_per_byte; + } + } + subrectangles = displayio_area_height(&clipped) / rows_per_buffer; + if (displayio_area_height(&clipped) % rows_per_buffer != 0) { + subrectangles++; + } + pixels_per_buffer = rows_per_buffer * displayio_area_width(&clipped); + buffer_size = pixels_per_buffer / pixels_per_word; + if (pixels_per_buffer % pixels_per_word) { + buffer_size += 1; + } + } + + // Allocated and shared as a uint32_t array so the compiler knows the + // alignment everywhere. + uint32_t buffer[buffer_size]; + volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1; + uint32_t mask[mask_length]; + + for (uint16_t k = 0; k < mask_length; k++) { + mask[k] = 0x00000000; + } + for (uint16_t k = 0; k < buffer_size; k++) { + buffer[k] = 0x00000000; + } + + displayio_display_fill_area(self, &area, mask, buffer); + + mp_obj_array_t *result = array_new(BYTEARRAY_TYPECODE, buffer_size); + for (int offset = 0; offset < buffer_size; offset++) { + array_subscr(result, MP_OBJ_NEW_SMALL_INT(offset), MP_OBJ_NEW_SMALL_INT(buffer[offset])); + } + return result; +} +MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_area_obj, 1, displayio_display_obj_fill_area); + + + + STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&displayio_display_show_obj) }, { MP_ROM_QSTR(MP_QSTR_refresh_soon), MP_ROM_PTR(&displayio_display_refresh_soon_obj) }, { MP_ROM_QSTR(MP_QSTR_wait_for_frame), MP_ROM_PTR(&displayio_display_wait_for_frame_obj) }, + { MP_ROM_QSTR(MP_QSTR_fill_area), MP_ROM_PTR(&displayio_display_fill_area_obj) }, { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&displayio_display_brightness_obj) }, { MP_ROM_QSTR(MP_QSTR_auto_brightness), MP_ROM_PTR(&displayio_display_auto_brightness_obj) }, @@ -359,6 +474,7 @@ STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_display_width_obj) }, { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) }, { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_display_bus_obj) }, + // { MP_ROM_QSTR(MP_QSTR_screenshot), MP_ROM_PTR(&displayio_display_screenshot_obj) }, }; STATIC MP_DEFINE_CONST_DICT(displayio_display_locals_dict, displayio_display_locals_dict_table); From 741cd9c40a4b3368ffa92286498883bd29b0fb70 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 31 Jul 2019 12:47:32 -0400 Subject: [PATCH 03/19] Get fill_area working --- shared-bindings/displayio/Display.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 2b9c740666..6338fe459a 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -451,9 +451,15 @@ STATIC mp_obj_t displayio_display_obj_fill_area(size_t n_args, const mp_obj_t *p displayio_display_fill_area(self, &area, mask, buffer); - mp_obj_array_t *result = array_new(BYTEARRAY_TYPECODE, buffer_size); - for (int offset = 0; offset < buffer_size; offset++) { - array_subscr(result, MP_OBJ_NEW_SMALL_INT(offset), MP_OBJ_NEW_SMALL_INT(buffer[offset])); + mp_obj_array_t *result = array_new(BYTEARRAY_TYPECODE, buffer_size * 4); + int byte_offset = 0; + for (int word_offset = 0; word_offset < buffer_size; word_offset++) { + uint32_t word = buffer[word_offset]; + for (int byte_count = 0; byte_count < 4; byte_count++) { + array_subscr(result, MP_OBJ_NEW_SMALL_INT(byte_offset), MP_OBJ_NEW_SMALL_INT(word & 0x000000FF)); + word >>= 8; + byte_offset++; + } } return result; } From 1f9cb44fa3a09996d042b7b9e01864bf2feac363 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 31 Jul 2019 15:00:21 -0400 Subject: [PATCH 04/19] Expose rotation with a property --- shared-bindings/displayio/Display.c | 18 ++++++++++++++++++ shared-bindings/displayio/Display.h | 1 + shared-module/displayio/Display.c | 6 +++++- shared-module/displayio/Display.h | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 6338fe459a..ab9bad19c6 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -329,6 +329,23 @@ const mp_obj_property_t displayio_display_height_obj = { (mp_obj_t)&mp_const_none_obj}, }; +//| .. attribute:: rotation +//| +//| The rotation of the display as an int in degrees. +//| +STATIC mp_obj_t displayio_display_obj_get_rotation(mp_obj_t self_in) { + displayio_display_obj_t *self = native_display(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_rotation(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_rotation_obj, displayio_display_obj_get_rotation); + +const mp_obj_property_t displayio_display_rotation_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_display_get_rotation_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + //| .. attribute:: bus //| //| The bus being used by the display @@ -479,6 +496,7 @@ STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_display_width_obj) }, { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) }, + { MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&displayio_display_rotation_obj) }, { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_display_bus_obj) }, // { MP_ROM_QSTR(MP_QSTR_screenshot), MP_ROM_PTR(&displayio_display_screenshot_obj) }, }; diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index e765e6f256..40793be149 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -68,6 +68,7 @@ void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* s uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t* self); uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t* self); +uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self); mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t* self); bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self, mp_float_t brightness); diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index a8515b9e58..74a96fac21 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -119,7 +119,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, self->width = width; self->height = height; - rotation = rotation % 360; + self->rotation = rotation % 360; self->transform.x = 0; self->transform.y = 0; self->transform.scale = 1; @@ -242,6 +242,10 @@ uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t* self){ return self->height; } +uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self){ + return self->rotation; +} + void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* self, bool auto_brightness) { self->auto_brightness = auto_brightness; } diff --git a/shared-module/displayio/Display.h b/shared-module/displayio/Display.h index 96d1c06d57..74ae175b1e 100644 --- a/shared-module/displayio/Display.h +++ b/shared-module/displayio/Display.h @@ -55,6 +55,7 @@ typedef struct { mp_float_t current_brightness; uint16_t width; uint16_t height; + uint16_t rotation; _displayio_colorspace_t colorspace; int16_t colstart; int16_t rowstart; From 263f6f439b659b31f283b40a1a14baac489e0ed9 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 7 Aug 2019 15:27:04 -0400 Subject: [PATCH 05/19] Remove obsolete experimental property --- shared-bindings/displayio/Display.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index b3ac532a36..e4e580d278 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -373,23 +373,6 @@ const mp_obj_property_t displayio_display_bus_obj = { }; -//| .. attribute:: screenshot -//| -//| Take a screenshot. -//| -//| -/* STATIC mp_obj_t displayio_display_obj_get_screenshot(mp_obj_t self_in) { */ -/* displayio_display_obj_t *self = native_display(self_in); */ -/* return mp_const_none; */ -/* } */ -/* MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_screenshot_obj, displayio_display_obj_get_screenshot); */ - -/* const mp_obj_property_t displayio_display_screenshot_obj = { */ -/* .base.type = &mp_type_property, */ -/* .proxy = {(mp_obj_t)&displayio_display_get_screenshot_obj, */ -/* (mp_obj_t)&mp_const_none_obj, */ -/* (mp_obj_t)&mp_const_none_obj}, */ -/* }; */ #include "py/objarray.h" From 239ad197657ffbfcaa95a095c6f0773033dd608a Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 7 Aug 2019 15:27:43 -0400 Subject: [PATCH 06/19] Pass in preallocated result buffer --- shared-bindings/displayio/Display.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index e4e580d278..91b03de4f7 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -389,12 +389,13 @@ mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value); //| :param int w: The width of the area //| :param int h: The height of the area STATIC mp_obj_t displayio_display_obj_fill_area(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_x, ARG_y, ARG_width, ARG_height }; + enum { ARG_x, ARG_y, ARG_width, ARG_height, ARG_buffer }; static const mp_arg_t allowed_args[] = { { MP_QSTR_x, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, { MP_QSTR_width, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, { MP_QSTR_height, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, + { MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, {} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -404,6 +405,11 @@ STATIC mp_obj_t displayio_display_obj_fill_area(size_t n_args, const mp_obj_t *p mp_int_t y = args[ARG_y].u_int; mp_int_t w = args[ARG_width].u_int; mp_int_t h = args[ARG_height].u_int; + mp_obj_array_t *result = (mp_obj_array_t *)(args[ARG_buffer].u_obj); + + if (result->typecode != BYTEARRAY_TYPECODE) { + mp_raise_ValueError(translate("Buffer is not a bytearray")); + } uint16_t buffer_size = 128; // In uint32_ts displayio_area_t area = { @@ -459,17 +465,20 @@ STATIC mp_obj_t displayio_display_obj_fill_area(size_t n_args, const mp_obj_t *p displayio_display_fill_area(self, &area, mask, buffer); - mp_obj_array_t *result = array_new(BYTEARRAY_TYPECODE, buffer_size * 4); - int byte_offset = 0; - for (int word_offset = 0; word_offset < buffer_size; word_offset++) { - uint32_t word = buffer[word_offset]; - for (int byte_count = 0; byte_count < 4; byte_count++) { - array_subscr(result, MP_OBJ_NEW_SMALL_INT(byte_offset), MP_OBJ_NEW_SMALL_INT(word & 0x000000FF)); - word >>= 8; - byte_offset++; + if ((result->len + result->free) >= (buffer_size * 4)) { + int byte_offset = 0; + for (int word_offset = 0; word_offset < buffer_size; word_offset++) { + uint32_t word = buffer[word_offset]; + for (int byte_count = 0; byte_count < 4; byte_count++) { + array_subscr(result, MP_OBJ_NEW_SMALL_INT(byte_offset), MP_OBJ_NEW_SMALL_INT(word & 0x000000FF)); + word >>= 8; + byte_offset++; + } } + return result; + } else { + mp_raise_ValueError(translate("Buffer is too small")); } - return result; } MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_area_obj, 1, displayio_display_obj_fill_area); From 7a235f3746291d2cf8d11f52e7d211b98d535f98 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Fri, 16 Aug 2019 21:10:09 -0400 Subject: [PATCH 07/19] Simplify to only extracting one line Since this was the usecase, doing so simplifies the function significantly. --- shared-bindings/displayio/Display.c | 72 ++++++++--------------------- 1 file changed, 18 insertions(+), 54 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 91b03de4f7..b14533ab2a 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -373,81 +373,46 @@ const mp_obj_property_t displayio_display_bus_obj = { }; - - #include "py/objarray.h" mp_obj_array_t *array_new(char typecode, size_t n); mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value); -//| .. method:: fill_area(x, y, w, h) +//| .. method:: fill_row(y, buffer) //| -//| Switches to displaying the given group of layers. When group is None, the default -//| CircuitPython terminal will be shown. +//| Extract the pixels fro a single row //| -//| :param int x: The left edge of the area //| :param int y: The top edge of the area -//| :param int w: The width of the area -//| :param int h: The height of the area -STATIC mp_obj_t displayio_display_obj_fill_area(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_x, ARG_y, ARG_width, ARG_height, ARG_buffer }; +//| :param bytearray buffer: The buffer in which to place the pixel data +STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_y, ARG_buffer }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_x, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, - { MP_QSTR_width, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, - { MP_QSTR_height, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, { MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, {} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - displayio_display_obj_t *self = native_display(pos_args[0]); - mp_int_t x = args[ARG_x].u_int; mp_int_t y = args[ARG_y].u_int; - mp_int_t w = args[ARG_width].u_int; - mp_int_t h = args[ARG_height].u_int; mp_obj_array_t *result = (mp_obj_array_t *)(args[ARG_buffer].u_obj); if (result->typecode != BYTEARRAY_TYPECODE) { - mp_raise_ValueError(translate("Buffer is not a bytearray")); + mp_raise_ValueError(translate("Buffer is not a bytearray.")); + } + if (self->colorspace.depth != 16) { + mp_raise_ValueError(translate("Display must have a 16 bit colorspace.")); } - uint16_t buffer_size = 128; // In uint32_ts displayio_area_t area = { - .x1 = x, + .x1 = 0, .y1 = y, - .x2 = x + w, - .y2 = y + h + .x2 = self->width, + .y2 = y + 1 }; - displayio_area_t clipped; - // Clip the area to the display by overlapping the areas. If there is no overlap then we're done. - if (!displayio_display_clip_area(self, &area, &clipped)) { - return mp_const_none; - } - uint16_t subrectangles = 1; - uint16_t rows_per_buffer = displayio_area_height(&clipped); uint8_t pixels_per_word = (sizeof(uint32_t) * 8) / self->colorspace.depth; - uint16_t pixels_per_buffer = displayio_area_size(&clipped); - if (displayio_area_size(&clipped) > buffer_size * pixels_per_word) { - rows_per_buffer = buffer_size * pixels_per_word / displayio_area_width(&clipped); - if (rows_per_buffer == 0) { - rows_per_buffer = 1; - } - // If pixels are packed by column then ensure rows_per_buffer is on a byte boundary. - if (self->colorspace.depth < 8 && !self->colorspace.pixels_in_byte_share_row) { - uint8_t pixels_per_byte = 8 / self->colorspace.depth; - if (rows_per_buffer % pixels_per_byte != 0) { - rows_per_buffer -= rows_per_buffer % pixels_per_byte; - } - } - subrectangles = displayio_area_height(&clipped) / rows_per_buffer; - if (displayio_area_height(&clipped) % rows_per_buffer != 0) { - subrectangles++; - } - pixels_per_buffer = rows_per_buffer * displayio_area_width(&clipped); - buffer_size = pixels_per_buffer / pixels_per_word; - if (pixels_per_buffer % pixels_per_word) { - buffer_size += 1; - } + uint16_t buffer_size = self->width / pixels_per_word; + uint16_t pixels_per_buffer = displayio_area_size(&area); + if (pixels_per_buffer % pixels_per_word) { + buffer_size += 1; } // Allocated and shared as a uint32_t array so the compiler knows the @@ -480,7 +445,7 @@ STATIC mp_obj_t displayio_display_obj_fill_area(size_t n_args, const mp_obj_t *p mp_raise_ValueError(translate("Buffer is too small")); } } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_area_obj, 1, displayio_display_obj_fill_area); +MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_row_obj, 1, displayio_display_obj_fill_row); @@ -489,7 +454,7 @@ STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&displayio_display_show_obj) }, { MP_ROM_QSTR(MP_QSTR_refresh_soon), MP_ROM_PTR(&displayio_display_refresh_soon_obj) }, { MP_ROM_QSTR(MP_QSTR_wait_for_frame), MP_ROM_PTR(&displayio_display_wait_for_frame_obj) }, - { MP_ROM_QSTR(MP_QSTR_fill_area), MP_ROM_PTR(&displayio_display_fill_area_obj) }, + { MP_ROM_QSTR(MP_QSTR_fill_row), MP_ROM_PTR(&displayio_display_fill_row_obj) }, { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&displayio_display_brightness_obj) }, { MP_ROM_QSTR(MP_QSTR_auto_brightness), MP_ROM_PTR(&displayio_display_auto_brightness_obj) }, @@ -498,7 +463,6 @@ STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) }, { MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&displayio_display_rotation_obj) }, { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_display_bus_obj) }, - // { MP_ROM_QSTR(MP_QSTR_screenshot), MP_ROM_PTR(&displayio_display_screenshot_obj) }, }; STATIC MP_DEFINE_CONST_DICT(displayio_display_locals_dict, displayio_display_locals_dict_table); From 2b7897cdeddd2651996fc1c3afff060a42d1609b Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 10:03:36 -0400 Subject: [PATCH 08/19] Fix typo --- shared-bindings/displayio/Display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index b14533ab2a..4ae3687b3d 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -379,7 +379,7 @@ mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value); //| .. method:: fill_row(y, buffer) //| -//| Extract the pixels fro a single row +//| Extract the pixels from a single row //| //| :param int y: The top edge of the area //| :param bytearray buffer: The buffer in which to place the pixel data From 10bc0d29d11b1806bd5620850daf3c6708643125 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 10:05:09 -0400 Subject: [PATCH 09/19] Switch to positional parameters --- shared-bindings/displayio/Display.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 4ae3687b3d..4afc4ca743 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -384,10 +384,10 @@ mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value); //| :param int y: The top edge of the area //| :param bytearray buffer: The buffer in which to place the pixel data STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_y, ARG_buffer }; + enum { ARG_y, ARG_buffer }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, - { MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, {} }, + { MP_QSTR_y, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = -1} }, + { MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED, {} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); From 53bb95a0233baa8cae7bbb36f2887a9475c1e37f Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 10:05:41 -0400 Subject: [PATCH 10/19] Rework to simplify --- shared-bindings/displayio/Display.c | 49 ++++++++++++++++------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 4afc4ca743..508d10ea41 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -415,31 +415,36 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po buffer_size += 1; } - // Allocated and shared as a uint32_t array so the compiler knows the - // alignment everywhere. - uint32_t buffer[buffer_size]; - volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1; - uint32_t mask[mask_length]; + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(result, &bufinfo, MP_BUFFER_WRITE); + uint32_t *result_buffer = bufinfo.buf; + size_t result_buffer_size = bufinfo.len; - for (uint16_t k = 0; k < mask_length; k++) { - mask[k] = 0x00000000; - } - for (uint16_t k = 0; k < buffer_size; k++) { - buffer[k] = 0x00000000; - } + if (result_buffer_size >= (buffer_size * 4)) { + // Allocated and shared as a uint32_t array so the compiler knows the + // alignment everywhere. + /* uint32_t buffer[buffer_size]; */ + volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1; + uint32_t mask[mask_length]; - displayio_display_fill_area(self, &area, mask, buffer); - - if ((result->len + result->free) >= (buffer_size * 4)) { - int byte_offset = 0; - for (int word_offset = 0; word_offset < buffer_size; word_offset++) { - uint32_t word = buffer[word_offset]; - for (int byte_count = 0; byte_count < 4; byte_count++) { - array_subscr(result, MP_OBJ_NEW_SMALL_INT(byte_offset), MP_OBJ_NEW_SMALL_INT(word & 0x000000FF)); - word >>= 8; - byte_offset++; - } + for (uint16_t k = 0; k < mask_length; k++) { + mask[k] = 0x00000000; } + /* for (uint16_t k = 0; k < buffer_size; k++) { */ + /* buffer[k] = 0x00000000; */ + /* } */ + + + displayio_display_fill_area(self, &area, mask, result_buffer); + /* int byte_offset = 0; */ + /* for (int word_offset = 0; word_offset < buffer_size; word_offset++) { */ + /* uint32_t word = buffer[word_offset]; */ + /* for (int byte_count = 0; byte_count < 4; byte_count++) { */ + /* array_subscr(result, MP_OBJ_NEW_SMALL_INT(byte_offset), MP_OBJ_NEW_SMALL_INT(word & 0x000000FF)); */ + /* word >>= 8; */ + /* byte_offset++; */ + /* } */ + /* } */ return result; } else { mp_raise_ValueError(translate("Buffer is too small")); From f3d476aad85ba497c060f44dee3009d018802b0e Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 12:25:56 -0400 Subject: [PATCH 11/19] Remove temporarily comments code --- shared-bindings/displayio/Display.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 508d10ea41..df6dde53a3 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -421,30 +421,14 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po size_t result_buffer_size = bufinfo.len; if (result_buffer_size >= (buffer_size * 4)) { - // Allocated and shared as a uint32_t array so the compiler knows the - // alignment everywhere. - /* uint32_t buffer[buffer_size]; */ volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1; uint32_t mask[mask_length]; for (uint16_t k = 0; k < mask_length; k++) { mask[k] = 0x00000000; } - /* for (uint16_t k = 0; k < buffer_size; k++) { */ - /* buffer[k] = 0x00000000; */ - /* } */ - displayio_display_fill_area(self, &area, mask, result_buffer); - /* int byte_offset = 0; */ - /* for (int word_offset = 0; word_offset < buffer_size; word_offset++) { */ - /* uint32_t word = buffer[word_offset]; */ - /* for (int byte_count = 0; byte_count < 4; byte_count++) { */ - /* array_subscr(result, MP_OBJ_NEW_SMALL_INT(byte_offset), MP_OBJ_NEW_SMALL_INT(word & 0x000000FF)); */ - /* word >>= 8; */ - /* byte_offset++; */ - /* } */ - /* } */ return result; } else { mp_raise_ValueError(translate("Buffer is too small")); From 0fd886fa7f923c6c8a1473712d238084d9004432 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 13:45:58 -0400 Subject: [PATCH 12/19] Remove array cast --- shared-bindings/displayio/Display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index df6dde53a3..b7b9a6981c 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -393,7 +393,7 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); displayio_display_obj_t *self = native_display(pos_args[0]); mp_int_t y = args[ARG_y].u_int; - mp_obj_array_t *result = (mp_obj_array_t *)(args[ARG_buffer].u_obj); + mp_obj_array_t *result = args[ARG_buffer].u_obj; if (result->typecode != BYTEARRAY_TYPECODE) { mp_raise_ValueError(translate("Buffer is not a bytearray.")); From eb0a8cc0bf5ccb93a4ad89e2cf965a45986fec2e Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 13:48:12 -0400 Subject: [PATCH 13/19] Move the get_buffer call earlier --- shared-bindings/displayio/Display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index b7b9a6981c..099035f41a 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -402,6 +402,9 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po mp_raise_ValueError(translate("Display must have a 16 bit colorspace.")); } + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(result, &bufinfo, MP_BUFFER_WRITE); + displayio_area_t area = { .x1 = 0, .y1 = y, @@ -415,8 +418,6 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po buffer_size += 1; } - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(result, &bufinfo, MP_BUFFER_WRITE); uint32_t *result_buffer = bufinfo.buf; size_t result_buffer_size = bufinfo.len; From 56aad056daf1a3377e437d011da4f6cf9a7c82ba Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 17:00:24 -0400 Subject: [PATCH 14/19] getting the buffer info should happen first (due to its check) --- shared-bindings/displayio/Display.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 099035f41a..c8cb66f696 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -395,6 +395,9 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po mp_int_t y = args[ARG_y].u_int; mp_obj_array_t *result = args[ARG_buffer].u_obj; + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(result, &bufinfo, MP_BUFFER_WRITE); + if (result->typecode != BYTEARRAY_TYPECODE) { mp_raise_ValueError(translate("Buffer is not a bytearray.")); } @@ -402,9 +405,6 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po mp_raise_ValueError(translate("Display must have a 16 bit colorspace.")); } - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(result, &bufinfo, MP_BUFFER_WRITE); - displayio_area_t area = { .x1 = 0, .y1 = y, From 8bbab0131671e5a30606ebaba11c8c38487344e3 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 21 Aug 2019 13:57:52 -0400 Subject: [PATCH 15/19] Remove unneeded lines --- shared-bindings/displayio/Display.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index c8cb66f696..92af869296 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -373,10 +373,6 @@ const mp_obj_property_t displayio_display_bus_obj = { }; -#include "py/objarray.h" -mp_obj_array_t *array_new(char typecode, size_t n); -mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value); - //| .. method:: fill_row(y, buffer) //| //| Extract the pixels from a single row From 5023b622688ef7a4c2e9add3156ffb04e7327674 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 21 Aug 2019 14:08:24 -0400 Subject: [PATCH 16/19] Make them static (fixing build break?) as they aren't needed by Display --- py/objarray.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/objarray.c b/py/objarray.c index 61d55f2559..9114a63c5a 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -92,7 +92,7 @@ STATIC void array_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t #endif #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY -mp_obj_array_t *array_new(char typecode, size_t n) { +STATIC mp_obj_array_t *array_new(char typecode, size_t n) { int typecode_size = mp_binary_get_size('@', typecode, NULL); mp_obj_array_t *o = m_new_obj(mp_obj_array_t); #if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_PY_ARRAY @@ -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 -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) { if (value == MP_OBJ_NULL) { // delete item // TODO implement From 8b2a1b9e97a16f9bdca430efa574150d0fdea3ea Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 21 Aug 2019 14:19:42 -0400 Subject: [PATCH 17/19] Add message ids for translation --- locale/ID.po | 14 +++++++++++++- locale/circuitpython.pot | 14 +++++++++++++- locale/de_DE.po | 14 +++++++++++++- locale/en_US.po | 14 +++++++++++++- locale/en_x_pirate.po | 14 +++++++++++++- locale/es.po | 14 +++++++++++++- locale/fil.po | 14 +++++++++++++- locale/fr.po | 14 +++++++++++++- locale/it_IT.po | 14 +++++++++++++- locale/pl.po | 14 +++++++++++++- locale/pt_BR.po | 14 +++++++++++++- locale/zh_Latn_pinyin.po | 19 ++++++++++++++++--- 12 files changed, 159 insertions(+), 14 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index bd12a5c943..74682ccef5 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -329,6 +329,14 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "" +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -506,6 +514,10 @@ msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment" msgid "Destination capacity is smaller than destination_length." msgstr "" +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 1b135822fd..f2c406ff52 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -325,6 +325,14 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "" +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -495,6 +503,10 @@ msgstr "" msgid "Destination capacity is smaller than destination_length." msgstr "" +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 7ad69e1ddf..3ed00c9384 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -329,6 +329,14 @@ msgstr "Die Helligkeit ist nicht einstellbar" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Der Puffergröße ist inkorrekt. Sie sollte %d bytes haben." +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Der Puffer muss eine Mindestenslänge von 1 haben" @@ -499,6 +507,10 @@ msgstr "Zu vielen Daten für das advertisement packet" msgid "Destination capacity is smaller than destination_length." msgstr "Die Zielkapazität ist kleiner als destination_length." +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "Die Rotation der Anzeige muss in 90-Grad-Schritten erfolgen" diff --git a/locale/en_US.po b/locale/en_US.po index 49699283c6..5b173fba65 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -325,6 +325,14 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "" +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -495,6 +503,10 @@ msgstr "" msgid "Destination capacity is smaller than destination_length." msgstr "" +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 885abe6818..fe04b804b2 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -329,6 +329,14 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "" +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -499,6 +507,10 @@ msgstr "" msgid "Destination capacity is smaller than destination_length." msgstr "" +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "" diff --git a/locale/es.po b/locale/es.po index 772570a31e..35d4bd320d 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -333,6 +333,14 @@ msgstr "El brillo no se puede ajustar" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Tamaño de buffer incorrecto. Debe ser de %d bytes." +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer debe ser de longitud 1 como minimo" @@ -503,6 +511,10 @@ msgstr "Data es muy grande para el paquete de advertisement." msgid "Destination capacity is smaller than destination_length." msgstr "Capacidad de destino es mas pequeña que destination_length." +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "Rotación de display debe ser en incrementos de 90 grados" diff --git a/locale/fil.po b/locale/fil.po index 8e4dbd9fd0..4469ab2775 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -331,6 +331,14 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Mali ang size ng buffer. Dapat %d bytes." +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer dapat ay hindi baba sa 1 na haba" @@ -507,6 +515,10 @@ msgid "Destination capacity is smaller than destination_length." msgstr "" "Ang kapasidad ng destinasyon ay mas maliit kaysa sa destination_length." +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 5bb51b622b..3fc0e5e080 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -336,6 +336,14 @@ msgstr "Luminosité non-ajustable" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Tampon de taille incorrect. Devrait être de %d octets." +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Le tampon doit être de longueur au moins 1" @@ -511,6 +519,10 @@ msgstr "Données trop volumineuses pour un paquet de diffusion" msgid "Destination capacity is smaller than destination_length." msgstr "La capacité de destination est plus petite que 'destination_length'." +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "La rotation d'affichage doit se faire par incréments de 90 degrés" diff --git a/locale/it_IT.po b/locale/it_IT.po index 2f8cfdc1e7..f49402dbd4 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -331,6 +331,14 @@ msgstr "Illiminazione non è regolabile" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Buffer di lunghezza non valida. Dovrebbe essere di %d bytes." +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Il buffer deve essere lungo almeno 1" @@ -507,6 +515,10 @@ msgstr "Impossibile inserire dati nel pacchetto di advertisement." msgid "Destination capacity is smaller than destination_length." msgstr "La capacità di destinazione è più piccola di destination_length." +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 83e408a3dc..93b988a971 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -328,6 +328,14 @@ msgstr "Jasność nie jest regulowana" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Zła wielkość bufora. Powinno być %d bajtów." +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Bufor musi mieć długość 1 lub więcej" @@ -498,6 +506,10 @@ msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" msgid "Destination capacity is smaller than destination_length." msgstr "Pojemność celu mniejsza od destination_length." +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "Wyświetlacz można obracać co 90 stopni" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index d3a8fe50a7..4bfc9eb65d 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -328,6 +328,14 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Buffer de tamanho incorreto. Deve ser %d bytes." +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -502,6 +510,10 @@ msgstr "Não é possível ajustar dados no pacote de anúncios." msgid "Destination capacity is smaller than destination_length." msgstr "" +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 055dd54612..e1637386dd 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-07-25 22:48-0700\n" +"POT-Creation-Date: 2019-08-21 14:18-0400\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -329,6 +329,14 @@ msgstr "Liàngdù wúfǎ tiáozhěng" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Huǎnchōng qū dàxiǎo bù zhèngquè. Yīnggāi shì %d zì jié." +#: shared-bindings/displayio/Display.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: shared-bindings/displayio/Display.c +msgid "Buffer is too small" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1" @@ -499,6 +507,10 @@ msgstr "Guǎnggào bāo de shùjù tài dà" msgid "Destination capacity is smaller than destination_length." msgstr "Mùbiāo róngliàng xiǎoyú mùdì de_chángdù." +#: shared-bindings/displayio/Display.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + #: shared-bindings/displayio/Display.c msgid "Display rotation must be in 90 degree increments" msgstr "Xiǎnshì xuánzhuǎn bìxū 90 dù jiā xīn" @@ -1128,8 +1140,9 @@ msgstr "" msgid "" "The `microcontroller` module was used to boot into safe mode. Press reset to " "exit safe mode.\n" -msgstr "“Wēi kòngzhì qì” mókuài yòng yú qǐdòng ānquán móshì. Àn chóng zhì kě " -"tuìchū ānquán móshì.\n" +msgstr "" +"“Wēi kòngzhì qì” mókuài yòng yú qǐdòng ānquán móshì. Àn chóng zhì kě tuìchū " +"ānquán móshì.\n" #: supervisor/shared/safe_mode.c msgid "" From dcf36db26315689fcec6674b31b3222021126c63 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 21 Aug 2019 14:46:10 -0400 Subject: [PATCH 18/19] Make room --- ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk index e427e94301..fd66f425da 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk @@ -14,3 +14,6 @@ LONGINT_IMPL = MPZ CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 + +CIRCUITPY_I2CSLAVE = 0 +CIRCUITPY_RTC = 0 From 99a3da3b60d518ee3b590fb6c693c1e189e3bb30 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 21 Aug 2019 15:24:39 -0400 Subject: [PATCH 19/19] Get rid of the last bits of array dependancy --- shared-bindings/displayio/Display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 92af869296..0c48b0cc51 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -389,12 +389,12 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); displayio_display_obj_t *self = native_display(pos_args[0]); mp_int_t y = args[ARG_y].u_int; - mp_obj_array_t *result = args[ARG_buffer].u_obj; + mp_obj_t *result = args[ARG_buffer].u_obj; mp_buffer_info_t bufinfo; mp_get_buffer_raise(result, &bufinfo, MP_BUFFER_WRITE); - if (result->typecode != BYTEARRAY_TYPECODE) { + if (bufinfo.typecode != BYTEARRAY_TYPECODE) { mp_raise_ValueError(translate("Buffer is not a bytearray.")); } if (self->colorspace.depth != 16) {