summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2021-02-11 16:37:34 -0600
committerJeff Epler <jepler@gmail.com>2021-02-12 08:25:15 -0600
commitff1942cff68a4e192f984a14a83b59800186e45a (patch)
tree7818252750d5819ddb518075a5e6d2f165712ec7 /shared-module
parentaae10fb37fa402f9bc51f3edec0d2f7772036a25 (diff)
Enable protomatter on RP2040 builds
Also found a race condition between timer_disable and redraw, which would happen if I debugger-paused inside common_hal_rgbmatrix_timer_disable or put a delay or print inside it. That's what pausing inside reconstruct fixes. So that the "right timer" can be chosen, `timer_allocate` now gets the `self` pointer. It's guaranteed at this point that the pin information is accurate, so you can e.g., find a PWM unit related to the pins themselves. This required touching each port to add the parameter even though it's unused everywhere but raspberrypi.
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/rgbmatrix/RGBMatrix.c4
-rw-r--r--shared-module/rgbmatrix/RGBMatrix.h1
2 files changed, 4 insertions, 1 deletions
diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c
index b8db0d893..a688d7fd6 100644
--- a/shared-module/rgbmatrix/RGBMatrix.c
+++ b/shared-module/rgbmatrix/RGBMatrix.c
@@ -56,7 +56,7 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i
self->tile = tile;
self->serpentine = serpentine;
- self->timer = timer ? timer : common_hal_rgbmatrix_timer_allocate();
+ self->timer = timer ? timer : common_hal_rgbmatrix_timer_allocate(self);
if (self->timer == NULL) {
mp_raise_ValueError(translate("No timer available"));
}
@@ -68,6 +68,8 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i
}
void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, mp_obj_t framebuffer) {
+ self->paused = 1;
+
common_hal_rgbmatrix_timer_disable(self->timer);
if (framebuffer) {
self->framebuffer = framebuffer;
diff --git a/shared-module/rgbmatrix/RGBMatrix.h b/shared-module/rgbmatrix/RGBMatrix.h
index 4a0e9235e..65bfc9799 100644
--- a/shared-module/rgbmatrix/RGBMatrix.h
+++ b/shared-module/rgbmatrix/RGBMatrix.h
@@ -26,6 +26,7 @@
#pragma once
+#include "py/obj.h"
#include "lib/protomatter/src/core.h"
extern const mp_obj_type_t rgbmatrix_RGBMatrix_type;