summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shared-bindings/_protomatter/Protomatter.c11
-rw-r--r--shared-bindings/_protomatter/Protomatter.h2
-rw-r--r--shared-module/_protomatter/Protomatter.c12
3 files changed, 17 insertions, 8 deletions
diff --git a/shared-bindings/_protomatter/Protomatter.c b/shared-bindings/_protomatter/Protomatter.c
index 3c790ff7d..b7b28630d 100644
--- a/shared-bindings/_protomatter/Protomatter.c
+++ b/shared-bindings/_protomatter/Protomatter.c
@@ -193,7 +193,7 @@ static void check_for_deinit(protomatter_protomatter_obj_t *self) {
STATIC mp_obj_t protomatter_protomatter_get_paused(mp_obj_t self_in) {
protomatter_protomatter_obj_t *self = (protomatter_protomatter_obj_t*)self_in;
check_for_deinit(self);
- return mp_obj_new_bool(self->paused);
+ return mp_obj_new_bool(common_hal_protomatter_protomatter_get_paused(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(protomatter_protomatter_get_paused_obj, protomatter_protomatter_get_paused);
@@ -201,12 +201,7 @@ STATIC mp_obj_t protomatter_protomatter_set_paused(mp_obj_t self_in, mp_obj_t va
protomatter_protomatter_obj_t *self = (protomatter_protomatter_obj_t*)self_in;
check_for_deinit(self);
bool paused = mp_obj_is_true(value_in);
- if (paused && !self->paused) {
- _PM_stop(&self->core);
- } else if (!paused && self->paused) {
- _PM_resume(&self->core);
- }
- self->paused = paused;
+ common_hal_protomatter_protomatter_set_paused(self, paused);
return mp_const_none;
}
@@ -262,7 +257,7 @@ STATIC void protomatter_protomatter_deinit_void(mp_obj_t self_in) {
}
STATIC void protomatter_protomatter_set_brightness(mp_obj_t self_in, mp_float_t value) {
- protomatter_protomatter_set_paused(self_in, mp_obj_new_bool(value <= 0));
+ common_hal_protomatter_protomatter_set_paused(self_in, value <= 0);
}
STATIC const framebuffer_p_t protomatter_protomatter_proto = {
diff --git a/shared-bindings/_protomatter/Protomatter.h b/shared-bindings/_protomatter/Protomatter.h
index cacc39a30..0a52c556f 100644
--- a/shared-bindings/_protomatter/Protomatter.h
+++ b/shared-bindings/_protomatter/Protomatter.h
@@ -52,5 +52,7 @@ void common_hal_protomatter_protomatter_construct(protomatter_protomatter_obj_t*
void common_hal_protomatter_protomatter_deinit(protomatter_protomatter_obj_t*);
void protomatter_protomatter_collect_ptrs(protomatter_protomatter_obj_t*);
void common_hal_protomatter_protomatter_reconstruct(protomatter_protomatter_obj_t* self, mp_obj_t framebuffer);
+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);
#endif
diff --git a/shared-module/_protomatter/Protomatter.c b/shared-module/_protomatter/Protomatter.c
index 59dac3e6d..9f67bfad3 100644
--- a/shared-module/_protomatter/Protomatter.c
+++ b/shared-module/_protomatter/Protomatter.c
@@ -180,3 +180,15 @@ void protomatter_protomatter_collect_ptrs(protomatter_protomatter_obj_t* self) {
gc_collect_ptr(self->core.screenData);
}
+void common_hal_protomatter_protomatter_set_paused(protomatter_protomatter_obj_t* self, bool paused) {
+ if (paused && !self->paused) {
+ _PM_stop(&self->core);
+ } else if (!paused && self->paused) {
+ _PM_resume(&self->core);
+ }
+ self->paused = paused;
+}
+
+bool common_hal_protomatter_protomatter_get_paused(protomatter_protomatter_obj_t* self) {
+ return self->paused;
+}