Tweaks based on dhalbert's feedback.
This commit is contained in:
parent
70f40a03cb
commit
1e16b3e134
|
@ -43,9 +43,11 @@
|
|||
//|
|
||||
//| .. class:: Group(*, max_size=4, scale=1)
|
||||
//|
|
||||
//| Create a Group of a given size.
|
||||
//| Create a Group of a given size and scale. Scale is in one dimension. For example, scale=2
|
||||
//| leads to a layer's pixel being 2x2 pixels when in the group.
|
||||
//|
|
||||
//| :param int max_size: The maximum group size.
|
||||
//| :param int scale: Scale of layer pixels in one dimension.
|
||||
//|
|
||||
STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_max_size, ARG_scale };
|
||||
|
@ -58,12 +60,12 @@ STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_arg
|
|||
|
||||
mp_int_t max_size = args[ARG_max_size].u_int;
|
||||
if (max_size < 1) {
|
||||
mp_raise_ValueError_varg(translate("Group must have %q at least 1"), MP_QSTR_max_size);
|
||||
mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_max_size);
|
||||
}
|
||||
|
||||
mp_int_t scale = args[ARG_scale].u_int;
|
||||
if (scale < 1) {
|
||||
mp_raise_ValueError_varg(translate("Group must have %q at least 1"), MP_QSTR_scale);
|
||||
mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_scale);
|
||||
}
|
||||
|
||||
displayio_group_t *self = m_new_obj(displayio_group_t);
|
||||
|
@ -76,7 +78,6 @@ STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_arg
|
|||
// Helper to ensure we have the native super class instead of a subclass.
|
||||
static displayio_group_t* native_group(mp_obj_t group_obj) {
|
||||
mp_obj_t native_group = mp_instance_cast_to_native_base(group_obj, &displayio_group_type);
|
||||
assert(native_group == MP_OBJ_NULL);
|
||||
return MP_OBJ_TO_PTR(native_group);
|
||||
}
|
||||
|
||||
|
@ -96,7 +97,7 @@ STATIC mp_obj_t displayio_group_obj_set_scale(mp_obj_t self_in, mp_obj_t scale_o
|
|||
|
||||
mp_int_t scale = mp_obj_get_int(scale_obj);
|
||||
if (scale < 1) {
|
||||
mp_raise_ValueError_varg(translate("Group must have %q at least 1"), MP_QSTR_scale);
|
||||
mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_scale);
|
||||
}
|
||||
common_hal_displayio_group_set_scale(self, scale);
|
||||
return mp_const_none;
|
||||
|
|
|
@ -39,8 +39,8 @@ uint32_t common_hal_displayio_group_get_scale(displayio_group_t* self) {
|
|||
}
|
||||
|
||||
void common_hal_displayio_group_set_scale(displayio_group_t* self, uint32_t scale) {
|
||||
self->needs_refresh = self->scale != scale;
|
||||
self->scale = scale;
|
||||
self->needs_refresh = true;
|
||||
}
|
||||
|
||||
mp_int_t common_hal_displayio_group_get_x(displayio_group_t* self) {
|
||||
|
@ -48,8 +48,8 @@ mp_int_t common_hal_displayio_group_get_x(displayio_group_t* self) {
|
|||
}
|
||||
|
||||
void common_hal_displayio_group_set_x(displayio_group_t* self, mp_int_t x) {
|
||||
self->needs_refresh = self->x != x;
|
||||
self->x = x;
|
||||
self->needs_refresh = true;
|
||||
}
|
||||
|
||||
mp_int_t common_hal_displayio_group_get_y(displayio_group_t* self) {
|
||||
|
@ -57,8 +57,8 @@ mp_int_t common_hal_displayio_group_get_y(displayio_group_t* self) {
|
|||
}
|
||||
|
||||
void common_hal_displayio_group_set_y(displayio_group_t* self, mp_int_t y) {
|
||||
self->needs_refresh = self->y != y;
|
||||
self->y = y;
|
||||
self->needs_refresh = true;
|
||||
}
|
||||
|
||||
void common_hal_displayio_group_insert(displayio_group_t* self, size_t index, mp_obj_t layer) {
|
||||
|
|
Loading…
Reference in New Issue