From 81fe8060d76d54a20701e6944dd29cdfab9fed4f Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Wed, 20 Mar 2019 19:29:20 +0100 Subject: [PATCH] Properly calculate BPP for displayio.Bitmap Fix #1669 --- locale/ID.po | 12 ++++++------ locale/circuitpython.pot | 12 ++++++------ locale/de_DE.po | 16 ++++++++++------ locale/en_US.po | 12 ++++++------ locale/en_x_pirate.po | 12 ++++++------ locale/es.po | 15 +++++++++------ locale/fil.po | 15 +++++++++------ locale/fr.po | 15 +++++++++------ locale/it_IT.po | 12 ++++++------ locale/pt_BR.po | 12 ++++++------ shared-bindings/displayio/Bitmap.c | 16 ++++++++++++---- 11 files changed, 85 insertions(+), 64 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 694b2964fd..1df86a7d25 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-03-25 14:08+0100\n" +"POT-Creation-Date: 2019-03-25 19:40+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -762,14 +762,10 @@ msgid "Frequency captured is above capability. Capture Paused." msgstr "" #: shared-bindings/bitbangio/SPI.c shared-bindings/bitbangio/I2C.c -#: shared-bindings/busio/SPI.c +#: shared-bindings/busio/SPI.c shared-bindings/busio/I2C.c msgid "Function requires lock" msgstr "" -#: shared-bindings/busio/I2C.c -msgid "Function requires lock." -msgstr "" - #: ports/esp8266/common-hal/digitalio/DigitalInOut.c msgid "GPIO16 does not support pull up." msgstr "GPIO16 tidak mendukung pull up" @@ -2838,6 +2834,10 @@ msgstr "" msgid "unsupported types for %q: '%s', '%s'" msgstr "" +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + #: ports/esp8266/modnetwork.c msgid "wifi_set_ip_info() failed" msgstr "wifi_set_ip_info() gagal" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 735459a47e..645b2e4add 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-03-25 14:08+0100\n" +"POT-Creation-Date: 2019-03-25 19:40+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -737,14 +737,10 @@ msgid "Frequency captured is above capability. Capture Paused." msgstr "" #: shared-bindings/bitbangio/SPI.c shared-bindings/bitbangio/I2C.c -#: shared-bindings/busio/SPI.c +#: shared-bindings/busio/SPI.c shared-bindings/busio/I2C.c msgid "Function requires lock" msgstr "" -#: shared-bindings/busio/I2C.c -msgid "Function requires lock." -msgstr "" - #: ports/esp8266/common-hal/digitalio/DigitalInOut.c msgid "GPIO16 does not support pull up." msgstr "" @@ -2789,6 +2785,10 @@ msgstr "" msgid "unsupported types for %q: '%s', '%s'" msgstr "" +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + #: ports/esp8266/modnetwork.c msgid "wifi_set_ip_info() failed" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 21fe860eb4..87e9659141 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-03-25 14:08+0100\n" +"POT-Creation-Date: 2019-03-25 19:40+0100\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -742,14 +742,10 @@ msgid "Frequency captured is above capability. Capture Paused." msgstr "" #: shared-bindings/bitbangio/SPI.c shared-bindings/bitbangio/I2C.c -#: shared-bindings/busio/SPI.c +#: shared-bindings/busio/SPI.c shared-bindings/busio/I2C.c msgid "Function requires lock" msgstr "Die Funktion erwartet, dass der 'lock'-Befehl zuvor ausgeführt wurde" -#: shared-bindings/busio/I2C.c -msgid "Function requires lock." -msgstr "Die Funktion erwartet, dass der 'lock'-Befehl zuvor ausgeführt wurde" - #: ports/esp8266/common-hal/digitalio/DigitalInOut.c msgid "GPIO16 does not support pull up." msgstr "GPIO16 unterstützt pull up nicht" @@ -2851,6 +2847,10 @@ msgstr "nicht unterstützter Typ für Operator" msgid "unsupported types for %q: '%s', '%s'" msgstr "nicht unterstützte Typen für %q: '%s', '%s'" +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + #: ports/esp8266/modnetwork.c msgid "wifi_set_ip_info() failed" msgstr "wifi_set_ip_info() fehlgeschlagen" @@ -2889,5 +2889,9 @@ msgstr "" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Kann den Attributwert nicht lesen. Status: 0x%04x" +#~ msgid "Function requires lock." +#~ msgstr "" +#~ "Die Funktion erwartet, dass der 'lock'-Befehl zuvor ausgeführt wurde" + #~ msgid "Only Windows format, uncompressed BMP supported %d" #~ msgstr "Nur unkomprimiertes Windows-Format (BMP) unterstützt %d" diff --git a/locale/en_US.po b/locale/en_US.po index 2f29498b95..da189c6616 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-03-25 14:08+0100\n" +"POT-Creation-Date: 2019-03-25 19:40+0100\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -737,14 +737,10 @@ msgid "Frequency captured is above capability. Capture Paused." msgstr "" #: shared-bindings/bitbangio/SPI.c shared-bindings/bitbangio/I2C.c -#: shared-bindings/busio/SPI.c +#: shared-bindings/busio/SPI.c shared-bindings/busio/I2C.c msgid "Function requires lock" msgstr "" -#: shared-bindings/busio/I2C.c -msgid "Function requires lock." -msgstr "" - #: ports/esp8266/common-hal/digitalio/DigitalInOut.c msgid "GPIO16 does not support pull up." msgstr "" @@ -2789,6 +2785,10 @@ msgstr "" msgid "unsupported types for %q: '%s', '%s'" msgstr "" +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + #: ports/esp8266/modnetwork.c msgid "wifi_set_ip_info() failed" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 0bcef80668..f9bb0f0ffe 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-03-25 14:08+0100\n" +"POT-Creation-Date: 2019-03-25 19:40+0100\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -741,14 +741,10 @@ msgid "Frequency captured is above capability. Capture Paused." msgstr "" #: shared-bindings/bitbangio/SPI.c shared-bindings/bitbangio/I2C.c -#: shared-bindings/busio/SPI.c +#: shared-bindings/busio/SPI.c shared-bindings/busio/I2C.c msgid "Function requires lock" msgstr "" -#: shared-bindings/busio/I2C.c -msgid "Function requires lock." -msgstr "" - #: ports/esp8266/common-hal/digitalio/DigitalInOut.c msgid "GPIO16 does not support pull up." msgstr "" @@ -2793,6 +2789,10 @@ msgstr "" msgid "unsupported types for %q: '%s', '%s'" msgstr "" +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + #: ports/esp8266/modnetwork.c msgid "wifi_set_ip_info() failed" msgstr "" diff --git a/locale/es.po b/locale/es.po index efae8c368c..9f71ac1600 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-03-25 14:08+0100\n" +"POT-Creation-Date: 2019-03-25 19:40+0100\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -767,14 +767,10 @@ msgid "Frequency captured is above capability. Capture Paused." msgstr "" #: shared-bindings/bitbangio/SPI.c shared-bindings/bitbangio/I2C.c -#: shared-bindings/busio/SPI.c +#: shared-bindings/busio/SPI.c shared-bindings/busio/I2C.c msgid "Function requires lock" msgstr "La función requiere lock" -#: shared-bindings/busio/I2C.c -msgid "Function requires lock." -msgstr "La función requiere lock" - #: ports/esp8266/common-hal/digitalio/DigitalInOut.c msgid "GPIO16 does not support pull up." msgstr "GPIO16 no soporta pull up." @@ -2874,6 +2870,10 @@ msgstr "tipo de operador no soportado" msgid "unsupported types for %q: '%s', '%s'" msgstr "tipos no soportados para %q: '%s', '%s'" +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + #: ports/esp8266/modnetwork.c msgid "wifi_set_ip_info() failed" msgstr "wifi_set_ip_info() ha fallado" @@ -2916,6 +2916,9 @@ msgstr "paso cero" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "No se puede leer el valor del atributo. status 0x%02x" +#~ msgid "Function requires lock." +#~ msgstr "La función requiere lock" + #~ msgid "Only Windows format, uncompressed BMP supported %d" #~ msgstr "Solo formato Windows, BMP sin comprimir soportado %d" diff --git a/locale/fil.po b/locale/fil.po index 42a1c9e262..230a095971 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-03-25 14:08+0100\n" +"POT-Creation-Date: 2019-03-25 19:40+0100\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -765,14 +765,10 @@ msgid "Frequency captured is above capability. Capture Paused." msgstr "" #: shared-bindings/bitbangio/SPI.c shared-bindings/bitbangio/I2C.c -#: shared-bindings/busio/SPI.c +#: shared-bindings/busio/SPI.c shared-bindings/busio/I2C.c msgid "Function requires lock" msgstr "Function nangangailangan ng lock" -#: shared-bindings/busio/I2C.c -msgid "Function requires lock." -msgstr "Kailangan ng lock ang function." - #: ports/esp8266/common-hal/digitalio/DigitalInOut.c msgid "GPIO16 does not support pull up." msgstr "Walang pull down support ang GPI016." @@ -2880,6 +2876,10 @@ msgstr "hindi sinusuportahang type para sa operator" msgid "unsupported types for %q: '%s', '%s'" msgstr "hindi sinusuportahang type para sa %q: '%s', '%s'" +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + #: ports/esp8266/modnetwork.c msgid "wifi_set_ip_info() failed" msgstr "nabigo ang wifi_set_ip_info()" @@ -2922,6 +2922,9 @@ msgstr "zero step" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Hindi mabasa ang value ng attribute, status: 0x%08lX" +#~ msgid "Function requires lock." +#~ msgstr "Kailangan ng lock ang function." + #~ msgid "Only Windows format, uncompressed BMP supported %d" #~ msgstr "Tanging Windows format, uncompressed BMP lamang ang supportado %d" diff --git a/locale/fr.po b/locale/fr.po index 1710a5ae97..f9c0078250 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-03-25 14:08+0100\n" +"POT-Creation-Date: 2019-03-25 19:40+0100\n" "PO-Revision-Date: 2018-12-23 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -764,14 +764,10 @@ msgid "Frequency captured is above capability. Capture Paused." msgstr "" #: shared-bindings/bitbangio/SPI.c shared-bindings/bitbangio/I2C.c -#: shared-bindings/busio/SPI.c +#: shared-bindings/busio/SPI.c shared-bindings/busio/I2C.c msgid "Function requires lock" msgstr "La fonction nécessite un verrou" -#: shared-bindings/busio/I2C.c -msgid "Function requires lock." -msgstr "La fonction nécessite un verrou." - #: ports/esp8266/common-hal/digitalio/DigitalInOut.c msgid "GPIO16 does not support pull up." msgstr "le GPIO16 ne supporte pas le tirage (pull-up)" @@ -2902,6 +2898,10 @@ msgstr "type non supporté pour l'opérateur" msgid "unsupported types for %q: '%s', '%s'" msgstr "type non supporté pour %q: '%s', '%s'" +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + #: ports/esp8266/modnetwork.c msgid "wifi_set_ip_info() failed" msgstr "wifi_set_ip_info() a échoué" @@ -2945,6 +2945,9 @@ msgstr "'step' nul" #~ msgid "Failed to read attribute value, err %0x04x" #~ msgstr "Impossible de lire la valeur de l'attribut. status: 0x%08lX" +#~ msgid "Function requires lock." +#~ msgstr "La fonction nécessite un verrou." + #~ msgid "Only Windows format, uncompressed BMP supported %d" #~ msgstr "Seul les BMP non-compressé au format Windows sont supportés %d" diff --git a/locale/it_IT.po b/locale/it_IT.po index 758307ff33..693f8a03c2 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-03-25 14:08+0100\n" +"POT-Creation-Date: 2019-03-25 19:40+0100\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -764,14 +764,10 @@ msgid "Frequency captured is above capability. Capture Paused." msgstr "" #: shared-bindings/bitbangio/SPI.c shared-bindings/bitbangio/I2C.c -#: shared-bindings/busio/SPI.c +#: shared-bindings/busio/SPI.c shared-bindings/busio/I2C.c msgid "Function requires lock" msgstr "" -#: shared-bindings/busio/I2C.c -msgid "Function requires lock." -msgstr "" - #: ports/esp8266/common-hal/digitalio/DigitalInOut.c msgid "GPIO16 does not support pull up." msgstr "GPIO16 non supporta pull-up" @@ -2876,6 +2872,10 @@ msgstr "tipo non supportato per l'operando" msgid "unsupported types for %q: '%s', '%s'" msgstr "tipi non supportati per %q: '%s', '%s'" +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + #: ports/esp8266/modnetwork.c msgid "wifi_set_ip_info() failed" msgstr "wifi_set_ip_info() faillito" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 5d00b4e03e..587ed00bac 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-03-25 14:08+0100\n" +"POT-Creation-Date: 2019-03-25 19:40+0100\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -757,14 +757,10 @@ msgid "Frequency captured is above capability. Capture Paused." msgstr "" #: shared-bindings/bitbangio/SPI.c shared-bindings/bitbangio/I2C.c -#: shared-bindings/busio/SPI.c +#: shared-bindings/busio/SPI.c shared-bindings/busio/I2C.c msgid "Function requires lock" msgstr "" -#: shared-bindings/busio/I2C.c -msgid "Function requires lock." -msgstr "" - #: ports/esp8266/common-hal/digitalio/DigitalInOut.c msgid "GPIO16 does not support pull up." msgstr "GPIO16 não suporta pull up." @@ -2826,6 +2822,10 @@ msgstr "" msgid "unsupported types for %q: '%s', '%s'" msgstr "" +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + #: ports/esp8266/modnetwork.c msgid "wifi_set_ip_info() failed" msgstr "wifi_set_ip_info() falhou" diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 3612b8d63f..91c17f2d13 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -58,14 +58,22 @@ STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_ar uint32_t width = mp_obj_get_int(pos_args[0]); uint32_t height = mp_obj_get_int(pos_args[1]); uint32_t value_count = mp_obj_get_int(pos_args[2]); - uint32_t power_of_two = 1; - while (value_count > (1U << power_of_two)) { - power_of_two <<= 1; + uint32_t bits = 1; + + if (value_count == 0) { + mp_raise_ValueError(translate("value_count must be > 0")); + } + while ((value_count - 1) >> bits) { + if (bits < 8) { + bits <<= 1; + } else { + bits += 8; + } } displayio_bitmap_t *self = m_new_obj(displayio_bitmap_t); self->base.type = &displayio_bitmap_type; - common_hal_displayio_bitmap_construct(self, width, height, power_of_two); + common_hal_displayio_bitmap_construct(self, width, height, bits); return MP_OBJ_FROM_PTR(self); }