From 7fd1a6c8a80780e227a0f4a7bdd6fda57853814b Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Thu, 25 Jul 2019 15:04:55 -0400 Subject: 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 9114a63c5..61d55f255 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 -- cgit v1.2.3 From b6178c9d85876c771b08188373df568da0acda87 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Thu, 25 Jul 2019 15:05:30 -0400 Subject: 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 361a37ece..2b9c74066 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); -- cgit v1.2.3 From 741cd9c40a4b3368ffa92286498883bd29b0fb70 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 31 Jul 2019 12:47:32 -0400 Subject: 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 2b9c74066..6338fe459 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; } -- cgit v1.2.3 From 1f9cb44fa3a09996d042b7b9e01864bf2feac363 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 31 Jul 2019 15:00:21 -0400 Subject: 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 6338fe459..ab9bad19c 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 e765e6f25..40793be14 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 a8515b9e5..74a96fac2 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 96d1c06d5..74ae175b1 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; -- cgit v1.2.3 From 263f6f439b659b31f283b40a1a14baac489e0ed9 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 7 Aug 2019 15:27:04 -0400 Subject: 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 b3ac532a3..e4e580d27 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" -- cgit v1.2.3 From 239ad197657ffbfcaa95a095c6f0773033dd608a Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 7 Aug 2019 15:27:43 -0400 Subject: 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 e4e580d27..91b03de4f 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); -- cgit v1.2.3 From 7a235f3746291d2cf8d11f52e7d211b98d535f98 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Fri, 16 Aug 2019 21:10:09 -0400 Subject: 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 91b03de4f..b14533ab2 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); -- cgit v1.2.3 From 2b7897cdeddd2651996fc1c3afff060a42d1609b Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 10:03:36 -0400 Subject: 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 b14533ab2..4ae3687b3 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 -- cgit v1.2.3 From 10bc0d29d11b1806bd5620850daf3c6708643125 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 10:05:09 -0400 Subject: 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 4ae3687b3..4afc4ca74 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); -- cgit v1.2.3 From 53bb95a0233baa8cae7bbb36f2887a9475c1e37f Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 10:05:41 -0400 Subject: Rework to simplify --- shared-bindings/displayio/Display.c | 53 ++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 4afc4ca74..508d10ea4 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]; - - 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); - - 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++; - } + 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; + + 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")); -- cgit v1.2.3 From f3d476aad85ba497c060f44dee3009d018802b0e Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 12:25:56 -0400 Subject: 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 508d10ea4..df6dde53a 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")); -- cgit v1.2.3 From 0fd886fa7f923c6c8a1473712d238084d9004432 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 13:45:58 -0400 Subject: 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 df6dde53a..b7b9a6981 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.")); -- cgit v1.2.3 From eb0a8cc0bf5ccb93a4ad89e2cf965a45986fec2e Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 13:48:12 -0400 Subject: 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 b7b9a6981..099035f41 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; -- cgit v1.2.3 From 6e3a6d0ac56b79bb005d6e4220c0fe1efe9f3532 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 20 Aug 2019 16:23:17 -0400 Subject: typo in IncrementalEncoder.c --- ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c index e3bcf395b..0922718f9 100644 --- a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -35,7 +35,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t* self, const mcu_pin_obj_t* pin_a, const mcu_pin_obj_t* pin_b) { - if (!pin_a->has_extint || !pin_a->has_extint) { + if (!pin_a->has_extint || !pin_b->has_extint) { mp_raise_RuntimeError(translate("Both pins must support hardware interrupts")); } -- cgit v1.2.3 From fe2ec6c887a5c4d8414fa19879dd5a1b083d0240 Mon Sep 17 00:00:00 2001 From: Benny Meisels Date: Sun, 18 Aug 2019 09:11:16 +0300 Subject: Add support for nrf boards that don't have an external crystal --- ports/nrf/common-hal/bleio/Adapter.c | 28 ++++++++++++++++++++++++---- ports/nrf/peripherals/nrf/clocks.c | 16 +++++++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/ports/nrf/common-hal/bleio/Adapter.c b/ports/nrf/common-hal/bleio/Adapter.c index 936dfcb9b..70e87cf78 100644 --- a/ports/nrf/common-hal/bleio/Adapter.c +++ b/ports/nrf/common-hal/bleio/Adapter.c @@ -39,17 +39,37 @@ #include "supervisor/usb.h" #include "shared-bindings/bleio/Adapter.h" #include "shared-bindings/bleio/Address.h" +#include "mpconfigboard.h" // for BOARD_HAS_CRYSTAL STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) { mp_raise_msg_varg(&mp_type_AssertionError, translate("Soft device assert, id: 0x%08lX, pc: 0x%08lX"), id, pc); } +static inline bool board_has_crystal(void) { +#ifdef BOARD_HAS_CRYSTAL + return BOARD_HAS_CRYSTAL == 1; +#else + return false; +#endif +} + STATIC uint32_t ble_stack_enable(void) { - nrf_clock_lf_cfg_t clock_config = { - .source = NRF_CLOCK_LF_SRC_XTAL, - .accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM - }; + nrf_clock_lf_cfg_t clock_config; + + // Set low-frequency clock source to be either an external 32.768kHz crystal if one exists on the board + // or an internal 32.768 kHz RC oscillator otherwise + if (board_has_crystal()) { + clock_config = (nrf_clock_lf_cfg_t){ + .source = NRF_CLOCK_LF_SRC_XTAL, + .accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM}; + } else { + clock_config = (nrf_clock_lf_cfg_t){ + .source = NRF_CLOCK_LF_SRC_RC, + .rc_ctiv = 16, + .rc_temp_ctiv = 2, + .accuracy = NRF_CLOCK_LF_ACCURACY_250_PPM}; + } uint32_t err_code = sd_softdevice_enable(&clock_config, softdevice_assert_handler); if (err_code != NRF_SUCCESS) diff --git a/ports/nrf/peripherals/nrf/clocks.c b/ports/nrf/peripherals/nrf/clocks.c index 4acb878db..de9eec6b5 100644 --- a/ports/nrf/peripherals/nrf/clocks.c +++ b/ports/nrf/peripherals/nrf/clocks.c @@ -26,11 +26,21 @@ */ #include "nrfx.h" +#include "mpconfigboard.h" // for BOARD_HAS_CRYSTAL + +static inline bool board_has_crystal(void) { +#ifdef BOARD_HAS_CRYSTAL + return BOARD_HAS_CRYSTAL == 1; +#else + return false; +#endif +} void nrf_peripherals_clocks_init(void) { - // Set low-frequency clock source to be crystal. If there's a crystalless board, this will need to be - // generalized. - NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); + // Set low-frequency clock source to be either an external 32.768kHz crystal if one exists on the board + // or an internal 32.768 kHz RC oscillator otherwise + uint32_t clock_src = board_has_crystal() ? CLOCK_LFCLKSRC_SRC_Xtal : CLOCK_LFCLKSRC_SRC_RC; + NRF_CLOCK->LFCLKSRC = (uint32_t)((clock_src << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); NRF_CLOCK->TASKS_LFCLKSTART = 1UL; // Wait for clocks to start. -- cgit v1.2.3 From 56aad056daf1a3377e437d011da4f6cf9a7c82ba Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 20 Aug 2019 17:00:24 -0400 Subject: 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 099035f41..c8cb66f69 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, -- cgit v1.2.3 From 8bbab0131671e5a30606ebaba11c8c38487344e3 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 21 Aug 2019 13:57:52 -0400 Subject: 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 c8cb66f69..92af86929 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 -- cgit v1.2.3 From 5023b622688ef7a4c2e9add3156ffb04e7327674 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 21 Aug 2019 14:08:24 -0400 Subject: 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 61d55f255..9114a63c5 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 -- cgit v1.2.3 From 8b2a1b9e97a16f9bdca430efa574150d0fdea3ea Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 21 Aug 2019 14:19:42 -0400 Subject: 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 bd12a5c94..74682ccef 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 1b135822f..f2c406ff5 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 7ad69e1dd..3ed00c938 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 49699283c..5b173fba6 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 885abe681..fe04b804b 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 772570a31..35d4bd320 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 8e4dbd9fd..4469ab277 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 5bb51b622..3fc0e5e08 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 2f8cfdc1e..f49402dbd 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 83e408a3d..93b988a97 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 d3a8fe50a..4bfc9eb65 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 055dd5461..e1637386d 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 "" -- cgit v1.2.3 From dcf36db26315689fcec6674b31b3222021126c63 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 21 Aug 2019 14:46:10 -0400 Subject: 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 e427e9430..fd66f425d 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 -- cgit v1.2.3 From 99a3da3b60d518ee3b590fb6c693c1e189e3bb30 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Wed, 21 Aug 2019 15:24:39 -0400 Subject: 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 92af86929..0c48b0cc5 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) { -- cgit v1.2.3 From d94023e9b310731807785ffc6f4249faf4912554 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 22 Aug 2019 01:04:00 -0400 Subject: Fix CPBlue LFCLKSRC; CPB has no status neopixel --- .../nrf/boards/circuitplayground_bluefruit/mpconfigboard.h | 2 -- .../nrf/boards/circuitplayground_bluefruit/mpconfigboard.mk | 3 +++ ports/nrf/common-hal/bleio/Adapter.c | 13 +++++++++++-- ports/nrf/common-hal/bleio/Characteristic.c | 2 +- ports/nrf/mpconfigport.mk | 5 +++++ ports/nrf/peripherals/nrf/clocks.c | 7 +++++-- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h index 04c7e8d60..f618a652c 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h +++ b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h @@ -34,8 +34,6 @@ #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (4096) -#define MICROPY_HW_NEOPIXEL (&pin_P0_13) - #define MICROPY_HW_LED_STATUS (&pin_P1_14) #if QSPI_FLASH_FILESYSTEM diff --git a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.mk b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.mk index dbb32629c..44c385c5b 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.mk +++ b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.mk @@ -10,6 +10,9 @@ MCU_CHIP = nrf52840 SD ?= s140 SOFTDEV_VERSION ?= 6.1.0 +# Unusually, board does not have a 32 kHz xtal. +BOARD_HAS_32KHZ_XTAL = 0 + BOOT_SETTING_ADDR = 0xFF000 ifeq ($(SD),) diff --git a/ports/nrf/common-hal/bleio/Adapter.c b/ports/nrf/common-hal/bleio/Adapter.c index 936dfcb9b..463e5d25b 100644 --- a/ports/nrf/common-hal/bleio/Adapter.c +++ b/ports/nrf/common-hal/bleio/Adapter.c @@ -47,8 +47,17 @@ STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) { STATIC uint32_t ble_stack_enable(void) { nrf_clock_lf_cfg_t clock_config = { - .source = NRF_CLOCK_LF_SRC_XTAL, - .accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM +#if BOARD_HAS_32KHZ_XTAL + .source = NRF_CLOCK_LF_SRC_XTAL, + .rc_ctiv = 0, + .rc_temp_ctiv = 0, + .accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM +#else + .source = NRF_CLOCK_LF_SRC_RC, + .rc_ctiv = 16, + .rc_temp_ctiv = 2, + .accuracy = NRF_CLOCK_LF_ACCURACY_250_PPM +#endif }; uint32_t err_code = sd_softdevice_enable(&clock_config, softdevice_assert_handler); diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c index 45e8d2495..604d24d73 100644 --- a/ports/nrf/common-hal/bleio/Characteristic.c +++ b/ports/nrf/common-hal/bleio/Characteristic.c @@ -183,7 +183,7 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, (self->props & CHAR_PROP_WRITE_NO_RESPONSE)); } else { if (self->fixed_length && bufinfo->len != self->max_length) { - mp_raise_ValueError(translate("Value length required fixed length")); + mp_raise_ValueError(translate("Value length != required fixed length")); } if (bufinfo->len > self->max_length) { mp_raise_ValueError(translate("Value length > max_length")); diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 55920b3f4..11058cd7e 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -28,6 +28,11 @@ CIRCUITPY_RTC = 1 # frequencyio not yet implemented CIRCUITPY_FREQUENCYIO = 0 +ifndef BOARD_HAS_32KHZ_XTAL +# Assume crystal is present, which is the most common case. +BOARD_HAS_32KHZ_XTAL = 1 +endif + # CircuitPython doesn't yet support NFC so force the NFC antenna pins to be GPIO. # See https://github.com/adafruit/circuitpython/issues/1300 # Defined here because system_nrf52840.c doesn't #include any of our own include files. diff --git a/ports/nrf/peripherals/nrf/clocks.c b/ports/nrf/peripherals/nrf/clocks.c index 4acb878db..b8f231385 100644 --- a/ports/nrf/peripherals/nrf/clocks.c +++ b/ports/nrf/peripherals/nrf/clocks.c @@ -28,9 +28,12 @@ #include "nrfx.h" void nrf_peripherals_clocks_init(void) { - // Set low-frequency clock source to be crystal. If there's a crystalless board, this will need to be - // generalized. + +#if BOARD_HAS_32KHZ_XTAL NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); +#else + NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); +#endif NRF_CLOCK->TASKS_LFCLKSTART = 1UL; // Wait for clocks to start. -- cgit v1.2.3 From 0b7291d76726616ade481bb802994bcd81dbb98f Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 22 Aug 2019 09:01:05 -0400 Subject: fix default crystal value; fix include order --- ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h | 2 -- ports/nrf/common-hal/bleio/Adapter.c | 4 ++-- ports/nrf/mpconfigport.h | 10 +++++----- ports/nrf/peripherals/nrf/clocks.c | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h index c422dbd55..1e55cd026 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h +++ b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h @@ -61,8 +61,6 @@ #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) -#define BOARD_HAS_CRYSTAL 1 - #define DEFAULT_I2C_BUS_SCL (&pin_P0_04) #define DEFAULT_I2C_BUS_SDA (&pin_P0_05) diff --git a/ports/nrf/common-hal/bleio/Adapter.c b/ports/nrf/common-hal/bleio/Adapter.c index 463e5d25b..15ae8840b 100644 --- a/ports/nrf/common-hal/bleio/Adapter.c +++ b/ports/nrf/common-hal/bleio/Adapter.c @@ -51,12 +51,12 @@ STATIC uint32_t ble_stack_enable(void) { .source = NRF_CLOCK_LF_SRC_XTAL, .rc_ctiv = 0, .rc_temp_ctiv = 0, - .accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM + .accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM, #else .source = NRF_CLOCK_LF_SRC_RC, .rc_ctiv = 16, .rc_temp_ctiv = 2, - .accuracy = NRF_CLOCK_LF_ACCURACY_250_PPM + .accuracy = NRF_CLOCK_LF_ACCURACY_250_PPM, #endif }; diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 3f939b492..0b755a156 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -38,11 +38,6 @@ #define MICROPY_PY_UBINASCII (1) #define MICROPY_PY_UJSON (1) -#ifndef BOARD_HAS_32KHZ_XTAL -// Assume crystal is present, which is the most common case. -#define BOARD_HAS_32KHZ_XTAL (0) -#endif - // TODO this is old BLE stuff #if BLUETOOTH_SD #define MICROPY_PY_BLEIO (1) @@ -58,6 +53,11 @@ #include "py/circuitpy_mpconfig.h" +#ifndef BOARD_HAS_32KHZ_XTAL +// Assume crystal is present, which is the most common case. +#define BOARD_HAS_32KHZ_XTAL (1) +#endif + #define MICROPY_PORT_ROOT_POINTERS \ CIRCUITPY_COMMON_ROOT_POINTERS \ ble_drv_evt_handler_entry_t* ble_drv_evt_handler_entries; \ diff --git a/ports/nrf/peripherals/nrf/clocks.c b/ports/nrf/peripherals/nrf/clocks.c index 67c748488..269365cc9 100644 --- a/ports/nrf/peripherals/nrf/clocks.c +++ b/ports/nrf/peripherals/nrf/clocks.c @@ -26,7 +26,7 @@ */ #include "nrfx.h" -#include "mpconfigboard.h" +#include "mpconfigport.h" void nrf_peripherals_clocks_init(void) { -- cgit v1.2.3