Merge pull request #1774 from tannewt/pybadge_revd

Tweak pybadge and fix display bugs
crypto-aes
Dan Halbert 4 years ago committed by GitHub
commit cf3f3e510c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
.gitignore vendored

@ -66,3 +66,5 @@ TAGS
# POEdit mo files
####################
*.mo
.vscode

@ -2575,7 +2575,7 @@ msgid "unsupported Xtensa instruction '%s' with %d arguments"
msgstr ""
#: shared-bindings/displayio/TileGrid.c
msgid "unsupported bitmap type"
msgid "unsupported %q type"
msgstr ""
#: py/objstr.c

@ -2528,7 +2528,7 @@ msgid "unsupported Xtensa instruction '%s' with %d arguments"
msgstr ""
#: shared-bindings/displayio/TileGrid.c
msgid "unsupported bitmap type"
msgid "unsupported %q type"
msgstr ""
#: py/objstr.c

@ -2584,8 +2584,8 @@ msgid "unsupported Xtensa instruction '%s' with %d arguments"
msgstr ""
#: shared-bindings/displayio/TileGrid.c
msgid "unsupported bitmap type"
msgstr "Nicht unterstützter Bitmap-Typ"
msgid "unsupported %q type"
msgstr "Nicht unterstützter %q-Typ"
#: py/objstr.c
#, c-format

@ -2528,7 +2528,7 @@ msgid "unsupported Xtensa instruction '%s' with %d arguments"
msgstr ""
#: shared-bindings/displayio/TileGrid.c
msgid "unsupported bitmap type"
msgid "unsupported %q type"
msgstr ""
#: py/objstr.c

@ -2532,7 +2532,7 @@ msgid "unsupported Xtensa instruction '%s' with %d arguments"
msgstr ""
#: shared-bindings/displayio/TileGrid.c
msgid "unsupported bitmap type"
msgid "unsupported %q type"
msgstr ""
#: py/objstr.c

@ -2614,8 +2614,8 @@ msgid "unsupported Xtensa instruction '%s' with %d arguments"
msgstr "instrucción Xtensa '%s' con %d argumentos no soportada"
#: shared-bindings/displayio/TileGrid.c
msgid "unsupported bitmap type"
msgstr "tipo de bitmap no soportado"
msgid "unsupported %q type"
msgstr "tipo de %q no soportado"
#: py/objstr.c
#, c-format

@ -2616,8 +2616,8 @@ msgid "unsupported Xtensa instruction '%s' with %d arguments"
msgstr "hindi sinusuportahan ang instruction ng Xtensa '%s' sa %d argumento"
#: shared-bindings/displayio/TileGrid.c
msgid "unsupported bitmap type"
msgstr "Hindi supportadong tipo ng bitmap"
msgid "unsupported %q type"
msgstr "Hindi supportadong tipo ng %q"
#: py/objstr.c
#, c-format

@ -2638,8 +2638,8 @@ msgstr "instruction Xtensa '%s' non supportée avec %d arguments"
#: shared-bindings/displayio/TileGrid.c
#, fuzzy
msgid "unsupported bitmap type"
msgstr "type de bitmap non supporté"
msgid "unsupported %q type"
msgstr "type de %q non supporté"
#: py/objstr.c
#, c-format

@ -2614,8 +2614,8 @@ msgid "unsupported Xtensa instruction '%s' with %d arguments"
msgstr "istruzione '%s' Xtensa non supportata con %d argomenti"
#: shared-bindings/displayio/TileGrid.c
msgid "unsupported bitmap type"
msgstr "tipo di bitmap non supportato"
msgid "unsupported %q type"
msgstr "tipo di %q non supportato"
#: py/objstr.c
#, c-format

@ -2561,8 +2561,8 @@ msgid "unsupported Xtensa instruction '%s' with %d arguments"
msgstr "niewspierana instrukcja Xtensa '%s' z %d argumentami"
#: shared-bindings/displayio/TileGrid.c
msgid "unsupported bitmap type"
msgstr "niewspierany typ bitmapy"
msgid "unsupported %q type"
msgstr "niewspierany typ %q"
#: py/objstr.c
#, c-format

@ -2565,7 +2565,7 @@ msgid "unsupported Xtensa instruction '%s' with %d arguments"
msgstr ""
#: shared-bindings/displayio/TileGrid.c
msgid "unsupported bitmap type"
msgid "unsupported %q type"
msgstr ""
#: py/objstr.c

@ -11,3 +11,5 @@ LONGINT_IMPL = MPZ
CHIP_VARIANT = SAMD21G18A
CHIP_FAMILY = samd21
CFLAGS_INLINE_LIMIT = 70

@ -964,6 +964,21 @@ STATIC bool check_for_special_accessors(mp_obj_t key, mp_obj_t value) {
#endif
return false;
}
STATIC bool map_has_special_accessors(const mp_map_t *map) {
if (map == NULL) {
return false;
}
for (size_t i = 0; i < map->alloc; i++) {
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
const mp_map_elem_t *elem = &map->table[i];
if (check_for_special_accessors(elem->key, elem->value)) {
return true;
}
}
}
return false;
}
#endif
STATIC void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
@ -1158,20 +1173,6 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
o->locals_dict = make_dict_long_lived(locals_dict, 10);
#if ENABLE_SPECIAL_ACCESSORS
// Check if the class has any special accessor methods
if (!(o->flags & TYPE_FLAG_HAS_SPECIAL_ACCESSORS)) {
for (size_t i = 0; i < o->locals_dict->map.alloc; i++) {
if (MP_MAP_SLOT_IS_FILLED(&o->locals_dict->map, i)) {
const mp_map_elem_t *elem = &o->locals_dict->map.table[i];
if (check_for_special_accessors(elem->key, elem->value)) {
o->flags |= TYPE_FLAG_HAS_SPECIAL_ACCESSORS;
break;
}
}
}
}
#endif
const mp_obj_type_t *native_base;
size_t num_native_bases = instance_count_native_bases(o, &native_base);
@ -1180,6 +1181,17 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
}
mp_map_t *locals_map = &o->locals_dict->map;
#if ENABLE_SPECIAL_ACCESSORS
// Check if the class has any special accessor methods
if (!(o->flags & TYPE_FLAG_HAS_SPECIAL_ACCESSORS) &&
(map_has_special_accessors(locals_map) ||
(num_native_bases == 1 &&
native_base->locals_dict != NULL &&
map_has_special_accessors(&native_base->locals_dict->map)))) {
o->flags |= TYPE_FLAG_HAS_SPECIAL_ACCESSORS;
}
#endif
mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(MP_QSTR___new__), MP_MAP_LOOKUP);
if (elem != NULL) {
// __new__ slot exists; check if it is a function

@ -157,13 +157,19 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
return self;
}
// Helper to ensure we have the native super class instead of a subclass.
static displayio_display_obj_t* native_display(mp_obj_t display_obj) {
mp_obj_t native_display = mp_instance_cast_to_native_base(display_obj, &displayio_display_type);
return MP_OBJ_TO_PTR(native_display);
}
//| .. method:: show(group)
//|
//| Switches to displaying the given group of layers. When group is None, the default
//| CircuitPython terminal will be shown.
//|
STATIC mp_obj_t displayio_display_obj_show(mp_obj_t self_in, mp_obj_t group_in) {
displayio_display_obj_t *self = MP_OBJ_TO_PTR(self_in);
displayio_display_obj_t *self = native_display(self_in);
displayio_group_t* group = NULL;
if (group_in != mp_const_none) {
mp_obj_t native_layer = mp_instance_cast_to_native_base(group_in, &displayio_group_type);
@ -183,7 +189,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show
//| Queues up a display refresh that happens in the background.
//|
STATIC mp_obj_t displayio_display_obj_refresh_soon(mp_obj_t self_in) {
displayio_display_obj_t *self = MP_OBJ_TO_PTR(self_in);
displayio_display_obj_t *self = native_display(self_in);
common_hal_displayio_display_refresh_soon(self);
return mp_const_none;
}
@ -195,7 +201,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_refresh_soon_obj, displayio_display_
//| behind the rendered frames. In that case, this will return immediately with the wait count.
//|
STATIC mp_obj_t displayio_display_obj_wait_for_frame(mp_obj_t self_in) {
displayio_display_obj_t *self = MP_OBJ_TO_PTR(self_in);
displayio_display_obj_t *self = native_display(self_in);
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_wait_for_frame(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_wait_for_frame_obj, displayio_display_obj_wait_for_frame);
@ -207,7 +213,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_wait_for_frame_obj, displayio_displa
//| effect. To control the brightness, auto_brightness must be false.
//|
STATIC mp_obj_t displayio_display_obj_get_brightness(mp_obj_t self_in) {
displayio_display_obj_t *self = MP_OBJ_TO_PTR(self_in);
displayio_display_obj_t *self = native_display(self_in);
mp_float_t brightness = common_hal_displayio_display_get_brightness(self);
if (brightness < 0) {
mp_raise_RuntimeError(translate("Brightness not adjustable"));
@ -217,7 +223,7 @@ STATIC mp_obj_t displayio_display_obj_get_brightness(mp_obj_t self_in) {
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_brightness_obj, displayio_display_obj_get_brightness);
STATIC mp_obj_t displayio_display_obj_set_brightness(mp_obj_t self_in, mp_obj_t brightness) {
displayio_display_obj_t *self = MP_OBJ_TO_PTR(self_in);
displayio_display_obj_t *self = native_display(self_in);
bool ok = common_hal_displayio_display_set_brightness(self, mp_obj_get_float(brightness));
if (!ok) {
mp_raise_RuntimeError(translate("Brightness not adjustable"));
@ -238,13 +244,13 @@ const mp_obj_property_t displayio_display_brightness_obj = {
//| True when the display brightness is auto adjusted.
//|
STATIC mp_obj_t displayio_display_obj_get_auto_brightness(mp_obj_t self_in) {
displayio_display_obj_t *self = MP_OBJ_TO_PTR(self_in);
displayio_display_obj_t *self = native_display(self_in);
return mp_obj_new_bool(common_hal_displayio_display_get_auto_brightness(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_auto_brightness_obj, displayio_display_obj_get_auto_brightness);
STATIC mp_obj_t displayio_display_obj_set_auto_brightness(mp_obj_t self_in, mp_obj_t auto_brightness) {
displayio_display_obj_t *self = MP_OBJ_TO_PTR(self_in);
displayio_display_obj_t *self = native_display(self_in);
common_hal_displayio_display_set_auto_brightness(self, mp_obj_is_true(auto_brightness));
@ -265,7 +271,7 @@ const mp_obj_property_t displayio_display_auto_brightness_obj = {
//|
//|
STATIC mp_obj_t displayio_display_obj_get_width(mp_obj_t self_in) {
displayio_display_obj_t *self = MP_OBJ_TO_PTR(self_in);
displayio_display_obj_t *self = native_display(self_in);
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_width(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_width_obj, displayio_display_obj_get_width);
@ -283,7 +289,7 @@ const mp_obj_property_t displayio_display_width_obj = {
//|
//|
STATIC mp_obj_t displayio_display_obj_get_height(mp_obj_t self_in) {
displayio_display_obj_t *self = MP_OBJ_TO_PTR(self_in);
displayio_display_obj_t *self = native_display(self_in);
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_height(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_height_obj, displayio_display_obj_get_height);
@ -301,7 +307,7 @@ const mp_obj_property_t displayio_display_height_obj = {
//|
//|
STATIC mp_obj_t displayio_display_obj_get_bus(mp_obj_t self_in) {
displayio_display_obj_t *self = MP_OBJ_TO_PTR(self_in);
displayio_display_obj_t *self = native_display(self_in);
return self->bus;
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_bus_obj, displayio_display_obj_get_bus);

@ -103,7 +103,12 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_
bitmap_width = bmp->width;
bitmap_height = bmp->height;
} else {
mp_raise_TypeError(translate("unsupported bitmap type"));
mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_bitmap);
}
mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj;
if (!MP_OBJ_IS_TYPE(pixel_shader, &displayio_colorconverter_type) &&
!MP_OBJ_IS_TYPE(pixel_shader, &displayio_palette_type)) {
mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader);
}
uint16_t tile_width = args[ARG_tile_width].u_int;
if (tile_width == 0) {
@ -126,7 +131,7 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_
displayio_tilegrid_t *self = m_new_obj(displayio_tilegrid_t);
self->base.type = &displayio_tilegrid_type;
common_hal_displayio_tilegrid_construct(self, native, bitmap_width / tile_width,
args[ARG_pixel_shader].u_obj, args[ARG_width].u_int, args[ARG_height].u_int,
pixel_shader, args[ARG_width].u_int, args[ARG_height].u_int,
tile_width, tile_height, x, y, args[ARG_default_tile].u_int);
return MP_OBJ_FROM_PTR(self);
}

Loading…
Cancel
Save