Skip to content

Commit 3cf9a47

Browse files
committed
fix 'white' byte for dotstars
1 parent 5c08182 commit 3cf9a47

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

shared-bindings/_pixelbuf/PixelBuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a
119119
byteorder_details.byteorder.r = r - byteorder;
120120
byteorder_details.byteorder.g = g - byteorder;
121121
byteorder_details.byteorder.b = b - byteorder;
122-
if (w)
123-
byteorder_details.byteorder.w = w - byteorder;
122+
byteorder_details.byteorder.w = w ? w - byteorder : 0;
124123
// The dotstar brightness byte is always first (as it goes with the pixel start bits)
125124
// if 'D' is found at the end, adjust byte position
126125
// if 'D' is elsewhere, error out
@@ -130,6 +129,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a
130129
byteorder_details.byteorder.b += 1;
131130
byteorder_details.byteorder.g += 1;
132131
byteorder_details.byteorder.r += 1;
132+
byteorder_details.byteorder.w = 0;
133133
} else if (dotstar_pos != 0) {
134134
mp_raise_ValueError(translate("Invalid byteorder string"));
135135
}

shared-module/_pixelbuf/PixelBuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ void pixelbuf_set_pixel(uint8_t *buf, uint8_t *rawbuf, float brightness, mp_obj_
4747
if (MP_OBJ_IS_INT(item)) {
4848
uint8_t *target = rawbuf ? rawbuf : buf;
4949
pixelbuf_set_pixel_int(target, mp_obj_get_int_truncated(item), byteorder);
50-
if (dotstar) {
50+
if (dotstar) {
5151
buf[0] = DOTSTAR_LED_START_FULL_BRIGHT;
5252
if (rawbuf)
5353
rawbuf[0] = DOTSTAR_LED_START_FULL_BRIGHT;
54-
}
54+
}
5555
if (rawbuf) {
5656
buf[byteorder->byteorder.r] = rawbuf[byteorder->byteorder.r] * brightness;
5757
buf[byteorder->byteorder.g] = rawbuf[byteorder->byteorder.g] * brightness;

0 commit comments

Comments
 (0)