From 12193913a802e3b9c72079a93cb40c97d95cc683 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 17:30:17 -0500 Subject: [PATCH] move native fill to a helper to work around being unable to call a subclass show method from the native superclass --- locale/ID.po | 7 +++++-- locale/circuitpython.pot | 7 +++++-- locale/de_DE.po | 7 +++++-- locale/en_US.po | 7 +++++-- locale/en_x_pirate.po | 7 +++++-- locale/es.po | 7 +++++-- locale/fil.po | 7 +++++-- locale/fr.po | 7 +++++-- locale/it_IT.po | 7 +++++-- locale/ko.po | 7 +++++-- locale/pl.po | 7 +++++-- locale/pt_BR.po | 7 +++++-- locale/zh_Latn_pinyin.po | 7 +++++-- shared-bindings/_pixelbuf/PixelBuf.c | 20 -------------------- shared-bindings/_pixelbuf/__init__.c | 24 ++++++++++++++++++++++++ 15 files changed, 89 insertions(+), 46 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 4808727066..20662ae9db 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -600,6 +600,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1078,7 +1082,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Nilai sampel terlalu tinggi. Nilai harus kurang dari %d" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 7adde9ba85..5cf44cc356 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -589,6 +589,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1062,7 +1066,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 4a2bc89947..17f2e38280 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -593,6 +593,10 @@ msgstr "Erwartet ein(e) %q" msgid "Expected a Characteristic" msgstr "Characteristic wird erwartet" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "Ein Service wird erwartet" @@ -1079,7 +1083,6 @@ msgid "Sample rate must be positive" msgstr "Abtastrate muss positiv sein" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Abtastrate zu hoch. Wert muss unter %d liegen" diff --git a/locale/en_US.po b/locale/en_US.po index 135aeda172..e6fbfc471b 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -589,6 +589,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1062,7 +1066,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 5ac17778af..5635102301 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -593,6 +593,10 @@ msgstr "" msgid "Expected a Characteristic" msgstr "" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1066,7 +1070,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/es.po b/locale/es.po index 331c1a3edd..c9688a41b1 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -595,6 +595,10 @@ msgstr "Se espera un %q" msgid "Expected a Characteristic" msgstr "Se esperaba una Característica." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1080,7 +1084,6 @@ msgid "Sample rate must be positive" msgstr "Sample rate debe ser positivo" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d" diff --git a/locale/fil.po b/locale/fil.po index a867e2a4f8..94f39f4064 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -602,6 +602,10 @@ msgstr "Umasa ng %q" msgid "Expected a Characteristic" msgstr "Hindi mabasa and Characteristic." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1086,7 +1090,6 @@ msgid "Sample rate must be positive" msgstr "Sample rate ay dapat positibo" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Sample rate ay masyadong mataas. Ito ay dapat hindi hiigit sa %d" diff --git a/locale/fr.po b/locale/fr.po index 22e3b5b5bc..42209a045e 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -605,6 +605,10 @@ msgstr "Attendu un %q" msgid "Expected a Characteristic" msgstr "Une 'Characteristic' est attendue" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1100,7 +1104,6 @@ msgid "Sample rate must be positive" msgstr "Le taux d'échantillonage doit être positif" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Taux d'échantillonage trop élevé. Doit être inf. à %d" diff --git a/locale/it_IT.po b/locale/it_IT.po index 575263b4be..684e2a90b9 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -602,6 +602,10 @@ msgstr "Atteso un %q" msgid "Expected a Characteristic" msgstr "Non è possibile aggiungere Characteristic." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1096,7 +1100,6 @@ msgid "Sample rate must be positive" msgstr "STA deve essere attiva" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 51544984ed..7b4240800b 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -593,6 +593,10 @@ msgstr "%q 이 예상되었습니다." msgid "Expected a Characteristic" msgstr "특성(Characteristic)이 예상되었습니다." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1066,7 +1070,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index 9b2208849b..1ef686e451 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -592,6 +592,10 @@ msgstr "Oczekiwano %q" msgid "Expected a Characteristic" msgstr "Oczekiwano charakterystyki" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1067,7 +1071,6 @@ msgid "Sample rate must be positive" msgstr "Częstotliwość próbkowania musi być dodatnia" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Zbyt wysoka częstotliwość próbkowania. Musi być mniejsza niż %d" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index a2ccd2625d..9d36696ce7 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-12 15:33-0800\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -597,6 +597,10 @@ msgstr "Esperado um" msgid "Expected a Characteristic" msgstr "Não é possível adicionar Característica." +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "" @@ -1079,7 +1083,6 @@ msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Taxa de amostragem muito alta. Deve ser menor que %d" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 5b636ff606..cb907e0a1f 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-12-13 13:44-0500\n" +"POT-Creation-Date: 2020-01-01 17:29-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -593,6 +593,10 @@ msgstr "Yùqí %q" msgid "Expected a Characteristic" msgstr "Yùqí de tèdiǎn" +#: shared-bindings/_pixelbuf/__init__.c +msgid "Expected a PixelBuf instance" +msgstr "" + #: shared-bindings/_bleio/Characteristic.c msgid "Expected a Service" msgstr "Yùqí fúwù" @@ -1072,7 +1076,6 @@ msgid "Sample rate must be positive" msgstr "Cǎiyàng lǜ bìxū wèi zhèng shù" #: ports/atmel-samd/common-hal/audioio/AudioOut.c -#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Cǎiyàng lǜ tài gāo. Tā bìxū xiǎoyú %d" diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index 7c624a8fdf..e422818546 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -341,25 +341,6 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show); -//| .. method:: fill(color) -//| -//| Fills the entire buffer with the given color. -//| - -STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { - pixelbuf_pixelbuf_obj_t *self = native_pixelbuf(self_in); - - for (size_t offset = 0; offset < self->bytes; offset+= self->pixel_step) { - pixelbuf_set_pixel(self->buf + offset, self->two_buffers ? (self->rawbuf + offset) : NULL, - self->brightness, value, &self->byteorder, self->byteorder.is_dotstar); - } - if (self->auto_write) - call_show(self_in); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill); - - //| .. method:: __getitem__(index) //| //| Returns the pixel value at the given index. @@ -464,7 +445,6 @@ STATIC const mp_rom_map_elem_t pixelbuf_pixelbuf_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_buf), MP_ROM_PTR(&pixelbuf_pixelbuf_buf_obj)}, { MP_ROM_QSTR(MP_QSTR_byteorder), MP_ROM_PTR(&pixelbuf_pixelbuf_byteorder_str)}, { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&pixelbuf_pixelbuf_show_obj)}, - { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&pixelbuf_pixelbuf_fill_obj)}, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_pixelbuf_locals_dict, pixelbuf_pixelbuf_locals_dict_table); diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index 75482cbc26..433f1d97b8 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -82,10 +82,34 @@ const int32_t colorwheel(float pos) { } } + +//| .. function:: fill(pixelbuf, color) +//| +//| Fills the given pixelbuf with the given color. +//| + +STATIC mp_obj_t pixelbuf_fill(mp_obj_t pixelbuf_in, mp_obj_t value) { + mp_obj_t obj = mp_instance_cast_to_native_base(pixelbuf_in, &pixelbuf_pixelbuf_type); + if (obj == MP_OBJ_NULL) + mp_raise_TypeError(translate("Expected a PixelBuf instance")); + pixelbuf_pixelbuf_obj_t *pixelbuf = MP_OBJ_TO_PTR(obj); + + for (size_t offset = 0; offset < pixelbuf->bytes; offset+= pixelbuf->pixel_step) { + pixelbuf_set_pixel(pixelbuf->buf + offset, pixelbuf->two_buffers ? (pixelbuf->rawbuf + offset) : NULL, + pixelbuf->brightness, value, &pixelbuf->byteorder, pixelbuf->byteorder.is_dotstar); + } + if (pixelbuf->auto_write) + call_show(pixelbuf_in); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_fill_obj, pixelbuf_fill); + + STATIC const mp_rom_map_elem_t pixelbuf_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pixelbuf) }, { MP_ROM_QSTR(MP_QSTR_PixelBuf), MP_ROM_PTR(&pixelbuf_pixelbuf_type) }, { MP_ROM_QSTR(MP_QSTR_wheel), MP_ROM_PTR(&pixelbuf_wheel_obj) }, + { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&pixelbuf_fill_obj) }, }; STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_table);