diff options
| author | sommersoft <sommersoft@gmail.com> | 2019-03-01 21:24:30 -0600 |
|---|---|---|
| committer | sommersoft <sommersoft@gmail.com> | 2019-03-01 21:24:30 -0600 |
| commit | a44bfc2730c246738dd8d636d18ffb6591673864 (patch) | |
| tree | 786621e0549a8f2dee327fc0d04bd2c5786c8d10 | |
| parent | 4d47ce5c60d5e024b9a95f58372bfbb27772ef1a (diff) | |
| parent | 17bf2afa414d605676643be301a05d74c3b68290 (diff) | |
Merge branch 'master' of https://github.com/adafruit/circuitpython into new_freq_in
32 files changed, 945 insertions, 195 deletions
diff --git a/.gitmodules b/.gitmodules index b36ad6203..1f7a28d14 100644 --- a/.gitmodules +++ b/.gitmodules @@ -92,3 +92,6 @@ [submodule "tools/Tecate-bitmap-fonts"] path = tools/Tecate-bitmap-fonts url = https://github.com/Tecate/bitmap-fonts.git +[submodule "frozen/pew-pewpew-standalone-10.x"] + path = frozen/pew-pewpew-standalone-10.x + url = https://github.com/pewpew-game/pew-pewpew-standalone-10.x.git diff --git a/frozen/pew-pewpew-standalone-10.x b/frozen/pew-pewpew-standalone-10.x new file mode 160000 +Subproject 87755e088150cc9bce42f4104cbd74d91b923c6 diff --git a/locale/ID.po b/locale/ID.po index bfa219222..f5fadce49 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-02-23 10:51-0800\n" +"POT-Creation-Date: 2019-03-01 07:16-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -756,28 +756,24 @@ msgstr "" msgid "Odd parity is not supported" msgstr "Parity ganjil tidak didukung" -#, c-format -msgid "" -"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x" -msgstr "" - msgid "Only 8 or 16 bit mono with " msgstr "Hanya 8 atau 16 bit mono dengan " #, c-format -msgid "Only Windows format, uncompressed BMP supported %d" +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" msgstr "" msgid "Only bit maps of 8 bit color or less are supported" msgstr "" -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #, c-format msgid "" -"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale " -"BMP supported %d" +"Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp " +"given" +msgstr "" + +msgid "Only slices with step=1 (aka None) are supported" msgstr "" msgid "Only tx supported on UART1 (GPIO2)." @@ -984,6 +980,9 @@ msgstr "Tidak dapat menemukan GCLK yang kosong" msgid "Unable to init parser" msgstr "" +msgid "Unable to read color palette data" +msgstr "" + msgid "Unable to remount filesystem" msgstr "Tidak dapat memasang filesystem kembali" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 318adc768..0808ae43e 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-02-23 19:57-0800\n" +"POT-Creation-Date: 2019-03-01 07:16-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -730,28 +730,24 @@ msgstr "" msgid "Odd parity is not supported" msgstr "" -#, c-format -msgid "" -"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x" -msgstr "" - msgid "Only 8 or 16 bit mono with " msgstr "" #, c-format -msgid "Only Windows format, uncompressed BMP supported %d" +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" msgstr "" msgid "Only bit maps of 8 bit color or less are supported" msgstr "" -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #, c-format msgid "" -"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale " -"BMP supported %d" +"Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp " +"given" +msgstr "" + +msgid "Only slices with step=1 (aka None) are supported" msgstr "" msgid "Only tx supported on UART1 (GPIO2)." @@ -951,6 +947,9 @@ msgstr "" msgid "Unable to init parser" msgstr "" +msgid "Unable to read color palette data" +msgstr "" + msgid "Unable to remount filesystem" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index d9354f01f..941a5d5d1 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-02-23 19:57-0800\n" +"POT-Creation-Date: 2019-03-01 07:16-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -748,29 +748,25 @@ msgstr "" msgid "Odd parity is not supported" msgstr "Eine ungerade Parität wird nicht unterstützt" -#, c-format -msgid "" -"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x" -msgstr "" - msgid "Only 8 or 16 bit mono with " msgstr "Nur 8 oder 16 bit mono mit " #, c-format -msgid "Only Windows format, uncompressed BMP supported %d" -msgstr "Nur unkomprimiertes Windows-Format (BMP) unterstützt %d" +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" +msgstr "" msgid "Only bit maps of 8 bit color or less are supported" msgstr "" "Es werden nur Bitmaps mit einer Farbtiefe von 8 Bit oder weniger unterstützt" -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #, c-format msgid "" -"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale " -"BMP supported %d" +"Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp " +"given" +msgstr "" + +msgid "Only slices with step=1 (aka None) are supported" msgstr "" msgid "Only tx supported on UART1 (GPIO2)." @@ -984,6 +980,9 @@ msgstr "Konnte keinen freien GCLK finden" msgid "Unable to init parser" msgstr "Parser konnte nicht gestartet werden" +msgid "Unable to read color palette data" +msgstr "" + msgid "Unable to remount filesystem" msgstr "Dateisystem konnte nicht wieder eingebunden werden." @@ -2142,3 +2141,6 @@ msgstr "y Wert außerhalb der Grenzen" msgid "zero step" msgstr "" + +#~ 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 cb9d85a18..01cbaeb51 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-02-23 10:51-0800\n" +"POT-Creation-Date: 2019-03-01 07:16-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -730,28 +730,24 @@ msgstr "" msgid "Odd parity is not supported" msgstr "" -#, c-format -msgid "" -"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x" -msgstr "" - msgid "Only 8 or 16 bit mono with " msgstr "" #, c-format -msgid "Only Windows format, uncompressed BMP supported %d" +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" msgstr "" msgid "Only bit maps of 8 bit color or less are supported" msgstr "" -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #, c-format msgid "" -"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale " -"BMP supported %d" +"Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp " +"given" +msgstr "" + +msgid "Only slices with step=1 (aka None) are supported" msgstr "" msgid "Only tx supported on UART1 (GPIO2)." @@ -951,6 +947,9 @@ msgstr "" msgid "Unable to init parser" msgstr "" +msgid "Unable to read color palette data" +msgstr "" + msgid "Unable to remount filesystem" msgstr "" diff --git a/locale/es.po b/locale/es.po index 06a1f10f9..a4eceb1fb 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-02-23 10:51-0800\n" +"POT-Creation-Date: 2019-03-01 07:16-0800\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -770,31 +770,27 @@ msgstr "" msgid "Odd parity is not supported" msgstr "Paridad impar no soportada" -#, c-format -msgid "" -"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x" -msgstr "" - msgid "Only 8 or 16 bit mono with " msgstr "Solo mono de 8 o 16 bit con " #, c-format -msgid "Only Windows format, uncompressed BMP supported %d" -msgstr "Solo formato Windows, BMP sin comprimir soportado %d" +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" +msgstr "" msgid "Only bit maps of 8 bit color or less are supported" msgstr "Solo se admiten bit maps de color de 8 bits o menos" -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "solo se admiten segmentos con step=1 (alias None)" - #, c-format msgid "" -"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale " -"BMP supported %d" +"Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp " +"given" msgstr "" +#, fuzzy +msgid "Only slices with step=1 (aka None) are supported" +msgstr "solo se admiten segmentos con step=1 (alias None)" + msgid "Only tx supported on UART1 (GPIO2)." msgstr "Solo tx soportada en UART1 (GPIO2)" @@ -1003,6 +999,9 @@ msgstr "No se pudo encontrar un GCLK libre" msgid "Unable to init parser" msgstr "Incapaz de inicializar el parser" +msgid "Unable to read color palette data" +msgstr "" + msgid "Unable to remount filesystem" msgstr "Incapaz de montar de nuevo el sistema de archivos" @@ -2168,5 +2167,8 @@ msgstr "address fuera de límites" msgid "zero step" msgstr "paso cero" +#~ msgid "Only Windows format, uncompressed BMP supported %d" +#~ msgstr "Solo formato Windows, BMP sin comprimir soportado %d" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Solo color verdadero (24 bpp o superior) BMP admitido %x" diff --git a/locale/fil.po b/locale/fil.po index 0e79f2031..fb6002a57 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-02-23 10:51-0800\n" +"POT-Creation-Date: 2019-03-01 07:16-0800\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy <me@timothygarcia.ca>\n" "Language-Team: fil\n" @@ -768,31 +768,27 @@ msgstr "" msgid "Odd parity is not supported" msgstr "Odd na parity ay hindi supportado" -#, c-format -msgid "" -"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x" -msgstr "" - msgid "Only 8 or 16 bit mono with " msgstr "Tanging 8 o 16 na bit mono na may " #, c-format -msgid "Only Windows format, uncompressed BMP supported %d" -msgstr "Tanging Windows format, uncompressed BMP lamang ang supportado %d" +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" +msgstr "" msgid "Only bit maps of 8 bit color or less are supported" msgstr "Tanging bit maps na may 8 bit color o mas mababa ang supportado" -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "ang mga slices lamang na may hakbang = 1 (aka None) ang sinusuportahan" - #, c-format msgid "" -"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale " -"BMP supported %d" +"Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp " +"given" msgstr "" +#, fuzzy +msgid "Only slices with step=1 (aka None) are supported" +msgstr "ang mga slices lamang na may hakbang = 1 (aka None) ang sinusuportahan" + msgid "Only tx supported on UART1 (GPIO2)." msgstr "Tanging suportado ang TX sa UART1 (GPIO2)." @@ -1005,6 +1001,9 @@ msgstr "Hindi mahanap ang libreng GCLK" msgid "Unable to init parser" msgstr "Hindi ma-init ang parser" +msgid "Unable to read color palette data" +msgstr "" + msgid "Unable to remount filesystem" msgstr "Hindi ma-remount ang filesystem" @@ -2174,5 +2173,8 @@ msgstr "wala sa sakop ang address" msgid "zero step" msgstr "zero step" +#~ msgid "Only Windows format, uncompressed BMP supported %d" +#~ msgstr "Tanging Windows format, uncompressed BMP lamang ang supportado %d" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Dapat true color (24 bpp o mas mataas) BMP lamang ang supportado %x" diff --git a/locale/fr.po b/locale/fr.po index cb81f74ca..c937a4b5b 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-02-23 10:51-0800\n" +"POT-Creation-Date: 2019-03-01 07:16-0800\n" "PO-Revision-Date: 2018-12-23 20:05+0100\n" "Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n" "Language-Team: fr\n" @@ -772,31 +772,27 @@ msgstr "" msgid "Odd parity is not supported" msgstr "parité impaire non supportée" -#, c-format -msgid "" -"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x" -msgstr "" - msgid "Only 8 or 16 bit mono with " msgstr "Uniquement 8 ou 16 bit mono avec " #, c-format -msgid "Only Windows format, uncompressed BMP supported %d" -msgstr "Seul les BMP non-compressé au format Windows sont supportés %d" +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" +msgstr "" msgid "Only bit maps of 8 bit color or less are supported" msgstr "Seules les bitmaps de 8bits par couleur ou moins sont supportées" -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "seuls les slices avec 'step=1' (cad None) sont supportées" - #, c-format msgid "" -"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale " -"BMP supported %d" +"Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp " +"given" msgstr "" +#, fuzzy +msgid "Only slices with step=1 (aka None) are supported" +msgstr "seuls les slices avec 'step=1' (cad None) sont supportées" + msgid "Only tx supported on UART1 (GPIO2)." msgstr "Seul le tx est supporté sur l'UART1 (GPIO2)." @@ -1016,6 +1012,9 @@ msgstr "Impossible de trouver un GCLK libre" msgid "Unable to init parser" msgstr "Impossible d'initialiser le parser" +msgid "Unable to read color palette data" +msgstr "" + msgid "Unable to remount filesystem" msgstr "Impossible de remonter le système de fichiers" @@ -2198,5 +2197,8 @@ msgstr "adresse hors limites" msgid "zero step" msgstr "'step' nul" +#~ msgid "Only Windows format, uncompressed BMP supported %d" +#~ msgstr "Seul les BMP non-compressé au format Windows sont supportés %d" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Seul les BMP 24bits ou plus sont supportés %x" diff --git a/locale/it_IT.po b/locale/it_IT.po index 83664a146..64fb22128 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-02-23 10:51-0800\n" +"POT-Creation-Date: 2019-03-01 07:16-0800\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n" "Language-Team: \n" @@ -767,31 +767,27 @@ msgstr "" msgid "Odd parity is not supported" msgstr "operazione I2C non supportata" -#, c-format -msgid "" -"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x" -msgstr "" - msgid "Only 8 or 16 bit mono with " msgstr "" #, c-format -msgid "Only Windows format, uncompressed BMP supported %d" -msgstr "Formato solo di Windows, BMP non compresso supportato %d" +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" +msgstr "" msgid "Only bit maps of 8 bit color or less are supported" msgstr "Sono supportate solo bitmap con colori a 8 bit o meno" -#, fuzzy -msgid "Only slices with step=1 (aka None) are supported" -msgstr "solo slice con step=1 (aka None) sono supportate" - #, c-format msgid "" -"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale " -"BMP supported %d" +"Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp " +"given" msgstr "" +#, fuzzy +msgid "Only slices with step=1 (aka None) are supported" +msgstr "solo slice con step=1 (aka None) sono supportate" + msgid "Only tx supported on UART1 (GPIO2)." msgstr "Solo tx supportato su UART1 (GPIO2)." @@ -1003,6 +999,9 @@ msgstr "Impossibile trovare un GCLK libero" msgid "Unable to init parser" msgstr "Inizilizzazione del parser non possibile" +msgid "Unable to read color palette data" +msgstr "" + msgid "Unable to remount filesystem" msgstr "Imposssibile rimontare il filesystem" @@ -2170,5 +2169,8 @@ msgstr "indirizzo fuori limite" msgid "zero step" msgstr "zero step" +#~ msgid "Only Windows format, uncompressed BMP supported %d" +#~ msgstr "Formato solo di Windows, BMP non compresso supportato %d" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Solo BMP true color (24 bpp o superiore) sono supportati %x" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 70e7bde4a..cf46dfbc5 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-02-23 10:51-0800\n" +"POT-Creation-Date: 2019-03-01 07:16-0800\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -756,28 +756,24 @@ msgstr "" msgid "Odd parity is not supported" msgstr "I2C operação não suportada" -#, c-format -msgid "" -"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x" -msgstr "" - msgid "Only 8 or 16 bit mono with " msgstr "" #, c-format -msgid "Only Windows format, uncompressed BMP supported %d" -msgstr "Apenas formato Windows, BMP descomprimido suportado" +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" +msgstr "" msgid "Only bit maps of 8 bit color or less are supported" msgstr "Apenas bit maps de cores de 8 bit ou menos são suportados" -msgid "Only slices with step=1 (aka None) are supported" -msgstr "" - #, c-format msgid "" -"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale " -"BMP supported %d" +"Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp " +"given" +msgstr "" + +msgid "Only slices with step=1 (aka None) are supported" msgstr "" msgid "Only tx supported on UART1 (GPIO2)." @@ -979,6 +975,9 @@ msgstr "Não é possível encontrar GCLK livre" msgid "Unable to init parser" msgstr "" +msgid "Unable to read color palette data" +msgstr "" + msgid "Unable to remount filesystem" msgstr "Não é possível remontar o sistema de arquivos" @@ -2118,5 +2117,8 @@ msgstr "" msgid "zero step" msgstr "passo zero" +#~ msgid "Only Windows format, uncompressed BMP supported %d" +#~ msgstr "Apenas formato Windows, BMP descomprimido suportado" + #~ msgid "Only true color (24 bpp or higher) BMP supported %x" #~ msgstr "Apenas cores verdadeiras (24 bpp ou maior) BMP suportadas" diff --git a/ports/atmel-samd/boards/pewpew10/board.c b/ports/atmel-samd/boards/pewpew10/board.c new file mode 100644 index 000000000..d7e856d61 --- /dev/null +++ b/ports/atmel-samd/boards/pewpew10/board.c @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h new file mode 100644 index 000000000..09618431b --- /dev/null +++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h @@ -0,0 +1,34 @@ +#define MICROPY_HW_BOARD_NAME "PewPew 10.2" +#define MICROPY_HW_MCU_NAME "samd21e18" + +#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) + + +#define IGNORE_PIN_PB00 1 +#define IGNORE_PIN_PB01 1 +#define IGNORE_PIN_PB02 1 +#define IGNORE_PIN_PB03 1 +#define IGNORE_PIN_PB04 1 +#define IGNORE_PIN_PB05 1 +#define IGNORE_PIN_PB06 1 +#define IGNORE_PIN_PB07 1 +#define IGNORE_PIN_PB08 1 +#define IGNORE_PIN_PB09 1 +#define IGNORE_PIN_PB10 1 +#define IGNORE_PIN_PB11 1 +#define IGNORE_PIN_PB12 1 +#define IGNORE_PIN_PB13 1 +#define IGNORE_PIN_PB14 1 +#define IGNORE_PIN_PB15 1 +#define IGNORE_PIN_PB16 1 +#define IGNORE_PIN_PB17 1 +#define IGNORE_PIN_PB22 1 +#define IGNORE_PIN_PB23 1 +#define IGNORE_PIN_PB30 1 +#define IGNORE_PIN_PB31 1 diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk new file mode 100644 index 000000000..983e48e21 --- /dev/null +++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk @@ -0,0 +1,22 @@ +LD_FILE = boards/samd21x18-bootloader.ld +USB_VID = 0x239A +USB_PID = 0x801D +USB_PRODUCT = "PewPew 10.2" +USB_MANUFACTURER = "Radomir Dopieralski" + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-standalone-10.x + +CIRCUITPY_PEW = 1 +CIRCUITPY_ANALOGIO = 1 +CIRCUITPY_MATH = 1 +CIRCUITPY_NEOPIXEL_WRITE = 1 +CIRCUITPY_RTC = 0 +CIRCUITPY_SAMD = 0 +CIRCUITPY_USB_MIDI = 0 +CIRCUITPY_SMALL_BUILD = 1 diff --git a/ports/atmel-samd/boards/pewpew10/pins.c b/ports/atmel-samd/boards/pewpew10/pins.c new file mode 100644 index 000000000..4a8225ad9 --- /dev/null +++ b/ports/atmel-samd/boards/pewpew10/pins.c @@ -0,0 +1,35 @@ +#include "shared-bindings/board/__init__.h" + +#include "supervisor/shared/board_busses.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR__R1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR__R2), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR__R3), MP_ROM_PTR(&pin_PA28) }, + { MP_ROM_QSTR(MP_QSTR__R4), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR__R5), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR__R6), MP_ROM_PTR(&pin_PA27) }, + { MP_ROM_QSTR(MP_QSTR__R7), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR__R8), MP_ROM_PTR(&pin_PA22) }, + + { MP_ROM_QSTR(MP_QSTR__C8), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR__C7), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR__C6), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR__C5), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR__C4), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR__C3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR__C2), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR__C1), MP_ROM_PTR(&pin_PA15) }, + + { MP_ROM_QSTR(MP_QSTR_P1), MP_ROM_PTR(&pin_PA30) }, + { MP_ROM_QSTR(MP_QSTR_P2), MP_ROM_PTR(&pin_PA31) }, + { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_PA04) }, + + { MP_ROM_QSTR(MP_QSTR__BUTTONS), MP_ROM_PTR(&pin_PA08) }, + +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/pyportal/pins.c b/ports/atmel-samd/boards/pyportal/pins.c index 24ebd92bb..6a4736a11 100644 --- a/ports/atmel-samd/boards/pyportal/pins.c +++ b/ports/atmel-samd/boards/pyportal/pins.c @@ -11,18 +11,21 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_AUDIO_OUT), MP_ROM_PTR(&pin_PA02) }, { MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, // analog out/in { MP_OBJ_NEW_QSTR(MP_QSTR_SPEAKER_ENABLE), MP_ROM_PTR(&pin_PA27) }, + + // Light sensor { MP_OBJ_NEW_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_PA07) }, { MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA07) }, // STEMMA connectors - { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA04) }, // D3 - { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA04) }, // A1/D3 - { MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA05) }, // D4 - { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, // A4/D4 + { MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA04) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA05) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, // Indicator LED - { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA27) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_PA27) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PB23) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_PB23) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL),MP_ROM_PTR(&pin_PB22) }, // LCD pins diff --git a/ports/atmel-samd/common-hal/pulseio/PWMOut.c b/ports/atmel-samd/common-hal/pulseio/PWMOut.c index 19daaa14f..dd85e8c02 100644 --- a/ports/atmel-samd/common-hal/pulseio/PWMOut.c +++ b/ports/atmel-samd/common-hal/pulseio/PWMOut.c @@ -328,32 +328,29 @@ extern void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, #endif #ifdef SAMD51 Tc* tc = tc_insts[t->index]; - while (tc->COUNT16.SYNCBUSY.bit.CC1 != 0) { - // Wait for a previous value to be written. This can wait up to one period so we do - // other stuff in the meantime. - #ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP - #endif - } + while (tc->COUNT16.SYNCBUSY.bit.CC1 != 0) {} tc->COUNT16.CCBUF[1].reg = adjusted_duty; #endif } else { uint32_t adjusted_duty = ((uint64_t) tcc_periods[t->index]) * duty / 0xffff; uint8_t channel = tcc_channel(t); Tcc* tcc = tcc_insts[t->index]; - while ((tcc->SYNCBUSY.vec.CC & (1 << channel)) != 0) { - // Wait for a previous value to be written. This can wait up to one period so we do - // other stuff in the meantime. - #ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP - #endif - } + + // Write into the CC buffer register, which will be transferred to the + // CC register on an UPDATE (when period is finished). + // Do clock domain syncing as necessary. + + while (tcc->SYNCBUSY.reg != 0) {} + + // Lock out double-buffering while updating the CCB value. + tcc->CTRLBSET.bit.LUPD = 1; #ifdef SAMD21 tcc->CCB[channel].reg = adjusted_duty; #endif #ifdef SAMD51 tcc->CCBUF[channel].reg = adjusted_duty; #endif + tcc->CTRLBCLR.bit.LUPD = 1; } } @@ -368,7 +365,12 @@ uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) { Tcc* tcc = tcc_insts[t->index]; uint8_t channel = tcc_channel(t); uint32_t cv = 0; + + while (tcc->SYNCBUSY.bit.CTRLB) {} + #ifdef SAMD21 + // If CCBV (CCB valid) is set, the CCB value hasn't yet been copied + // to the CC value. if ((tcc->STATUS.vec.CCBV & (1 << channel)) != 0) { cv = tcc->CCB[channel].reg; } else { @@ -425,9 +427,7 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, tc->COUNT16.CC[0].reg = new_top; #endif #ifdef SAMD51 - while (tc->COUNT16.SYNCBUSY.reg != 0) { - /* Wait for sync */ - } + while (tc->COUNT16.SYNCBUSY.reg != 0) {} tc->COUNT16.CCBUF[0].reg = new_top; #endif } else { @@ -438,14 +438,12 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, tcc->CTRLA.bit.PRESCALER = new_divisor; tcc_set_enable(tcc, true); } + while (tcc->SYNCBUSY.reg != 0) {} tcc_periods[t->index] = new_top; #ifdef SAMD21 tcc->PERB.bit.PERB = new_top; #endif #ifdef SAMD51 - while (tcc->SYNCBUSY.reg != 0) { - /* Wait for sync */ - } tcc->PERBUF.bit.PERBUF = new_top; #endif } diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index aee082de0..8d25806b7 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -68,9 +68,10 @@ #include "tusb.h" -#ifdef CIRCUITPY_GAMEPAD_TICKS +#if CIRCUITPY_GAMEPAD #include "shared-module/gamepad/__init__.h" #endif +#include "shared-module/_pew/PewPew.h" extern volatile bool mp_msc_enabled; @@ -222,9 +223,12 @@ void reset_port(void) { reset_gclks(); -#ifdef CIRCUITPY_GAMEPAD_TICKS +#if CIRCUITPY_GAMEPAD gamepad_reset(); #endif +#if CIRCUITPY_PEW + pew_reset(); +#endif reset_event_system(); diff --git a/ports/atmel-samd/timer_handler.c b/ports/atmel-samd/timer_handler.c index 7f68e4a92..059d4330e 100644 --- a/ports/atmel-samd/timer_handler.c +++ b/ports/atmel-samd/timer_handler.c @@ -30,7 +30,7 @@ #include "timer_handler.h" #include "common-hal/pulseio/PulseOut.h" -#include "common-hal/frequencyio/FrequencyIn.h" +#include "shared-module/_pew/PewPew.h" static uint8_t tc_handler[TC_INST_NUM]; @@ -45,10 +45,17 @@ void shared_timer_handler(bool is_tc, uint8_t index) { // Make sure to add the handler #define to timer_handler.h if (is_tc) { uint8_t handler = tc_handler[index]; - if (handler == TC_HANDLER_PULSEOUT) { - pulseout_interrupt_handler(index); - } else if (handler == TC_HANDLER_FREQUENCYIN) { - frequencyin_interrupt_handler(index); + switch(handler) { + case TC_HANDLER_PULSEOUT: + pulseout_interrupt_handler(index); + break; + case TC_HANDLER_PEW: +#if CIRCUITPY_PEW + pewpew_interrupt_handler(index); +#endif + break; + default: + break; } } } diff --git a/ports/atmel-samd/timer_handler.h b/ports/atmel-samd/timer_handler.h index a495e21f2..e249fca36 100644 --- a/ports/atmel-samd/timer_handler.h +++ b/ports/atmel-samd/timer_handler.h @@ -28,7 +28,7 @@ #define TC_HANDLER_NO_INTERRUPT 0x0 #define TC_HANDLER_PULSEOUT 0x1 -#define TC_HANDLER_FREQUENCYIN 0x2 +#define TC_HANDLER_PEW 0x2 void set_timer_handler(bool is_tc, uint8_t index, uint8_t timer_handler); void shared_timer_handler(bool is_tc, uint8_t index); diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 9bda124fc..09d0a93e2 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -201,6 +201,9 @@ endif ifeq ($(CIRCUITPY_USTACK),1) SRC_PATTERNS += ustack/% endif +ifeq ($(CIRCUITPY_PEW),1) +SRC_PATTERNS += _pew/% +endif # All possible sources are listed here, and are filtered by SRC_PATTERNS. SRC_COMMON_HAL = \ @@ -323,6 +326,8 @@ $(filter $(SRC_PATTERNS), \ terminalio/__init__.c \ uheap/__init__.c \ ustack/__init__.c \ + _pew/__init__.c \ + _pew/PewPew.c \ ) ifeq ($(INTERNAL_LIBM),1) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 218fc3d05..00f3c7b3f 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -470,6 +470,13 @@ extern const struct _mp_obj_module_t ustack_module; #define USTACK_MODULE #endif +#if CIRCUITPY_PEW +extern const struct _mp_obj_module_t pew_module; +#define PEW_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__pew),(mp_obj_t)&pew_module }, +#else +#define PEW_MODULE +#endif + // These modules are not yet in shared-bindings, but we prefer the non-uxxx names. #if MICROPY_PY_UERRNO #define ERRNO_MODULE { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, @@ -529,6 +536,7 @@ extern const struct _mp_obj_module_t ustack_module; NETWORK_MODULE \ SOCKET_MODULE \ WIZNET_MODULE \ + PEW_MODULE \ PIXELBUF_MODULE \ PULSEIO_MODULE \ RANDOM_MODULE \ @@ -570,6 +578,7 @@ extern const struct _mp_obj_module_t ustack_module; vstr_t *repl_line; \ mp_obj_t rtc_time_source; \ mp_obj_t gamepad_singleton; \ + mp_obj_t pew_singleton; \ mp_obj_t terminal_tilegrid_tiles; \ FLASH_ROOT_POINTERS \ NETWORK_ROOT_POINTERS \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index e10c7f66e..8ea72f0bf 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -218,6 +218,11 @@ CIRCUITPY_USB_MIDI = 1 endif CFLAGS += -DCIRCUITPY_USB_MIDI=$(CIRCUITPY_USB_MIDI) +ifndef CIRCUITPY_PEW +CIRCUITPY_PEW = 0 +endif +CFLAGS += -DCIRCUITPY_PEW=$(CIRCUITPY_PEW) + # For debugging. ifndef CIRCUITPY_USTACK CIRCUITPY_USTACK = 0 diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c new file mode 100644 index 000000000..50647488c --- /dev/null +++ b/shared-bindings/_pew/PewPew.c @@ -0,0 +1,151 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Radomir Dopieralski + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "py/obj.h" +#include "py/runtime.h" +#include "py/mphal.h" +#include "py/gc.h" +#include "py/mpstate.h" +#include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/util.h" +#include "PewPew.h" +#include "shared-module/_pew/PewPew.h" +#include "supervisor/shared/translate.h" + + +//| .. currentmodule:: _pew +//| +//| :class:`PewPew` -- LED matrix and button driver +//| =============================================== +//| +//| This is an internal module to be used by the ``pew.py`` library from +//| https://github.com/pewpew-game/pew-pewpew-standalone-10.x to handle the +//| LED matrix display and buttons on the ``pewpew10`` board. +//| +//| Usage:: +//| +//| This singleton class is instantiated by the ``pew`` library, and +//| used internally by it. All user-visible interactions are done through +//| that library. +//| + +//| .. class:: PewPew(buffer, rows, cols, buttons) +//| +//| Initializes matrix scanning routines. +//| +//| The ``buffer`` is a 64 byte long ``bytearray`` that stores what should +//| be displayed on the matrix. ``rows`` and ``cols`` are both lists of +//| eight ``DigitalInputOutput`` objects that are connected to the matrix +//| rows and columns. ``buttons`` is a ``DigitalInputOutput`` object that +//| is connected to the common side of all buttons (the other sides of the +//| buttons are connected to rows of the matrix). +//| +STATIC mp_obj_t pewpew_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, 4, 4, true); + enum { ARG_buffer, ARG_rows, ARG_cols, ARG_buttons }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_rows, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_cols, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_buttons, MP_ARG_OBJ | MP_ARG_REQUIRED }, + }; + 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); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); + + size_t rows_size = 0; + mp_obj_t *rows; + mp_obj_get_array(args[ARG_rows].u_obj, &rows_size, &rows); + + size_t cols_size = 0; + mp_obj_t *cols; + mp_obj_get_array(args[ARG_cols].u_obj, &cols_size, &cols); + + if (bufinfo.len != rows_size * cols_size) { + mp_raise_ValueError(translate("")); + } + + for (size_t i = 0; i < rows_size; ++i) { + if (!MP_OBJ_IS_TYPE(rows[i], &digitalio_digitalinout_type)) { + mp_raise_TypeError(translate("")); + } + digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(rows[i]); + raise_error_if_deinited( + common_hal_digitalio_digitalinout_deinited(pin)); + } + + for (size_t i = 0; i < cols_size; ++i) { + if (!MP_OBJ_IS_TYPE(cols[i], &digitalio_digitalinout_type)) { + mp_raise_TypeError(translate("")); + } + digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(cols[i]); + raise_error_if_deinited( + common_hal_digitalio_digitalinout_deinited(pin)); + } + + if (!MP_OBJ_IS_TYPE(args[ARG_buttons].u_obj, + &digitalio_digitalinout_type)) { + mp_raise_TypeError(translate("")); + } + digitalio_digitalinout_obj_t *buttons = MP_OBJ_TO_PTR( + args[ARG_buttons].u_obj); + raise_error_if_deinited( + common_hal_digitalio_digitalinout_deinited(buttons)); + + pew_obj_t *pew = MP_STATE_VM(pew_singleton); + if (!pew) { + pew = m_new_obj(pew_obj_t); + pew->base.type = &pewpew_type; + pew = gc_make_long_lived(pew); + MP_STATE_VM(pew_singleton) = pew; + } + + pew->buffer = bufinfo.buf; + pew->rows = rows; + pew->rows_size = rows_size; + pew->cols = cols; + pew->cols_size = cols_size; + pew->buttons = buttons; + pew->pressed = 0; + pew_init(); + + return MP_OBJ_FROM_PTR(pew); +} + + +STATIC const mp_rom_map_elem_t pewpew_locals_dict_table[] = { +}; +STATIC MP_DEFINE_CONST_DICT(pewpew_locals_dict, pewpew_locals_dict_table); +const mp_obj_type_t pewpew_type = { + { &mp_type_type }, + .name = MP_QSTR_PewPew, + .make_new = pewpew_make_new, + .locals_dict = (mp_obj_dict_t*)&pewpew_locals_dict, +}; + diff --git a/shared-bindings/_pew/PewPew.h b/shared-bindings/_pew/PewPew.h new file mode 100644 index 000000000..f76384757 --- /dev/null +++ b/shared-bindings/_pew/PewPew.h @@ -0,0 +1,33 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Radomir Dopieralski + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_PEW_PEWPEW_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_PEW_PEWPEW_H + +extern const mp_obj_type_t pewpew_type; + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_PEW_PEWPEW_H diff --git a/shared-bindings/_pew/__init__.c b/shared-bindings/_pew/__init__.c new file mode 100644 index 000000000..6c5520ac5 --- /dev/null +++ b/shared-bindings/_pew/__init__.c @@ -0,0 +1,67 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Radomir Dopieralski + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "py/obj.h" +#include "py/runtime.h" +#include "py/mphal.h" +#include "PewPew.h" +#include "shared-module/_pew/PewPew.h" + +STATIC mp_obj_t get_pressed(void) { + pew_obj_t *pew = MP_STATE_VM(pew_singleton); + if (!pew) { + return mp_const_none; + } + uint8_t pressed = pew->pressed; + pew->pressed = 0; + return mp_obj_new_int(pressed); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(get_pressed_obj, get_pressed); + + +//| :mod:`_pew` --- LED matrix driver +//| ================================== +//| +//| .. module:: _pew +//| :synopsis: LED matrix driver +//| :platform: SAMD21 +//| +//| .. toctree:: +//| :maxdepth: 3 +//| +//| PewPew +//| +STATIC const mp_rom_map_elem_t pew_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pew) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_PewPew), MP_ROM_PTR(&pewpew_type)}, + { MP_OBJ_NEW_QSTR(MP_QSTR_get_pressed), MP_ROM_PTR(&get_pressed_obj)}, +}; +STATIC MP_DEFINE_CONST_DICT(pew_module_globals, + pew_module_globals_table); + +const mp_obj_module_t pew_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&pew_module_globals, +}; diff --git a/shared-module/_pew/PewPew.c b/shared-module/_pew/PewPew.c new file mode 100644 index 000000000..c1d6aa5c3 --- /dev/null +++ b/shared-module/_pew/PewPew.c @@ -0,0 +1,125 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Radomir Dopieralski + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include <stdbool.h> + +#include "py/mpstate.h" +#include "py/runtime.h" +#include "__init__.h" +#include "PewPew.h" + +#include "shared-bindings/digitalio/Pull.h" +#include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/util.h" +#include "samd/timers.h" +#include "supervisor/shared/translate.h" +#include "timer_handler.h" + + +static uint8_t pewpew_tc_index = 0xff; + + +void pewpew_interrupt_handler(uint8_t index) { + if (index != pewpew_tc_index) { + return; + } + Tc* tc = tc_insts[index]; + if (!tc->COUNT16.INTFLAG.bit.MC0) { + return; + } + + pew_tick(); + + // Clear the interrupt bit. + tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0; +} + +void pew_init() { + pew_obj_t* pew = MP_STATE_VM(pew_singleton); + + common_hal_digitalio_digitalinout_switch_to_input(pew->buttons, PULL_UP); + + for (size_t i = 0; i < pew->rows_size; ++i) { + digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(pew->rows[i]); + common_hal_digitalio_digitalinout_switch_to_output(pin, false, + DRIVE_MODE_PUSH_PULL); + } + for (size_t i = 0; i < pew->cols_size; ++i) { + digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(pew->cols[i]); + common_hal_digitalio_digitalinout_switch_to_output(pin, true, + DRIVE_MODE_OPEN_DRAIN); + } + if (pewpew_tc_index == 0xff) { + // Find a spare timer. + uint8_t index = find_free_timer(); + if (index == 0xff) { + mp_raise_RuntimeError(translate("")); + } + Tc *tc = tc_insts[index]; + + pewpew_tc_index = index; + set_timer_handler(true, index, TC_HANDLER_PEW); + + // We use GCLK0 for SAMD21 and GCLK1 for SAMD51 because they both run + // at 48mhz making our math the same across the boards. + #ifdef SAMD21 + turn_on_clocks(true, index, 0); + #endif + #ifdef SAMD51 + turn_on_clocks(true, index, 1); + #endif + + + #ifdef SAMD21 + tc->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | + TC_CTRLA_PRESCALER_DIV64 | + TC_CTRLA_WAVEGEN_MFRQ; + #endif + #ifdef SAMD51 + tc_reset(tc); + tc_set_enable(tc, false); + tc->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 + | TC_CTRLA_PRESCALER_DIV64; + tc->COUNT16.WAVE.reg = TC_WAVE_WAVEGEN_MFRQ; + #endif + + tc_set_enable(tc, true); + tc->COUNT16.CC[0].reg = 160; + + // Clear our interrupt in case it was set earlier + tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0; + tc->COUNT16.INTENSET.reg = TC_INTENSET_MC0; + tc_enable_interrupts(pewpew_tc_index); + } +} + +void pew_reset(void) { + if (pewpew_tc_index != 0xff) { + tc_reset(tc_insts[pewpew_tc_index]); + pewpew_tc_index = 0xff; + } + MP_STATE_VM(pew_singleton) = NULL; +} diff --git a/shared-module/_pew/PewPew.h b/shared-module/_pew/PewPew.h new file mode 100644 index 000000000..da1cae0a2 --- /dev/null +++ b/shared-module/_pew/PewPew.h @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Radomir Dopieralski + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_PEW_PEWPEW_H +#define MICROPY_INCLUDED_PEW_PEWPEW_H + +#include <stdint.h> +#include "shared-bindings/digitalio/DigitalInOut.h" + +typedef struct { + mp_obj_base_t base; + uint8_t* buffer; + mp_obj_t* rows; + mp_obj_t* cols; + digitalio_digitalinout_obj_t *buttons; + uint8_t rows_size; + uint8_t cols_size; + uint8_t pressed; +} pew_obj_t; + +void pew_init(void); +void pewpew_interrupt_handler(uint8_t index); +void pew_reset(void); + +#endif // MICROPY_INCLUDED_PEW_PEWPEW_H diff --git a/shared-module/_pew/__init__.c b/shared-module/_pew/__init__.c new file mode 100644 index 000000000..90fba3990 --- /dev/null +++ b/shared-module/_pew/__init__.c @@ -0,0 +1,85 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Radomir Dopieralski + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include <stdbool.h> + +#include "py/mpstate.h" +#include "__init__.h" +#include "PewPew.h" + +#include "shared-bindings/digitalio/DigitalInOut.h" + + +void pew_tick(void) { + static uint8_t col = 0; + static uint8_t turn = 0; + static uint8_t pressed = 0; + static uint8_t last_pressed = 0; + digitalio_digitalinout_obj_t *pin; + + pew_obj_t* pew = MP_STATE_VM(pew_singleton); + if (!pew) { return; } + + pin = MP_OBJ_TO_PTR(pew->cols[col]); + ++col; + if (col >= pew->cols_size) { + pew->pressed |= last_pressed & pressed; + last_pressed = pressed; + pressed = 0; + col = 0; + ++turn; + if (turn >= 8) { + turn = 0; + } + } + if (!common_hal_digitalio_digitalinout_get_value(pew->buttons)) { + pressed |= 1 << col; + } + common_hal_digitalio_digitalinout_set_value(pin, true); + for (size_t x = 0; x < pew->rows_size; ++x) { + pin = MP_OBJ_TO_PTR(pew->rows[x]); + uint8_t color = pew->buffer[col * (pew->rows_size) + x]; + bool value = false; + switch (color & 0x03) { + case 3: + value = true; + break; + case 2: + if (turn == 2 || turn == 4 || turn == 6) { + value = true; + } + case 1: + if (turn == 0) { + value = true; + } + case 0: + break; + } + common_hal_digitalio_digitalinout_set_value(pin, value); + } + pin = MP_OBJ_TO_PTR(pew->cols[col]); + common_hal_digitalio_digitalinout_set_value(pin, false); +} diff --git a/shared-module/_pew/__init__.h b/shared-module/_pew/__init__.h new file mode 100644 index 000000000..4f953c610 --- /dev/null +++ b/shared-module/_pew/__init__.h @@ -0,0 +1,32 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Radomir Dopieralski + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_PEW_H +#define MICROPY_INCLUDED_PEW_H + +void pew_tick(void); + +#endif // MICROPY_INCLUDED_PEW_H diff --git a/shared-module/displayio/OnDiskBitmap.c b/shared-module/displayio/OnDiskBitmap.c index bc3064632..d710bdae0 100644 --- a/shared-module/displayio/OnDiskBitmap.c +++ b/shared-module/displayio/OnDiskBitmap.c @@ -56,42 +56,65 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, uint16_t bits_per_pixel = bmp_header[14]; uint32_t compression = read_word(bmp_header, 15); uint32_t number_of_colors = read_word(bmp_header, 23); + + bool indexed = ((bits_per_pixel <= 8) && (number_of_colors != 0)); self->bitfield_compressed = (compression == 3); - - self->grayscale = ((bits_per_pixel == 8) && (number_of_colors == 256)); + self->bits_per_pixel = bits_per_pixel; + self->width = read_word(bmp_header, 9); + self->height = read_word(bmp_header, 11); + if (bits_per_pixel == 16){ - if (((header_size == 124) || (header_size == 56)) && (self->bitfield_compressed)) { + if (((header_size >= 56)) || (self->bitfield_compressed)) { self->r_bitmask = read_word(bmp_header, 27); self->g_bitmask = read_word(bmp_header, 29); self->b_bitmask = read_word(bmp_header, 31); - if (!((self->r_bitmask == 0xf800) && (self->g_bitmask == 0x07e0) && (self->b_bitmask == 0x001f))){ - mp_raise_ValueError_varg(translate("Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"), - self->r_bitmask, self->g_bitmask, self->b_bitmask); - } - } else if (header_size == 40){ // no bitmasks means 5:5:5 + } else { // no compression or short header means 5:5:5 self->r_bitmask = 0x7c00; self->g_bitmask = 0x3e0; self->b_bitmask = 0x1f; } + } else if ((indexed) && (self->bits_per_pixel != 1)) { + uint16_t palette_size = number_of_colors * sizeof(uint32_t); + uint16_t palette_offset = 0xe + header_size; + + self->palette_data = m_malloc(palette_size, false); + + f_rewind(&self->file->fp); + f_lseek(&self->file->fp, palette_offset); + + UINT palette_bytes_read; + if (f_read(&self->file->fp, self->palette_data, palette_size, &palette_bytes_read) != FR_OK) { + mp_raise_OSError(MP_EIO); + } + if (palette_bytes_read != palette_size) { + mp_raise_ValueError(translate("Unable to read color palette data")); + } + - } else if (!(header_size == 12 || header_size == 40 || header_size == 108 || header_size == 124) || - !(compression == 0)) { - mp_raise_ValueError_varg(translate("Only Windows format, uncompressed BMP supported %d"), header_size); + } else if (!(header_size == 12 || header_size == 40 || header_size == 108 || header_size == 124)) { + mp_raise_ValueError_varg(translate("Only Windows format, uncompressed BMP supported: given header size is %d"), header_size); } - if (bits_per_pixel < 16 && !(self->grayscale)) { - mp_raise_ValueError_varg(translate("Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale BMP supported %d"), bits_per_pixel); + if ((bits_per_pixel == 4 ) || (( bits_per_pixel == 8) && (number_of_colors == 0))) { + mp_raise_ValueError_varg(translate("Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp given"), bits_per_pixel); } - self->bytes_per_pixel = bits_per_pixel / 8; - self->width = read_word(bmp_header, 9); - self->height = read_word(bmp_header, 11); - uint32_t byte_width = self->width * self->bytes_per_pixel; - self->stride = byte_width; - // Rows are word aligned. - if (self->stride % 4 != 0) { - self->stride += 4 - self->stride % 4; + + if (self->bits_per_pixel >=8){ + self->stride = (self->width * (bits_per_pixel / 8)); + // Rows are word aligned. + if (self->stride % 4 != 0) { + self->stride += 4 - self->stride % 4; + } + + } else { + uint32_t bit_stride = self->width; + if (bit_stride % 32 != 0) { + bit_stride += 32 - bit_stride % 32; + } + self->stride = (bit_stride / 8); } + } @@ -100,39 +123,54 @@ uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *s if (x < 0 || x >= self->width || y < 0 || y >= self->height) { return 0; } - uint32_t location = self->data_offset + (self->height - y) * self->stride + x * self->bytes_per_pixel; + uint32_t location; + uint8_t bytes_per_pixel = (self->bits_per_pixel / 8) ? (self->bits_per_pixel /8) : 1; + if (self->bits_per_pixel >= 8){ + location = self->data_offset + (self->height - y) * self->stride + x * bytes_per_pixel; + } else { + location = self->data_offset + (self->height - y) * self->stride + x / 8; + } // We don't cache here because the underlying FS caches sectors. f_lseek(&self->file->fp, location); UINT bytes_read; - uint32_t pixel = 0; - uint32_t result = f_read(&self->file->fp, &pixel, self->bytes_per_pixel, &bytes_read); + uint32_t pixel_data = 0; + uint32_t result = f_read(&self->file->fp, &pixel_data, bytes_per_pixel, &bytes_read); if (result == FR_OK) { uint32_t tmp = 0; uint8_t red; uint8_t green; uint8_t blue; - if (self->grayscale){ - red = pixel; - green = pixel; - blue = pixel; - tmp = (red << 16 | green << 8 | blue); - return tmp; - } else if (self->bytes_per_pixel == 2) { - if (self->bitfield_compressed){ - red =((pixel & self->r_bitmask) >>11); - green = ((pixel & self->g_bitmask) >>5); - blue = ((pixel & self->b_bitmask) >> 0); + if (self->bits_per_pixel == 1){ + uint8_t bit_offset = x%8; + tmp = ( pixel_data & (0x80 >> (bit_offset))) >> (7 - bit_offset); + if (tmp == 1) { + return 0x00FFFFFF; } else { - red =((pixel & self->r_bitmask) >>10); - green = ((pixel & self->g_bitmask) >>4); - blue = ((pixel & self->b_bitmask) >> 0); + return 0x00000000; + } + } else if (bytes_per_pixel == 1){ + blue = ((self->palette_data[pixel_data] & 0xFF) >> 0); + red = ((self->palette_data[pixel_data] & 0xFF0000) >> 16); + green = ((self->palette_data[pixel_data] & 0xFF00) >> 8); + tmp = (red << 16 | green << 8 | blue ); + return tmp; + } else if (bytes_per_pixel == 2) { + if (self->g_bitmask == 0x07e0) { // 565 + red =((pixel_data & self->r_bitmask) >>11); + green = ((pixel_data & self->g_bitmask) >>5); + blue = ((pixel_data & self->b_bitmask) >> 0); + } else { // 555 + red =((pixel_data & self->r_bitmask) >>10); + green = ((pixel_data & self->g_bitmask) >>4); + blue = ((pixel_data & self->b_bitmask) >> 0); } tmp = (red << 19 | green << 10 | blue << 3); return tmp; - }else { - return pixel; + } else if ((bytes_per_pixel == 4) && (self->bitfield_compressed)) { + return pixel_data & 0x00FFFFFF; + } else { + return pixel_data; } - } return 0; } diff --git a/shared-module/displayio/OnDiskBitmap.h b/shared-module/displayio/OnDiskBitmap.h index 2102863d6..28426f11b 100644 --- a/shared-module/displayio/OnDiskBitmap.h +++ b/shared-module/displayio/OnDiskBitmap.h @@ -44,9 +44,9 @@ typedef struct { uint32_t g_bitmask; uint32_t b_bitmask; bool bitfield_compressed; - bool grayscale; pyb_file_obj_t* file; - uint8_t bytes_per_pixel; + uint8_t bits_per_pixel; + uint32_t* palette_data; } displayio_ondiskbitmap_t; #endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_ONDISKBITMAP_H |
