Skip to content

Commit db84445

Browse files
committed
WIP: refactor _pixelbuf to use strings instead of classes
1 parent a98bfa6 commit db84445

5 files changed

Lines changed: 88 additions & 125 deletions

File tree

shared-bindings/_pixelbuf/PixelBuf.c

Lines changed: 63 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,50 @@
4040
#include "../../shared-module/_pixelbuf/PixelBuf.h"
4141
#include "shared-bindings/digitalio/DigitalInOut.h"
4242

43-
extern const pixelbuf_byteorder_obj_t byteorder_BGR;
44-
extern const mp_obj_type_t pixelbuf_byteorder_type;
4543
extern const int32_t colorwheel(float pos);
4644

45+
int parse_byteorder_string(const char *byteorder, pixelbuf_byteorder_details_t details) {
46+
details.bpp = strlen(byteorder);
47+
char *dotstar = strchr(byteorder, 'D');
48+
char *r = strchr(byteorder, 'R');
49+
char *g = strchr(byteorder, 'G');
50+
char *b = strchr(byteorder, 'B');
51+
char *w = strchr(byteorder, 'W');
52+
int num_chars = (dotstar ? 1 : 0) + (w ? 1 : 0) + (r ? 1 : 0) + (g ? 1 : 0) + (b ? 1 : 0);
53+
if (num_chars < details.bpp)
54+
mp_raise_ValueError(translate("Unexpected character in byteorder"));
55+
if (!(r && b && g))
56+
mp_raise_ValueError(translate("Incomplete byteorder string"));
57+
details.is_dotstar = dotstar ? true : false;
58+
details.has_white = w ? true : false;
59+
details.byteorder.r = byteorder - r;
60+
details.byteorder.g = byteorder - g;
61+
details.byteorder.b = byteorder - b;
62+
if (w)
63+
details.byteorder.w = byteorder - w;
64+
// The dotstar brightness byte is always first (as it goes with the pixel start bits)
65+
// if 'D' is found at the end, adjust byte position
66+
// if 'D' is elsewhere, error out
67+
if (dotstar) {
68+
size_t dotstar_pos = dotstar - byteorder;
69+
if (dotstar_pos == 4) {
70+
details.byteorder.b += 1;
71+
details.byteorder.g += 1;
72+
details.byteorder.r += 1;
73+
} else if (dotstar_pos != 0) {
74+
mp_raise_ValueError(translate("Dotstar position invalid"));
75+
}
76+
}
77+
}
78+
4779
//| .. currentmodule:: pixelbuf
4880
//|
4981
//| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices
5082
//| ===========================================================================
5183
//|
5284
//| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction.
5385
//|
54-
//| .. class:: PixelBuf(size, buf, byteorder=BGR, brightness=0, rawbuf=None, offset=0, dotstar=False, auto_write=False, write_function=None, write_args=None)
86+
//| .. class:: PixelBuf(size, buf, byteorder="BGR", brightness=0, rawbuf=None, offset=0, auto_write=False, write_function=None, write_args=None)
5587
//|
5688
//| Create a PixelBuf object of the specified size, byteorder, and bits per pixel.
5789
//|
@@ -60,25 +92,23 @@ extern const int32_t colorwheel(float pos);
6092
//|
6193
//| When only given ``buf``, ``brightness`` applies to the next pixel assignment.
6294
//|
63-
//| When ``dotstar`` is True, and ``bpp`` is 4, the 4th value in a tuple/list
64-
//| is the individual pixel brightness (0-1). Not compatible with RGBW Byteorders.
65-
//| Compatible `ByteOrder` classes are bpp=3, or bpp=4 and has_luminosity=True (g LBGR).
95+
//| When ``D`` (dotstar mode) is present in the byteorder configuration, the
96+
//| 4th value in a tuple/list is the individual pixel brightness (0-1).
6697
//|
6798
//| :param ~int size: Number of pixelsx
68-
//| :param ~bytearray buf: Bytearray to store pixel data in
69-
//| :param ~_pixelbuf.ByteOrder byteorder: Byte order constant from `_pixelbuf`
99+
//| :param ~bytearray buf: Bytearray in which to store pixel data
100+
//| :param ~str byteorder: Byte order string (such as "BGR" or "BGRD")
70101
//| :param ~float brightness: Brightness (0 to 1.0, default 1.0)
71-
//| :param ~bytearray rawbuf: Bytearray to store raw pixel colors in
102+
//| :param ~bytearray rawbuf: Bytearray in which to store raw pixel data (before brightness adjustment)
72103
//| :param ~int offset: Offset from start of buffer (default 0)
73-
//| :param ~bool dotstar: Dotstar mode (default False)
74104
//| :param ~bool auto_write: Whether to automatically write pixels (Default False)
75105
//| :param ~callable write_function: (optional) Callable to use to send pixels
76106
//| :param ~list write_args: (optional) Tuple or list of args to pass to ``write_function``. The
77107
//| PixelBuf instance is appended after these args.
78108
//|
79109
STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
80110
mp_arg_check_num(n_args, kw_args, 2, MP_OBJ_FUN_ARGS_MAX, true);
81-
enum { ARG_size, ARG_buf, ARG_byteorder, ARG_brightness, ARG_rawbuf, ARG_offset, ARG_dotstar,
111+
enum { ARG_size, ARG_buf, ARG_byteorder, ARG_brightness, ARG_rawbuf, ARG_offset,
82112
ARG_auto_write, ARG_write_function, ARG_write_args };
83113
static const mp_arg_t allowed_args[] = {
84114
{ MP_QSTR_size, MP_ARG_REQUIRED | MP_ARG_INT },
@@ -87,23 +117,30 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a
87117
{ MP_QSTR_brightness, MP_ARG_OBJ, { .u_obj = mp_const_none } },
88118
{ MP_QSTR_rawbuf, MP_ARG_OBJ, { .u_obj = mp_const_none } },
89119
{ MP_QSTR_offset, MP_ARG_INT, { .u_int = 0 } },
90-
{ MP_QSTR_dotstar, MP_ARG_BOOL, { .u_bool = false } },
91120
{ MP_QSTR_auto_write, MP_ARG_BOOL, {.u_bool = false} },
92121
{ MP_QSTR_write_function, MP_ARG_OBJ, {.u_obj = mp_const_none} },
93122
{ MP_QSTR_write_args, MP_ARG_OBJ, {.u_obj = mp_const_none} },
94123
};
95124
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
96125
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
97126

98-
if (mp_obj_is_subclass_fast(args[ARG_byteorder].u_obj, &pixelbuf_byteorder_type))
99-
mp_raise_TypeError_varg(translate("byteorder is not an instance of ByteOrder (got a %s)"), mp_obj_get_type_str(args[ARG_byteorder].u_obj));
127+
if (!MP_OBJ_IS_STR(args[ARG_byteorder].u_obj))
128+
mp_raise_TypeError(translate("byteorder is not a string"));
100129

101-
pixelbuf_byteorder_obj_t *byteorder = (args[ARG_byteorder].u_obj == mp_const_none) ? MP_OBJ_FROM_PTR(&byteorder_BGR) : args[ARG_byteorder].u_obj;
130+
const char *byteorder_str = NULL;
131+
pixelbuf_byteorder_details_t byteorder_details;
132+
size_t bo_len;
133+
if (args[ARG_byteorder].u_obj == NULL)
134+
byteorder_str = "BGR";
135+
else
136+
byteorder_str = mp_obj_str_get_data(byteorder_str, bo_len);
102137

103-
if (byteorder->has_white && args[ARG_dotstar].u_bool)
104-
mp_raise_ValueError_varg(translate("Can not use dotstar with %s"), mp_obj_get_type_str(byteorder));
138+
parse_byteorder_string(byteorder_str, byteorder_details);
105139

106-
size_t effective_bpp = args[ARG_dotstar].u_bool ? 4 : byteorder->bpp; // Always 4 for DotStar
140+
if (byteorder_details.has_white && byteorder_details.is_dotstar)
141+
mp_raise_ValueError(translate("Can not use dotstar with a white byte"));
142+
143+
size_t effective_bpp = byteorder_details.is_dotstar ? 4 : byteorder_details.bpp; // Always 4 for DotStar
107144
size_t bytes = args[ARG_size].u_int * effective_bpp;
108145
size_t offset = args[ARG_offset].u_int;
109146
mp_buffer_info_t bufinfo, rawbufinfo;
@@ -133,28 +170,16 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a
133170
self->base.type = &pixelbuf_pixelbuf_type;
134171
self->pixels = args[ARG_size].u_int;
135172
self->bytes = bytes;
136-
self->byteorder = *byteorder; // Copied because we modify for dotstar
173+
self->byteorder = byteorder_details; // Copied because we modify for dotstar
137174
self->bytearray = args[ARG_buf].u_obj;
138175
self->two_buffers = two_buffers;
139176
self->rawbytearray = two_buffers ? args[ARG_rawbuf].u_obj : NULL;
140177
self->offset = offset;
141-
self->dotstar_mode = args[ARG_dotstar].u_bool;
142178
self->buf = (uint8_t *)bufinfo.buf + offset;
143179
self->rawbuf = two_buffers ? (uint8_t *)rawbufinfo.buf + offset : NULL;
144180
self->pixel_step = effective_bpp;
145181
self->auto_write = args[ARG_auto_write].u_bool;
146182

147-
if (self->dotstar_mode) {
148-
// Ensure sane configuration
149-
if (!self->byteorder.has_luminosity) {
150-
self->byteorder.has_luminosity = true;
151-
self->byteorder.byteorder.b += 1;
152-
self->byteorder.byteorder.g += 1;
153-
self->byteorder.byteorder.r += 1;
154-
}
155-
self->byteorder.byteorder.w = 0;
156-
}
157-
158183
// Show/auto-write callbacks
159184
self->write_function = args[ARG_write_function].u_obj;
160185
mp_obj_t function_args = args[ARG_write_args].u_obj;
@@ -187,7 +212,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a
187212
self->brightness = 1;
188213
}
189214

190-
if (self->dotstar_mode) {
215+
if (self->byteorder.is_dotstar) {
191216
// Initialize the buffer with the dotstar start bytes.
192217
// Header and end must be setup by caller
193218
for (uint i = 0; i < self->pixels * 4; i += 4) {
@@ -266,7 +291,7 @@ void pixelbuf_recalculate_brightness(pixelbuf_pixelbuf_obj_t *self) {
266291
// Compensate for shifted buffer (bpp=3 dotstar)
267292
for (uint i = 0; i < self->bytes; i++) {
268293
// Don't adjust per-pixel luminance bytes in dotstar mode
269-
if (!self->dotstar_mode || (i % 4 != 0))
294+
if (!self->byteorder.is_dotstar || (i % 4 != 0))
270295
buf[i] = rawbuf[i] * self->brightness;
271296
}
272297
}
@@ -321,7 +346,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_buf_obj = {
321346

322347
//| .. attribute:: byteorder
323348
//|
324-
//| `ByteOrder` class for the buffer (read-only)
349+
//| byteorder string for the buffer (read-only)
325350
//|
326351
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) {
327352
mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_pixelbuf_type));
@@ -397,7 +422,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp
397422

398423
if (value == MP_OBJ_SENTINEL) { // Get
399424
size_t len = slice.stop - slice.start;
400-
return pixelbuf_get_pixel_array((uint8_t *) self->buf + slice.start, len, &self->byteorder, self->pixel_step, self->dotstar_mode);
425+
return pixelbuf_get_pixel_array((uint8_t *) self->buf + slice.start, len, &self->byteorder, self->pixel_step, self->byteorder.is_dotstar);
401426
} else { // Set
402427
#if MICROPY_PY_ARRAY_SLICE_ASSIGN
403428

@@ -426,7 +451,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp
426451
if (MP_OBJ_IS_TYPE(value, &mp_type_list) || MP_OBJ_IS_TYPE(value, &mp_type_tuple) || MP_OBJ_IS_INT(value)) {
427452
pixelbuf_set_pixel(self->buf + (i * self->pixel_step),
428453
self->two_buffers ? self->rawbuf + (i * self->pixel_step) : NULL,
429-
self->brightness, item, &self->byteorder, self->dotstar_mode);
454+
self->brightness, item, &self->byteorder, self->byteorder.is_dotstar);
430455
}
431456
}
432457
if (self->auto_write)
@@ -445,10 +470,10 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp
445470

446471
if (value == MP_OBJ_SENTINEL) { // Get
447472
uint8_t *pixelstart = (uint8_t *)(self->two_buffers ? self->rawbuf : self->buf) + offset;
448-
return pixelbuf_get_pixel(pixelstart, &self->byteorder, self->dotstar_mode);
473+
return pixelbuf_get_pixel(pixelstart, &self->byteorder, self->byteorder.is_dotstar);
449474
} else { // Store
450475
pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? self->rawbuf + offset : NULL,
451-
self->brightness, value, &self->byteorder, self->dotstar_mode);
476+
self->brightness, value, &self->byteorder, self->byteorder.is_dotstar);
452477
if (self->auto_write)
453478
call_write_function(self);
454479
return mp_const_none;

shared-bindings/_pixelbuf/PixelBuf.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ typedef struct {
3636
size_t pixels;
3737
size_t bytes;
3838
size_t pixel_step;
39-
pixelbuf_byteorder_obj_t byteorder;
39+
pixelbuf_byteorder_details_t byteorder;
4040
mp_obj_t bytearray;
4141
mp_obj_t rawbytearray;
4242
mp_float_t brightness;
4343
bool two_buffers;
4444
size_t offset;
45-
bool dotstar_mode;
4645
uint8_t *rawbuf;
4746
uint8_t *buf;
4847
mp_obj_t write_function;

shared-bindings/_pixelbuf/__init__.c

Lines changed: 22 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@
4242
//| .. module:: _pixelbuf
4343
//| :synopsis: A fast RGB(W) pixel buffer library for like NeoPixel and DotStar.
4444
//|
45-
//| The `_pixelbuf` module provides :py:class:`PixelBuf` and :py:class:`ByteOrder` classes to accelerate
45+
//| The `_pixelbuf` module provides the :py:class:`PixelBuf` class to accelerate
4646
//| RGB(W) strip/matrix manipulation, such as DotStar and Neopixel.
4747
//|
48+
//| Byteorders are configured with strings, such as "RGB" or "RGBD".
49+
//| TODO: Pull in docs from pypixelbuf.
4850

4951
//| Libraries
5052
//|
@@ -53,31 +55,6 @@
5355
//|
5456
//| PixelBuf
5557

56-
//| .. class:: ByteOrder()
57-
//|
58-
//| Classes representing byteorders for circuitpython
59-
60-
61-
//| .. attribute:: bpp
62-
//|
63-
//| The number of bytes per pixel (read-only)
64-
//|
65-
66-
//| .. attribute:: has_white
67-
//|
68-
//| Whether the pixel has white (in addition to RGB)
69-
//|
70-
71-
//| .. attribute:: has_luminosity
72-
//|
73-
//| Whether the pixel has luminosity (in addition to RGB)
74-
//|
75-
76-
//| .. attribute:: byteorder
77-
//|
78-
//| Tuple of byte order (r, g, b) or (r, g, b, w) or (r, g, b, l)
79-
//|
80-
8158

8259
STATIC void pixelbuf_byteorder_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
8360
mp_check_self(MP_OBJ_IS_TYPE(self_in, &pixelbuf_byteorder_type));
@@ -113,33 +90,6 @@ STATIC void pixelbuf_byteorder_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest)
11390
}
11491
}
11592

116-
STATIC mp_obj_t pixelbuf_byteorder_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
117-
pixelbuf_byteorder_obj_t *self = MP_OBJ_TO_PTR(self_in);
118-
switch (op) {
119-
case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->bpp);
120-
default: return MP_OBJ_NULL; // op not supported
121-
}
122-
}
123-
124-
const mp_obj_type_t pixelbuf_byteorder_type = {
125-
{ &mp_type_type },
126-
.name = MP_QSTR_ByteOrder,
127-
.print = pixelbuf_byteorder_print,
128-
.unary_op = pixelbuf_byteorder_unary_op,
129-
.attr = pixelbuf_byteorder_attr,
130-
};
131-
132-
133-
// This macro is used to simplify RGB subclass definition
134-
#define PIXELBUF_BYTEORDER(p_name, p_bpp, p_r, p_g, p_b, p_w, p_has_white, p_has_luminosity) \
135-
const pixelbuf_byteorder_obj_t byteorder_## p_name = { \
136-
{ &pixelbuf_byteorder_type }, \
137-
.name = MP_QSTR_## p_name, \
138-
.bpp = p_bpp, \
139-
.byteorder = { p_r, p_g, p_b, p_w }, \
140-
.has_white = p_has_white, \
141-
.has_luminosity = p_has_luminosity, \
142-
};
14393

14494
//| .. function:: wheel(n)
14595
//|
@@ -290,36 +240,29 @@ PIXELBUF_BYTEORDER(LBGR, 4, 3, 2, 1, 0, false, true)
290240
STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = {
291241
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) },
292242
{ MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) },
293-
{ MP_ROM_QSTR(MP_QSTR_ByteOrder), MP_ROM_PTR(&pixelbuf_byteorder_type) },
294-
{ MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_PTR(&byteorder_RGB) },
295-
{ MP_ROM_QSTR(MP_QSTR_RBG), MP_ROM_PTR(&byteorder_RBG) },
296-
{ MP_ROM_QSTR(MP_QSTR_GRB), MP_ROM_PTR(&byteorder_GRB) },
297-
{ MP_ROM_QSTR(MP_QSTR_GBR), MP_ROM_PTR(&byteorder_GBR) },
298-
{ MP_ROM_QSTR(MP_QSTR_BRG), MP_ROM_PTR(&byteorder_BRG) },
299-
{ MP_ROM_QSTR(MP_QSTR_BGR), MP_ROM_PTR(&byteorder_BGR) },
300-
{ MP_ROM_QSTR(MP_QSTR_RGBW), MP_ROM_PTR(&byteorder_RGBW) },
301-
{ MP_ROM_QSTR(MP_QSTR_RBGW), MP_ROM_PTR(&byteorder_RBGW) },
302-
{ MP_ROM_QSTR(MP_QSTR_GRBW), MP_ROM_PTR(&byteorder_GRBW) },
303-
{ MP_ROM_QSTR(MP_QSTR_GBRW), MP_ROM_PTR(&byteorder_GBRW) },
304-
{ MP_ROM_QSTR(MP_QSTR_BRGW), MP_ROM_PTR(&byteorder_BRGW) },
305-
{ MP_ROM_QSTR(MP_QSTR_BGRW), MP_ROM_PTR(&byteorder_BGRW) },
306-
{ MP_ROM_QSTR(MP_QSTR_LRGB), MP_ROM_PTR(&byteorder_LRGB) },
307-
{ MP_ROM_QSTR(MP_QSTR_LRBG), MP_ROM_PTR(&byteorder_LRBG) },
308-
{ MP_ROM_QSTR(MP_QSTR_LGRB), MP_ROM_PTR(&byteorder_LGRB) },
309-
{ MP_ROM_QSTR(MP_QSTR_LGBR), MP_ROM_PTR(&byteorder_LGBR) },
310-
{ MP_ROM_QSTR(MP_QSTR_LBRG), MP_ROM_PTR(&byteorder_LBRG) },
311-
{ MP_ROM_QSTR(MP_QSTR_LBGR), MP_ROM_PTR(&byteorder_LBGR) },
312-
{ MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) },
243+
{ MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_QSTR(MP_QSTR_RGB) },
244+
{ MP_ROM_QSTR(MP_QSTR_RBG), MP_ROM_QSTR(MP_QSTR_RBG) },
245+
{ MP_ROM_QSTR(MP_QSTR_GRB), MP_ROM_QSTR(MP_QSTR_GRB) },
246+
{ MP_ROM_QSTR(MP_QSTR_GBR), MP_ROM_QSTR(MP_QSTR_GBR) },
247+
{ MP_ROM_QSTR(MP_QSTR_BRG), MP_ROM_QSTR(MP_QSTR_BRG) },
248+
{ MP_ROM_QSTR(MP_QSTR_BGR), MP_ROM_QSTR(MP_QSTR_BGR) },
249+
{ MP_ROM_QSTR(MP_QSTR_RGBW), MP_ROM_QSTR(MP_QSTR_RGBW) },
250+
{ MP_ROM_QSTR(MP_QSTR_RBGW), MP_ROM_QSTR(MP_QSTR_RBGW) },
251+
{ MP_ROM_QSTR(MP_QSTR_GRBW), MP_ROM_QSTR(MP_QSTR_GRBW) },
252+
{ MP_ROM_QSTR(MP_QSTR_GBRW), MP_ROM_QSTR(MP_QSTR_GBRW) },
253+
{ MP_ROM_QSTR(MP_QSTR_BRGW), MP_ROM_QSTR(MP_QSTR_BRGW) },
254+
{ MP_ROM_QSTR(MP_QSTR_BGRW), MP_ROM_QSTR(MP_QSTR_BGRW) },
255+
{ MP_ROM_QSTR(MP_QSTR_RGBD), MP_ROM_QSTR(MP_QSTR_RGBD) },
256+
{ MP_ROM_QSTR(MP_QSTR_RBGD), MP_ROM_QSTR(MP_QSTR_RBGD) },
257+
{ MP_ROM_QSTR(MP_QSTR_GRBD), MP_ROM_QSTR(MP_QSTR_GRBD) },
258+
{ MP_ROM_QSTR(MP_QSTR_GBRD), MP_ROM_QSTR(MP_QSTR_GBRD) },
259+
{ MP_ROM_QSTR(MP_QSTR_BRGD), MP_ROM_QSTR(MP_QSTR_BRGD) },
260+
{ MP_ROM_QSTR(MP_QSTR_BGRD), MP_ROM_QSTR(MP_QSTR_BGRD) },
261+
{ MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_QSTR(&pixelbuf_wheel_obj) },
313262
};
314263

315264
STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_table);
316265

317-
STATIC void pixelbuf_byteorder_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
318-
pixelbuf_byteorder_obj_t *self = MP_OBJ_TO_PTR(self_in);
319-
mp_printf(print, "%q.%q", MP_QSTR__pixelbuf, self->name);
320-
return;
321-
}
322-
323266
const mp_obj_module_t pixelbuf_module = {
324267
.base = { &mp_type_module },
325268
.globals = (mp_obj_dict_t*)&pixelbuf_module_globals,

shared-bindings/_pixelbuf/__init__.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929

3030
#include "common-hal/digitalio/DigitalInOut.h"
3131

32-
STATIC void pixelbuf_byteorder_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind);
3332
const int32_t colorwheel(float pos);
34-
const mp_obj_type_t pixelbuf_byteorder_type;
3533
extern void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* gpio, uint8_t *pixels, uint32_t numBytes);
3634

3735
#endif //CP_SHARED_BINDINGS_PIXELBUF_INIT_H

shared-bindings/_pixelbuf/types.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ typedef struct {
3737
} pixelbuf_rgbw_t;
3838

3939
typedef struct {
40-
mp_obj_base_t base;
41-
qstr name;
4240
uint8_t bpp;
4341
pixelbuf_rgbw_t byteorder;
4442
bool has_white;
45-
bool has_luminosity;
46-
} pixelbuf_byteorder_obj_t;
43+
bool is_dotstar;
44+
} pixelbuf_byteorder_details_t;
4745

4846
#endif // CIRCUITPYTHON_PIXELBUF_TYPES_H

0 commit comments

Comments
 (0)