summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorMatthew Newberg <mnewberg@gmail.com>2019-09-06 16:23:24 -0400
committerMatthew Newberg <mnewberg@gmail.com>2019-09-06 16:23:24 -0400
commit8e552324928ea0081cb67c818a26d2b83da55f05 (patch)
tree2432a8aa377e835cac847c149929b7d45cbb1263 /shared-bindings
parentb2fb5ac1c12a21d9b6cb8c60a30db65db399ca66 (diff)
Use kwargs for dither in ColorConverter constructor
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/displayio/ColorConverter.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c
index 8a74e467b..75eb8ba32 100644
--- a/shared-bindings/displayio/ColorConverter.c
+++ b/shared-bindings/displayio/ColorConverter.c
@@ -47,22 +47,23 @@
//|
//| Create a ColorConverter object to convert color formats. Only supports RGB888 to RGB565
//| currently.
-//|
+//| :param bool dither: Adds random noise to dither the output image
+
// TODO(tannewt): Add support for other color formats.
//|
STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- mp_arg_check_num(n_args, kw_args, 0, 1, false);
+ enum { ARG_dither};
+
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_dither, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
+ };
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
displayio_colorconverter_t *self = m_new_obj(displayio_colorconverter_t);
self->base.type = &displayio_colorconverter_type;
-
- bool dither = false;
-
- if (n_args > 0) {
- dither = mp_obj_is_true(pos_args[0]);
- }
- common_hal_displayio_colorconverter_construct(self, dither);
+ common_hal_displayio_colorconverter_construct(self, args[ARG_dither].u_bool);
return MP_OBJ_FROM_PTR(self);
}