From 64c3968a2e2c626036fcd3d148eae7ba092e6096 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 15 Apr 2020 10:19:33 -0500 Subject: [PATCH] protomatter: move get_width/height to common_hal --- shared-bindings/protomatter/Protomatter.c | 5 ++--- shared-bindings/protomatter/Protomatter.h | 2 ++ shared-module/protomatter/Protomatter.c | 9 +++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/shared-bindings/protomatter/Protomatter.c b/shared-bindings/protomatter/Protomatter.c index e3f735dde6..4554c30bf0 100644 --- a/shared-bindings/protomatter/Protomatter.c +++ b/shared-bindings/protomatter/Protomatter.c @@ -321,7 +321,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(protomatter_protomatter_refresh_obj, protomatter_proto STATIC mp_obj_t protomatter_protomatter_get_width(mp_obj_t self_in) { protomatter_protomatter_obj_t *self = (protomatter_protomatter_obj_t*)self_in; check_for_deinit(self); - return MP_OBJ_NEW_SMALL_INT(self->width); + return MP_OBJ_NEW_SMALL_INT(common_hal_protomatter_protomatter_get_width(self)); } MP_DEFINE_CONST_FUN_OBJ_1(protomatter_protomatter_get_width_obj, protomatter_protomatter_get_width); const mp_obj_property_t protomatter_protomatter_width_obj = { @@ -338,8 +338,7 @@ const mp_obj_property_t protomatter_protomatter_width_obj = { STATIC mp_obj_t protomatter_protomatter_get_height(mp_obj_t self_in) { protomatter_protomatter_obj_t *self = (protomatter_protomatter_obj_t*)self_in; check_for_deinit(self); - int computed_get_height = (self->rgb_count / 3) << (self->addr_count); - return MP_OBJ_NEW_SMALL_INT(computed_get_height); + return MP_OBJ_NEW_SMALL_INT(common_hal_protomatter_protomatter_get_height(self)); } MP_DEFINE_CONST_FUN_OBJ_1(protomatter_protomatter_get_height_obj, protomatter_protomatter_get_height); diff --git a/shared-bindings/protomatter/Protomatter.h b/shared-bindings/protomatter/Protomatter.h index 4704a626ff..061c8de4e5 100644 --- a/shared-bindings/protomatter/Protomatter.h +++ b/shared-bindings/protomatter/Protomatter.h @@ -55,5 +55,7 @@ void common_hal_protomatter_protomatter_reconstruct(protomatter_protomatter_obj_ void common_hal_protomatter_protomatter_set_paused(protomatter_protomatter_obj_t* self, bool paused); bool common_hal_protomatter_protomatter_get_paused(protomatter_protomatter_obj_t* self); void common_hal_protomatter_protomatter_refresh(protomatter_protomatter_obj_t* self); +int common_hal_protomatter_protomatter_get_width(protomatter_protomatter_obj_t* self); +int common_hal_protomatter_protomatter_get_height(protomatter_protomatter_obj_t* self); #endif diff --git a/shared-module/protomatter/Protomatter.c b/shared-module/protomatter/Protomatter.c index 37721cb1cf..e7fa4ba9ae 100644 --- a/shared-module/protomatter/Protomatter.c +++ b/shared-module/protomatter/Protomatter.c @@ -198,3 +198,12 @@ void common_hal_protomatter_protomatter_refresh(protomatter_protomatter_obj_t* s _PM_swapbuffer_maybe(&self->core); } +int common_hal_protomatter_protomatter_get_width(protomatter_protomatter_obj_t* self) { + return self->width; +} + +int common_hal_protomatter_protomatter_get_height(protomatter_protomatter_obj_t* self) { + int computed_height = (self->rgb_count / 3) << (self->addr_count); + return computed_height; +} +