summaryrefslogtreecommitdiff
path: root/shared-module/_pixelbuf
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2020-01-13 18:15:32 -0500
committerDan Halbert <halbert@halwitz.org>2020-01-13 18:15:32 -0500
commit2a75196aa3598b3daf4c6fcebdc47dcad597b332 (patch)
tree7c615930405baea093ec7c61e29dcf91c3b6c01b /shared-module/_pixelbuf
parent4ad004f24eb79a382f1e6230f8ff02784d469d87 (diff)
parent2eb26a6d0b48fb82932190f67475ec101969d3ac (diff)
merge from adafruit/circuitpython
Diffstat (limited to 'shared-module/_pixelbuf')
-rw-r--r--shared-module/_pixelbuf/PixelBuf.c14
-rw-r--r--shared-module/_pixelbuf/PixelBuf.h8
2 files changed, 11 insertions, 11 deletions
diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c
index d32697239..020151bc3 100644
--- a/shared-module/_pixelbuf/PixelBuf.c
+++ b/shared-module/_pixelbuf/PixelBuf.c
@@ -31,7 +31,7 @@
#include "PixelBuf.h"
#include <string.h>
-void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_obj_t *byteorder) {
+void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_details_t *byteorder) {
buf[byteorder->byteorder.r] = value >> 16 & 0xff;
buf[byteorder->byteorder.g] = (value >> 8) & 0xff;
buf[byteorder->byteorder.b] = value & 0xff;
@@ -43,15 +43,15 @@ void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_obj
}
}
-void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_obj_t *byteorder, bool dotstar) {
+void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_details_t *byteorder, bool dotstar) {
if (MP_OBJ_IS_INT(item)) {
uint8_t *target = rawbuf ? rawbuf : buf;
pixelbuf_set_pixel_int(target, mp_obj_get_int_truncated(item), byteorder);
- if (dotstar) {
+ if (dotstar) {
buf[0] = DOTSTAR_LED_START_FULL_BRIGHT;
if (rawbuf)
rawbuf[0] = DOTSTAR_LED_START_FULL_BRIGHT;
- }
+ }
if (rawbuf) {
buf[byteorder->byteorder.r] = rawbuf[byteorder->byteorder.r] * brightness;
buf[byteorder->byteorder.g] = rawbuf[byteorder->byteorder.g] * brightness;
@@ -94,15 +94,15 @@ 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_obj_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];
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);
}
-mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_obj_t *byteorder, bool dotstar) {
+mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_details_t *byteorder, bool dotstar) {
mp_obj_t elems[byteorder->bpp];
elems[0] = mp_obj_new_int(buf[byteorder->byteorder.r]);
diff --git a/shared-module/_pixelbuf/PixelBuf.h b/shared-module/_pixelbuf/PixelBuf.h
index 9e115fe0c..173ce61a8 100644
--- a/shared-module/_pixelbuf/PixelBuf.h
+++ b/shared-module/_pixelbuf/PixelBuf.h
@@ -42,9 +42,9 @@
#define DOTSTAR_GET_BRIGHTNESS(value) ((value & 0b00011111) / 31.0)
#define DOTSTAR_LED_START_FULL_BRIGHT 0xFF
-void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_t *item, pixelbuf_byteorder_obj_t *byteorder, bool dotstar);
-mp_obj_t *pixelbuf_get_pixel(uint8_t *buf, pixelbuf_byteorder_obj_t *byteorder, bool dotstar);
-mp_obj_t *pixelbuf_get_pixel_array(uint8_t *buf, uint len, pixelbuf_byteorder_obj_t *byteorder, uint8_t step, bool dotstar);
-void pixelbuf_set_pixel_int(uint8_t *buf, mp_int_t value, pixelbuf_byteorder_obj_t *byteorder);
+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, 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