summaryrefslogtreecommitdiff
path: root/shared-module/_pixelbuf
diff options
context:
space:
mode:
authorRoy Hooper <rhooper@toybox.ca>2019-10-20 19:54:25 -0400
committerRoy Hooper <rhooper@toybox.ca>2019-10-20 19:54:25 -0400
commit2970680e6af663200b35227bfbca5240542a4c47 (patch)
tree472131277db9bf2493443b0296dc1116677daee5 /shared-module/_pixelbuf
parentdc8c27d1292673f1610f6440fa0de810018995fe (diff)
fix show and fix step > 1
Diffstat (limited to 'shared-module/_pixelbuf')
-rw-r--r--shared-module/_pixelbuf/PixelBuf.c7
-rw-r--r--shared-module/_pixelbuf/PixelBuf.h2
2 files changed, 6 insertions, 3 deletions
diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c
index e26f05ac3..a0071903a 100644
--- a/shared-module/_pixelbuf/PixelBuf.c
+++ b/shared-module/_pixelbuf/PixelBuf.c
@@ -94,10 +94,13 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_
}
}
-mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, bool dotstar) {
+mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, mp_int_t slice_step, bool dotstar) {
mp_obj_t elems[len];
+ if (slice_step > 1) {
+ len = len / slice_step;
+ }
for (uint i = 0; i < len; i++) {
- elems[i] = pixelbuf_get_pixel(buf + (i * step), byteorder, dotstar);
+ elems[i] = pixelbuf_get_pixel(buf + ((i * slice_step) * step), byteorder, dotstar);
}
return mp_obj_new_tuple(len, elems);
}
diff --git a/shared-module/_pixelbuf/PixelBuf.h b/shared-module/_pixelbuf/PixelBuf.h
index 6b3272e19..173ce61a8 100644
--- a/shared-module/_pixelbuf/PixelBuf.h
+++ b/shared-module/_pixelbuf/PixelBuf.h
@@ -44,7 +44,7 @@
void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_details_t *byteorder, bool dotstar);
mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_details_t *byteorder, bool dotstar);
-mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, bool dotstar);
+mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_details_t *byteorder, uint8_t step, mp_int_t slice_step, bool dotstar);
void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_details_t *byteorder);
#endif