Merge pull request #1998 from tannewt/monocolor

Add support for grayscale displays
This commit is contained in:
Dan Halbert 2019-07-22 22:30:28 -04:00 committed by GitHub
commit 82ab998cd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 1065 additions and 231 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:06-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\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"
@ -312,6 +312,10 @@ msgstr ""
msgid "Both pins must support hardware interrupts"
msgstr "Kedua pin harus mendukung hardware interrut"
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr ""
@ -443,6 +447,10 @@ msgstr "Clock unit sedang digunakan"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr ""
@ -1171,7 +1179,8 @@ msgstr "Untuk keluar, silahkan reset board tanpa "
msgid "Too many channels in sample."
msgstr "Terlalu banyak channel dalam sampel"
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@ -1212,6 +1221,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Tidak dapat mengalokasikan buffer untuk signed conversion"
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-11 18:42-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\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"
@ -308,6 +308,10 @@ msgstr ""
msgid "Both pins must support hardware interrupts"
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr ""
@ -433,6 +437,10 @@ msgstr ""
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr ""
@ -1148,7 +1156,8 @@ msgstr ""
msgid "Too many channels in sample."
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@ -1189,6 +1198,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr ""
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:06-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@ -312,6 +312,10 @@ msgstr "Bit depth muss ein Vielfaches von 8 sein."
msgid "Both pins must support hardware interrupts"
msgstr "Beide pins müssen Hardware Interrupts unterstützen"
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "Die Helligkeit muss zwischen 0 und 255 liegen"
@ -437,6 +441,10 @@ msgstr "Clock unit wird benutzt"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr "Der Befehl muss ein int zwischen 0 und 255 sein"
@ -1177,7 +1185,8 @@ msgstr "Zum beenden, resette bitte das board ohne "
msgid "Too many channels in sample."
msgstr "Zu viele Kanäle im sample"
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@ -1218,6 +1227,11 @@ msgstr "Der UUID-Wert ist kein str-, int- oder Byte-Puffer"
msgid "Unable to allocate buffers for signed conversion"
msgstr "Konnte keine Buffer für Vorzeichenumwandlung allozieren"
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:06-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -308,6 +308,10 @@ msgstr ""
msgid "Both pins must support hardware interrupts"
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr ""
@ -433,6 +437,10 @@ msgstr ""
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr ""
@ -1148,7 +1156,8 @@ msgstr ""
msgid "Too many channels in sample."
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@ -1189,6 +1198,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr ""
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:06-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: @sommersoft, @MrCertainly\n"
@ -312,6 +312,10 @@ msgstr ""
msgid "Both pins must support hardware interrupts"
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr ""
@ -437,6 +441,10 @@ msgstr ""
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr ""
@ -1152,7 +1160,8 @@ msgstr ""
msgid "Too many channels in sample."
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@ -1193,6 +1202,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr ""
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:07-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -316,6 +316,10 @@ msgstr "Bits depth debe ser múltiplo de 8."
msgid "Both pins must support hardware interrupts"
msgstr "Ambos pines deben soportar interrupciones por hardware"
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "El brillo debe estar entro 0 y 255"
@ -441,6 +445,10 @@ msgstr "Clock unit está siendo utilizado"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr "Entrada de columna debe ser digitalio.DigitalInOut"
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr "Command debe estar entre 0 y 255."
@ -1188,7 +1196,8 @@ msgstr "Para salir, por favor reinicia la tarjeta sin "
msgid "Too many channels in sample."
msgstr "Demasiados canales en sample."
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr "Demasiados buses de pantalla"
@ -1229,6 +1238,11 @@ msgstr "UUID valor no es un str, int o byte buffer"
msgid "Unable to allocate buffers for signed conversion"
msgstr "No se pudieron asignar buffers para la conversión con signo"
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:06-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@ -314,6 +314,10 @@ msgstr "Bit depth ay dapat multiple ng 8."
msgid "Both pins must support hardware interrupts"
msgstr "Ang parehong mga pin ay dapat na sumusuporta sa hardware interrupts"
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "Ang liwanag ay dapat sa gitna ng 0 o 255"
@ -441,6 +445,10 @@ msgstr "Clock unit ginagamit"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#, fuzzy
msgid "Command must be an int between 0 and 255"
@ -1191,7 +1199,8 @@ msgstr "Para lumabas, paki-reset ang board na wala ang "
msgid "Too many channels in sample."
msgstr "Sobra ang channels sa sample."
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@ -1232,6 +1241,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Hindi ma-allocate ang buffers para sa naka-sign na conversion"
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:06-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2019-04-14 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@ -319,6 +319,10 @@ msgstr "La profondeur de bit doit être un multiple de 8."
msgid "Both pins must support hardware interrupts"
msgstr "Les deux entrées doivent supporter les interruptions matérielles"
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "La luminosité doit être entre 0 et 255"
@ -447,6 +451,10 @@ msgstr "Horloge en cours d'utilisation"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr "L'entrée 'Column' doit être un digitalio.DigitalInOut"
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#, fuzzy
msgid "Command must be an int between 0 and 255"
@ -1212,7 +1220,8 @@ msgstr "Pour quitter, redémarrez la carte SVP sans "
msgid "Too many channels in sample."
msgstr "Trop de canaux dans l'échantillon."
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr "Trop de bus d'affichage"
@ -1256,6 +1265,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Impossible d'allouer des tampons pour une conversion signée"
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:06-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@ -314,6 +314,10 @@ msgstr "La profondità di bit deve essere multipla di 8."
msgid "Both pins must support hardware interrupts"
msgstr "Entrambi i pin devono supportare gli interrupt hardware"
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "La luminosità deve essere compreso tra 0 e 255"
@ -442,6 +446,10 @@ msgstr "Unità di clock in uso"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#, fuzzy
msgid "Command must be an int between 0 and 255"
@ -1190,7 +1198,8 @@ msgstr "Per uscire resettare la scheda senza "
msgid "Too many channels in sample."
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@ -1231,6 +1240,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Ipossibilitato ad allocare buffer per la conversione con segno"
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:06-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
"Language-Team: pl\n"
@ -311,6 +311,10 @@ msgstr "Głębia musi być wielokrotnością 8."
msgid "Both pins must support hardware interrupts"
msgstr "Obie nóżki muszą wspierać przerwania sprzętowe"
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "Jasność musi być pomiędzy 0 a 255"
@ -436,6 +440,10 @@ msgstr "Jednostka zegara w użyciu"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr "Kolumny muszą być typu digitalio.DigitalInOut"
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr "Komenda musi być int pomiędzy 0 a 255"
@ -1168,7 +1176,8 @@ msgstr "By wyjść, proszę zresetować płytkę bez "
msgid "Too many channels in sample."
msgstr "Zbyt wiele kanałów."
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr "Zbyt wiele magistrali"
@ -1209,6 +1218,11 @@ msgstr "UUID nie jest typu str, int lub bytes"
msgid "Unable to allocate buffers for signed conversion"
msgstr "Nie udała się alokacja buforów do konwersji ze znakiem"
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:06-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -311,6 +311,10 @@ msgstr ""
msgid "Both pins must support hardware interrupts"
msgstr "Ambos os pinos devem suportar interrupções de hardware"
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "O brilho deve estar entre 0 e 255"
@ -438,6 +442,10 @@ msgstr "Unidade de Clock em uso"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#, fuzzy
msgid "Command must be an int between 0 and 255"
@ -1168,7 +1176,8 @@ msgstr "Para sair, por favor, reinicie a placa sem "
msgid "Too many channels in sample."
msgstr "Muitos canais na amostra."
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@ -1209,6 +1218,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Não é possível alocar buffers para conversão assinada"
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 09:06-0400\n"
"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@ -312,6 +312,10 @@ msgstr "Bǐtè shēndù bìxū shì 8 bèi yǐshàng."
msgid "Both pins must support hardware interrupts"
msgstr "Liǎng gè yǐn jiǎo dōu bìxū zhīchí yìngjiàn zhōngduàn"
#: shared-bindings/displayio/Display.c
msgid "Brightness must be 0-1.0"
msgstr ""
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "Liàngdù bìxū jiè yú 0 dào 255 zhī jiān"
@ -437,6 +441,10 @@ msgstr "Shǐyòng shízhōng dānwèi"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr "Liè tiáomù bìxū shì digitalio.DigitalInOut"
#: shared-bindings/displayio/I2CDisplay.c
msgid "Command must be 0-255"
msgstr ""
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr "Mìnglìng bìxū shì 0 dào 255 zhī jiān de int"
@ -1173,7 +1181,8 @@ msgstr "Yào tuìchū, qǐng chóng zhì bǎnkuài ér bùyòng "
msgid "Too many channels in sample."
msgstr "Chōuyàng zhōng de píndào tài duō."
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr "Xiǎnshì zǒngxiàn tài duōle"
@ -1214,6 +1223,11 @@ msgstr "UUID zhí bùshì str,int huò zì jié huǎnchōng qū"
msgid "Unable to allocate buffers for signed conversion"
msgstr "Wúfǎ fēnpèi huǎnchōng qū yòng yú qiānmíng zhuǎnhuàn"
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"

View File

@ -91,6 +91,8 @@ void board_init(void) {
1, // row start
0, // rotation
16, // Color depth
false, // Grayscale
false, // Pixels in a byte share a row. Only used for depth < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@ -98,6 +100,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA00,
NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds

View File

@ -16,6 +16,7 @@ LONGINT_IMPL = MPZ
CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_BITBANGIO = 0
SUPEROPT_GC = 0
# Include these Python libraries in firmware.

View File

@ -93,6 +93,8 @@ void board_init(void) {
0, // row start
270, // rotation
16, // Color depth
false, // grayscale
false, // pixels in byte share row. only used for depth < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@ -100,6 +102,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA01, // backlight pin
NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds

View File

@ -71,6 +71,8 @@ void board_init(void) {
0, // row start
90, // rotation
16, // Color depth
false, // grayscale
false, // pixels in byte share row. Only used for depth < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@ -78,6 +80,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA01, // backlight pin
NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds

View File

@ -93,6 +93,8 @@ void board_init(void) {
0, // row start
270, // rotation
16, // Color depth
false, // Grayscale
false, // pixels in a byte share a row. Only valid for depths < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@ -100,6 +102,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA01, // backlight pin
NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds

View File

@ -71,6 +71,8 @@ void board_init(void) {
0, // row start
90, // rotation
16, // Color depth
false, // Grayscale
false, // pixels in a byte share a row. Only valid for depths < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@ -78,6 +80,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA01, // backlight pin
NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds

View File

@ -83,13 +83,16 @@ void board_init(void) {
0, // row start
0, // rotation
16, // Color depth
false, // grayscale
false, // pixels_in_byte_share_row (unused for depths > 8)
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
0x37, // Set vertical scroll command
display_init_sequence,
sizeof(display_init_sequence),
&pin_PB31,
&pin_PB31, // Backlight pin
NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds

View File

@ -91,6 +91,8 @@ void board_init(void) {
2, // row start
0, // rotation
16, // Color depth
false, // grayscale
false, // pixels in byte share row. Only used with depth < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@ -98,6 +100,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
NULL,
NO_BRIGHTNESS_COMMAND,
1.0f, // brightness
false, // auto_brightness
false, // single_byte_bounds

View File

@ -36,6 +36,8 @@
#include "shared-bindings/microcontroller/__init__.h"
#include "supervisor/shared/translate.h"
#include "common-hal/busio/SPI.h" // for never_reset_sercom
// Number of times to try to send packet if failed.
#define ATTEMPTS 2
@ -225,3 +227,10 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr,
}
return MP_EIO;
}
void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
never_reset_sercom(self->i2c_desc.device.hw);
never_reset_pin_number(self->scl_pin);
never_reset_pin_number(self->sda_pin);
}

View File

@ -43,6 +43,7 @@ typedef struct {
} busio_spi_obj_t;
void reset_sercoms(void);
void never_reset_sercom(Sercom* sercom);
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_SPI_H

View File

@ -31,6 +31,7 @@
#include "common-hal/microcontroller/Pin.h"
#include "py/runtime.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "tick.h"
@ -66,10 +67,6 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel
common_hal_digitalio_digitalinout_construct(&self->chip_select, chip_select);
common_hal_digitalio_digitalinout_switch_to_output(&self->chip_select, true, DRIVE_MODE_PUSH_PULL);
self->reset.base.type = &digitalio_digitalinout_type;
common_hal_digitalio_digitalinout_construct(&self->reset, reset);
common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL);
self->write.base.type = &digitalio_digitalinout_type;
common_hal_digitalio_digitalinout_construct(&self->write, write);
common_hal_digitalio_digitalinout_switch_to_output(&self->write, true, DRIVE_MODE_PUSH_PULL);
@ -82,11 +79,21 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel
self->write_group = &PORT->Group[write->number / 32];
self->write_mask = 1 << (write->number % 32);
if (reset != NULL) {
self->reset.base.type = &digitalio_digitalinout_type;
common_hal_digitalio_digitalinout_construct(&self->reset, reset);
common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL);
never_reset_pin_number(reset->number);
common_hal_digitalio_digitalinout_set_value(&self->reset, false);
common_hal_mcu_delay_us(4);
common_hal_digitalio_digitalinout_set_value(&self->reset, true);
}
never_reset_pin_number(command->number);
never_reset_pin_number(chip_select->number);
never_reset_pin_number(write->number);
never_reset_pin_number(read->number);
never_reset_pin_number(reset->number);
for (uint8_t i = 0; i < 8; i++) {
never_reset_pin_number(data_pin + i);
}

View File

@ -17,7 +17,7 @@ endif
# Put samd21-only choices here.
ifeq ($(CHIP_FAMILY),samd21)
# frequencyio not yet verified as working on SAMD21.
CIRCUITPY_FRQUENCYIO = 0
CIRCUITPY_FREQUENCYIO = 0
endif
# Put samd51-only choices here.

View File

@ -57,13 +57,30 @@ STATIC twim_peripheral_t twim_peripherals[] = {
#endif
};
STATIC bool never_reset[MP_ARRAY_SIZE(twim_peripherals)];
void i2c_reset(void) {
for (size_t i = 0 ; i < MP_ARRAY_SIZE(twim_peripherals); i++) {
if (never_reset[i]) {
continue;
}
nrf_twim_disable(twim_peripherals[i].twim.p_twim);
twim_peripherals[i].in_use = false;
}
}
void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
for (size_t i = 0 ; i < MP_ARRAY_SIZE(twim_peripherals); i++) {
if (self->twim_peripheral == &twim_peripherals[i]) {
never_reset[i] = true;
never_reset_pin_number(self->scl_pin_number);
never_reset_pin_number(self->sda_pin_number);
break;
}
}
}
static uint8_t twi_error_to_mp(const nrfx_err_t err) {
switch (err) {
case NRFX_ERROR_DRV_TWI_ERR_ANACK:

View File

@ -61,7 +61,7 @@ STATIC spim_peripheral_t spim_peripherals[] = {
#endif
};
STATIC bool never_reset[4];
STATIC bool never_reset[MP_ARRAY_SIZE(spim_peripherals)];
void spi_reset(void) {
for (size_t i = 0 ; i < MP_ARRAY_SIZE(spim_peripherals); i++) {

View File

@ -317,6 +317,7 @@ $(filter $(SRC_PATTERNS), \
displayio/Display.c \
displayio/FourWire.c \
displayio/Group.c \
displayio/I2CDisplay.c \
displayio/OnDiskBitmap.c \
displayio/Palette.c \
displayio/Shape.c \

View File

@ -95,7 +95,12 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) {
MICROPY_VM_HOOK_LOOP ;
#endif
}
displayio_display_set_region_to_update(display, x0, y0, x1, y1);
displayio_area_t area;
area.x1 = x0;
area.y1 = y0;
area.x2 = x1;
area.y2 = y1;
displayio_display_set_region_to_update(display, &area);
render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size, display);
displayio_display_end_transaction(display);

View File

@ -69,4 +69,7 @@ extern uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addres
extern uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address,
uint8_t * data, size_t len);
// This is used by the supervisor to claim I2C devices indefinitely.
extern void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_I2C_H

View File

@ -62,6 +62,8 @@ STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz
//| .. method:: convert(color)
//|
//| Converts the given RGB888 color to RGB565
//|
STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t color_obj) {
displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in);
@ -69,8 +71,10 @@ STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t
if (!mp_obj_get_int_maybe(color_obj, &color)) {
mp_raise_ValueError(translate("color should be an int"));
}
uint16_t output_color;
common_hal_displayio_colorconverter_convert(self, color, &output_color);
_displayio_colorspace_t colorspace;
colorspace.depth = 16;
uint32_t output_color;
common_hal_displayio_colorconverter_convert(self, &colorspace, color, &output_color);
return MP_OBJ_NEW_SMALL_INT(output_color);
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_colorconverter_convert_obj, displayio_colorconverter_obj_convert);

View File

@ -29,9 +29,11 @@
#include "shared-module/displayio/ColorConverter.h"
#include "shared-module/displayio/Palette.h"
extern const mp_obj_type_t displayio_colorconverter_type;
void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t* self);
bool common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *colorconverter, uint32_t input_color, uint16_t* output_color);
void common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *colorconverter, const _displayio_colorspace_t* colorspace, uint32_t input_color, uint32_t* output_color);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_COLORCONVERTER_H

View File

@ -51,7 +51,7 @@
//| Most people should not use this class directly. Use a specific display driver instead that will
//| contain the initialization sequence at minimum.
//|
//| .. class:: Display(display_bus, init_sequence, *, width, height, colstart=0, rowstart=0, rotation=0, color_depth=16, set_column_command=0x2a, set_row_command=0x2b, write_ram_command=0x2c, set_vertical_scroll=0, backlight_pin=None, brightness=1.0, auto_brightness=False, single_byte_bounds=False, data_as_commands=False)
//| .. class:: Display(display_bus, init_sequence, *, width, height, colstart=0, rowstart=0, rotation=0, color_depth=16, grayscale=False, pixels_in_byte_share_row=True, set_column_command=0x2a, set_row_command=0x2b, write_ram_command=0x2c, set_vertical_scroll=0, backlight_pin=None, brightness_command=None, brightness=1.0, auto_brightness=False, single_byte_bounds=False, data_as_commands=False)
//|
//| Create a Display object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`).
//|
@ -88,18 +88,21 @@
//| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270)
//| :param int color_depth: The number of bits of color per pixel transmitted. (Some displays
//| support 18 bit but 16 is easier to transmit. The last bit is extrapolated.)
//| :param bool grayscale: True if the display only shows a single color.
//| :param bool pixels_in_byte_share_row: True when pixels are less than a byte and a byte includes pixels from the same row of the display. When False, pixels share a column.
//| :param int set_column_command: Command used to set the start and end columns to update
//| :param int set_row_command: Command used so set the start and end rows to update
//| :param int write_ram_command: Command used to write pixels values into the update region
//| :param int write_ram_command: Command used to write pixels values into the update region. Ignored if data_as_commands is set.
//| :param int set_vertical_scroll: Command used to set the first row to show
//| :param microcontroller.Pin backlight_pin: Pin connected to the display's backlight
//| :param int brightness_command: Command to set display brightness. Usually available in OLED controllers.
//| :param bool brightness: Initial display brightness. This value is ignored if auto_brightness is True.
//| :param bool auto_brightness: If True, brightness is controlled via an ambient light sensor or other mechanism.
//| :param bool single_byte_bounds: Display column and row commands use single bytes
//| :param bool data_as_commands: Treat all init and boundary data as SPI commands. Certain displays require this.
//|
STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands };
enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ },
{ MP_QSTR_init_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ },
@ -109,11 +112,14 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
{ MP_QSTR_rowstart, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} },
{ MP_QSTR_rotation, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} },
{ MP_QSTR_color_depth, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 16} },
{ MP_QSTR_grayscale, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
{ MP_QSTR_pixels_in_byte_share_row, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
{ MP_QSTR_set_column_command, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x2a} },
{ MP_QSTR_set_row_command, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x2b} },
{ MP_QSTR_write_ram_command, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x2c} },
{ MP_QSTR_set_vertical_scroll, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x0} },
{ MP_QSTR_backlight_pin, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
{ MP_QSTR_brightness_command, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = NO_BRIGHTNESS_COMMAND} },
{ MP_QSTR_brightness, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(1)} },
{ MP_QSTR_auto_brightness, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
{ MP_QSTR_single_byte_bounds, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
@ -157,11 +163,13 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
common_hal_displayio_display_construct(
self,
display_bus, args[ARG_width].u_int, args[ARG_height].u_int, args[ARG_colstart].u_int, args[ARG_rowstart].u_int, rotation,
args[ARG_color_depth].u_int, args[ARG_set_column_command].u_int, args[ARG_set_row_command].u_int,
args[ARG_color_depth].u_int, args[ARG_grayscale].u_bool, args[ARG_pixels_in_byte_share_row].u_bool,
args[ARG_set_column_command].u_int, args[ARG_set_row_command].u_int,
args[ARG_write_ram_command].u_int,
args[ARG_set_vertical_scroll].u_int,
bufinfo.buf, bufinfo.len,
MP_OBJ_TO_PTR(backlight_pin),
args[ARG_brightness_command].u_int,
brightness,
args[ARG_auto_brightness].u_bool,
args[ARG_single_byte_bounds].u_bool,
@ -234,10 +242,14 @@ STATIC mp_obj_t displayio_display_obj_get_brightness(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_brightness_obj, displayio_display_obj_get_brightness);
STATIC mp_obj_t displayio_display_obj_set_brightness(mp_obj_t self_in, mp_obj_t brightness) {
STATIC mp_obj_t displayio_display_obj_set_brightness(mp_obj_t self_in, mp_obj_t brightness_obj) {
displayio_display_obj_t *self = native_display(self_in);
common_hal_displayio_display_set_auto_brightness(self, false);
bool ok = common_hal_displayio_display_set_brightness(self, mp_obj_get_float(brightness));
mp_float_t brightness = mp_obj_get_float(brightness_obj);
if (brightness < 0 || brightness > 1.0) {
mp_raise_ValueError(translate("Brightness must be 0-1.0"));
}
bool ok = common_hal_displayio_display_set_brightness(self, brightness);
if (!ok) {
mp_raise_RuntimeError(translate("Brightness not adjustable"));
}

View File

@ -36,11 +36,13 @@ extern const mp_obj_type_t displayio_display_type;
#define DELAY 0x80
#define NO_BRIGHTNESS_COMMAND 0x100
void common_hal_displayio_display_construct(displayio_display_obj_t* self,
mp_obj_t bus, uint16_t width, uint16_t height,
int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth,
int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row,
uint8_t set_column_command, uint8_t set_row_command, uint8_t write_ram_command, uint8_t set_vertical_scroll,
uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin,
uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command,
mp_float_t brightness, bool auto_brightness,
bool single_byte_bounds, bool data_as_commands);
@ -54,7 +56,7 @@ bool displayio_display_begin_transaction(displayio_display_obj_t* self);
void displayio_display_end_transaction(displayio_display_obj_t* self);
// The second point of the region is exclusive.
void displayio_display_set_region_to_update(displayio_display_obj_t* self, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
void displayio_display_set_region_to_update(displayio_display_obj_t* self, displayio_area_t* area);
bool displayio_display_frame_queued(displayio_display_obj_t* self);
bool displayio_display_refresh_queued(displayio_display_obj_t* self);

View File

@ -0,0 +1,138 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 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 "shared-bindings/displayio/I2CDisplay.h"
#include <stdint.h>
#include <string.h>
#include "lib/utils/context_manager_helpers.h"
#include "py/binary.h"
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/util.h"
#include "shared-module/displayio/__init__.h"
#include "supervisor/shared/translate.h"
//| .. currentmodule:: displayio
//|
//| :class:`I2CDisplay` -- Manage updating a display over I2C
//| ==========================================================================
//|
//| Manage updating a display over I2C in the background while Python code runs.
//| It doesn't handle display initialization.
//|
//| .. class:: I2CDisplay(i2c_bus, *, device_address, reset=None)
//|
//| Create a I2CDisplay object associated with the given I2C bus and reset pin.
//|
//| The I2C bus and pins are then in use by the display until `displayio.release_displays()` is
//| called even after a reload. (It does this so CircuitPython can use the display after your code
//| is done.) So, the first time you initialize a display bus in code.py you should call
//| :py:func`displayio.release_displays` first, otherwise it will error after the first code.py run.
//|
//| :param busio.I2C i2c_bus: The I2C bus that make up the clock and data lines
//| :param int device_address: The I2C address of the device
//| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used
//|
STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_i2c_bus, ARG_device_address, ARG_reset };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_i2c_bus, MP_ARG_REQUIRED | MP_ARG_OBJ },
{ MP_QSTR_device_address, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
{ MP_QSTR_reset, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
};
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_obj_t reset = args[ARG_reset].u_obj;
if (reset != mp_const_none) {
assert_pin_free(reset);
} else {
reset = NULL;
}
displayio_i2cdisplay_obj_t* self = NULL;
mp_obj_t i2c = args[ARG_i2c_bus].u_obj;
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
if (displays[i].i2cdisplay_bus.base.type == NULL ||
displays[i].i2cdisplay_bus.base.type == &mp_type_NoneType) {
self = &displays[i].i2cdisplay_bus;
self->base.type = &displayio_i2cdisplay_type;
break;
}
}
if (self == NULL) {
mp_raise_RuntimeError(translate("Too many display busses"));
}
common_hal_displayio_i2cdisplay_construct(self,
MP_OBJ_TO_PTR(i2c), args[ARG_device_address].u_int, reset);
return self;
}
//| .. method:: send(command, data)
//|
//| Sends the given command value followed by the full set of data. Display state, such as
//| vertical scroll, set via ``send`` may or may not be reset once the code is done.
//|
STATIC mp_obj_t displayio_i2cdisplay_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) {
mp_int_t command_int = MP_OBJ_SMALL_INT_VALUE(command_obj);
if (!MP_OBJ_IS_SMALL_INT(command_obj) || command_int > 255 || command_int < 0) {
mp_raise_ValueError(translate("Command must be 0-255"));
}
uint8_t command = command_int;
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(data_obj, &bufinfo, MP_BUFFER_READ);
// Wait for display bus to be available.
while (!common_hal_displayio_i2cdisplay_begin_transaction(self)) {
#ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP ;
#endif
}
uint8_t full_command[bufinfo.len + 1];
full_command[0] = command;
memcpy(full_command + 1, ((uint8_t*) bufinfo.buf), bufinfo.len);
common_hal_displayio_i2cdisplay_send(self, true, full_command, bufinfo.len + 1);
common_hal_displayio_i2cdisplay_end_transaction(self);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_3(displayio_i2cdisplay_send_obj, displayio_i2cdisplay_obj_send);
STATIC const mp_rom_map_elem_t displayio_i2cdisplay_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&displayio_i2cdisplay_send_obj) },
};
STATIC MP_DEFINE_CONST_DICT(displayio_i2cdisplay_locals_dict, displayio_i2cdisplay_locals_dict_table);
const mp_obj_type_t displayio_i2cdisplay_type = {
{ &mp_type_type },
.name = MP_QSTR_I2CDisplay,
.make_new = displayio_i2cdisplay_make_new,
.locals_dict = (mp_obj_dict_t*)&displayio_i2cdisplay_locals_dict,
};

View File

@ -0,0 +1,46 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017, 2018 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.
*/
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_I2CDISPLAY_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_I2CDISPLAY_H
#include "shared-module/displayio/I2CDisplay.h"
#include "common-hal/microcontroller/Pin.h"
extern const mp_obj_type_t displayio_i2cdisplay_type;
void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
busio_i2c_obj_t* i2c, uint16_t device_address, const mcu_pin_obj_t* reset);
void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t* self);
bool common_hal_displayio_i2cdisplay_begin_transaction(mp_obj_t self);
void common_hal_displayio_i2cdisplay_send(mp_obj_t self, bool command, uint8_t *data, uint32_t data_length);
void common_hal_displayio_i2cdisplay_end_transaction(mp_obj_t self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_I2CDISPLAY_H

View File

@ -66,11 +66,26 @@ STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_a
return MP_OBJ_FROM_PTR(self);
}
//| .. method:: __len__()
//|
//| Returns the number of colors in a Palette
//|
STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
displayio_palette_t *self = MP_OBJ_TO_PTR(self_in);
switch (op) {
case MP_UNARY_OP_BOOL: return mp_const_true;
case MP_UNARY_OP_LEN:
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_palette_get_len(self));
default: return MP_OBJ_NULL; // op not supported
}
}
//| .. method:: __setitem__(index, value)
//|
//| Sets the pixel color at the given index. The index should be an integer in the range 0 to color_count-1.
//|
//| The value argument represents a color, and can be from 0x000000 to 0xFFFFFF (to represent an RGB value).
//| The value argument represents a color, and can be from 0x000000 to 0xFFFFFF (to represent an RGB value).
//| Value can be an int, bytes (3 bytes (RGB) or 4 bytes (RGB + pad byte)), or bytearray.
//|
//| This allows you to::
@ -89,12 +104,12 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val
if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) {
return MP_OBJ_NULL;
}
// index read is not supported
if (value == MP_OBJ_SENTINEL) {
return MP_OBJ_NULL;
}
displayio_palette_t *self = MP_OBJ_TO_PTR(self_in);
size_t index = mp_get_index(&displayio_palette_type, self->color_count, index_in, false);
// index read
if (value == MP_OBJ_SENTINEL) {
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_palette_get_color(self, index));
}
uint32_t color;
mp_int_t int_value;
@ -160,5 +175,7 @@ const mp_obj_type_t displayio_palette_type = {
.name = MP_QSTR_Palette,
.make_new = displayio_palette_make_new,
.subscr = palette_subscr,
.unary_op = group_unary_op,
.getiter = mp_obj_new_generic_iterator,
.locals_dict = (mp_obj_dict_t*)&displayio_palette_locals_dict,
};

View File

@ -33,6 +33,8 @@ extern const mp_obj_type_t displayio_palette_type;
void common_hal_displayio_palette_construct(displayio_palette_t* self, uint16_t color_count);
void common_hal_displayio_palette_set_color(displayio_palette_t* self, uint32_t palette_index, uint32_t color);
uint32_t common_hal_displayio_palette_get_color(displayio_palette_t* self, uint32_t palette_index);
uint32_t common_hal_displayio_palette_get_len(displayio_palette_t* self);
void common_hal_displayio_palette_make_opaque(displayio_palette_t* self, uint32_t palette_index);
void common_hal_displayio_palette_make_transparent(displayio_palette_t* self, uint32_t palette_index);

View File

@ -35,6 +35,7 @@
#include "shared-bindings/displayio/Display.h"
#include "shared-bindings/displayio/FourWire.h"
#include "shared-bindings/displayio/Group.h"
#include "shared-bindings/displayio/I2CDisplay.h"
#include "shared-bindings/displayio/OnDiskBitmap.h"
#include "shared-bindings/displayio/Palette.h"
#include "shared-bindings/displayio/ParallelBus.h"
@ -61,6 +62,7 @@
//| Display
//| FourWire
//| Group
//| I2CDisplay
//| OnDiskBitmap
//| Palette
//| ParallelBus
@ -96,6 +98,7 @@ STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_TileGrid), MP_ROM_PTR(&displayio_tilegrid_type) },
{ MP_ROM_QSTR(MP_QSTR_FourWire), MP_ROM_PTR(&displayio_fourwire_type) },
{ MP_ROM_QSTR(MP_QSTR_I2CDisplay), MP_ROM_PTR(&displayio_i2cdisplay_type) },
{ MP_ROM_QSTR(MP_QSTR_ParallelBus), MP_ROM_PTR(&displayio_parallelbus_type) },
{ MP_ROM_QSTR(MP_QSTR_release_displays), MP_ROM_PTR(&displayio_release_displays_obj) },

View File

@ -29,15 +29,36 @@
void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t* self) {
}
bool common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *self, uint32_t input_color, uint16_t* output_color) {
// TODO(tannewt): Validate the color input against the input format.
uint32_t r5 = (input_color >> 19);
uint32_t g6 = (input_color >> 10) & 0x3f;
uint32_t b5 = (input_color >> 3) & 0x1f;
uint16_t displayio_colorconverter_compute_rgb565(uint32_t color_rgb888) {
uint32_t r5 = (color_rgb888 >> 19);
uint32_t g6 = (color_rgb888 >> 10) & 0x3f;
uint32_t b5 = (color_rgb888 >> 3) & 0x1f;
uint32_t packed = r5 << 11 | g6 << 5 | b5;
// swap bytes
*output_color = __builtin_bswap16(packed);
return true;
return __builtin_bswap16(packed);
}
uint8_t displayio_colorconverter_compute_luma(uint32_t color_rgb888) {
uint32_t r8 = (color_rgb888 >> 16);
uint32_t g8 = (color_rgb888 >> 8) & 0xff;
uint32_t b8 = color_rgb888 & 0xff;
return (r8 * 19) / 255 + (g8 * 182) / 255 + (b8 + 54) / 255;
}
bool displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t* colorspace, uint32_t input_color, uint32_t* output_color) {
if (colorspace->depth == 16) {
*output_color = displayio_colorconverter_compute_rgb565(input_color);
return true;
} else if (colorspace->grayscale && colorspace->depth <= 8) {
uint8_t luma = displayio_colorconverter_compute_luma(input_color);
*output_color = luma >> (8 - colorspace->depth);
return true;
}
return false;
}
void common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t* colorspace, uint32_t input_color, uint32_t* output_color) {
displayio_colorconverter_convert(self, colorspace, input_color, output_color);
}
// Currently no refresh logic is needed for a ColorConverter.

View File

@ -31,6 +31,7 @@
#include <stdint.h>
#include "py/obj.h"
#include "shared-module/displayio/Palette.h"
typedef struct {
mp_obj_base_t base;
@ -38,5 +39,8 @@ typedef struct {
bool displayio_colorconverter_needs_refresh(displayio_colorconverter_t *self);
void displayio_colorconverter_finish_refresh(displayio_colorconverter_t *self);
bool displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t* colorspace, uint32_t input_color, uint32_t* output_color);
uint16_t displayio_colorconverter_compute_rgb565(uint32_t color_rgb888);
uint8_t displayio_colorconverter_compute_luma(uint32_t color_rgb888);
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_COLORCONVERTER_H

View File

@ -28,6 +28,7 @@
#include "py/runtime.h"
#include "shared-bindings/displayio/FourWire.h"
#include "shared-bindings/displayio/I2CDisplay.h"
#include "shared-bindings/displayio/ParallelBus.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/time/__init__.h"
@ -35,6 +36,7 @@
#include "supervisor/shared/display.h"
#include <stdint.h>
#include <string.h>
#include "tick.h"
@ -42,11 +44,14 @@
void common_hal_displayio_display_construct(displayio_display_obj_t* self,
mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation,
uint16_t color_depth, uint8_t set_column_command, uint8_t set_row_command,
uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row,
uint8_t set_column_command, uint8_t set_row_command,
uint8_t write_ram_command, uint8_t set_vertical_scroll, uint8_t* init_sequence, uint16_t init_sequence_len,
const mcu_pin_obj_t* backlight_pin, mp_float_t brightness, bool auto_brightness,
const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness,
bool single_byte_bounds, bool data_as_commands) {
self->color_depth = color_depth;
self->colorspace.depth = color_depth;
self->colorspace.grayscale = grayscale;
self->colorspace.pixels_in_byte_share_row = pixels_in_byte_share_row;
self->set_column_command = set_column_command;
self->set_row_command = set_row_command;
self->write_ram_command = write_ram_command;
@ -54,6 +59,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
self->current_group = NULL;
self->colstart = colstart;
self->rowstart = rowstart;
self->brightness_command = brightness_command;
self->auto_brightness = auto_brightness;
self->data_as_commands = data_as_commands;
self->single_byte_bounds = single_byte_bounds;
@ -66,6 +72,10 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
self->begin_transaction = common_hal_displayio_fourwire_begin_transaction;
self->send = common_hal_displayio_fourwire_send;
self->end_transaction = common_hal_displayio_fourwire_end_transaction;
} else if (MP_OBJ_IS_TYPE(bus, &displayio_i2cdisplay_type)) {
self->begin_transaction = common_hal_displayio_i2cdisplay_begin_transaction;
self->send = common_hal_displayio_i2cdisplay_send;
self->end_transaction = common_hal_displayio_i2cdisplay_end_transaction;
} else {
mp_raise_ValueError(translate("Unsupported display bus type"));
}
@ -83,13 +93,13 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
bool delay = (data_size & DELAY) != 0;
data_size &= ~DELAY;
uint8_t *data = cmd + 2;
self->send(self->bus, true, cmd, 1);
if (self->data_as_commands) {
// Loop through each parameter to force a CS toggle
for (uint32_t j=0; j < data_size; j++) {
self->send(self->bus, true, data + j, 1);
}
uint8_t full_command[data_size + 1];
full_command[0] = cmd[0];
memcpy(full_command + 1, data, data_size);
self->send(self->bus, true, full_command, data_size + 1);
} else {
self->send(self->bus, true, cmd, 1);
self->send(self->bus, false, data, data_size);
}
uint16_t delay_length_ms = 10;
@ -141,11 +151,14 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
} else {
self->backlight_pwm.base.type = &pulseio_pwmout_type;
common_hal_pulseio_pwmout_never_reset(&self->backlight_pwm);
if (!self->auto_brightness) {
common_hal_displayio_display_set_brightness(self, brightness);
}
}
}
if (!self->auto_brightness && (self->backlight_inout.base.type != &mp_type_NoneType ||
brightness_command != NO_BRIGHTNESS_COMMAND)) {
common_hal_displayio_display_set_brightness(self, brightness);
} else {
self->current_brightness = -1.0;
}
self->area.x1 = 0;
self->area.y1 = 0;
@ -234,17 +247,7 @@ void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* s
}
mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t* self) {
if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
uint16_t duty_cycle = common_hal_pulseio_pwmout_get_duty_cycle(&self->backlight_pwm);
return duty_cycle / ((mp_float_t) 0xffff);
} else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
if (common_hal_digitalio_digitalinout_get_value(&self->backlight_inout)) {
return 1.0;
} else {
return 0.0;
}
}
return -1.0;
return self->current_brightness;
}
bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self, mp_float_t brightness) {
@ -256,8 +259,26 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self,
} else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
common_hal_digitalio_digitalinout_set_value(&self->backlight_inout, brightness > 0.99);
ok = true;
} else if (self->brightness_command != NO_BRIGHTNESS_COMMAND) {
ok = self->begin_transaction(self->bus);
if (ok) {
if (self->data_as_commands) {
uint8_t set_brightness[2] = {self->brightness_command, (uint8_t) (0xff * brightness)};
self->send(self->bus, true, set_brightness, 2);
} else {
uint8_t command = self->brightness_command;
uint8_t hex_brightness = 0xff * brightness;
self->send(self->bus, true, &command, 1);
self->send(self->bus, false, &hex_brightness, 1);
}
self->end_transaction(self->bus);
}
}
self->updating_backlight = false;
if (ok) {
self->current_brightness = brightness;
}
return ok;
}
@ -269,35 +290,64 @@ void displayio_display_end_transaction(displayio_display_obj_t* self) {
self->end_transaction(self->bus);
}
void displayio_display_set_region_to_update(displayio_display_obj_t* self, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
self->send(self->bus, true, &self->set_column_command, 1);
bool isCommand = self->data_as_commands;
if (self->single_byte_bounds) {
uint8_t data[2];
data[0] = x0 + self->colstart;
data[1] = x1 - 1 + self->colstart;
self->send(self->bus, isCommand, (uint8_t*) data, 2);
} else {
uint16_t data[2];
data[0] = __builtin_bswap16(x0 + self->colstart);
data[1] = __builtin_bswap16(x1 - 1 + self->colstart);
self->send(self->bus, isCommand, (uint8_t*) data, 4);
}
self->send(self->bus, true, &self->set_row_command, 1);
if (self->single_byte_bounds) {
uint8_t data[2];
data[0] = y0 + self->rowstart;
data[1] = y1 - 1 + self->rowstart;
self->send(self->bus, isCommand, (uint8_t*) data, 2);
} else {
uint16_t data[2];
data[0] = __builtin_bswap16(y0 + self->rowstart);
data[1] = __builtin_bswap16(y1 - 1 + self->rowstart);
self->send(self->bus, isCommand, (uint8_t*) data, 4);
void displayio_display_set_region_to_update(displayio_display_obj_t* self, displayio_area_t* area) {
uint16_t x1 = area->x1;
uint16_t x2 = area->x2;
uint16_t y1 = area->y1;
uint16_t y2 = area->y2;
// Collapse down the dimension where multiple pixels are in a byte.
if (self->colorspace.depth < 8) {
uint8_t pixels_per_byte = 8 / self->colorspace.depth;
if (self->colorspace.pixels_in_byte_share_row) {
x1 /= pixels_per_byte;
x2 /= pixels_per_byte;
} else {
y1 /= pixels_per_byte;
y2 /= pixels_per_byte;
}
}
// Set column.
uint8_t data[5];
data[0] = self->set_column_command;
uint8_t data_length = 1;
if (!self->data_as_commands) {
self->send(self->bus, true, &self->write_ram_command, 1);
self->send(self->bus, true, data, 1);
data_length = 0;
}
if (self->single_byte_bounds) {
data[data_length++] = x1 + self->colstart;
data[data_length++] = x2 - 1 + self->colstart;
data_length += 2;
} else {
x1 += self->colstart;
x2 += self->colstart - 1;
data[data_length++] = x1 >> 8;
data[data_length++] = x1 & 0xff;
data[data_length++] = x2 >> 8;
data[data_length++] = x2 & 0xff;
}
self->send(self->bus, self->data_as_commands, data, data_length);
// Set row.
data[0] = self->set_row_command;
data_length = 1;
if (!self->data_as_commands) {
self->send(self->bus, true, data, 1);
data_length = 0;
}
if (self->single_byte_bounds) {
data[data_length++] = y1 + self->rowstart;
data[data_length++] = y2 - 1 + self->rowstart;
} else {
y1 += self->rowstart;
y2 += self->rowstart - 1;
data[data_length++] = y1 >> 8;
data[data_length++] = y1 & 0xff;
data[data_length++] = y2 >> 8;
data[data_length++] = y2 & 0xff;
}
self->send(self->bus, self->data_as_commands, data, data_length);
}
void displayio_display_start_refresh(displayio_display_obj_t* self) {
@ -322,6 +372,9 @@ void displayio_display_finish_refresh(displayio_display_obj_t* self) {
}
void displayio_display_send_pixels(displayio_display_obj_t* self, uint8_t* pixels, uint32_t length) {
if (!self->data_as_commands) {
self->send(self->bus, true, &self->write_ram_command, 1);
}
self->send(self->bus, false, pixels, length);
}
@ -349,9 +402,33 @@ void release_display(displayio_display_obj_t* self) {
}
bool displayio_display_fill_area(displayio_display_obj_t *self, displayio_area_t* area, uint32_t* mask, uint32_t *buffer) {
return displayio_group_fill_area(self->current_group, area, mask, buffer);
return displayio_group_fill_area(self->current_group, &self->colorspace, area, mask, buffer);
}
bool displayio_display_clip_area(displayio_display_obj_t *self, const displayio_area_t* area, displayio_area_t* clipped) {
return displayio_area_compute_overlap(&self->area, area, clipped);
bool overlaps = displayio_area_compute_overlap(&self->area, area, clipped);
if (!overlaps) {
return false;
}
// Expand the area if we have multiple pixels per byte and we need to byte
// align the bounds.
if (self->colorspace.depth < 8) {
uint8_t pixels_per_byte = 8 / self->colorspace.depth;
if (self->colorspace.pixels_in_byte_share_row) {
if (clipped->x1 % pixels_per_byte != 0) {
clipped->x1 -= clipped->x1 % pixels_per_byte;
}
if (clipped->x2 % pixels_per_byte != 0) {
clipped->x2 += pixels_per_byte - clipped->x2 % pixels_per_byte;
}
} else {
if (clipped->y1 % pixels_per_byte != 0) {
clipped->y1 -= clipped->y1 % pixels_per_byte;
}
if (clipped->y2 % pixels_per_byte != 0) {
clipped->y2 += pixels_per_byte - clipped->y2 % pixels_per_byte;
}
}
}
return true;
}

View File

@ -52,11 +52,13 @@ typedef struct {
uint64_t last_backlight_refresh;
displayio_buffer_transform_t transform;
displayio_area_t area;
mp_float_t current_brightness;
uint16_t width;
uint16_t height;
uint16_t color_depth;
_displayio_colorspace_t colorspace;
int16_t colstart;
int16_t rowstart;
uint16_t brightness_command;
uint8_t set_column_command;
uint8_t set_row_command;
uint8_t write_ram_command;

View File

@ -59,6 +59,11 @@ void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self,
common_hal_digitalio_digitalinout_construct(&self->reset, reset);
common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL);
never_reset_pin_number(reset->number);
common_hal_digitalio_digitalinout_set_value(&self->reset, false);
common_hal_mcu_delay_us(10);
common_hal_digitalio_digitalinout_set_value(&self->reset, true);
common_hal_mcu_delay_us(10);
}
never_reset_pin_number(command->number);
@ -88,13 +93,19 @@ bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t obj) {
void common_hal_displayio_fourwire_send(mp_obj_t obj, bool command, uint8_t *data, uint32_t data_length) {
displayio_fourwire_obj_t* self = MP_OBJ_TO_PTR(obj);
if (command) {
common_hal_digitalio_digitalinout_set_value(&self->chip_select, true);
common_hal_mcu_delay_us(1);
common_hal_digitalio_digitalinout_set_value(&self->chip_select, false);
}
common_hal_digitalio_digitalinout_set_value(&self->command, !command);
common_hal_busio_spi_write(self->bus, data, data_length);
if (command) {
// Toggle chip select after each command byte in case the display driver
// IC latches commands based on it.
for (size_t i = 0; i < data_length; i++) {
common_hal_busio_spi_write(self->bus, &data[i], 1);
common_hal_digitalio_digitalinout_set_value(&self->chip_select, true);
common_hal_mcu_delay_us(1);
common_hal_digitalio_digitalinout_set_value(&self->chip_select, false);
}
} else {
common_hal_busio_spi_write(self->bus, data, data_length);
}
}
void common_hal_displayio_fourwire_end_transaction(mp_obj_t obj) {

View File

@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_FOURWIRE_H
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_FOURWIRE_H
#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FOURWIRE_H
#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FOURWIRE_H
#include "common-hal/busio/SPI.h"
#include "common-hal/digitalio/DigitalInOut.h"
@ -43,4 +43,4 @@ typedef struct {
uint8_t phase;
} displayio_fourwire_obj_t;
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_FOURWIRE_H
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FOURWIRE_H

View File

@ -270,19 +270,19 @@ void displayio_group_construct(displayio_group_t* self, displayio_group_child_t*
self->in_group = false;
}
bool displayio_group_fill_area(displayio_group_t *self, const displayio_area_t* area, uint32_t* mask, uint32_t* buffer) {
bool displayio_group_fill_area(displayio_group_t *self, const _displayio_colorspace_t* colorspace, const displayio_area_t* area, uint32_t* mask, uint32_t* buffer) {
// Track if any of the layers finishes filling in the given area. We can ignore any remaining
// layers at that point.
bool full_coverage = false;
for (int32_t i = self->size - 1; i >= 0 ; i--) {
mp_obj_t layer = self->children[i].native;
if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) {
if (displayio_tilegrid_fill_area(layer, area, mask, buffer)) {
if (displayio_tilegrid_fill_area(layer, colorspace, area, mask, buffer)) {
full_coverage = true;
break;
}
} else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) {
if (displayio_group_fill_area(layer, area, mask, buffer)) {
if (displayio_group_fill_area(layer, colorspace, area, mask, buffer)) {
full_coverage = true;
break;
}

View File

@ -32,6 +32,7 @@
#include "py/obj.h"
#include "shared-module/displayio/area.h"
#include "shared-module/displayio/Palette.h"
typedef struct {
mp_obj_t native;
@ -54,7 +55,7 @@ typedef struct {
void displayio_group_construct(displayio_group_t* self, displayio_group_child_t* child_array, uint32_t max_size, uint32_t scale, mp_int_t x, mp_int_t y);
bool displayio_group_get_previous_area(displayio_group_t *group, displayio_area_t* area);
bool displayio_group_fill_area(displayio_group_t *group, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
bool displayio_group_fill_area(displayio_group_t *group, const _displayio_colorspace_t* colorspace, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
void displayio_group_update_transform(displayio_group_t *group, const displayio_buffer_transform_t* parent_transform);
void displayio_group_finish_refresh(displayio_group_t *self);
displayio_area_t* displayio_group_get_refresh_areas(displayio_group_t *self, displayio_area_t* tail);

View File

@ -0,0 +1,105 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 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 "shared-bindings/displayio/I2CDisplay.h"
#include <stdint.h>
#include <string.h>
#include "py/gc.h"
#include "py/runtime.h"
#include "shared-bindings/busio/I2C.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/time/__init__.h"
#include "tick.h"
void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
busio_i2c_obj_t* i2c, uint16_t device_address, const mcu_pin_obj_t* reset) {
// Probe the bus to see if a device acknowledges the given address.
if (!common_hal_busio_i2c_probe(i2c, device_address)) {
mp_raise_ValueError_varg(translate("Unable to find I2C Display at %x"), device_address);
}
// Write to the device and return 0 on success or an appropriate error code from mperrno.h
self->bus = i2c;
common_hal_busio_i2c_never_reset(self->bus);
// Our object is statically allocated off the heap so make sure the bus object lives to the end
// of the heap as well.
gc_never_free(self->bus);
self->address = device_address;
if (reset != NULL) {
common_hal_digitalio_digitalinout_construct(&self->reset, reset);
common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL);
never_reset_pin_number(reset->number);
common_hal_digitalio_digitalinout_set_value(&self->reset, false);
common_hal_mcu_delay_us(1);
common_hal_digitalio_digitalinout_set_value(&self->reset, true);
}
}
void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t* self) {
if (self->bus == &self->inline_bus) {
common_hal_busio_i2c_deinit(self->bus);
}
reset_pin_number(self->reset.pin->number);
}
bool common_hal_displayio_i2cdisplay_begin_transaction(mp_obj_t obj) {
displayio_i2cdisplay_obj_t* self = MP_OBJ_TO_PTR(obj);
if (!common_hal_busio_i2c_try_lock(self->bus)) {
return false;
}
return true;
}
void common_hal_displayio_i2cdisplay_send(mp_obj_t obj, bool command, uint8_t *data, uint32_t data_length) {
displayio_i2cdisplay_obj_t* self = MP_OBJ_TO_PTR(obj);
if (command) {
uint8_t command_bytes[2 * data_length];
for (uint32_t i = 0; i < data_length; i++) {
command_bytes[2 * i] = 0x80;
command_bytes[2 * i + 1] = data[i];
}
common_hal_busio_i2c_write(self->bus, self->address, command_bytes, 2 * data_length, true);
} else {
uint8_t data_bytes[data_length + 1];
data_bytes[0] = 0x40;
memcpy(data_bytes + 1, data, data_length);
common_hal_busio_i2c_write(self->bus, self->address, data_bytes, data_length + 1, true);
}
}
void common_hal_displayio_i2cdisplay_end_transaction(mp_obj_t obj) {
displayio_i2cdisplay_obj_t* self = MP_OBJ_TO_PTR(obj);
common_hal_busio_i2c_unlock(self->bus);
}

View File

@ -0,0 +1,41 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 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.
*/
#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_I2CDISPLAY_H
#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_I2CDISPLAY_H
#include "common-hal/busio/I2C.h"
#include "common-hal/digitalio/DigitalInOut.h"
typedef struct {
mp_obj_base_t base;
busio_i2c_obj_t* bus;
busio_i2c_obj_t inline_bus;
digitalio_digitalinout_obj_t reset;
uint16_t address;
} displayio_i2cdisplay_obj_t;
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_I2CDISPLAY_H

View File

@ -26,49 +26,49 @@
#include "shared-bindings/displayio/Palette.h"
#include "shared-module/displayio/ColorConverter.h"
void common_hal_displayio_palette_construct(displayio_palette_t* self, uint16_t color_count) {
self->color_count = color_count;
self->colors = (uint32_t *) m_malloc(color_count * sizeof(uint16_t), false);
uint32_t opaque_byte_count = color_count / 8;
if (color_count % 8 > 0) {
opaque_byte_count += 1;
}
self->opaque = (uint32_t *) m_malloc(opaque_byte_count, false);
self->colors = (_displayio_color_t *) m_malloc(color_count * sizeof(_displayio_color_t), false);
}
void common_hal_displayio_palette_make_opaque(displayio_palette_t* self, uint32_t palette_index) {
self->opaque[palette_index / 32] &= ~(0x1 << (palette_index % 32));
self->colors[palette_index].transparent = false;
}
void common_hal_displayio_palette_make_transparent(displayio_palette_t* self, uint32_t palette_index) {
self->opaque[palette_index / 32] |= (0x1 << (palette_index % 32));
self->colors[palette_index].transparent = true;
}
uint32_t common_hal_displayio_palette_get_len(displayio_palette_t* self) {
return self->color_count;
}
void common_hal_displayio_palette_set_color(displayio_palette_t* self, uint32_t palette_index, uint32_t color) {
uint32_t shift = (palette_index % 2) * 16;
uint32_t masked = self->colors[palette_index / 2] & ~(0xffff << shift);
uint32_t r5 = (color >> 19);
uint32_t g6 = (color >> 10) & 0x3f;
uint32_t b5 = (color >> 3) & 0x1f;
uint32_t packed = r5 << 11 | g6 << 5 | b5;
// swap bytes
packed = __builtin_bswap16(packed);
uint32_t final_color = masked | packed << shift;
if (self->colors[palette_index / 2] == final_color) {
if (self->colors[palette_index].rgb888 == color) {
return;
}
self->colors[palette_index / 2] = final_color;
self->colors[palette_index].rgb888 = color;
self->colors[palette_index].luma = displayio_colorconverter_compute_luma(color);
self->colors[palette_index].rgb565 = displayio_colorconverter_compute_rgb565(color);
self->needs_refresh = true;
}
bool displayio_palette_get_color(displayio_palette_t *self, uint32_t palette_index, uint16_t* color) {
if (palette_index > self->color_count) {
return false;
uint32_t common_hal_displayio_palette_get_color(displayio_palette_t* self, uint32_t palette_index) {
return self->colors[palette_index].rgb888;
}
bool displayio_palette_get_color(displayio_palette_t *self, const _displayio_colorspace_t* colorspace, uint32_t palette_index, uint32_t* color) {
if (palette_index > self->color_count || self->colors[palette_index].transparent) {
return false; // returns opaque
}
if ((self->opaque[palette_index / 32] & (0x1 << (palette_index % 32))) != 0) {
return false;
if (colorspace->grayscale) {
*color = self->colors[palette_index].luma >> (8 - colorspace->depth);
} else {
*color = self->colors[palette_index].rgb565;
}
*color = (self->colors[palette_index / 2] >> (16 * (palette_index % 2))) & 0xffff;
return true;
}

View File

@ -32,15 +32,30 @@
#include "py/obj.h"
typedef struct {
uint8_t depth;
bool grayscale;
bool pixels_in_byte_share_row;
uint8_t hue;
} _displayio_colorspace_t;
typedef struct {
uint32_t rgb888;
uint16_t rgb565;
uint8_t luma;
bool transparent; // This may have additional bits added later for blending.
} _displayio_color_t;
typedef struct {
mp_obj_base_t base;
uint32_t* opaque;
uint32_t* colors;
_displayio_color_t* colors;
uint32_t color_count;
bool needs_refresh;
} displayio_palette_t;
bool displayio_palette_get_color(displayio_palette_t *palette, uint32_t palette_index, uint16_t* color);
// Returns false if color fetch did not succeed (out of range or transparent).
// Returns true if color is opaque, and sets color.
bool displayio_palette_get_color(displayio_palette_t *palette, const _displayio_colorspace_t* colorspace, uint32_t palette_index, uint32_t* color);
bool displayio_palette_needs_refresh(displayio_palette_t *self);
void displayio_palette_finish_refresh(displayio_palette_t *self);

View File

@ -291,7 +291,7 @@ void common_hal_displayio_tilegrid_set_top_left(displayio_tilegrid_t *self, uint
self->full_change = true;
}
bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer) {
bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const _displayio_colorspace_t* colorspace, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer) {
// If no tiles are present we have no impact.
uint8_t* tiles = self->tiles;
if (self->inline_tiles) {
@ -371,14 +371,15 @@ bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const displayio_ar
y_shift = temp_shift;
}
uint8_t pixels_per_byte = 8 / colorspace->depth;
for (int16_t y = start_y; y < end_y; y++) {
int16_t row_start = start + (y - start_y + y_shift) * y_stride;
int16_t row_start = start + (y - start_y + y_shift) * y_stride; // in pixels
int16_t local_y = y / self->absolute_transform->scale;
for (int16_t x = start_x; x < end_x; x++) {
// Compute the destination pixel in the buffer and mask based on the transformations.
int16_t offset = row_start + (x - start_x + x_shift) * x_stride;
int16_t offset = row_start + (x - start_x + x_shift) * x_stride; // in pixels
// This is super useful for debugging out range accesses. Uncomment to use.
// This is super useful for debugging out of range accesses. Uncomment to use.
// if (offset < 0 || offset >= (int32_t) displayio_area_size(area)) {
// asm("bkpt");
// }
@ -404,23 +405,38 @@ bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const displayio_ar
value = common_hal_displayio_ondiskbitmap_get_pixel(self->bitmap, tile_x, tile_y);
}
uint16_t* pixel = ((uint16_t*) buffer) + offset;
uint32_t pixel;
bool opaque = true;
if (self->pixel_shader == mp_const_none) {
*pixel = value;
return true;
pixel = value;
} else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type)) {
if (!displayio_palette_get_color(self->pixel_shader, value, pixel)) {
// A pixel is transparent so we haven't fully covered the area ourselves.
full_coverage = false;
} else {
mask[offset / 32] |= 1 << (offset % 32);
}
opaque = displayio_palette_get_color(self->pixel_shader, colorspace, value, &pixel);
} else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type)) {
if (!common_hal_displayio_colorconverter_convert(self->pixel_shader, value, pixel)) {
// A pixel is transparent so we haven't fully covered the area ourselves.
full_coverage = false;
} else {
mask[offset / 32] |= 1 << (offset % 32);
opaque = displayio_colorconverter_convert(self->pixel_shader, colorspace, value, &pixel);
}
if (!opaque) {
// A pixel is transparent so we haven't fully covered the area ourselves.
full_coverage = false;
} else {
mask[offset / 32] |= 1 << (offset % 32);
if (colorspace->depth == 16) {
*(((uint16_t*) buffer) + offset) = pixel;
} else if (colorspace->depth == 8) {
*(((uint8_t*) buffer) + offset) = pixel;
} else if (colorspace->depth < 8) {
// Reorder the offsets to pack multiple rows into a byte (meaning they share a column).
if (!colorspace->pixels_in_byte_share_row) {
uint16_t width = displayio_area_width(area);
uint16_t row = offset / width;
uint16_t col = offset % width;
// Dividing by pixels_per_byte does truncated division even if we multiply it back out.
offset = col * pixels_per_byte + (row / pixels_per_byte) * pixels_per_byte * width + row % pixels_per_byte;
// Also useful for validating that the bitpacking worked correctly.
// if (offset > displayio_area_size(area)) {
// asm("bkpt");
// }
}
((uint8_t*)buffer)[offset / pixels_per_byte] |= pixel << ((offset % pixels_per_byte) * colorspace->depth);
}
}
}

View File

@ -32,6 +32,7 @@
#include "py/obj.h"
#include "shared-module/displayio/area.h"
#include "shared-module/displayio/Palette.h"
typedef struct {
mp_obj_base_t base;
@ -71,7 +72,7 @@ displayio_area_t* displayio_tilegrid_get_refresh_areas(displayio_tilegrid_t *sel
// Area is always in absolute screen coordinates. Update transform is used to inform TileGrids how
// they relate to it.
bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const _displayio_colorspace_t* colorspace, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
void displayio_tilegrid_update_transform(displayio_tilegrid_t *group, const displayio_buffer_transform_t* parent_transform);
// Fills in area with the maximum bounds of all related pixels in the last rendered frame. Returns

View File

@ -19,9 +19,10 @@
#include "supervisor/usb.h"
primary_display_t displays[CIRCUITPY_DISPLAY_LIMIT];
uint32_t frame_count = 0;
bool refresh_area(displayio_display_obj_t* display, const displayio_area_t* area) {
uint16_t buffer_size = 512;
uint16_t buffer_size = 128; // In uint32_ts
displayio_area_t clipped;
// Clip the area to the display by overlapping the areas. If there is no overlap then we're done.
@ -30,15 +31,36 @@ bool refresh_area(displayio_display_obj_t* display, const displayio_area_t* area
}
uint16_t subrectangles = 1;
uint16_t rows_per_buffer = displayio_area_height(&clipped);
if (displayio_area_size(area) > buffer_size) {
rows_per_buffer = buffer_size / displayio_area_width(&clipped);
uint8_t pixels_per_word = (sizeof(uint32_t) * 8) / display->colorspace.depth;
uint16_t pixels_per_buffer = displayio_area_size(&clipped);
if (displayio_area_size(&clipped) > buffer_size * pixels_per_word) {
rows_per_buffer = buffer_size * pixels_per_word / displayio_area_width(&clipped);
if (rows_per_buffer == 0) {
rows_per_buffer = 1;
}
// If pixels are packed by column then ensure rows_per_buffer is on a byte boundary.
if (display->colorspace.depth < 8 && !display->colorspace.pixels_in_byte_share_row) {
uint8_t pixels_per_byte = 8 / display->colorspace.depth;
if (rows_per_buffer % pixels_per_byte != 0) {
rows_per_buffer -= rows_per_buffer % pixels_per_byte;
}
}
subrectangles = displayio_area_height(&clipped) / rows_per_buffer;
if (displayio_area_height(&clipped) % rows_per_buffer != 0) {
subrectangles++;
}
buffer_size = rows_per_buffer * displayio_area_width(&clipped);
pixels_per_buffer = rows_per_buffer * displayio_area_width(&clipped);
buffer_size = pixels_per_buffer / pixels_per_word;
if (pixels_per_buffer % pixels_per_word) {
buffer_size += 1;
}
}
uint32_t buffer[buffer_size / 2];
// Allocated and shared as a uint32_t array so the compiler knows the
// alignment everywhere.
uint32_t buffer[buffer_size];
volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1;
uint32_t mask[mask_length];
uint16_t remaining_rows = displayio_area_height(&clipped);
for (uint16_t j = 0; j < subrectangles; j++) {
@ -54,37 +76,30 @@ bool refresh_area(displayio_display_obj_t* display, const displayio_area_t* area
remaining_rows -= rows_per_buffer;
displayio_display_begin_transaction(display);
displayio_display_set_region_to_update(display, subrectangle.x1, subrectangle.y1,
subrectangle.x2, subrectangle.y2);
displayio_display_set_region_to_update(display, &subrectangle);
displayio_display_end_transaction(display);
uint32_t mask[(buffer_size / 32) + 1];
for (uint16_t k = 0; k < (buffer_size / 32) + 1; k++) {
mask[k] = 0x00000000;
uint16_t subrectangle_size_bytes;
if (display->colorspace.depth >= 8) {
subrectangle_size_bytes = displayio_area_size(&subrectangle) * (display->colorspace.depth / 8);
} else {
subrectangle_size_bytes = displayio_area_size(&subrectangle) / (8 / display->colorspace.depth);
}
bool full_coverage = displayio_display_fill_area(display, &subrectangle, mask, buffer);
if (!full_coverage) {
uint32_t index = 0;
uint32_t current_mask = 0;
for (int16_t y = subrectangle.y1; y < subrectangle.y2; y++) {
for (int16_t x = subrectangle.x1; x < subrectangle.x2; x++) {
if (index % 32 == 0) {
current_mask = mask[index / 32];
}
if ((current_mask & (1 << (index % 32))) == 0) {
((uint16_t*) buffer)[index] = 0x0000;
}
index++;
}
}
for (uint16_t k = 0; k < mask_length; k++) {
mask[k] = 0x00000000;
}
for (uint16_t k = 0; k < buffer_size; k++) {
buffer[k] = 0x00000000;
}
displayio_display_fill_area(display, &subrectangle, mask, buffer);
if (!displayio_display_begin_transaction(display)) {
// Can't acquire display bus; skip the rest of the data. Try next display.
return false;
}
displayio_display_send_pixels(display, (uint8_t*) buffer, displayio_area_size(&subrectangle) * sizeof(uint16_t));
displayio_display_send_pixels(display, (uint8_t*) buffer, subrectangle_size_bytes);
displayio_display_end_transaction(display);
// TODO(tannewt): Make refresh displays faster so we don't starve other
@ -96,7 +111,6 @@ bool refresh_area(displayio_display_obj_t* display, const displayio_area_t* area
// Check for recursive calls to displayio_refresh_displays.
bool refresh_displays_in_progress = false;
uint32_t frame_count = 0;
void displayio_refresh_displays(void) {
if (mp_hal_is_interrupted()) {
@ -153,6 +167,8 @@ void common_hal_displayio_release_displays(void) {
continue;
} else if (bus_type == &displayio_fourwire_type) {
common_hal_displayio_fourwire_deinit(&displays[i].fourwire_bus);
} else if (bus_type == &displayio_i2cdisplay_type) {
common_hal_displayio_i2cdisplay_deinit(&displays[i].i2cdisplay_bus);
} else if (bus_type == &displayio_parallelbus_type) {
common_hal_displayio_parallelbus_deinit(&displays[i].parallel_bus);
}
@ -169,30 +185,53 @@ void common_hal_displayio_release_displays(void) {
void reset_displays(void) {
// The SPI buses used by FourWires may be allocated on the heap so we need to move them inline.
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
if (displays[i].fourwire_bus.base.type != &displayio_fourwire_type) {
continue;
}
displayio_fourwire_obj_t* fourwire = &displays[i].fourwire_bus;
if (((uint32_t) fourwire->bus) < ((uint32_t) &displays) ||
((uint32_t) fourwire->bus) > ((uint32_t) &displays + CIRCUITPY_DISPLAY_LIMIT)) {
busio_spi_obj_t* original_spi = fourwire->bus;
#if BOARD_SPI
// We don't need to move original_spi if it is the board.SPI object because it is
// statically allocated already. (Doing so would also make it impossible to reference in
// a subsequent VM run.)
if (original_spi == common_hal_board_get_spi()) {
continue;
}
#endif
memcpy(&fourwire->inline_bus, original_spi, sizeof(busio_spi_obj_t));
fourwire->bus = &fourwire->inline_bus;
// Check for other displays that use the same spi bus and swap them too.
for (uint8_t j = i + 1; j < CIRCUITPY_DISPLAY_LIMIT; j++) {
if (displays[i].fourwire_bus.bus == original_spi) {
displays[i].fourwire_bus.bus = &fourwire->inline_bus;
if (displays[i].fourwire_bus.base.type == &displayio_fourwire_type) {
displayio_fourwire_obj_t* fourwire = &displays[i].fourwire_bus;
if (((uint32_t) fourwire->bus) < ((uint32_t) &displays) ||
((uint32_t) fourwire->bus) > ((uint32_t) &displays + CIRCUITPY_DISPLAY_LIMIT)) {
busio_spi_obj_t* original_spi = fourwire->bus;
#if BOARD_SPI
// We don't need to move original_spi if it is the board.SPI object because it is
// statically allocated already. (Doing so would also make it impossible to reference in
// a subsequent VM run.)
if (original_spi == common_hal_board_get_spi()) {
continue;
}
#endif
memcpy(&fourwire->inline_bus, original_spi, sizeof(busio_spi_obj_t));
fourwire->bus = &fourwire->inline_bus;
// Check for other displays that use the same spi bus and swap them too.
for (uint8_t j = i + 1; j < CIRCUITPY_DISPLAY_LIMIT; j++) {
if (displays[i].fourwire_bus.base.type == &displayio_fourwire_type &&
displays[i].fourwire_bus.bus == original_spi) {
displays[i].fourwire_bus.bus = &fourwire->inline_bus;
}
}
}
} else if (displays[i].i2cdisplay_bus.base.type == &displayio_i2cdisplay_type) {
displayio_i2cdisplay_obj_t* i2c = &displays[i].i2cdisplay_bus;
if (((uint32_t) i2c->bus) < ((uint32_t) &displays) ||
((uint32_t) i2c->bus) > ((uint32_t) &displays + CIRCUITPY_DISPLAY_LIMIT)) {
busio_i2c_obj_t* original_i2c = i2c->bus;
#if BOARD_I2C
// We don't need to move original_i2c if it is the board.SPI object because it is
// statically allocated already. (Doing so would also make it impossible to reference in
// a subsequent VM run.)
if (original_i2c == common_hal_board_get_i2c()) {
continue;
}
#endif
memcpy(&i2c->inline_bus, original_i2c, sizeof(busio_i2c_obj_t));
i2c->bus = &i2c->inline_bus;
// Check for other displays that use the same i2c bus and swap them too.
for (uint8_t j = i + 1; j < CIRCUITPY_DISPLAY_LIMIT; j++) {
if (displays[i].i2cdisplay_bus.base.type == &displayio_i2cdisplay_type &&
displays[i].i2cdisplay_bus.bus == original_i2c) {
displays[i].i2cdisplay_bus.bus = &i2c->inline_bus;
}
}
}
}
}
}
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {

View File

@ -30,11 +30,13 @@
#include "shared-bindings/displayio/Display.h"
#include "shared-bindings/displayio/FourWire.h"
#include "shared-bindings/displayio/Group.h"
#include "shared-bindings/displayio/I2CDisplay.h"
#include "shared-bindings/displayio/ParallelBus.h"
typedef struct {
union {
displayio_fourwire_obj_t fourwire_bus;
displayio_i2cdisplay_obj_t i2cdisplay_bus;
displayio_parallelbus_obj_t parallel_bus;
};
displayio_display_obj_t display;

View File

@ -35,6 +35,8 @@ void common_hal_terminalio_terminal_construct(terminalio_terminal_obj_t *self, d
self->font = font;
self->tilegrid = tilegrid;
self->first_row = 0;
common_hal_displayio_tilegrid_set_top_left(self->tilegrid, 0, 1);
}
size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, const byte *data, size_t len, int *errcode) {

View File

@ -82,8 +82,7 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
grid->pixel_height = height_in_tiles * grid->tile_height;
grid->tiles = tiles;
supervisor_terminal.cursor_x = 0;
supervisor_terminal.cursor_y = 0;
common_hal_terminalio_terminal_construct(&supervisor_terminal, grid, &supervisor_terminal_font);
}
void supervisor_stop_terminal(void) {
@ -147,17 +146,49 @@ displayio_bitmap_t blinka_bitmap = {
.read_only = true
};
uint32_t blinka_transparency[1] = {0x80000000};
// These colors are RGB 565 with the bytes swapped.
uint32_t blinka_colors[8] = {0x78890000, 0x9F86B8FC, 0xffff0D5A, 0x0000f501,
0x00000000, 0x00000000, 0x00000000, 0x00000000};
_displayio_color_t blinka_colors[7] = {
{
.rgb888 = 0x000000,
.rgb565 = 0x0000,
.luma = 0x00,
.transparent = true
},
{
.rgb888 = 0x8428bc,
.rgb565 = 0x7889,
.luma = 0xff // We cheat the luma here. It is actually 0x60
},
{
.rgb888 = 0xff89bc,
.rgb565 = 0xB8FC,
.luma = 0xb5
},
{
.rgb888 = 0x7beffe,
.rgb565 = 0x9F86,
.luma = 0xe0
},
{
.rgb888 = 0x51395f,
.rgb565 = 0x0D5A,
.luma = 0x47
},
{
.rgb888 = 0xffffff,
.rgb565 = 0xffff,
.luma = 0xff
},
{
.rgb888 = 0x0736a0,
.rgb565 = 0xf501,
.luma = 0x44
},
};
displayio_palette_t blinka_palette = {
.base = {.type = &displayio_palette_type },
.opaque = blinka_transparency,
.colors = blinka_colors,
.color_count = 16,
.color_count = 7,
.needs_refresh = false
};

View File

@ -98,14 +98,21 @@ c_file.write("""\
""")
c_file.write("""\
uint32_t terminal_transparency[1] = {0x00000000};
// These colors are RGB 565 with the bytes swapped.
uint32_t terminal_colors[1] = {0xffff0000};
_displayio_color_t terminal_colors[2] = {
{
.rgb888 = 0x000000,
.rgb565 = 0x0000,
.luma = 0x00
},
{
.rgb888 = 0xffffff,
.rgb565 = 0xffff,
.luma = 0xff
},
};
displayio_palette_t supervisor_terminal_color = {
.base = {.type = &displayio_palette_type },
.opaque = terminal_transparency,
.colors = terminal_colors,
.color_count = 2,
.needs_refresh = false