diff options
Diffstat (limited to 'shared-bindings/_pixelbuf')
| -rw-r--r-- | shared-bindings/_pixelbuf/PixelBuf.c | 36 | ||||
| -rw-r--r-- | shared-bindings/_pixelbuf/PixelBuf.h | 6 | ||||
| -rw-r--r-- | shared-bindings/_pixelbuf/__init__.c | 6 | ||||
| -rw-r--r-- | shared-bindings/_pixelbuf/__init__.h | 2 |
4 files changed, 26 insertions, 24 deletions
diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index a4b5b5b1b..22923e97d 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -46,7 +46,7 @@ extern const int32_t colorwheel(float pos); -static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed); +static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t *parsed); //| class PixelBuf: //| """A fast RGB[W] pixel buffer for LED and similar devices.""" @@ -113,13 +113,13 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a pixelbuf_pixelbuf_obj_t *self = m_new_obj(pixelbuf_pixelbuf_obj_t); self->base.type = &pixelbuf_pixelbuf_type; common_hal__pixelbuf_pixelbuf_construct(self, args[ARG_size].u_int, - &byteorder_details, brightness, args[ARG_auto_write].u_bool, header_bufinfo.buf, - header_bufinfo.len, trailer_bufinfo.buf, trailer_bufinfo.len); + &byteorder_details, brightness, args[ARG_auto_write].u_bool, header_bufinfo.buf, + header_bufinfo.len, trailer_bufinfo.buf, trailer_bufinfo.len); return MP_OBJ_FROM_PTR(self); } -static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed) { +static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t *parsed) { if (!MP_OBJ_IS_STR(byteorder_obj)) { mp_raise_TypeError(translate("byteorder is not a string")); } @@ -242,10 +242,12 @@ const mp_obj_property_t pixelbuf_pixelbuf_byteorder_str = { STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { switch (op) { - case MP_UNARY_OP_BOOL: return mp_const_true; + case MP_UNARY_OP_BOOL: + return mp_const_true; case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(common_hal__pixelbuf_pixelbuf_get_len(self_in)); - default: return MP_OBJ_NULL; // op not supported + default: + return MP_OBJ_NULL; // op not supported } } @@ -303,7 +305,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } if (0) { -#if MICROPY_PY_BUILTINS_SLICE + #if MICROPY_PY_BUILTINS_SLICE } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { mp_bound_slice_t slice; @@ -332,7 +334,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } if (value == MP_OBJ_SENTINEL) { // Get - mp_obj_tuple_t* t = MP_OBJ_TO_PTR(mp_obj_new_tuple(slice_len, NULL)); + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(slice_len, NULL)); for (uint i = 0; i < slice_len; i++) { t->items[i] = common_hal__pixelbuf_pixelbuf_get_pixel(self_in, i * slice.step + slice.start); } @@ -352,7 +354,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp return MP_OBJ_NULL; // op not supported #endif } -#endif + #endif } else { // Single index rather than slice. size_t length = common_hal__pixelbuf_pixelbuf_get_len(self_in); size_t index = mp_get_index(mp_obj_get_type(self_in), length, index_in, false); @@ -379,12 +381,12 @@ STATIC MP_DEFINE_CONST_DICT(pixelbuf_pixelbuf_locals_dict, pixelbuf_pixelbuf_loc const mp_obj_type_t pixelbuf_pixelbuf_type = { - { &mp_type_type }, - .name = MP_QSTR_PixelBuf, - .subscr = pixelbuf_pixelbuf_subscr, - .make_new = pixelbuf_pixelbuf_make_new, - .unary_op = pixelbuf_pixelbuf_unary_op, - .getiter = mp_obj_new_generic_iterator, - .print = NULL, - .locals_dict = (mp_obj_t)&pixelbuf_pixelbuf_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_PixelBuf, + .subscr = pixelbuf_pixelbuf_subscr, + .make_new = pixelbuf_pixelbuf_make_new, + .unary_op = pixelbuf_pixelbuf_unary_op, + .getiter = mp_obj_new_generic_iterator, + .print = NULL, + .locals_dict = (mp_obj_t)&pixelbuf_pixelbuf_locals_dict, }; diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index d41082059..5e83b9b2d 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -32,8 +32,8 @@ extern const mp_obj_type_t pixelbuf_pixelbuf_type; void common_hal__pixelbuf_pixelbuf_construct(pixelbuf_pixelbuf_obj_t *self, size_t n, - pixelbuf_byteorder_details_t* byteorder, mp_float_t brightness, bool auto_write, uint8_t* header, - size_t header_len, uint8_t* trailer, size_t trailer_len); + pixelbuf_byteorder_details_t *byteorder, mp_float_t brightness, bool auto_write, uint8_t *header, + size_t header_len, uint8_t *trailer, size_t trailer_len); // These take mp_obj_t because they are called on subclasses of PixelBuf. uint8_t common_hal__pixelbuf_pixelbuf_get_bpp(mp_obj_t self); @@ -47,6 +47,6 @@ void common_hal__pixelbuf_pixelbuf_fill(mp_obj_t self, mp_obj_t item); void common_hal__pixelbuf_pixelbuf_show(mp_obj_t self); mp_obj_t common_hal__pixelbuf_pixelbuf_get_pixel(mp_obj_t self, size_t index); void common_hal__pixelbuf_pixelbuf_set_pixel(mp_obj_t self, size_t index, mp_obj_t item); -void common_hal__pixelbuf_pixelbuf_set_pixels(mp_obj_t self_in, size_t start, mp_int_t step, size_t slice_len, mp_obj_t* values, mp_obj_tuple_t *flatten_to); +void common_hal__pixelbuf_pixelbuf_set_pixels(mp_obj_t self_in, size_t start, mp_int_t step, size_t slice_len, mp_obj_t *values, mp_obj_tuple_t *flatten_to); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index fdd02509c..5e87bacab 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -59,9 +59,9 @@ const int32_t colorwheel(float pos) { if (pos > 255) { pos = pos - ((uint32_t)(pos / 256) * 256); } - if (pos < 85) + if (pos < 85) { return (uint8_t)(255 - (pos * 3)) << 16 | (uint8_t)(pos * 3) << 8; - else if (pos < 170) { + } else if (pos < 170) { pos -= 85; return (uint8_t)(255 - (pos * 3)) << 8 | (uint8_t)(pos * 3); } else { @@ -81,5 +81,5 @@ STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_tab const mp_obj_module_t pixelbuf_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&pixelbuf_module_globals, + .globals = (mp_obj_dict_t *)&pixelbuf_module_globals, }; diff --git a/shared-bindings/_pixelbuf/__init__.h b/shared-bindings/_pixelbuf/__init__.h index 0e8c4a37f..890543d3e 100644 --- a/shared-bindings/_pixelbuf/__init__.h +++ b/shared-bindings/_pixelbuf/__init__.h @@ -31,4 +31,4 @@ const int32_t colorwheel(float pos); -#endif //CP_SHARED_BINDINGS_PIXELBUF_INIT_H +#endif // CP_SHARED_BINDINGS_PIXELBUF_INIT_H |
