From f21cf15c384756ae462fdffded79c4bda8afcc28 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 10 Sep 2018 22:00:21 -0700 Subject: [PATCH 1/3] Add OnDiskBitmap which loads pixel data straight from disk. Also, renamed Sprite's palette to pixel_shader so it can be anything that produces colors based on values (including color values). Added a ColorConverter that converts RGB888 (found in bitmaps) to RGB565 for the display. Fixes #1182 --- ports/atmel-samd/Makefile | 2 + shared-bindings/displayio/ColorConverter.c | 90 ++++++++++++++++++ shared-bindings/displayio/ColorConverter.h | 37 ++++++++ shared-bindings/displayio/Group.c | 11 +++ shared-bindings/displayio/Group.h | 1 + shared-bindings/displayio/OnDiskBitmap.c | 104 +++++++++++++++++++++ shared-bindings/displayio/OnDiskBitmap.h | 40 ++++++++ shared-bindings/displayio/Sprite.c | 51 +++++----- shared-bindings/displayio/Sprite.h | 6 +- shared-bindings/displayio/__init__.c | 6 ++ shared-module/displayio/ColorConverter.c | 41 ++++++++ shared-module/displayio/ColorConverter.h | 39 ++++++++ shared-module/displayio/Group.c | 16 ++++ shared-module/displayio/Group.h | 1 + shared-module/displayio/OnDiskBitmap.c | 93 ++++++++++++++++++ shared-module/displayio/OnDiskBitmap.h | 47 ++++++++++ shared-module/displayio/Sprite.c | 33 ++++--- shared-module/displayio/Sprite.h | 3 +- 18 files changed, 583 insertions(+), 38 deletions(-) create mode 100644 shared-bindings/displayio/ColorConverter.c create mode 100644 shared-bindings/displayio/ColorConverter.h create mode 100644 shared-bindings/displayio/OnDiskBitmap.c create mode 100644 shared-bindings/displayio/OnDiskBitmap.h create mode 100644 shared-module/displayio/ColorConverter.c create mode 100644 shared-module/displayio/ColorConverter.h create mode 100644 shared-module/displayio/OnDiskBitmap.c create mode 100644 shared-module/displayio/OnDiskBitmap.h diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 9c94e442f0..11b9a0de67 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -384,7 +384,9 @@ SRC_SHARED_MODULE = \ busio/OneWire.c \ displayio/__init__.c \ displayio/Bitmap.c \ + displayio/ColorConverter.c \ displayio/Group.c \ + displayio/OnDiskBitmap.c \ displayio/Palette.c \ displayio/Sprite.c \ gamepad/__init__.c \ diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c new file mode 100644 index 0000000000..6705788889 --- /dev/null +++ b/shared-bindings/displayio/ColorConverter.c @@ -0,0 +1,90 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/displayio/ColorConverter.h" + +#include + +#include "lib/utils/context_manager_helpers.h" +#include "py/binary.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" + +//| .. currentmodule:: displayio +//| +//| :class:`ColorConverter` -- Converts one color format to another +//| ========================================================================================= +//| +//| Converts one color format to another. +//| +//| .. warning:: This will be changed before 4.0.0. Consider it very experimental. +//| +//| .. class:: ColorConverter() +//| +//| Create a ColorConverter object to convert color formats. Only supports RGB888 to RGB565 +//| currently. +//| +// TODO(tannewt): Add support for other color formats. +//| +STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { + mp_arg_check_num(n_args, n_kw, 0, 0, true); + + displayio_colorconverter_t *self = m_new_obj(displayio_colorconverter_t); + self->base.type = &displayio_colorconverter_type; + common_hal_displayio_colorconverter_construct(self); + + return MP_OBJ_FROM_PTR(self); +} + +//| .. method:: convert(color) +//| +STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t color_obj) { + displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in); + + mp_int_t color; + if (!mp_obj_get_int_maybe(color_obj, &color)) { + mp_raise_ValueError(translate("color should be an int")); + } + uint16_t output_color; + common_hal_displayio_colorconverter_convert(self, color, &output_color); + return MP_OBJ_NEW_SMALL_INT(output_color); +} +MP_DEFINE_CONST_FUN_OBJ_2(displayio_colorconverter_convert_obj, displayio_colorconverter_obj_convert); + +STATIC const mp_rom_map_elem_t displayio_colorconverter_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_convert), MP_ROM_PTR(&displayio_colorconverter_convert_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(displayio_colorconverter_locals_dict, displayio_colorconverter_locals_dict_table); + +const mp_obj_type_t displayio_colorconverter_type = { + { &mp_type_type }, + .name = MP_QSTR_ColorConverter, + .make_new = displayio_colorconverter_make_new, + .locals_dict = (mp_obj_dict_t*)&displayio_colorconverter_locals_dict, +}; diff --git a/shared-bindings/displayio/ColorConverter.h b/shared-bindings/displayio/ColorConverter.h new file mode 100644 index 0000000000..71be7f5430 --- /dev/null +++ b/shared-bindings/displayio/ColorConverter.h @@ -0,0 +1,37 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_COLORCONVERTER_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_COLORCONVERTER_H + +#include "shared-module/displayio/ColorConverter.h" + +extern const mp_obj_type_t displayio_colorconverter_type; + +void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t* self); +bool common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *colorconverter, uint32_t input_color, uint16_t* output_color); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_COLORCONVERTER_H diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index e6f1fbbf5d..98257673b9 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -83,8 +83,19 @@ STATIC mp_obj_t displayio_group_obj_append(mp_obj_t self_in, mp_obj_t layer) { } MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_append_obj, displayio_group_obj_append); +//| .. method:: pop() +//| +//| Remove the last item and return it. +//| +STATIC mp_obj_t displayio_group_obj_pop(mp_obj_t self_in) { + displayio_group_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_displayio_group_pop(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_group_pop_obj, displayio_group_obj_pop); + STATIC const mp_rom_map_elem_t displayio_group_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&displayio_group_append_obj) }, + { MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&displayio_group_pop_obj) }, }; STATIC MP_DEFINE_CONST_DICT(displayio_group_locals_dict, displayio_group_locals_dict_table); diff --git a/shared-bindings/displayio/Group.h b/shared-bindings/displayio/Group.h index aeb5a7b545..a85098e6d1 100644 --- a/shared-bindings/displayio/Group.h +++ b/shared-bindings/displayio/Group.h @@ -34,5 +34,6 @@ extern const mp_obj_type_t displayio_group_type; void common_hal_displayio_group_construct(displayio_group_t* self, uint32_t max_size); void common_hal_displayio_group_append(displayio_group_t* self, mp_obj_t layer); +mp_obj_t common_hal_displayio_group_pop(displayio_group_t* self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_GROUP_H diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c new file mode 100644 index 0000000000..d3d413da1d --- /dev/null +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -0,0 +1,104 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/displayio/OnDiskBitmap.h" + +#include + +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + +//| .. currentmodule:: displayio +//| +//| :class:`OnDiskBitmap` -- Loads pixels straight from disk +//| ========================================================================== +//| +//| Loads values straight from disk. This minimizes memory use but can lead to +//| much slower pixel load times. These load times may result in frame tearing where only part of +//| the image is visible. +//| +//| .. warning:: This will likely be changed before 4.0.0. Consider it very experimental. +//| +//| It's easiest to use on a board with a built in display such as the `Hallowing M0 Express +//| `_. +//| +//| .. code-block:: Python +//| +//| import board +//| import displayio +//| import time +//| import pulseio +//| +//| backlight = pulseio.PWMOut(board.TFT_BACKLIGHT) +//| splash = displayio.Group() +//| board.DISPLAY.show(splash) +//| +//| with open("/sample.bmp", "rb") as f: +//| odb = displayio.OnDiskBitmap(f) +//| face = displayio.Sprite(odb, pixel_shader=displayio.ColorConverter(), position=(0,0)) +//| splash.append(face) +//| # Wait for the image to load. +//| board.DISPLAY.wait_for_frame() +//| +//| # Fade up the backlight +//| for i in range(100): +//| backlight.duty_cycle = i * (2 ** 15) // 100 +//| time.sleep(0.01) +//| +//| # Wait forever +//| while True: +//| pass +//| +//| .. class:: OnDiskBitmap(file) +//| +//| Create an OnDiskBitmap object with the given file. +//| +//| :param file file: The open bitmap file +//| +STATIC mp_obj_t displayio_ondiskbitmap_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); + + if (!MP_OBJ_IS_TYPE(pos_args[0], &mp_type_fileio)) { + mp_raise_TypeError(translate("file must be a file opened in byte mode")); + } + + displayio_ondiskbitmap_t *self = m_new_obj(displayio_ondiskbitmap_t); + self->base.type = &displayio_ondiskbitmap_type; + common_hal_displayio_ondiskbitmap_construct(self, MP_OBJ_TO_PTR(pos_args[0])); + + return MP_OBJ_FROM_PTR(self); +} + +STATIC const mp_rom_map_elem_t displayio_ondiskbitmap_locals_dict_table[] = { +}; +STATIC MP_DEFINE_CONST_DICT(displayio_ondiskbitmap_locals_dict, displayio_ondiskbitmap_locals_dict_table); + +const mp_obj_type_t displayio_ondiskbitmap_type = { + { &mp_type_type }, + .name = MP_QSTR_OnDiskBitmap, + .make_new = displayio_ondiskbitmap_make_new, + .locals_dict = (mp_obj_dict_t*)&displayio_ondiskbitmap_locals_dict, +}; diff --git a/shared-bindings/displayio/OnDiskBitmap.h b/shared-bindings/displayio/OnDiskBitmap.h new file mode 100644 index 0000000000..ab8b8dcd80 --- /dev/null +++ b/shared-bindings/displayio/OnDiskBitmap.h @@ -0,0 +1,40 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_ONDISKBITMAP_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_ONDISKBITMAP_H + +#include "shared-module/displayio/OnDiskBitmap.h" +#include "extmod/vfs_fat.h" + +extern const mp_obj_type_t displayio_ondiskbitmap_type; + +void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, pyb_file_obj_t* file); + +uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *bitmap, + int16_t x, int16_t y); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_ONDISKBITMAP_H diff --git a/shared-bindings/displayio/Sprite.c b/shared-bindings/displayio/Sprite.c index 223a8a394c..69c1a58965 100644 --- a/shared-bindings/displayio/Sprite.c +++ b/shared-bindings/displayio/Sprite.c @@ -33,6 +33,9 @@ #include "py/objproperty.h" #include "py/runtime.h" #include "shared-bindings/displayio/Bitmap.h" +#include "shared-bindings/displayio/ColorConverter.h" +#include "shared-bindings/displayio/OnDiskBitmap.h" +#include "shared-bindings/displayio/Palette.h" #include "supervisor/shared/translate.h" void unpack_position(mp_obj_t position_obj, int16_t* x, int16_t* y) { @@ -51,23 +54,26 @@ void unpack_position(mp_obj_t position_obj, int16_t* x, int16_t* y) { //| :class:`Sprite` -- A particular copy of an image to display //| ========================================================================== //| -//| Position a particular image and palette combination. +//| Position a particular image and pixel_shader combination. Multiple sprites can share bitmaps +//| pixel shaders. //| //| .. warning:: This will be changed before 4.0.0. Consider it very experimental. //| -//| .. class:: Sprite(bitmap, *, palette, position, width, height) +//| .. class:: Sprite(bitmap, *, pixel_shader, position, width, height) //| -//| Create a Sprite object +//| Create a Sprite object. The bitmap is source for 2d pixels. The pixel_shader is used to +//| convert the value and its location to a display native pixel color. This may be a simple color +//| palette lookup, a gradient, a pattern or a color transformer. //| //| STATIC mp_obj_t displayio_sprite_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { mp_arg_check_num(n_args, n_kw, 1, 4, true); mp_map_t kw_args; mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); - enum { ARG_bitmap, ARG_palette, ARG_position, ARG_width, ARG_height }; + enum { ARG_bitmap, ARG_pixel_shader, ARG_position, ARG_width, ARG_height }; static const mp_arg_t allowed_args[] = { { MP_QSTR_bitmap, MP_ARG_OBJ | MP_ARG_REQUIRED }, - { MP_QSTR_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY }, + { MP_QSTR_pixel_shader, MP_ARG_OBJ | MP_ARG_KW_ONLY }, { MP_QSTR_position, MP_ARG_OBJ | MP_ARG_KW_ONLY }, { 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} }, @@ -83,6 +89,10 @@ STATIC mp_obj_t displayio_sprite_make_new(const mp_obj_type_t *type, size_t n_ar displayio_bitmap_t* bmp = MP_OBJ_TO_PTR(bitmap); width = bmp->width; height = bmp->height; + } else if (MP_OBJ_IS_TYPE(bitmap, &displayio_ondiskbitmap_type)) { + displayio_ondiskbitmap_t* bmp = MP_OBJ_TO_PTR(bitmap); + width = bmp->width; + height = bmp->height; } else { mp_raise_TypeError(translate("unsupported bitmap type")); } @@ -93,7 +103,7 @@ STATIC mp_obj_t displayio_sprite_make_new(const mp_obj_type_t *type, size_t n_ar displayio_sprite_t *self = m_new_obj(displayio_sprite_t); self->base.type = &displayio_sprite_type; - common_hal_displayio_sprite_construct(self, bitmap, args[ARG_palette].u_obj, + common_hal_displayio_sprite_construct(self, bitmap, args[ARG_pixel_shader].u_obj, width, height, x, y); return MP_OBJ_FROM_PTR(self); } @@ -136,40 +146,39 @@ const mp_obj_property_t displayio_sprite_position_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| .. attribute:: palette +//| .. attribute:: pixel_shader //| -//| The color palette of the sprite. +//| The pixel shader of the sprite. //| -STATIC mp_obj_t displayio_sprite_obj_get_palette(mp_obj_t self_in) { +STATIC mp_obj_t displayio_sprite_obj_get_pixel_shader(mp_obj_t self_in) { displayio_sprite_t *self = MP_OBJ_TO_PTR(self_in); - return common_hal_displayio_sprite_get_palette(self); + return common_hal_displayio_sprite_get_pixel_shader(self); } -MP_DEFINE_CONST_FUN_OBJ_1(displayio_sprite_get_palette_obj, displayio_sprite_obj_get_palette); +MP_DEFINE_CONST_FUN_OBJ_1(displayio_sprite_get_pixel_shader_obj, displayio_sprite_obj_get_pixel_shader); -STATIC mp_obj_t displayio_sprite_obj_set_palette(mp_obj_t self_in, mp_obj_t palette_in) { +STATIC mp_obj_t displayio_sprite_obj_set_pixel_shader(mp_obj_t self_in, mp_obj_t pixel_shader) { displayio_sprite_t *self = MP_OBJ_TO_PTR(self_in); - if (!MP_OBJ_IS_TYPE(palette_in, &displayio_palette_type)) { - mp_raise_TypeError(translate("palette must be displayio.Palette")); + if (!MP_OBJ_IS_TYPE(pixel_shader, &displayio_palette_type) && !MP_OBJ_IS_TYPE(pixel_shader, &displayio_colorconverter_type)) { + mp_raise_TypeError(translate("pixel_shader must be displayio.Palette or displayio.ColorConverter")); } - displayio_palette_t *palette = MP_OBJ_TO_PTR(palette_in); - common_hal_displayio_sprite_set_palette(self, palette); + common_hal_displayio_sprite_set_pixel_shader(self, pixel_shader); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(displayio_sprite_set_palette_obj, displayio_sprite_obj_set_palette); +MP_DEFINE_CONST_FUN_OBJ_2(displayio_sprite_set_pixel_shader_obj, displayio_sprite_obj_set_pixel_shader); -const mp_obj_property_t displayio_sprite_palette_obj = { +const mp_obj_property_t displayio_sprite_pixel_shader_obj = { .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&displayio_sprite_get_palette_obj, - (mp_obj_t)&displayio_sprite_set_palette_obj, + .proxy = {(mp_obj_t)&displayio_sprite_get_pixel_shader_obj, + (mp_obj_t)&displayio_sprite_set_pixel_shader_obj, (mp_obj_t)&mp_const_none_obj}, }; STATIC const mp_rom_map_elem_t displayio_sprite_locals_dict_table[] = { // Properties { MP_ROM_QSTR(MP_QSTR_position), MP_ROM_PTR(&displayio_sprite_position_obj) }, - { MP_ROM_QSTR(MP_QSTR_palette), MP_ROM_PTR(&displayio_sprite_palette_obj) }, + { MP_ROM_QSTR(MP_QSTR_pixel_shader), MP_ROM_PTR(&displayio_sprite_pixel_shader_obj) }, }; STATIC MP_DEFINE_CONST_DICT(displayio_sprite_locals_dict, displayio_sprite_locals_dict_table); diff --git a/shared-bindings/displayio/Sprite.h b/shared-bindings/displayio/Sprite.h index 0bfa400446..1944e1d743 100644 --- a/shared-bindings/displayio/Sprite.h +++ b/shared-bindings/displayio/Sprite.h @@ -32,12 +32,12 @@ extern const mp_obj_type_t displayio_sprite_type; void common_hal_displayio_sprite_construct(displayio_sprite_t *self, mp_obj_t bitmap, - mp_obj_t palette, uint16_t width, uint16_t height, uint16_t x, uint16_t y); + mp_obj_t pixel_shader, uint16_t width, uint16_t height, uint16_t x, uint16_t y); void common_hal_displayio_sprite_get_position(displayio_sprite_t *self, int16_t* x, int16_t* y); void common_hal_displayio_sprite_set_position(displayio_sprite_t *self, int16_t x, int16_t y); -displayio_palette_t* common_hal_displayio_sprite_get_palette(displayio_sprite_t *self); -void common_hal_displayio_sprite_set_palette(displayio_sprite_t *self, displayio_palette_t* palette); +mp_obj_t common_hal_displayio_sprite_get_pixel_shader(displayio_sprite_t *self); +void common_hal_displayio_sprite_set_pixel_shader(displayio_sprite_t *self, mp_obj_t pixel_shader); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_SPRITE_H diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index 73f12db955..0610d71f63 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -31,8 +31,10 @@ #include "shared-bindings/displayio/__init__.h" #include "shared-bindings/displayio/Bitmap.h" +#include "shared-bindings/displayio/ColorConverter.h" #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/Group.h" +#include "shared-bindings/displayio/OnDiskBitmap.h" #include "shared-bindings/displayio/Palette.h" #include "shared-bindings/displayio/Sprite.h" @@ -57,8 +59,10 @@ //| :maxdepth: 3 //| //| Bitmap +//| ColorConverter //| FourWire //| Group +//| OnDiskBitmap //| Palette //| Sprite //| @@ -68,7 +72,9 @@ STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_displayio) }, { MP_ROM_QSTR(MP_QSTR_Bitmap), MP_ROM_PTR(&displayio_bitmap_type) }, + { MP_ROM_QSTR(MP_QSTR_ColorConverter), MP_ROM_PTR(&displayio_colorconverter_type) }, { MP_ROM_QSTR(MP_QSTR_Group), MP_ROM_PTR(&displayio_group_type) }, + { MP_ROM_QSTR(MP_QSTR_OnDiskBitmap), MP_ROM_PTR(&displayio_ondiskbitmap_type) }, { MP_ROM_QSTR(MP_QSTR_Palette), MP_ROM_PTR(&displayio_palette_type) }, { MP_ROM_QSTR(MP_QSTR_Sprite), MP_ROM_PTR(&displayio_sprite_type) }, diff --git a/shared-module/displayio/ColorConverter.c b/shared-module/displayio/ColorConverter.c new file mode 100644 index 0000000000..d20b24c01a --- /dev/null +++ b/shared-module/displayio/ColorConverter.c @@ -0,0 +1,41 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/displayio/ColorConverter.h" + +void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t* self) { +} + +bool common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *self, uint32_t input_color, uint16_t* output_color) { + // TODO(tannewt): Validate the color input against the input format. + uint32_t r5 = (input_color >> 19); + uint32_t g6 = (input_color >> 10) & 0x3f; + uint32_t b5 = (input_color >> 3) & 0x1f; + uint32_t packed = r5 << 11 | g6 << 5 | b5; + // swap bytes + *output_color = __builtin_bswap16(packed); + return true; +} diff --git a/shared-module/displayio/ColorConverter.h b/shared-module/displayio/ColorConverter.h new file mode 100644 index 0000000000..62ef2eaab9 --- /dev/null +++ b/shared-module/displayio/ColorConverter.h @@ -0,0 +1,39 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_COLORCONVERTER_H +#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_COLORCONVERTER_H + +#include +#include + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; +} displayio_colorconverter_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_COLORCONVERTER_H diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c index 885131d47c..52b89b5ae2 100644 --- a/shared-module/displayio/Group.c +++ b/shared-module/displayio/Group.c @@ -40,6 +40,18 @@ void common_hal_displayio_group_append(displayio_group_t* self, mp_obj_t layer) } self->children[self->size] = layer; self->size++; + self->needs_refresh = true; +} + +mp_obj_t common_hal_displayio_group_pop(displayio_group_t* self) { + if (self->size == 0) { + mp_raise_IndexError(translate("Group empty")); + } + self->size--; + mp_obj_t item = self->children[self->size]; + self->children[self->size] = NULL; + self->needs_refresh = true; + return item; } void displayio_group_construct(displayio_group_t* self, mp_obj_t* child_array, uint32_t max_size) { @@ -65,6 +77,9 @@ bool displayio_group_get_pixel(displayio_group_t *self, int16_t x, int16_t y, ui } bool displayio_group_needs_refresh(displayio_group_t *self) { + if (self->needs_refresh) { + return true; + } for (int32_t i = self->size - 1; i >= 0 ; i--) { mp_obj_t layer = self->children[i]; if (MP_OBJ_IS_TYPE(layer, &displayio_sprite_type)) { @@ -78,6 +93,7 @@ bool displayio_group_needs_refresh(displayio_group_t *self) { } void displayio_group_finish_refresh(displayio_group_t *self) { + self->needs_refresh = false; for (int32_t i = self->size - 1; i >= 0 ; i--) { mp_obj_t layer = self->children[i]; if (MP_OBJ_IS_TYPE(layer, &displayio_sprite_type)) { diff --git a/shared-module/displayio/Group.h b/shared-module/displayio/Group.h index 7f3e5646a6..272f3114ce 100644 --- a/shared-module/displayio/Group.h +++ b/shared-module/displayio/Group.h @@ -39,6 +39,7 @@ typedef struct { uint16_t size; uint16_t max_size; mp_obj_t* children; + bool needs_refresh; } displayio_group_t; diff --git a/shared-module/displayio/OnDiskBitmap.c b/shared-module/displayio/OnDiskBitmap.c new file mode 100644 index 0000000000..6e4a4c6f07 --- /dev/null +++ b/shared-module/displayio/OnDiskBitmap.c @@ -0,0 +1,93 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/displayio/OnDiskBitmap.h" + +#include + +#include "py/mperrno.h" +#include "py/runtime.h" + +static uint32_t read_word(uint16_t* bmp_header, uint16_t index) { + return bmp_header[index] | bmp_header[index + 1] << 16; +} + +void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, pyb_file_obj_t* file) { + // Load the wave + self->file = file; + uint16_t bmp_header[24]; + f_rewind(&self->file->fp); + UINT bytes_read; + if (f_read(&self->file->fp, bmp_header, 48, &bytes_read) != FR_OK) { + mp_raise_OSError(MP_EIO); + } + if (bytes_read != 48 || + memcmp(bmp_header, "BM", 2) != 0) { + mp_raise_ValueError(translate("Invalid BMP file")); + } + + // We can't cast because we're not aligned. + self->data_offset = read_word(bmp_header, 5); + + uint32_t header_size = read_word(bmp_header, 7); + uint32_t compression = read_word(bmp_header, 15); + if (!(header_size == 12 || header_size == 40 || header_size == 108 || header_size == 124) || + !(compression == 0)) { + mp_raise_ValueError_varg(translate("Only Windows format, uncompressed BMP supported %d"), header_size); + } + // TODO(tannewt): Support bitfield compressed colors since RGB565 can be produced by the GIMP. + uint16_t bits_per_pixel = bmp_header[14]; + if (bits_per_pixel < 24) { + mp_raise_ValueError_varg(translate("Only true color (24 bpp or higher) BMP supported %x"), bits_per_pixel); + } + self->bytes_per_pixel = bits_per_pixel / 8; + self->width = read_word(bmp_header, 9); + self->height = read_word(bmp_header, 11); + uint32_t byte_width = self->width * self->bytes_per_pixel; + self->stride = byte_width; + // Rows are word aligned. + if (self->stride % 4 != 0) { + self->stride += 4 - self->stride % 4; + } +} + + +uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *self, + int16_t x, int16_t y) { + if (x < 0 || x >= self->width || y < 0 || y >= self->height) { + return 0; + } + uint32_t location = self->data_offset + (self->height - y) * self->stride + x * self->bytes_per_pixel; + // We don't cache here because the underlying FS caches sectors. + f_lseek(&self->file->fp, location); + UINT bytes_read; + uint32_t pixel = 0; + uint32_t result = f_read(&self->file->fp, &pixel, self->bytes_per_pixel, &bytes_read); + if (result == FR_OK) { + return pixel; + } + return 0; +} diff --git a/shared-module/displayio/OnDiskBitmap.h b/shared-module/displayio/OnDiskBitmap.h new file mode 100644 index 0000000000..31d6c95501 --- /dev/null +++ b/shared-module/displayio/OnDiskBitmap.h @@ -0,0 +1,47 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_ONDISKBITMAP_H +#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_ONDISKBITMAP_H + +#include +#include + +#include "py/obj.h" + +#include "extmod/vfs_fat.h" + +typedef struct { + mp_obj_base_t base; + uint16_t width; + uint16_t height; + uint16_t data_offset; + uint16_t stride; + pyb_file_obj_t* file; + uint8_t bytes_per_pixel; +} displayio_ondiskbitmap_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_ONDISKBITMAP_H diff --git a/shared-module/displayio/Sprite.c b/shared-module/displayio/Sprite.c index b584c05690..4fe8d1ff63 100644 --- a/shared-module/displayio/Sprite.c +++ b/shared-module/displayio/Sprite.c @@ -26,15 +26,17 @@ #include "shared-bindings/displayio/Sprite.h" - #include "shared-bindings/displayio/Bitmap.h" +#include "shared-bindings/displayio/ColorConverter.h" +#include "shared-bindings/displayio/OnDiskBitmap.h" +#include "shared-bindings/displayio/Palette.h" void common_hal_displayio_sprite_construct(displayio_sprite_t *self, mp_obj_t bitmap, - mp_obj_t palette, uint16_t width, uint16_t height, uint16_t x, uint16_t y) { + mp_obj_t pixel_shader, uint16_t width, uint16_t height, uint16_t x, uint16_t y) { self->width = width; self->height = height; self->bitmap = bitmap; - self->palette = palette; + self->pixel_shader = pixel_shader; self->x = x; self->y = y; } @@ -51,12 +53,12 @@ void common_hal_displayio_sprite_set_position(displayio_sprite_t *self, int16_t } -displayio_palette_t* common_hal_displayio_sprite_get_palette(displayio_sprite_t *self) { - return self->palette; +mp_obj_t common_hal_displayio_sprite_get_pixel_shader(displayio_sprite_t *self) { + return self->pixel_shader; } -void common_hal_displayio_sprite_set_palette(displayio_sprite_t *self, displayio_palette_t* palette) { - self->palette = palette; +void common_hal_displayio_sprite_set_pixel_shader(displayio_sprite_t *self, mp_obj_t pixel_shader) { + self->pixel_shader = pixel_shader; self->needs_refresh = true; } @@ -66,12 +68,19 @@ bool displayio_sprite_get_pixel(displayio_sprite_t *self, int16_t x, int16_t y, if (y < 0 || y >= self->height || x >= self->width || x < 0) { return false; } + uint32_t value; + if (MP_OBJ_IS_TYPE(self->bitmap, &displayio_bitmap_type)) { + value = common_hal_displayio_bitmap_get_pixel(self->bitmap, x, y); + } else if (MP_OBJ_IS_TYPE(self->bitmap, &displayio_ondiskbitmap_type)) { + value = common_hal_displayio_ondiskbitmap_get_pixel(self->bitmap, x, y); + } - uint32_t value = common_hal_displayio_bitmap_get_pixel(self->bitmap, x, y); - if (self->palette == mp_const_none) { + if (self->pixel_shader == mp_const_none) { *pixel = value; return true; - } else if (MP_OBJ_IS_TYPE(self->palette, &displayio_palette_type) && displayio_palette_get_color(self->palette, value, pixel)) { + } else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type) && displayio_palette_get_color(self->pixel_shader, value, pixel)) { + return true; + } else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type) && common_hal_displayio_colorconverter_convert(self->pixel_shader, value, pixel)) { return true; } @@ -79,12 +88,12 @@ bool displayio_sprite_get_pixel(displayio_sprite_t *self, int16_t x, int16_t y, } bool displayio_sprite_needs_refresh(displayio_sprite_t *self) { - return self->needs_refresh || displayio_palette_needs_refresh(self->palette); + return self->needs_refresh || displayio_palette_needs_refresh(self->pixel_shader); } void displayio_sprite_finish_refresh(displayio_sprite_t *self) { self->needs_refresh = false; - displayio_palette_finish_refresh(self->palette); + displayio_palette_finish_refresh(self->pixel_shader); // TODO(tannewt): We could double buffer changes to position and move them over here. // That way they won't change during a refresh and tear. } diff --git a/shared-module/displayio/Sprite.h b/shared-module/displayio/Sprite.h index 213130af83..dc368c4b74 100644 --- a/shared-module/displayio/Sprite.h +++ b/shared-module/displayio/Sprite.h @@ -31,12 +31,11 @@ #include #include "py/obj.h" -#include "shared-bindings/displayio/Palette.h" typedef struct { mp_obj_base_t base; mp_obj_t bitmap; - displayio_palette_t* palette; + mp_obj_t pixel_shader; uint16_t x; uint16_t y; uint16_t width; From fb833b25d504d610269481b1bcf7375c6ca24873 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 12 Sep 2018 16:25:35 -0700 Subject: [PATCH 2/3] Update translations and limit Sphinx to <1.8.0 --- .travis.yml | 2 +- locale/circuitpython.pot | 39 +++++++++++++++++++++++++------- locale/de_DE.po | 40 +++++++++++++++++++++++++------- locale/en_US.po | 39 +++++++++++++++++++++++++------- locale/es.po | 41 ++++++++++++++++++++++++++------- locale/fil.po | 49 ++++++++++++++++++++++++++++++++-------- locale/fr.po | 49 ++++++++++++++++++++++++++++++++-------- 7 files changed, 206 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index 641730c12e..f1ba0c2a10 100755 --- a/.travis.yml +++ b/.travis.yml @@ -62,7 +62,7 @@ before_script: # For coverage testing (upgrade is used to get latest urllib3 version) - ([[ -z "$TRAVIS_TEST" ]] || sudo apt-get install -y python3-pip) - ([[ -z "$TRAVIS_TEST" ]] || sudo pip install --upgrade cpp-coveralls) - - ([[ $TRAVIS_TEST != "docs" ]] || sudo pip install Sphinx sphinx-rtd-theme recommonmark) + - ([[ $TRAVIS_TEST != "docs" ]] || sudo pip install 'Sphinx<1.8.0' sphinx-rtd-theme recommonmark) - ([[ $TRAVIS_TEST != "translations" ]] || sudo pip3 install polib) - gcc --version - ([[ -z "$TRAVIS_BOARD" || $TRAVIS_BOARD = "feather_huzzah" ]] || arm-none-eabi-gcc --version) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index c2ebcf176d..ef9b56e131 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: 2018-09-06 14:55-0700\n" +"POT-Creation-Date: 2018-09-12 16:24-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -123,7 +123,7 @@ msgstr "" msgid "queue overflow" msgstr "" -#: extmod/moduzlib.c:97 +#: extmod/moduzlib.c:98 msgid "compression header" msgstr "" @@ -214,7 +214,7 @@ msgstr "" msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" -#: main.c:415 +#: main.c:416 msgid "soft reboot\n" msgstr "" @@ -393,7 +393,7 @@ msgid "No TX pin" msgstr "" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:142 msgid "Cannot get pull while in output mode" msgstr "" @@ -1960,6 +1960,7 @@ msgid "buffer must be a bytes-like object" msgstr "" #: shared-bindings/audioio/WaveFile.c:78 +#: shared-bindings/displayio/OnDiskBitmap.c:85 msgid "file must be a file opened in byte mode" msgstr "" @@ -2034,6 +2035,10 @@ msgstr "" msgid "row data must be a buffer" msgstr "" +#: shared-bindings/displayio/ColorConverter.c:72 +msgid "color should be an int" +msgstr "" + #: shared-bindings/displayio/FourWire.c:55 #: shared-bindings/displayio/FourWire.c:64 msgid "displayio is a work in progress" @@ -2064,16 +2069,16 @@ msgstr "" msgid "palette_index should be an int" msgstr "" -#: shared-bindings/displayio/Sprite.c:45 +#: shared-bindings/displayio/Sprite.c:48 msgid "position must be 2-tuple" msgstr "" -#: shared-bindings/displayio/Sprite.c:87 +#: shared-bindings/displayio/Sprite.c:97 msgid "unsupported bitmap type" msgstr "" -#: shared-bindings/displayio/Sprite.c:152 -msgid "palette must be displayio.Palette" +#: shared-bindings/displayio/Sprite.c:162 +msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" #: shared-bindings/gamepad/GamePad.c:100 @@ -2302,6 +2307,24 @@ msgstr "" msgid "Group full" msgstr "" +#: shared-module/displayio/Group.c:48 +msgid "Group empty" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:49 +msgid "Invalid BMP file" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:59 +#, c-format +msgid "Only Windows format, uncompressed BMP supported %d" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:64 +#, c-format +msgid "Only true color (24 bpp or higher) BMP supported %x" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 5e69c1479c..eb8392532e 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: 2018-09-06 14:55-0700\n" +"POT-Creation-Date: 2018-09-12 16:24-0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Sebastian Plamauer\n" "Language-Team: \n" @@ -123,7 +123,7 @@ msgstr "ungültiges cert" msgid "queue overflow" msgstr "Warteschlangenüberlauf" -#: extmod/moduzlib.c:97 +#: extmod/moduzlib.c:98 msgid "compression header" msgstr "kompression header" @@ -223,7 +223,7 @@ msgstr "" "Drücke eine Taste um dich mit der REPL zu verbinden. Drücke Strg-D zum neu " "laden" -#: main.c:415 +#: main.c:416 msgid "soft reboot\n" msgstr "weicher reboot\n" @@ -402,7 +402,7 @@ msgid "No TX pin" msgstr "Kein TX Pin" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:142 msgid "Cannot get pull while in output mode" msgstr "Pull up im Ausgabemodus nicht möglich" @@ -1969,6 +1969,7 @@ msgid "buffer must be a bytes-like object" msgstr "" #: shared-bindings/audioio/WaveFile.c:78 +#: shared-bindings/displayio/OnDiskBitmap.c:85 msgid "file must be a file opened in byte mode" msgstr "" @@ -2043,6 +2044,10 @@ msgstr "" msgid "row data must be a buffer" msgstr "" +#: shared-bindings/displayio/ColorConverter.c:72 +msgid "color should be an int" +msgstr "" + #: shared-bindings/displayio/FourWire.c:55 #: shared-bindings/displayio/FourWire.c:64 msgid "displayio is a work in progress" @@ -2073,17 +2078,17 @@ msgstr "" msgid "palette_index should be an int" msgstr "" -#: shared-bindings/displayio/Sprite.c:45 +#: shared-bindings/displayio/Sprite.c:48 msgid "position must be 2-tuple" msgstr "" -#: shared-bindings/displayio/Sprite.c:87 +#: shared-bindings/displayio/Sprite.c:97 #, fuzzy msgid "unsupported bitmap type" msgstr "Baudrate wird nicht unterstütz" -#: shared-bindings/displayio/Sprite.c:152 -msgid "palette must be displayio.Palette" +#: shared-bindings/displayio/Sprite.c:162 +msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" #: shared-bindings/gamepad/GamePad.c:100 @@ -2312,6 +2317,25 @@ msgstr "" msgid "Group full" msgstr "" +#: shared-module/displayio/Group.c:48 +msgid "Group empty" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:49 +#, fuzzy +msgid "Invalid BMP file" +msgstr "Ungültiger Pin" + +#: shared-module/displayio/OnDiskBitmap.c:59 +#, c-format +msgid "Only Windows format, uncompressed BMP supported %d" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:64 +#, c-format +msgid "Only true color (24 bpp or higher) BMP supported %x" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po index a38e88276e..f5b1599b44 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: 2018-09-06 14:55-0700\n" +"POT-Creation-Date: 2018-09-12 16:24-0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -123,7 +123,7 @@ msgstr "" msgid "queue overflow" msgstr "" -#: extmod/moduzlib.c:97 +#: extmod/moduzlib.c:98 msgid "compression header" msgstr "" @@ -214,7 +214,7 @@ msgstr "" msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" -#: main.c:415 +#: main.c:416 msgid "soft reboot\n" msgstr "" @@ -393,7 +393,7 @@ msgid "No TX pin" msgstr "" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:142 msgid "Cannot get pull while in output mode" msgstr "" @@ -1960,6 +1960,7 @@ msgid "buffer must be a bytes-like object" msgstr "" #: shared-bindings/audioio/WaveFile.c:78 +#: shared-bindings/displayio/OnDiskBitmap.c:85 msgid "file must be a file opened in byte mode" msgstr "" @@ -2034,6 +2035,10 @@ msgstr "" msgid "row data must be a buffer" msgstr "" +#: shared-bindings/displayio/ColorConverter.c:72 +msgid "color should be an int" +msgstr "" + #: shared-bindings/displayio/FourWire.c:55 #: shared-bindings/displayio/FourWire.c:64 msgid "displayio is a work in progress" @@ -2064,16 +2069,16 @@ msgstr "" msgid "palette_index should be an int" msgstr "" -#: shared-bindings/displayio/Sprite.c:45 +#: shared-bindings/displayio/Sprite.c:48 msgid "position must be 2-tuple" msgstr "" -#: shared-bindings/displayio/Sprite.c:87 +#: shared-bindings/displayio/Sprite.c:97 msgid "unsupported bitmap type" msgstr "" -#: shared-bindings/displayio/Sprite.c:152 -msgid "palette must be displayio.Palette" +#: shared-bindings/displayio/Sprite.c:162 +msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" #: shared-bindings/gamepad/GamePad.c:100 @@ -2302,6 +2307,24 @@ msgstr "" msgid "Group full" msgstr "" +#: shared-module/displayio/Group.c:48 +msgid "Group empty" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:49 +msgid "Invalid BMP file" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:59 +#, c-format +msgid "Only Windows format, uncompressed BMP supported %d" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:64 +#, c-format +msgid "Only true color (24 bpp or higher) BMP supported %x" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "" diff --git a/locale/es.po b/locale/es.po index bd4feef0a2..53da649ac5 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: 2018-09-06 14:55-0700\n" +"POT-Creation-Date: 2018-09-12 16:24-0700\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -123,7 +123,7 @@ msgstr "certificado inválido" msgid "queue overflow" msgstr "desborde de queue" -#: extmod/moduzlib.c:97 +#: extmod/moduzlib.c:98 msgid "compression header" msgstr "encabezado de compresión" @@ -229,7 +229,7 @@ msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" "Presiona cualquier tecla para entrar al REPL. Usa CTRL-D para recargar." -#: main.c:415 +#: main.c:416 msgid "soft reboot\n" msgstr "reinicio suave\n" @@ -409,7 +409,7 @@ msgid "No TX pin" msgstr "" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:142 msgid "Cannot get pull while in output mode" msgstr "" @@ -2005,6 +2005,7 @@ msgid "buffer must be a bytes-like object" msgstr "" #: shared-bindings/audioio/WaveFile.c:78 +#: shared-bindings/displayio/OnDiskBitmap.c:85 msgid "file must be a file opened in byte mode" msgstr "" @@ -2080,6 +2081,10 @@ msgstr "" msgid "row data must be a buffer" msgstr "" +#: shared-bindings/displayio/ColorConverter.c:72 +msgid "color should be an int" +msgstr "" + #: shared-bindings/displayio/FourWire.c:55 #: shared-bindings/displayio/FourWire.c:64 msgid "displayio is a work in progress" @@ -2110,16 +2115,16 @@ msgstr "" msgid "palette_index should be an int" msgstr "" -#: shared-bindings/displayio/Sprite.c:45 +#: shared-bindings/displayio/Sprite.c:48 msgid "position must be 2-tuple" msgstr "" -#: shared-bindings/displayio/Sprite.c:87 +#: shared-bindings/displayio/Sprite.c:97 msgid "unsupported bitmap type" msgstr "" -#: shared-bindings/displayio/Sprite.c:152 -msgid "palette must be displayio.Palette" +#: shared-bindings/displayio/Sprite.c:162 +msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" #: shared-bindings/gamepad/GamePad.c:100 @@ -2349,6 +2354,26 @@ msgstr "" msgid "Group full" msgstr "" +#: shared-module/displayio/Group.c:48 +#, fuzzy +msgid "Group empty" +msgstr "heap vacío" + +#: shared-module/displayio/OnDiskBitmap.c:49 +#, fuzzy +msgid "Invalid BMP file" +msgstr "pin inválido" + +#: shared-module/displayio/OnDiskBitmap.c:59 +#, c-format +msgid "Only Windows format, uncompressed BMP supported %d" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:64 +#, c-format +msgid "Only true color (24 bpp or higher) BMP supported %x" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "" diff --git a/locale/fil.po b/locale/fil.po index 7d5102d480..795abe2af2 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: 2018-09-06 14:55-0700\n" +"POT-Creation-Date: 2018-09-12 16:24-0700\n" "PO-Revision-Date: 2018-08-30 23:04-0700\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -123,7 +123,7 @@ msgstr "mali ang cert" msgid "queue overflow" msgstr "puno na ang pila (overflow)" -#: extmod/moduzlib.c:97 +#: extmod/moduzlib.c:98 msgid "compression header" msgstr "compression header" @@ -226,7 +226,7 @@ msgstr "" "Pindutin ang anumang key upang ipasok ang REPL. Gamitin ang CTRL-D upang i-" "reload." -#: main.c:415 +#: main.c:416 msgid "soft reboot\n" msgstr "malambot na reboot\n" @@ -405,7 +405,7 @@ msgid "No TX pin" msgstr "Walang TX pin" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:142 msgid "Cannot get pull while in output mode" msgstr "Hindi makakakuha ng pull habang nasa output mode" @@ -1998,6 +1998,7 @@ msgid "buffer must be a bytes-like object" msgstr "buffer ay dapat bytes-like object" #: shared-bindings/audioio/WaveFile.c:78 +#: shared-bindings/displayio/OnDiskBitmap.c:85 msgid "file must be a file opened in byte mode" msgstr "file ay dapat buksan sa byte mode" @@ -2077,6 +2078,11 @@ msgstr "" msgid "row data must be a buffer" msgstr "constant ay dapat na integer" +#: shared-bindings/displayio/ColorConverter.c:72 +#, fuzzy +msgid "color should be an int" +msgstr "Haba ay dapat int" + #: shared-bindings/displayio/FourWire.c:55 #: shared-bindings/displayio/FourWire.c:64 msgid "displayio is a work in progress" @@ -2113,20 +2119,19 @@ msgstr "buffer ay dapat bytes-like object" msgid "palette_index should be an int" msgstr "" -#: shared-bindings/displayio/Sprite.c:45 +#: shared-bindings/displayio/Sprite.c:48 #, fuzzy msgid "position must be 2-tuple" msgstr "stop dapat 1 o 2" -#: shared-bindings/displayio/Sprite.c:87 +#: shared-bindings/displayio/Sprite.c:97 #, fuzzy msgid "unsupported bitmap type" msgstr "Hindi supportadong baudrate" -#: shared-bindings/displayio/Sprite.c:152 -#, fuzzy -msgid "palette must be displayio.Palette" -msgstr "ang palette ay dapat 32 bytes ang haba" +#: shared-bindings/displayio/Sprite.c:162 +msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" +msgstr "" #: shared-bindings/gamepad/GamePad.c:100 msgid "too many arguments" @@ -2357,6 +2362,26 @@ msgstr "" msgid "Group full" msgstr "" +#: shared-module/displayio/Group.c:48 +#, fuzzy +msgid "Group empty" +msgstr "walang laman" + +#: shared-module/displayio/OnDiskBitmap.c:49 +#, fuzzy +msgid "Invalid BMP file" +msgstr "Mali ang file" + +#: shared-module/displayio/OnDiskBitmap.c:59 +#, c-format +msgid "Only Windows format, uncompressed BMP supported %d" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:64 +#, c-format +msgid "Only true color (24 bpp or higher) BMP supported %x" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "Ang 'S' at 'O' ay hindi suportadong uri ng format" @@ -2364,3 +2389,7 @@ msgstr "Ang 'S' at 'O' ay hindi suportadong uri ng format" #: shared-module/struct/__init__.c:83 msgid "too many arguments provided with the given format" msgstr "masyadong maraming mga argumento na ibinigay sa ibinigay na format" + +#, fuzzy +#~ msgid "palette must be displayio.Palette" +#~ msgstr "ang palette ay dapat 32 bytes ang haba" diff --git a/locale/fr.po b/locale/fr.po index 5ef13110b6..951c68d94a 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-09-06 14:55-0700\n" +"POT-Creation-Date: 2018-09-12 16:24-0700\n" "PO-Revision-Date: 2018-08-14 11:01+0200\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -122,7 +122,7 @@ msgstr "certificat invalide" msgid "queue overflow" msgstr "dépassement de file" -#: extmod/moduzlib.c:97 +#: extmod/moduzlib.c:98 msgid "compression header" msgstr "entête de compression" @@ -221,7 +221,7 @@ msgstr "" msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "Appuyez sur une touche pour entrer sur REPL ou CTRL-D pour recharger." -#: main.c:415 +#: main.c:416 msgid "soft reboot\n" msgstr "redémarrage logiciel\n" @@ -400,7 +400,7 @@ msgid "No TX pin" msgstr "Pas de broche TX" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:142 msgid "Cannot get pull while in output mode" msgstr "Ne peux être tirer ('pull') en mode 'output'" @@ -1989,6 +1989,7 @@ msgid "buffer must be a bytes-like object" msgstr "le tampon doit être un objet bytes-like" #: shared-bindings/audioio/WaveFile.c:78 +#: shared-bindings/displayio/OnDiskBitmap.c:85 msgid "file must be a file opened in byte mode" msgstr "le fichier doit être un fichier ouvert en mode byte" @@ -2068,6 +2069,11 @@ msgstr "" msgid "row data must be a buffer" msgstr "les constantes doivent être des entiers" +#: shared-bindings/displayio/ColorConverter.c:72 +#, fuzzy +msgid "color should be an int" +msgstr "La longueur doit être entière" + #: shared-bindings/displayio/FourWire.c:55 #: shared-bindings/displayio/FourWire.c:64 msgid "displayio is a work in progress" @@ -2105,20 +2111,19 @@ msgstr "le tampon doit être un objet bytes-like" msgid "palette_index should be an int" msgstr "Les valeurs du tableau doivent être des octets simples 'bytes'" -#: shared-bindings/displayio/Sprite.c:45 +#: shared-bindings/displayio/Sprite.c:48 #, fuzzy msgid "position must be 2-tuple" msgstr "stop doit être 1 ou 2" -#: shared-bindings/displayio/Sprite.c:87 +#: shared-bindings/displayio/Sprite.c:97 #, fuzzy msgid "unsupported bitmap type" msgstr "Débit non supporté" -#: shared-bindings/displayio/Sprite.c:152 -#, fuzzy -msgid "palette must be displayio.Palette" -msgstr "la palette doit être longue de 32 octets" +#: shared-bindings/displayio/Sprite.c:162 +msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" +msgstr "" #: shared-bindings/gamepad/GamePad.c:100 msgid "too many arguments" @@ -2353,6 +2358,26 @@ msgstr "" msgid "Group full" msgstr "" +#: shared-module/displayio/Group.c:48 +#, fuzzy +msgid "Group empty" +msgstr "vide" + +#: shared-module/displayio/OnDiskBitmap.c:49 +#, fuzzy +msgid "Invalid BMP file" +msgstr "Fichier invalide" + +#: shared-module/displayio/OnDiskBitmap.c:59 +#, c-format +msgid "Only Windows format, uncompressed BMP supported %d" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c:64 +#, c-format +msgid "Only true color (24 bpp or higher) BMP supported %x" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "'S' et 'O' ne sont pas des types de format supportés" @@ -2364,3 +2389,7 @@ msgstr "trop d'arguments fournis avec ce format" #, fuzzy #~ msgid "value_size must be power of two" #~ msgstr "'len' doit être un multiple de 4" + +#, fuzzy +#~ msgid "palette must be displayio.Palette" +#~ msgstr "la palette doit être longue de 32 octets" From 75d497bcc8552ad324a2abb31d1a6bbaa64b1007 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 13 Sep 2018 10:42:12 -0700 Subject: [PATCH 3/3] More explicit init in Group --- shared-module/displayio/Group.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c index 52b89b5ae2..655376da0a 100644 --- a/shared-module/displayio/Group.c +++ b/shared-module/displayio/Group.c @@ -56,9 +56,10 @@ mp_obj_t common_hal_displayio_group_pop(displayio_group_t* self) { void displayio_group_construct(displayio_group_t* self, mp_obj_t* child_array, uint32_t max_size) { self->x = 0; - self->y = 1; + self->y = 0; self->children = child_array; self->max_size = max_size; + self->needs_refresh = false; } bool displayio_group_get_pixel(displayio_group_t *self, int16_t x, int16_t y, uint16_t* pixel) {