Skip to content

Commit 64c3968

Browse files
committed
protomatter: move get_width/height to common_hal
1 parent 545b6e5 commit 64c3968

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

shared-bindings/protomatter/Protomatter.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(protomatter_protomatter_refresh_obj, protomatter_proto
321321
STATIC mp_obj_t protomatter_protomatter_get_width(mp_obj_t self_in) {
322322
protomatter_protomatter_obj_t *self = (protomatter_protomatter_obj_t*)self_in;
323323
check_for_deinit(self);
324-
return MP_OBJ_NEW_SMALL_INT(self->width);
324+
return MP_OBJ_NEW_SMALL_INT(common_hal_protomatter_protomatter_get_width(self));
325325
}
326326
MP_DEFINE_CONST_FUN_OBJ_1(protomatter_protomatter_get_width_obj, protomatter_protomatter_get_width);
327327
const mp_obj_property_t protomatter_protomatter_width_obj = {
@@ -338,8 +338,7 @@ const mp_obj_property_t protomatter_protomatter_width_obj = {
338338
STATIC mp_obj_t protomatter_protomatter_get_height(mp_obj_t self_in) {
339339
protomatter_protomatter_obj_t *self = (protomatter_protomatter_obj_t*)self_in;
340340
check_for_deinit(self);
341-
int computed_get_height = (self->rgb_count / 3) << (self->addr_count);
342-
return MP_OBJ_NEW_SMALL_INT(computed_get_height);
341+
return MP_OBJ_NEW_SMALL_INT(common_hal_protomatter_protomatter_get_height(self));
343342
}
344343
MP_DEFINE_CONST_FUN_OBJ_1(protomatter_protomatter_get_height_obj, protomatter_protomatter_get_height);
345344

shared-bindings/protomatter/Protomatter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,7 @@ void common_hal_protomatter_protomatter_reconstruct(protomatter_protomatter_obj_
5555
void common_hal_protomatter_protomatter_set_paused(protomatter_protomatter_obj_t* self, bool paused);
5656
bool common_hal_protomatter_protomatter_get_paused(protomatter_protomatter_obj_t* self);
5757
void common_hal_protomatter_protomatter_refresh(protomatter_protomatter_obj_t* self);
58+
int common_hal_protomatter_protomatter_get_width(protomatter_protomatter_obj_t* self);
59+
int common_hal_protomatter_protomatter_get_height(protomatter_protomatter_obj_t* self);
5860

5961
#endif

shared-module/protomatter/Protomatter.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,12 @@ void common_hal_protomatter_protomatter_refresh(protomatter_protomatter_obj_t* s
198198
_PM_swapbuffer_maybe(&self->core);
199199
}
200200

201+
int common_hal_protomatter_protomatter_get_width(protomatter_protomatter_obj_t* self) {
202+
return self->width;
203+
}
204+
205+
int common_hal_protomatter_protomatter_get_height(protomatter_protomatter_obj_t* self) {
206+
int computed_height = (self->rgb_count / 3) << (self->addr_count);
207+
return computed_height;
208+
}
209+

0 commit comments

Comments
 (0)