diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index ddf3ce98fd..c2ebcf176d 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-08-30 23:06-0700\n" +"POT-Creation-Date: 2018-09-06 14:55-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -231,15 +231,15 @@ msgstr "" msgid "calibration is out of range" msgstr "" -#: ports/atmel-samd/board_busses.c:39 +#: ports/atmel-samd/board_busses.c:39 ports/nrf/board_busses.c:39 msgid "No default I2C bus" msgstr "" -#: ports/atmel-samd/board_busses.c:64 +#: ports/atmel-samd/board_busses.c:64 ports/nrf/board_busses.c:64 msgid "No default SPI bus" msgstr "" -#: ports/atmel-samd/board_busses.c:91 +#: ports/atmel-samd/board_busses.c:91 ports/nrf/board_busses.c:91 msgid "No default UART bus" msgstr "" @@ -388,12 +388,12 @@ msgstr "" msgid "No RX pin" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c:284 +#: ports/atmel-samd/common-hal/busio/UART.c:288 msgid "No TX pin" msgstr "" -#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:168 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:158 +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 msgid "Cannot get pull while in output mode" msgstr "" @@ -426,12 +426,12 @@ msgstr "" msgid "Failed to allocate RX buffer of %d bytes" msgstr "" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:203 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205 #: ports/esp8266/common-hal/pulseio/PulseIn.c:151 msgid "pop from an empty PulseIn" msgstr "" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:235 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 #: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 msgid "index out of range" msgstr "" @@ -685,11 +685,11 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:45 ports/nrf/common-hal/busio/UART.c:49 -#: ports/nrf/common-hal/busio/UART.c:53 ports/nrf/common-hal/busio/UART.c:62 -#: ports/nrf/common-hal/busio/UART.c:68 ports/nrf/common-hal/busio/UART.c:73 -#: ports/nrf/common-hal/busio/UART.c:78 ports/nrf/common-hal/busio/UART.c:83 -#: ports/nrf/common-hal/busio/UART.c:88 +#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 +#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 +#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 +#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 +#: ports/nrf/common-hal/busio/UART.c:86 msgid "busio.UART not yet implemented" msgstr "" @@ -2022,6 +2022,60 @@ msgstr "" msgid "Unsupported pull value." msgstr "" +#: shared-bindings/displayio/Bitmap.c:84 +msgid "y should be an int" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c:89 +msgid "row buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c:94 +msgid "row data must be a buffer" +msgstr "" + +#: shared-bindings/displayio/FourWire.c:55 +#: shared-bindings/displayio/FourWire.c:64 +msgid "displayio is a work in progress" +msgstr "" + +#: shared-bindings/displayio/Group.c:65 +msgid "Group must have size at least 1" +msgstr "" + +#: shared-bindings/displayio/Palette.c:96 +msgid "color buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" + +#: shared-bindings/displayio/Palette.c:102 +msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" +msgstr "" + +#: shared-bindings/displayio/Palette.c:106 +msgid "color must be between 0x000000 and 0xffffff" +msgstr "" + +#: shared-bindings/displayio/Palette.c:110 +msgid "color buffer must be a buffer or int" +msgstr "" + +#: shared-bindings/displayio/Palette.c:123 +#: shared-bindings/displayio/Palette.c:137 +msgid "palette_index should be an int" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:45 +msgid "position must be 2-tuple" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:87 +msgid "unsupported bitmap type" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:152 +msgid "palette must be displayio.Palette" +msgstr "" + #: shared-bindings/gamepad/GamePad.c:100 msgid "too many arguments" msgstr "" @@ -2236,6 +2290,18 @@ msgstr "" msgid "Cannot transfer without MOSI and MISO pins." msgstr "" +#: shared-module/displayio/Bitmap.c:49 +msgid "Only bit maps of 8 bit color or less are supported" +msgstr "" + +#: shared-module/displayio/Bitmap.c:69 +msgid "row must be packed and word aligned" +msgstr "" + +#: shared-module/displayio/Group.c:39 +msgid "Group full" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index c3883a7db7..5e69c1479c 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-08-20 09:37-0700\n" +"POT-Creation-Date: 2018-09-06 14:55-0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Sebastian Plamauer\n" "Language-Team: \n" @@ -159,7 +159,8 @@ msgstr " Ausgabe:\n" msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" -msgstr "Automatisches Neuladen ist aktiv. Speichere Dateien über USB um sie " +msgstr "" +"Automatisches Neuladen ist aktiv. Speichere Dateien über USB um sie " "auszuführen oder verbinde dich mit der REPL um zu deaktivieren.\n" #: main.c:159 @@ -197,26 +198,30 @@ msgstr "CircuitPython ist abgestürzt. Ups!\n" #: main.c:252 msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" -msgstr "Bitte erstelle ein issue hier mit dem Inhalt deines CIRCUITPY-speichers:\n" +msgstr "" +"Bitte erstelle ein issue hier mit dem Inhalt deines CIRCUITPY-speichers:\n" #: main.c:255 msgid "" "The microcontroller's power dipped. Please make sure your power supply " "provides\n" -msgstr "Die Stromversorgung des Mikrocontrollers ist eingebrochen. Stelle sicher," +msgstr "" +"Die Stromversorgung des Mikrocontrollers ist eingebrochen. Stelle sicher," "dass deine Stromversorgung\n" #: main.c:256 msgid "" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" -msgstr "genug Strom für den ganzen Schaltkreis liefert und drücke reset (nach dem" -"sicheren Auswerfen von CIRCUITPY.)\n" +msgstr "" +"genug Strom für den ganzen Schaltkreis liefert und drücke reset (nach " +"demsicheren Auswerfen von CIRCUITPY.)\n" #: main.c:260 msgid "Press any key to enter the REPL. Use CTRL-D to reload." -msgstr "Drücke eine Taste um dich mit der REPL zu verbinden. Drücke Strg-D zum neu" -" laden" +msgstr "" +"Drücke eine Taste um dich mit der REPL zu verbinden. Drücke Strg-D zum neu " +"laden" #: main.c:415 msgid "soft reboot\n" @@ -235,15 +240,15 @@ msgstr "Kalibrierung ist Schreibgeschützt" msgid "calibration is out of range" msgstr "Kalibrierung ist außerhalb der Reichweite" -#: ports/atmel-samd/board_busses.c:39 +#: ports/atmel-samd/board_busses.c:39 ports/nrf/board_busses.c:39 msgid "No default I2C bus" msgstr "Kein Standard I2C Bus" -#: ports/atmel-samd/board_busses.c:64 +#: ports/atmel-samd/board_busses.c:64 ports/nrf/board_busses.c:64 msgid "No default SPI bus" msgstr "Kein Standard SPI Bus" -#: ports/atmel-samd/board_busses.c:91 +#: ports/atmel-samd/board_busses.c:91 ports/nrf/board_busses.c:91 msgid "No default UART bus" msgstr "Kein Standard UART Bus" @@ -392,12 +397,12 @@ msgstr "Konnte UART nicht initialisieren" msgid "No RX pin" msgstr "Kein RX Pin" -#: ports/atmel-samd/common-hal/busio/UART.c:284 +#: ports/atmel-samd/common-hal/busio/UART.c:288 msgid "No TX pin" msgstr "Kein TX Pin" -#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:168 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:158 +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 msgid "Cannot get pull while in output mode" msgstr "Pull up im Ausgabemodus nicht möglich" @@ -430,12 +435,12 @@ msgstr "EXTINT Kanal wird benutzt" msgid "Failed to allocate RX buffer of %d bytes" msgstr "Konnte keine RX Buffer mit %d allozieren" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:203 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205 #: ports/esp8266/common-hal/pulseio/PulseIn.c:151 msgid "pop from an empty PulseIn" msgstr "pop von einem leeren PulseIn" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:235 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 #: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 msgid "index out of range" msgstr "index außerhalb der Reichweite" @@ -614,11 +619,11 @@ msgid "frequency can only be either 80Mhz or 160MHz" msgstr "" #: ports/esp8266/modnetwork.c:61 -msgid "STA required" +msgid "AP required" msgstr "" #: ports/esp8266/modnetwork.c:61 -msgid "AP required" +msgid "STA required" msgstr "" #: ports/esp8266/modnetwork.c:87 @@ -689,11 +694,11 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:45 ports/nrf/common-hal/busio/UART.c:49 -#: ports/nrf/common-hal/busio/UART.c:53 ports/nrf/common-hal/busio/UART.c:62 -#: ports/nrf/common-hal/busio/UART.c:68 ports/nrf/common-hal/busio/UART.c:73 -#: ports/nrf/common-hal/busio/UART.c:78 ports/nrf/common-hal/busio/UART.c:83 -#: ports/nrf/common-hal/busio/UART.c:88 +#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 +#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 +#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 +#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 +#: ports/nrf/common-hal/busio/UART.c:86 msgid "busio.UART not yet implemented" msgstr "" @@ -2026,6 +2031,61 @@ msgstr "" msgid "Unsupported pull value." msgstr "" +#: shared-bindings/displayio/Bitmap.c:84 +msgid "y should be an int" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c:89 +msgid "row buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c:94 +msgid "row data must be a buffer" +msgstr "" + +#: shared-bindings/displayio/FourWire.c:55 +#: shared-bindings/displayio/FourWire.c:64 +msgid "displayio is a work in progress" +msgstr "" + +#: shared-bindings/displayio/Group.c:65 +msgid "Group must have size at least 1" +msgstr "" + +#: shared-bindings/displayio/Palette.c:96 +msgid "color buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" + +#: shared-bindings/displayio/Palette.c:102 +msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" +msgstr "" + +#: shared-bindings/displayio/Palette.c:106 +msgid "color must be between 0x000000 and 0xffffff" +msgstr "" + +#: shared-bindings/displayio/Palette.c:110 +msgid "color buffer must be a buffer or int" +msgstr "" + +#: shared-bindings/displayio/Palette.c:123 +#: shared-bindings/displayio/Palette.c:137 +msgid "palette_index should be an int" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:45 +msgid "position must be 2-tuple" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:87 +#, fuzzy +msgid "unsupported bitmap type" +msgstr "Baudrate wird nicht unterstütz" + +#: shared-bindings/displayio/Sprite.c:152 +msgid "palette must be displayio.Palette" +msgstr "" + #: shared-bindings/gamepad/GamePad.c:100 msgid "too many arguments" msgstr "" @@ -2131,7 +2191,7 @@ msgid "empty sequence" msgstr "" #: shared-bindings/rtc/RTC.c:40 shared-bindings/rtc/RTC.c:44 -#: shared-bindings/time/__init__.c:192 +#: shared-bindings/time/__init__.c:190 msgid "RTC is not supported on this board" msgstr "" @@ -2151,27 +2211,27 @@ msgstr "" msgid "Stack size must be at least 256" msgstr "" -#: shared-bindings/time/__init__.c:80 +#: shared-bindings/time/__init__.c:78 msgid "sleep length must be non-negative" msgstr "" -#: shared-bindings/time/__init__.c:90 +#: shared-bindings/time/__init__.c:88 msgid "time.struct_time() takes exactly 1 argument" msgstr "" -#: shared-bindings/time/__init__.c:93 +#: shared-bindings/time/__init__.c:91 msgid "time.struct_time() takes a 9-sequence" msgstr "" -#: shared-bindings/time/__init__.c:171 shared-bindings/time/__init__.c:252 +#: shared-bindings/time/__init__.c:169 shared-bindings/time/__init__.c:250 msgid "Tuple or struct_time argument required" msgstr "" -#: shared-bindings/time/__init__.c:176 shared-bindings/time/__init__.c:257 +#: shared-bindings/time/__init__.c:174 shared-bindings/time/__init__.c:255 msgid "function takes exactly 9 arguments" msgstr "" -#: shared-bindings/time/__init__.c:228 shared-bindings/time/__init__.c:261 +#: shared-bindings/time/__init__.c:226 shared-bindings/time/__init__.c:259 msgid "timestamp out of range for platform time_t" msgstr "" @@ -2240,6 +2300,18 @@ msgstr "" msgid "Cannot transfer without MOSI and MISO pins." msgstr "" +#: shared-module/displayio/Bitmap.c:49 +msgid "Only bit maps of 8 bit color or less are supported" +msgstr "" + +#: shared-module/displayio/Bitmap.c:69 +msgid "row must be packed and word aligned" +msgstr "" + +#: shared-module/displayio/Group.c:39 +msgid "Group full" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po index 439b67a0ab..a38e88276e 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-08-30 16:12-0700\n" +"POT-Creation-Date: 2018-09-06 14:55-0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -231,15 +231,15 @@ msgstr "" msgid "calibration is out of range" msgstr "" -#: ports/atmel-samd/board_busses.c:39 +#: ports/atmel-samd/board_busses.c:39 ports/nrf/board_busses.c:39 msgid "No default I2C bus" msgstr "" -#: ports/atmel-samd/board_busses.c:64 +#: ports/atmel-samd/board_busses.c:64 ports/nrf/board_busses.c:64 msgid "No default SPI bus" msgstr "" -#: ports/atmel-samd/board_busses.c:91 +#: ports/atmel-samd/board_busses.c:91 ports/nrf/board_busses.c:91 msgid "No default UART bus" msgstr "" @@ -388,12 +388,12 @@ msgstr "" msgid "No RX pin" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c:284 +#: ports/atmel-samd/common-hal/busio/UART.c:288 msgid "No TX pin" msgstr "" -#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:168 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:158 +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 msgid "Cannot get pull while in output mode" msgstr "" @@ -426,12 +426,12 @@ msgstr "" msgid "Failed to allocate RX buffer of %d bytes" msgstr "" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:203 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205 #: ports/esp8266/common-hal/pulseio/PulseIn.c:151 msgid "pop from an empty PulseIn" msgstr "" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:235 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 #: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 msgid "index out of range" msgstr "" @@ -685,11 +685,11 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:45 ports/nrf/common-hal/busio/UART.c:49 -#: ports/nrf/common-hal/busio/UART.c:53 ports/nrf/common-hal/busio/UART.c:62 -#: ports/nrf/common-hal/busio/UART.c:68 ports/nrf/common-hal/busio/UART.c:73 -#: ports/nrf/common-hal/busio/UART.c:78 ports/nrf/common-hal/busio/UART.c:83 -#: ports/nrf/common-hal/busio/UART.c:88 +#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 +#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 +#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 +#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 +#: ports/nrf/common-hal/busio/UART.c:86 msgid "busio.UART not yet implemented" msgstr "" @@ -2022,6 +2022,60 @@ msgstr "" msgid "Unsupported pull value." msgstr "" +#: shared-bindings/displayio/Bitmap.c:84 +msgid "y should be an int" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c:89 +msgid "row buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c:94 +msgid "row data must be a buffer" +msgstr "" + +#: shared-bindings/displayio/FourWire.c:55 +#: shared-bindings/displayio/FourWire.c:64 +msgid "displayio is a work in progress" +msgstr "" + +#: shared-bindings/displayio/Group.c:65 +msgid "Group must have size at least 1" +msgstr "" + +#: shared-bindings/displayio/Palette.c:96 +msgid "color buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" + +#: shared-bindings/displayio/Palette.c:102 +msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" +msgstr "" + +#: shared-bindings/displayio/Palette.c:106 +msgid "color must be between 0x000000 and 0xffffff" +msgstr "" + +#: shared-bindings/displayio/Palette.c:110 +msgid "color buffer must be a buffer or int" +msgstr "" + +#: shared-bindings/displayio/Palette.c:123 +#: shared-bindings/displayio/Palette.c:137 +msgid "palette_index should be an int" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:45 +msgid "position must be 2-tuple" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:87 +msgid "unsupported bitmap type" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:152 +msgid "palette must be displayio.Palette" +msgstr "" + #: shared-bindings/gamepad/GamePad.c:100 msgid "too many arguments" msgstr "" @@ -2236,6 +2290,18 @@ msgstr "" msgid "Cannot transfer without MOSI and MISO pins." msgstr "" +#: shared-module/displayio/Bitmap.c:49 +msgid "Only bit maps of 8 bit color or less are supported" +msgstr "" + +#: shared-module/displayio/Bitmap.c:69 +msgid "row must be packed and word aligned" +msgstr "" + +#: shared-module/displayio/Group.c:39 +msgid "Group full" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "" diff --git a/locale/es.po b/locale/es.po index 19d2830ad9..bd4feef0a2 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-08-30 16:12-0700\n" +"POT-Creation-Date: 2018-09-06 14:55-0700\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -246,15 +246,15 @@ msgstr "" msgid "calibration is out of range" msgstr "" -#: ports/atmel-samd/board_busses.c:39 +#: ports/atmel-samd/board_busses.c:39 ports/nrf/board_busses.c:39 msgid "No default I2C bus" msgstr "" -#: ports/atmel-samd/board_busses.c:64 +#: ports/atmel-samd/board_busses.c:64 ports/nrf/board_busses.c:64 msgid "No default SPI bus" msgstr "" -#: ports/atmel-samd/board_busses.c:91 +#: ports/atmel-samd/board_busses.c:91 ports/nrf/board_busses.c:91 msgid "No default UART bus" msgstr "" @@ -404,12 +404,12 @@ msgstr "" msgid "No RX pin" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c:284 +#: ports/atmel-samd/common-hal/busio/UART.c:288 msgid "No TX pin" msgstr "" -#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:168 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:158 +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 msgid "Cannot get pull while in output mode" msgstr "" @@ -442,12 +442,12 @@ msgstr "El canal EXTINT ya esta siendo usado" msgid "Failed to allocate RX buffer of %d bytes" msgstr "Fallo la asignación del buffer RX de %d bytes" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:203 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205 #: ports/esp8266/common-hal/pulseio/PulseIn.c:151 msgid "pop from an empty PulseIn" msgstr "" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:235 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 #: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 msgid "index out of range" msgstr "" @@ -703,11 +703,11 @@ msgstr "" msgid "AnalogOut functionality not supported" msgstr "" -#: ports/nrf/common-hal/busio/UART.c:45 ports/nrf/common-hal/busio/UART.c:49 -#: ports/nrf/common-hal/busio/UART.c:53 ports/nrf/common-hal/busio/UART.c:62 -#: ports/nrf/common-hal/busio/UART.c:68 ports/nrf/common-hal/busio/UART.c:73 -#: ports/nrf/common-hal/busio/UART.c:78 ports/nrf/common-hal/busio/UART.c:83 -#: ports/nrf/common-hal/busio/UART.c:88 +#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 +#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 +#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 +#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 +#: ports/nrf/common-hal/busio/UART.c:86 msgid "busio.UART not yet implemented" msgstr "" @@ -2068,6 +2068,60 @@ msgstr "" msgid "Unsupported pull value." msgstr "" +#: shared-bindings/displayio/Bitmap.c:84 +msgid "y should be an int" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c:89 +msgid "row buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c:94 +msgid "row data must be a buffer" +msgstr "" + +#: shared-bindings/displayio/FourWire.c:55 +#: shared-bindings/displayio/FourWire.c:64 +msgid "displayio is a work in progress" +msgstr "" + +#: shared-bindings/displayio/Group.c:65 +msgid "Group must have size at least 1" +msgstr "" + +#: shared-bindings/displayio/Palette.c:96 +msgid "color buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" + +#: shared-bindings/displayio/Palette.c:102 +msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" +msgstr "" + +#: shared-bindings/displayio/Palette.c:106 +msgid "color must be between 0x000000 and 0xffffff" +msgstr "" + +#: shared-bindings/displayio/Palette.c:110 +msgid "color buffer must be a buffer or int" +msgstr "" + +#: shared-bindings/displayio/Palette.c:123 +#: shared-bindings/displayio/Palette.c:137 +msgid "palette_index should be an int" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:45 +msgid "position must be 2-tuple" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:87 +msgid "unsupported bitmap type" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:152 +msgid "palette must be displayio.Palette" +msgstr "" + #: shared-bindings/gamepad/GamePad.c:100 msgid "too many arguments" msgstr "" @@ -2283,6 +2337,18 @@ msgstr "" msgid "Cannot transfer without MOSI and MISO pins." msgstr "" +#: shared-module/displayio/Bitmap.c:49 +msgid "Only bit maps of 8 bit color or less are supported" +msgstr "" + +#: shared-module/displayio/Bitmap.c:69 +msgid "row must be packed and word aligned" +msgstr "" + +#: shared-module/displayio/Group.c:39 +msgid "Group full" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "" diff --git a/locale/fil.po b/locale/fil.po index 7e8b9c7a3a..7d5102d480 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-08-30 18:29-0700\n" +"POT-Creation-Date: 2018-09-06 14:55-0700\n" "PO-Revision-Date: 2018-08-30 23:04-0700\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -243,15 +243,15 @@ msgstr "pagkakalibrate ay basahin lamang" msgid "calibration is out of range" msgstr "kalibrasion ay wala sa sakop" -#: ports/atmel-samd/board_busses.c:39 +#: ports/atmel-samd/board_busses.c:39 ports/nrf/board_busses.c:39 msgid "No default I2C bus" msgstr "Walang default na I2C bus" -#: ports/atmel-samd/board_busses.c:64 +#: ports/atmel-samd/board_busses.c:64 ports/nrf/board_busses.c:64 msgid "No default SPI bus" msgstr "Walang default SPI bus" -#: ports/atmel-samd/board_busses.c:91 +#: ports/atmel-samd/board_busses.c:91 ports/nrf/board_busses.c:91 msgid "No default UART bus" msgstr "Walang default UART bus" @@ -400,12 +400,12 @@ msgstr "Hindi ma-initialize ang UART" msgid "No RX pin" msgstr "Walang RX pin" -#: ports/atmel-samd/common-hal/busio/UART.c:284 +#: ports/atmel-samd/common-hal/busio/UART.c:288 msgid "No TX pin" msgstr "Walang TX pin" -#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:168 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:158 +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 msgid "Cannot get pull while in output mode" msgstr "Hindi makakakuha ng pull habang nasa output mode" @@ -438,12 +438,12 @@ msgstr "Ginagamit na ang EXTINT channel" msgid "Failed to allocate RX buffer of %d bytes" msgstr "Nabigong ilaan ang RX buffer ng %d bytes" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:203 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205 #: ports/esp8266/common-hal/pulseio/PulseIn.c:151 msgid "pop from an empty PulseIn" msgstr "pop mula sa walang laman na PulseIn" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:235 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 #: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 msgid "index out of range" msgstr "index wala sa sakop" @@ -700,11 +700,11 @@ msgstr "hindi alam na config param" msgid "AnalogOut functionality not supported" msgstr "Hindi supportado ang AnalogOut" -#: ports/nrf/common-hal/busio/UART.c:45 ports/nrf/common-hal/busio/UART.c:49 -#: ports/nrf/common-hal/busio/UART.c:53 ports/nrf/common-hal/busio/UART.c:62 -#: ports/nrf/common-hal/busio/UART.c:68 ports/nrf/common-hal/busio/UART.c:73 -#: ports/nrf/common-hal/busio/UART.c:78 ports/nrf/common-hal/busio/UART.c:83 -#: ports/nrf/common-hal/busio/UART.c:88 +#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 +#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 +#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 +#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 +#: ports/nrf/common-hal/busio/UART.c:86 msgid "busio.UART not yet implemented" msgstr "hindi pa implemented ang busio.UART" @@ -2060,6 +2060,74 @@ msgstr "Pull hindi ginagamit kapag ang direksyon ay output." msgid "Unsupported pull value." msgstr "Hindi suportado ang pull value." +#: shared-bindings/displayio/Bitmap.c:84 +#, fuzzy +msgid "y should be an int" +msgstr "Haba ay dapat int" + +#: shared-bindings/displayio/Bitmap.c:89 +#, fuzzy +msgid "row buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" +"ang sample_source buffer ay dapat na isang bytearray o array ng uri na 'h', " +"'H', 'b' o'B'" + +#: shared-bindings/displayio/Bitmap.c:94 +#, fuzzy +msgid "row data must be a buffer" +msgstr "constant ay dapat na integer" + +#: shared-bindings/displayio/FourWire.c:55 +#: shared-bindings/displayio/FourWire.c:64 +msgid "displayio is a work in progress" +msgstr "" + +#: shared-bindings/displayio/Group.c:65 +#, fuzzy +msgid "Group must have size at least 1" +msgstr "Buffer dapat ay hindi baba sa 1 na haba" + +#: shared-bindings/displayio/Palette.c:96 +#, fuzzy +msgid "color buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" +"ang sample_source buffer ay dapat na isang bytearray o array ng uri na 'h', " +"'H', 'b' o'B'" + +#: shared-bindings/displayio/Palette.c:102 +msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" +msgstr "" + +#: shared-bindings/displayio/Palette.c:106 +#, fuzzy +msgid "color must be between 0x000000 and 0xffffff" +msgstr "Sa gitna ng 0 o 255 dapat ang bytes." + +#: shared-bindings/displayio/Palette.c:110 +#, fuzzy +msgid "color buffer must be a buffer or int" +msgstr "buffer ay dapat bytes-like object" + +#: shared-bindings/displayio/Palette.c:123 +#: shared-bindings/displayio/Palette.c:137 +msgid "palette_index should be an int" +msgstr "" + +#: shared-bindings/displayio/Sprite.c:45 +#, fuzzy +msgid "position must be 2-tuple" +msgstr "stop dapat 1 o 2" + +#: shared-bindings/displayio/Sprite.c:87 +#, fuzzy +msgid "unsupported bitmap type" +msgstr "Hindi supportadong baudrate" + +#: shared-bindings/displayio/Sprite.c:152 +#, fuzzy +msgid "palette must be displayio.Palette" +msgstr "ang palette ay dapat 32 bytes ang haba" + #: shared-bindings/gamepad/GamePad.c:100 msgid "too many arguments" msgstr "masyadong maraming argumento" @@ -2277,6 +2345,18 @@ msgstr "Hindi maaring mabasa kapag walang MISO pin." msgid "Cannot transfer without MOSI and MISO pins." msgstr "Hindi maaaring ilipat kapag walang MOSI at MISO pin." +#: shared-module/displayio/Bitmap.c:49 +msgid "Only bit maps of 8 bit color or less are supported" +msgstr "" + +#: shared-module/displayio/Bitmap.c:69 +msgid "row must be packed and word aligned" +msgstr "" + +#: shared-module/displayio/Group.c:39 +msgid "Group full" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "Ang 'S' at 'O' ay hindi suportadong uri ng format" diff --git a/locale/fr.po b/locale/fr.po index 732e663f23..5ef13110b6 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-08-30 16:12-0700\n" +"POT-Creation-Date: 2018-09-06 14:55-0700\n" "PO-Revision-Date: 2018-08-14 11:01+0200\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -238,15 +238,15 @@ msgstr "la calibration est en lecture seule" msgid "calibration is out of range" msgstr "la calibration est hors gamme" -#: ports/atmel-samd/board_busses.c:39 +#: ports/atmel-samd/board_busses.c:39 ports/nrf/board_busses.c:39 msgid "No default I2C bus" msgstr "Pas de bus I2C par défaut" -#: ports/atmel-samd/board_busses.c:64 +#: ports/atmel-samd/board_busses.c:64 ports/nrf/board_busses.c:64 msgid "No default SPI bus" msgstr "Pas de bus SPI par défaut" -#: ports/atmel-samd/board_busses.c:91 +#: ports/atmel-samd/board_busses.c:91 ports/nrf/board_busses.c:91 msgid "No default UART bus" msgstr "Pas de bus UART par défaut" @@ -395,12 +395,12 @@ msgstr "L'UART n'a pu être initialisé" msgid "No RX pin" msgstr "Pas de broche RX" -#: ports/atmel-samd/common-hal/busio/UART.c:284 +#: ports/atmel-samd/common-hal/busio/UART.c:288 msgid "No TX pin" msgstr "Pas de broche TX" -#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:168 -#: ports/nrf/common-hal/digitalio/DigitalInOut.c:158 +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 +#: ports/nrf/common-hal/digitalio/DigitalInOut.c:153 msgid "Cannot get pull while in output mode" msgstr "Ne peux être tirer ('pull') en mode 'output'" @@ -434,12 +434,12 @@ msgstr "Canal EXTINT déjà utilisé" msgid "Failed to allocate RX buffer of %d bytes" msgstr "Echec de l'allocation de %d octets du tampon RX" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:203 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205 #: ports/esp8266/common-hal/pulseio/PulseIn.c:151 msgid "pop from an empty PulseIn" msgstr "'pop' d'une entrée PulseIn vide" -#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:235 +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 #: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 msgid "index out of range" msgstr "index hors gamme" @@ -696,11 +696,11 @@ msgstr "paramètre de config. inconnu" msgid "AnalogOut functionality not supported" msgstr "AnalogOut non supporté" -#: ports/nrf/common-hal/busio/UART.c:45 ports/nrf/common-hal/busio/UART.c:49 -#: ports/nrf/common-hal/busio/UART.c:53 ports/nrf/common-hal/busio/UART.c:62 -#: ports/nrf/common-hal/busio/UART.c:68 ports/nrf/common-hal/busio/UART.c:73 -#: ports/nrf/common-hal/busio/UART.c:78 ports/nrf/common-hal/busio/UART.c:83 -#: ports/nrf/common-hal/busio/UART.c:88 +#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47 +#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60 +#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71 +#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81 +#: ports/nrf/common-hal/busio/UART.c:86 msgid "busio.UART not yet implemented" msgstr "busio.UART pas encore implémenté" @@ -2051,6 +2051,75 @@ msgstr "Le tirage 'pull' n'est pas utilisé quand la direction est 'output'" msgid "Unsupported pull value." msgstr "Valeur de 'pull' non supportée" +#: shared-bindings/displayio/Bitmap.c:84 +#, fuzzy +msgid "y should be an int" +msgstr "La longueur doit être entière" + +#: shared-bindings/displayio/Bitmap.c:89 +#, fuzzy +msgid "row buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" +"le tampon de sample_source doit être un bytearray ou un tableau de type " +"'h','H', 'b' ou 'B'" + +#: shared-bindings/displayio/Bitmap.c:94 +#, fuzzy +msgid "row data must be a buffer" +msgstr "les constantes doivent être des entiers" + +#: shared-bindings/displayio/FourWire.c:55 +#: shared-bindings/displayio/FourWire.c:64 +msgid "displayio is a work in progress" +msgstr "" + +#: shared-bindings/displayio/Group.c:65 +#, fuzzy +msgid "Group must have size at least 1" +msgstr "Le tampon doit être de longueur au moins 1" + +#: shared-bindings/displayio/Palette.c:96 +#, fuzzy +msgid "color buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" +"le tampon de sample_source doit être un bytearray ou un tableau de type " +"'h','H', 'b' ou 'B'" + +#: shared-bindings/displayio/Palette.c:102 +msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" +msgstr "" + +#: shared-bindings/displayio/Palette.c:106 +#, fuzzy +msgid "color must be between 0x000000 and 0xffffff" +msgstr "Les octets 'bytes' doivent être entre 0 et 255" + +#: shared-bindings/displayio/Palette.c:110 +#, fuzzy +msgid "color buffer must be a buffer or int" +msgstr "le tampon doit être un objet bytes-like" + +#: shared-bindings/displayio/Palette.c:123 +#: shared-bindings/displayio/Palette.c:137 +#, fuzzy +msgid "palette_index should be an int" +msgstr "Les valeurs du tableau doivent être des octets simples 'bytes'" + +#: shared-bindings/displayio/Sprite.c:45 +#, fuzzy +msgid "position must be 2-tuple" +msgstr "stop doit être 1 ou 2" + +#: shared-bindings/displayio/Sprite.c:87 +#, fuzzy +msgid "unsupported bitmap type" +msgstr "Débit non supporté" + +#: shared-bindings/displayio/Sprite.c:152 +#, fuzzy +msgid "palette must be displayio.Palette" +msgstr "la palette doit être longue de 32 octets" + #: shared-bindings/gamepad/GamePad.c:100 msgid "too many arguments" msgstr "trop d'arguments" @@ -2272,6 +2341,18 @@ msgstr "Impossible de lire sans broche MISO." msgid "Cannot transfer without MOSI and MISO pins." msgstr "Pas de transfert sans broches MOSI et MISO" +#: shared-module/displayio/Bitmap.c:49 +msgid "Only bit maps of 8 bit color or less are supported" +msgstr "" + +#: shared-module/displayio/Bitmap.c:69 +msgid "row must be packed and word aligned" +msgstr "" + +#: shared-module/displayio/Group.c:39 +msgid "Group full" +msgstr "" + #: shared-module/struct/__init__.c:39 msgid "'S' and 'O' are not supported format types" msgstr "'S' et 'O' ne sont pas des types de format supportés" @@ -2279,3 +2360,7 @@ msgstr "'S' et 'O' ne sont pas des types de format supportés" #: shared-module/struct/__init__.c:83 msgid "too many arguments provided with the given format" msgstr "trop d'arguments fournis avec ce format" + +#, fuzzy +#~ msgid "value_size must be power of two" +#~ msgstr "'len' doit être un multiple de 4" diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index e1634a1b9b..9c94e442f0 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -308,6 +308,7 @@ SRC_COMMON_HAL = \ busio/UART.c \ digitalio/__init__.c \ digitalio/DigitalInOut.c \ + displayio/FourWire.c \ i2cslave/__init__.c \ i2cslave/I2CSlave.c \ microcontroller/__init__.c \ @@ -381,6 +382,11 @@ SRC_SHARED_MODULE = \ bitbangio/OneWire.c \ bitbangio/SPI.c \ busio/OneWire.c \ + displayio/__init__.c \ + displayio/Bitmap.c \ + displayio/Group.c \ + displayio/Palette.c \ + displayio/Sprite.c \ gamepad/__init__.c \ gamepad/GamePad.c \ _stage/__init__.c \ diff --git a/ports/atmel-samd/background.c b/ports/atmel-samd/background.c index 62d891b15a..f25ec7200d 100644 --- a/ports/atmel-samd/background.c +++ b/ports/atmel-samd/background.c @@ -30,12 +30,17 @@ #include "usb.h" #include "usb_mass_storage.h" +#include "shared-module/displayio/__init__.h" + volatile uint64_t last_finished_tick = 0; void run_background_tasks(void) { #if (defined(SAMD21) && defined(PIN_PA02)) || defined(SAMD51) audio_dma_background(); #endif + #ifdef CIRCUITPY_DISPLAYIO + displayio_refresh_display(); + #endif usb_msc_background(); usb_cdc_background(); last_finished_tick = ticks_ms; diff --git a/ports/atmel-samd/boards/board.h b/ports/atmel-samd/boards/board.h index a2a73cfab4..61acc730ef 100644 --- a/ports/atmel-samd/boards/board.h +++ b/ports/atmel-samd/boards/board.h @@ -31,6 +31,14 @@ #include +#include "py/mpconfig.h" + +#ifdef CIRCUITPY_DISPLAYIO +#include "common-hal/displayio/FourWire.h" + +extern displayio_fourwire_obj_t board_display_obj; +#endif + // Initializes board related state once on start up. void board_init(void); diff --git a/ports/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c index c8e20206a1..b47c5fbb22 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c @@ -26,8 +26,89 @@ #include "boards/board.h" -void board_init(void) -{ +#include "shared-bindings/displayio/FourWire.h" +#include "shared-module/displayio/mipi_constants.h" + +#include "tick.h" + +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 + +uint8_t display_init_sequence[] = { + 0x01, 0 | DELAY, 150, // SWRESET + 0x11, 0 | DELAY, 255, // SLPOUT + 0xb1, 3, 0x01, 0x2C, 0x2D, // _FRMCTR1 + 0xb2, 3, 0x01, 0x2C, 0x2D, // + 0xb3, 6, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D, + 0xb4, 1, 0x07, // _INVCTR line inversion + 0xc0, 3, 0xa2, 0x02, 0x84, // _PWCTR1 GVDD = 4.7V, 1.0uA + 0xc1, 1, 0xc5, // _PWCTR2 VGH=14.7V, VGL=-7.35V + 0xc2, 2, 0x0a, 0x00, // _PWCTR3 Opamp current small, Boost frequency + 0xc3, 2, 0x8a, 0x2a, + 0xc4, 2, 0x8a, 0xee, + 0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V + 0x2a, 0, // _INVOFF + 0x36, 1, 0x18, // _MADCTL bottom to top refresh + // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, + // fix on VTL + 0x3a, 1, 0x05, // COLMOD - 16bit color + 0xe0, 16, 0x02, 0x1c, 0x07, 0x12, // _GMCTRP1 Gamma + 0x37, 0x32, 0x29, 0x2d, + 0x29, 0x25, 0x2B, 0x39, + 0x00, 0x01, 0x03, 0x10, + 0xe1, 16, 0x03, 0x1d, 0x07, 0x06, // _GMCTRN1 + 0x2E, 0x2C, 0x29, 0x2D, + 0x2E, 0x2E, 0x37, 0x3F, + 0x00, 0x00, 0x02, 0x10, + 0x2a, 3, 0x02, 0x00, 0x81, // _CASET XSTART = 2, XEND = 129 + 0x2b, 3, 0x02, 0x00, 0x81, // _RASET XSTART = 2, XEND = 129 + 0x13, 0 | DELAY, 10, // _NORON + 0x29, 0 | DELAY, 100, // _DISPON +}; + +void board_init(void) { + board_display_obj.base.type = &displayio_fourwire_type; + common_hal_displayio_fourwire_construct(&board_display_obj, + &pin_PB23, // Clock + &pin_PB22, // Data + &pin_PA28, // Command or data + &pin_PA01, // Chip select + &pin_PA27, // Reset + 128, // Width + 128, // Height + 2, // column start + 0, // row start + 16, // Color depth + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command + MIPI_COMMAND_WRITE_MEMORY_START); // Write memory command + + uint32_t i = 0; + common_hal_displayio_fourwire_begin_transaction(&board_display_obj); + while (i < sizeof(display_init_sequence)) { + uint8_t *cmd = display_init_sequence + i; + uint8_t data_size = *(cmd + 1); + bool delay = (data_size & DELAY) != 0; + data_size &= ~DELAY; + uint8_t *data = cmd + 2; + common_hal_displayio_fourwire_send(&board_display_obj, true, cmd, 1); + common_hal_displayio_fourwire_send(&board_display_obj, false, data, data_size); + if (delay) { + data_size++; + uint16_t delay_length_ms = *(cmd + 1 + data_size); + if (delay_length_ms == 255) { + delay_length_ms = 500; + } + uint64_t start = ticks_ms; + while (ticks_ms - start < delay_length_ms) {} + } else { + uint64_t start = ticks_ms; + while (ticks_ms - start < 10) {} + } + i += 2 + data_size; + } + common_hal_displayio_fourwire_end_transaction(&board_display_obj); } bool board_requests_safe_mode(void) { @@ -35,4 +116,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { + common_hal_displayio_fourwire_show(&board_display_obj, NULL); } diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h index 34e9ac3279..977ba183f6 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h @@ -3,7 +3,7 @@ #define MICROPY_HW_NEOPIXEL (&pin_PA12) -// Clock rates are off: Salae reads 12MHz which is the limit even though we set it to the safer 8MHz. +// Clock rates are off: Saleae reads 12MHz which is the limit even though we set it to the safer 8MHz. #define SPI_FLASH_BAUDRATE (8000000) #define SPI_FLASH_MOSI_PIN PIN_PB10 @@ -27,8 +27,8 @@ #define SPI_FLASH_DIPO 1 // same as MISO pad // These are pins not to reset. -#define MICROPY_PORT_A (PORT_PA07 | PORT_PA12 | PORT_PA13 | PORT_PA24 | PORT_PA25) -#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 ) +#define MICROPY_PORT_A ( PORT_PA01 | PORT_PA07 | PORT_PA12 | PORT_PA13 | PORT_PA24 | PORT_PA25 | PORT_PA27 | PORT_PA28) +#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 | PORT_PB23 ) #define MICROPY_PORT_C ( 0 ) #include "external_flash/external_flash.h" @@ -61,3 +61,5 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 + +#define CIRCUITPY_DISPLAYIO diff --git a/ports/atmel-samd/boards/hallowing_m0_express/pins.c b/ports/atmel-samd/boards/hallowing_m0_express/pins.c index 8d6f9431e4..7d4afc7a41 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/pins.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/pins.c @@ -1,5 +1,6 @@ #include "shared-bindings/board/__init__.h" +#include "boards/board.h" #include "board_busses.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { @@ -56,5 +57,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&board_display_obj)} }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/common-hal/displayio/FourWire.c b/ports/atmel-samd/common-hal/displayio/FourWire.c new file mode 100644 index 0000000000..6c3b75a85b --- /dev/null +++ b/ports/atmel-samd/common-hal/displayio/FourWire.c @@ -0,0 +1,139 @@ +/* + * 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/FourWire.h" + +#include + +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/digitalio/DigitalInOut.h" + +#include "tick.h" + +void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self, + const mcu_pin_obj_t* clock, const mcu_pin_obj_t* data, const mcu_pin_obj_t* command, + const mcu_pin_obj_t* chip_select, const mcu_pin_obj_t* reset, uint16_t width, + uint16_t height, int16_t colstart, int16_t rowstart, uint16_t color_depth, + uint8_t set_column_command, uint8_t set_row_command, uint8_t write_ram_command) { + + common_hal_busio_spi_construct(&self->bus, clock, data, mp_const_none); + common_hal_digitalio_digitalinout_construct(&self->command, command); + common_hal_digitalio_digitalinout_switch_to_output(&self->command, true, DRIVE_MODE_PUSH_PULL); + 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); + + common_hal_digitalio_digitalinout_construct(&self->reset, reset); + common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL); + + self->width = width; + self->height = height; + self->color_depth = color_depth; + self->set_column_command = set_column_command; + self->set_row_command = set_row_command; + self->write_ram_command = write_ram_command; + self->current_group = NULL; + self->colstart = colstart; + self->rowstart = rowstart; +} + +bool common_hal_displayio_fourwire_begin_transaction(displayio_fourwire_obj_t* self) { + if (!common_hal_busio_spi_try_lock(&self->bus)) { + return false; + } + // TODO(tannewt): Stop hardcoding SPI frequency, polarity and phase. + common_hal_busio_spi_configure(&self->bus, 12000000, 0, 0, 8); + common_hal_digitalio_digitalinout_set_value(&self->chip_select, false); + return true; +} + +void common_hal_displayio_fourwire_send(displayio_fourwire_obj_t* self, bool command, uint8_t *data, uint32_t data_length) { + common_hal_digitalio_digitalinout_set_value(&self->command, !command); + common_hal_busio_spi_write(&self->bus, data, data_length); +} + +void common_hal_displayio_fourwire_end_transaction(displayio_fourwire_obj_t* self) { + common_hal_digitalio_digitalinout_set_value(&self->chip_select, true); + common_hal_busio_spi_unlock(&self->bus); +} + +void common_hal_displayio_fourwire_show(displayio_fourwire_obj_t* self, displayio_group_t* root_group) { + self->current_group = root_group; + common_hal_displayio_fourwire_refresh_soon(self); +} + +void common_hal_displayio_fourwire_refresh_soon(displayio_fourwire_obj_t* self) { + self->refresh = true; +} + +int32_t common_hal_displayio_fourwire_wait_for_frame(displayio_fourwire_obj_t* self) { + uint64_t last_refresh = self->last_refresh; + while (last_refresh == self->last_refresh) { + MICROPY_VM_HOOK_LOOP + } + return 0; +} + +void displayio_fourwire_start_region_update(displayio_fourwire_obj_t* self, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { + // TODO(tannewt): Handle displays with single byte bounds. + common_hal_displayio_fourwire_begin_transaction(self); + uint16_t data[2]; + common_hal_displayio_fourwire_send(self, true, &self->set_column_command, 1); + data[0] = __builtin_bswap16(x0 + self->colstart); + data[1] = __builtin_bswap16(x1-1 + self->colstart); + common_hal_displayio_fourwire_send(self, false, (uint8_t*) data, 4); + common_hal_displayio_fourwire_send(self, true, &self->set_row_command, 1); + data[0] = __builtin_bswap16(y0 + 1 + self->rowstart); + data[1] = __builtin_bswap16(y1 + self->rowstart); + common_hal_displayio_fourwire_send(self, false, (uint8_t*) data, 4); + common_hal_displayio_fourwire_send(self, true, &self->write_ram_command, 1); +} + +bool displayio_fourwire_send_pixels(displayio_fourwire_obj_t* self, uint32_t* pixels, uint32_t length) { + // TODO: Set this up so its async and 32 bit DMA transfers. + common_hal_displayio_fourwire_send(self, false, (uint8_t*) pixels, length*4); + return true; +} + +void displayio_fourwire_finish_region_update(displayio_fourwire_obj_t* self) { + common_hal_displayio_fourwire_end_transaction(self); +} + +bool displayio_fourwire_frame_queued(displayio_fourwire_obj_t* self) { + // Refresh at ~30 fps. + return (ticks_ms - self->last_refresh) > 32; +} + +bool displayio_fourwire_refresh_queued(displayio_fourwire_obj_t* self) { + return self->refresh || (self->current_group != NULL && displayio_group_needs_refresh(self->current_group)); +} + +void displayio_fourwire_finish_refresh(displayio_fourwire_obj_t* self) { + if (self->current_group != NULL) { + displayio_group_finish_refresh(self->current_group); + } + self->refresh = false; + self->last_refresh = ticks_ms; +} diff --git a/ports/atmel-samd/common-hal/displayio/FourWire.h b/ports/atmel-samd/common-hal/displayio/FourWire.h new file mode 100644 index 0000000000..b997176701 --- /dev/null +++ b/ports/atmel-samd/common-hal/displayio/FourWire.h @@ -0,0 +1,53 @@ +/* + * 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. + */ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_FOURWIRE_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_FOURWIRE_H + +#include "common-hal/busio/SPI.h" +#include "common-hal/digitalio/DigitalInOut.h" +#include "shared-module/displayio/Group.h" + +typedef struct { + mp_obj_base_t base; + busio_spi_obj_t bus; + digitalio_digitalinout_obj_t command; + digitalio_digitalinout_obj_t chip_select; + digitalio_digitalinout_obj_t reset; + uint16_t width; + uint16_t height; + uint16_t color_depth; + uint8_t set_column_command; + uint8_t set_row_command; + uint8_t write_ram_command; + displayio_group_t *current_group; + bool refresh; + uint64_t last_refresh; + int16_t colstart; + int16_t rowstart; +} displayio_fourwire_obj_t; + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_FOURWIRE_H diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 5763254619..14f72ccfb0 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -171,6 +171,7 @@ extern const struct _mp_obj_module_t audioio_module; extern const struct _mp_obj_module_t audiobusio_module; extern const struct _mp_obj_module_t analogio_module; extern const struct _mp_obj_module_t digitalio_module; +extern const struct _mp_obj_module_t displayio_module; extern const struct _mp_obj_module_t pulseio_module; extern const struct _mp_obj_module_t busio_module; extern const struct _mp_obj_module_t board_module; @@ -232,11 +233,18 @@ extern const struct _mp_obj_module_t usb_hid_module; #define I2CSLAVE_MODULE #endif + #ifdef CIRCUITPY_DISPLAYIO + #define DISPLAYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_displayio), (mp_obj_t)&displayio_module }, + #else + #define DISPLAYIO_MODULE + #endif + #ifndef EXTRA_BUILTIN_MODULES #define EXTRA_BUILTIN_MODULES \ AUDIOIO_MODULE \ AUDIOBUSIO_MODULE \ { MP_OBJ_NEW_QSTR(MP_QSTR_bitbangio), (mp_obj_t)&bitbangio_module }, \ + DISPLAYIO_MODULE \ I2CSLAVE_MODULE \ { MP_OBJ_NEW_QSTR(MP_QSTR_rotaryio), (mp_obj_t)&rotaryio_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_gamepad),(mp_obj_t)&gamepad_module } diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 9576422693..f6d968a1cb 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -186,8 +186,6 @@ safe_mode_t port_init(void) { #endif clock_init(); - board_init(); - // Configure millisecond timer initialization. tick_init(); @@ -196,6 +194,10 @@ safe_mode_t port_init(void) { #endif init_shared_dma(); + + // Init the board last so everything else is ready + board_init(); + #ifdef CIRCUITPY_CANARY_WORD // Run in safe mode if the canary is corrupt. if (_ezero != CIRCUITPY_CANARY_WORD) { @@ -234,6 +236,12 @@ void reset_port(void) { if (sercom_instances[i] == MICROPY_HW_APA102_SERCOM) { continue; } +#endif +#ifdef CIRCUITPY_DISPLAYIO + // TODO(tannewt): Make this dynamic. + if (sercom_instances[i] == board_display_obj.bus.spi_desc.dev.prvt) { + continue; + } #endif // SWRST is same for all modes of SERCOMs. sercom_instances[i]->SPI.CTRLA.bit.SWRST = 1; diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c new file mode 100644 index 0000000000..d415127d2f --- /dev/null +++ b/shared-bindings/displayio/Bitmap.c @@ -0,0 +1,112 @@ +/* + * This file is part of the Micro Python 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/Bitmap.h" + +#include + +#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 "supervisor/shared/translate.h" + +//| .. currentmodule:: displayio +//| +//| :class:`Bitmap` -- Stores values in a 2D array +//| ========================================================================== +//| +//| Stores values of a certain size in a 2D array +//| +//| .. warning:: This will likely be changed before 4.0.0. Consider it very experimental. +//| +//| .. class:: Bitmap(width, height, value_count) +//| +//| Create a Bitmap object with the given fixed size. Each pixel stores a value that is used to +//| index into a corresponding palette. This enables differently colored sprites to share the +//| underlying Bitmap. value_count is used to minimize the memory used to store the Bitmap. +//| +//| :param int width: The number of values wide +//| :param int height: The number of values high +//| :param int value_count: The number of possible pixel values. +//| +STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { + mp_arg_check_num(n_args, n_kw, 3, 3, false); + uint32_t width = mp_obj_get_int(pos_args[0]); + uint32_t height = mp_obj_get_int(pos_args[1]); + uint32_t value_count = mp_obj_get_int(pos_args[2]); + uint32_t power_of_two = 1; + while (value_count > (1U << power_of_two)) { + power_of_two <<= 1; + } + + displayio_bitmap_t *self = m_new_obj(displayio_bitmap_t); + self->base.type = &displayio_bitmap_type; + common_hal_displayio_bitmap_construct(self, width, height, power_of_two); + + return MP_OBJ_FROM_PTR(self); +} + + +//| .. method:: _load_row(y, data) +//| +//| Loads pre-packed data into the given row. +//| +STATIC mp_obj_t displayio_bitmap_obj__load_row(mp_obj_t self_in, mp_obj_t y_in, mp_obj_t data_in) { + displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t y; + if (!mp_obj_get_int_maybe(y_in, &y)) { + mp_raise_ValueError(translate("y should be an int")); + } + mp_buffer_info_t bufinfo; + if (mp_get_buffer(data_in, &bufinfo, MP_BUFFER_READ)) { + if (bufinfo.typecode != 'b' && bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) { + mp_raise_ValueError(translate("row buffer must be a bytearray or array of type 'b' or 'B'")); + } + uint8_t* buf = bufinfo.buf; + common_hal_displayio_bitmap_load_row(self, y, buf, bufinfo.len); + } else { + mp_raise_TypeError(translate("row data must be a buffer")); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_3(displayio_bitmap__load_row_obj, displayio_bitmap_obj__load_row); + +STATIC const mp_rom_map_elem_t displayio_bitmap_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR__load_row), MP_ROM_PTR(&displayio_bitmap__load_row_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(displayio_bitmap_locals_dict, displayio_bitmap_locals_dict_table); + +const mp_obj_type_t displayio_bitmap_type = { + { &mp_type_type }, + .name = MP_QSTR_Bitmap, + .make_new = displayio_bitmap_make_new, + // TODO(tannewt): Implement subscr after slices support start, stop and step tuples. + // .subscr = displayio_bitmap_subscr, + .locals_dict = (mp_obj_dict_t*)&displayio_bitmap_locals_dict, +}; diff --git a/shared-bindings/displayio/Bitmap.h b/shared-bindings/displayio/Bitmap.h new file mode 100644 index 0000000000..b736f9459c --- /dev/null +++ b/shared-bindings/displayio/Bitmap.h @@ -0,0 +1,41 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_BITMAP_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_BITMAP_H + +#include "shared-module/displayio/Bitmap.h" + +extern const mp_obj_type_t displayio_bitmap_type; + +void common_hal_displayio_bitmap_construct(displayio_bitmap_t *self, uint32_t width, + uint32_t height, uint32_t bits_per_value); + +void common_hal_displayio_bitmap_load_row(displayio_bitmap_t *self, uint16_t y, uint8_t* data, + uint16_t len); +uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *bitmap, int16_t x, int16_t y); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_BITMAP_H diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c new file mode 100644 index 0000000000..c0d60bd3b4 --- /dev/null +++ b/shared-bindings/displayio/FourWire.c @@ -0,0 +1,118 @@ +/* + * This file is part of the Micro Python 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/FourWire.h" + +#include + +#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 "supervisor/shared/translate.h" + +//| .. currentmodule:: displayio +//| +//| :class:`FourWire` -- Manage updating a display over SPI four wire protocol +//| ========================================================================== +//| +//| Manage updating a display over SPI four wire protocol in the background while Python code runs. +//| It doesn't handle display initialization. +//| +//| .. warning:: This will be changed before 4.0.0. Consider it very experimental. +//| +//| .. class:: FourWire(*, clock, data, command, chip_select, width, height, colstart, rowstart, +//| color_depth, set_column_command, set_row_command, write_ram_command) +//| +//| Create a FourWire object associated with the given pins. +//| +STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { + mp_raise_NotImplementedError(translate("displayio is a work in progress")); + return mp_const_none; +} + + +//| .. method:: send(command, data) +//| +//| +STATIC mp_obj_t displayio_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + mp_raise_NotImplementedError(translate("displayio is a work in progress")); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(displayio_fourwire_send_obj, 1, displayio_fourwire_obj_send); + +//| .. method:: show(group) +//| +//| Switches do displaying the given group of elements. +//| +STATIC mp_obj_t displayio_fourwire_obj_show(mp_obj_t self_in, mp_obj_t group_in) { + displayio_fourwire_obj_t *self = MP_OBJ_TO_PTR(self_in); + displayio_group_t* group = MP_OBJ_TO_PTR(group_in); + common_hal_displayio_fourwire_show(self, group); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(displayio_fourwire_show_obj, displayio_fourwire_obj_show); + +//| .. method:: refresh_soon() +//| +//| Queues up a display refresh that happens in the background. +//| +STATIC mp_obj_t displayio_fourwire_obj_refresh_soon(mp_obj_t self_in) { + displayio_fourwire_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_displayio_fourwire_refresh_soon(self); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_fourwire_refresh_soon_obj, displayio_fourwire_obj_refresh_soon); + +//| .. method:: wait_for_frame() +//| +//| Waits until the next frame has been transmitted to the display unless the wait count is +//| behind the rendered frames. In that case, this will return immediately with the wait count. +//| +STATIC mp_obj_t displayio_fourwire_obj_wait_for_frame(mp_obj_t self_in) { + displayio_fourwire_obj_t *self = MP_OBJ_TO_PTR(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_fourwire_wait_for_frame(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_fourwire_wait_for_frame_obj, displayio_fourwire_obj_wait_for_frame); + + +STATIC const mp_rom_map_elem_t displayio_fourwire_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&displayio_fourwire_send_obj) }, + { MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&displayio_fourwire_show_obj) }, + { MP_ROM_QSTR(MP_QSTR_refresh_soon), MP_ROM_PTR(&displayio_fourwire_refresh_soon_obj) }, + { MP_ROM_QSTR(MP_QSTR_wait_for_frame), MP_ROM_PTR(&displayio_fourwire_wait_for_frame_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(displayio_fourwire_locals_dict, displayio_fourwire_locals_dict_table); + +const mp_obj_type_t displayio_fourwire_type = { + { &mp_type_type }, + .name = MP_QSTR_FourWire, + .make_new = displayio_fourwire_make_new, + .locals_dict = (mp_obj_dict_t*)&displayio_fourwire_locals_dict, +}; diff --git a/shared-bindings/displayio/FourWire.h b/shared-bindings/displayio/FourWire.h new file mode 100644 index 0000000000..fc51f558dd --- /dev/null +++ b/shared-bindings/displayio/FourWire.h @@ -0,0 +1,65 @@ +/* + * 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_FOURWIRE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_FOURWIRE_H + +#include "common-hal/displayio/FourWire.h" +#include "common-hal/microcontroller/Pin.h" + +#include "shared-module/displayio/Group.h" + +extern const mp_obj_type_t displayio_fourwire_type; + +// TODO(tannewt): Split this apart into FourWire and a Display object because the dimensions and +// commands are also used for the parallel buses. +void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self, + const mcu_pin_obj_t* clock, const mcu_pin_obj_t* data, const mcu_pin_obj_t* command, + const mcu_pin_obj_t* chip_select, const mcu_pin_obj_t* reset, uint16_t width, uint16_t height, + int16_t colstart, int16_t rowstart, uint16_t color_depth, + uint8_t set_column_command, uint8_t set_row_command, uint8_t write_ram_command); + +int32_t common_hal_displayio_fourwire_wait_for_frame(displayio_fourwire_obj_t* self); + +bool common_hal_displayio_fourwire_begin_transaction(displayio_fourwire_obj_t* self); + +void common_hal_displayio_fourwire_send(displayio_fourwire_obj_t* self, bool command, uint8_t *data, uint32_t data_length); + +void common_hal_displayio_fourwire_end_transaction(displayio_fourwire_obj_t* self); + +void common_hal_displayio_fourwire_show(displayio_fourwire_obj_t* self, displayio_group_t* root_group); + +void common_hal_displayio_fourwire_refresh_soon(displayio_fourwire_obj_t* self); + +void displayio_fourwire_start_region_update(displayio_fourwire_obj_t* self, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); +void displayio_fourwire_finish_region_update(displayio_fourwire_obj_t* self); +bool displayio_fourwire_frame_queued(displayio_fourwire_obj_t* self); + +bool displayio_fourwire_refresh_queued(displayio_fourwire_obj_t* self); +void displayio_fourwire_finish_refresh(displayio_fourwire_obj_t* self); +bool displayio_fourwire_send_pixels(displayio_fourwire_obj_t* self, uint32_t* pixels, uint32_t length); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_FOURWIRE_H diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c new file mode 100644 index 0000000000..e6f1fbbf5d --- /dev/null +++ b/shared-bindings/displayio/Group.c @@ -0,0 +1,96 @@ +/* + * This file is part of the Micro Python 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/Group.h" + +#include + +#include "lib/utils/context_manager_helpers.h" +#include "py/binary.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + +//| .. currentmodule:: displayio +//| +//| :class:`Group` -- Group together sprites and subgroups +//| ========================================================================== +//| +//| Manage a group of sprites and groups and how they are inter-related. +//| +//| .. warning:: This will be changed before 4.0.0. Consider it very experimental. +//| +//| .. class:: Group(*, max_size=4) +//| +//| Create a Group of a given size. +//| +//| :param int max_size: The maximum group size. +//| +STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { + mp_arg_check_num(n_args, n_kw, 0, 0, true); + mp_map_t kw_args; + mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); + enum { ARG_max_size }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_max_size, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 4} }, + }; + 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_int_t max_size = args[ARG_max_size].u_int; + if (max_size < 1) { + mp_raise_ValueError(translate("Group must have size at least 1")); + } + + displayio_group_t *self = m_new_obj(displayio_group_t); + self->base.type = &displayio_group_type; + common_hal_displayio_group_construct(self, max_size); + + return MP_OBJ_FROM_PTR(self); +} + +//| .. method:: append(layer) +//| +//| Append a layer to the group. It will be drawn above other layers. +//| +STATIC mp_obj_t displayio_group_obj_append(mp_obj_t self_in, mp_obj_t layer) { + displayio_group_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_displayio_group_append(self, layer); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_append_obj, displayio_group_obj_append); + +STATIC const mp_rom_map_elem_t displayio_group_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&displayio_group_append_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(displayio_group_locals_dict, displayio_group_locals_dict_table); + +const mp_obj_type_t displayio_group_type = { + { &mp_type_type }, + .name = MP_QSTR_Group, + .make_new = displayio_group_make_new, + .locals_dict = (mp_obj_dict_t*)&displayio_group_locals_dict, +}; diff --git a/shared-bindings/displayio/Group.h b/shared-bindings/displayio/Group.h new file mode 100644 index 0000000000..aeb5a7b545 --- /dev/null +++ b/shared-bindings/displayio/Group.h @@ -0,0 +1,38 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_GROUP_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_GROUP_H + +#include "shared-module/displayio/Group.h" + +extern const mp_obj_type_t displayio_group_type; + + +void common_hal_displayio_group_construct(displayio_group_t* self, uint32_t max_size); +void common_hal_displayio_group_append(displayio_group_t* self, mp_obj_t layer); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_GROUP_H diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c new file mode 100644 index 0000000000..7086d0ab11 --- /dev/null +++ b/shared-bindings/displayio/Palette.c @@ -0,0 +1,156 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/displayio/Palette.h" + +#include + +#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 "supervisor/shared/translate.h" + +//| .. currentmodule:: displayio +//| +//| :class:`Palette` -- Stores a mapping from bitmap pixel palette_indexes to display colors +//| ========================================================================================= +//| +//| Map a pixel palette_index to a full color. Colors are transformed to the display's format internally to +//| save memory. +//| +//| .. warning:: This will be changed before 4.0.0. Consider it very experimental. +//| +//| .. class:: Palette(color_count) +//| +//| Create a Palette object to store a set number of colors. +//| +//| :param int color_count: The number of colors in the Palette +// TODO(tannewt): Add support for other color formats. +// TODO(tannewt): Add support for 8-bit alpha blending. +//| +STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { + mp_arg_check_num(n_args, n_kw, 1, 1, true); + mp_map_t kw_args; + mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); + enum { ARG_color_count }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_color_count, MP_ARG_INT | MP_ARG_REQUIRED }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + displayio_palette_t *self = m_new_obj(displayio_palette_t); + self->base.type = &displayio_palette_type; + common_hal_displayio_palette_construct(self, args[ARG_color_count].u_int); + + return MP_OBJ_FROM_PTR(self); +} + +STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { + if (value == MP_OBJ_NULL) { + // delete item + return MP_OBJ_NULL; // op not supported + } + // Slicing not supported. Use a duplicate Palette to swap multiple colors atomically. + 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); + + uint32_t color; + mp_int_t int_value; + mp_buffer_info_t bufinfo; + if (mp_get_buffer(value, &bufinfo, MP_BUFFER_READ)) { + if (bufinfo.typecode != 'b' && bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) { + mp_raise_ValueError(translate("color buffer must be a bytearray or array of type 'b' or 'B'")); + } + uint8_t* buf = bufinfo.buf; + if (bufinfo.len == 3 || bufinfo.len == 4) { + color = buf[0] << 16 | buf[1] << 8 | buf[2]; + } else { + mp_raise_ValueError(translate("color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)")); + } + } else if (mp_obj_get_int_maybe(value, &int_value)) { + if (int_value < 0 || int_value > 0xffffff) { + mp_raise_TypeError(translate("color must be between 0x000000 and 0xffffff")); + } + color = int_value; + } else { + mp_raise_TypeError(translate("color buffer must be a buffer or int")); + } + common_hal_displayio_palette_set_color(self, index, color); + return mp_const_none; +} + +//| .. method:: make_transparent(palette_index) +//| +STATIC mp_obj_t displayio_palette_obj_make_transparent(mp_obj_t self_in, mp_obj_t palette_index_obj) { + displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); + + mp_int_t palette_index; + if (!mp_obj_get_int_maybe(palette_index_obj, &palette_index)) { + mp_raise_ValueError(translate("palette_index should be an int")); + } + common_hal_displayio_palette_make_transparent(self, palette_index); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(displayio_palette_make_transparent_obj, displayio_palette_obj_make_transparent); + +//| .. method:: make_opaque(palette_index) +//| +STATIC mp_obj_t displayio_palette_obj_make_opaque(mp_obj_t self_in, mp_obj_t palette_index_obj) { + displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); + + mp_int_t palette_index; + if (!mp_obj_get_int_maybe(palette_index_obj, &palette_index)) { + mp_raise_ValueError(translate("palette_index should be an int")); + } + common_hal_displayio_palette_make_opaque(self, palette_index); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(displayio_palette_make_opaque_obj, displayio_palette_obj_make_opaque); + +STATIC const mp_rom_map_elem_t displayio_palette_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_make_transparent), MP_ROM_PTR(&displayio_palette_make_transparent_obj) }, + { MP_ROM_QSTR(MP_QSTR_make_opaque), MP_ROM_PTR(&displayio_palette_make_opaque_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(displayio_palette_locals_dict, displayio_palette_locals_dict_table); + +const mp_obj_type_t displayio_palette_type = { + { &mp_type_type }, + .name = MP_QSTR_Palette, + .make_new = displayio_palette_make_new, + .subscr = palette_subscr, + .locals_dict = (mp_obj_dict_t*)&displayio_palette_locals_dict, +}; diff --git a/shared-bindings/displayio/Palette.h b/shared-bindings/displayio/Palette.h new file mode 100644 index 0000000000..767fc7b636 --- /dev/null +++ b/shared-bindings/displayio/Palette.h @@ -0,0 +1,40 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_PALETTE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_PALETTE_H + +#include "shared-module/displayio/Palette.h" + +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); + +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); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_PALETTE_H diff --git a/shared-bindings/displayio/Sprite.c b/shared-bindings/displayio/Sprite.c new file mode 100644 index 0000000000..223a8a394c --- /dev/null +++ b/shared-bindings/displayio/Sprite.c @@ -0,0 +1,181 @@ +/* + * This file is part of the Micro Python 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/Sprite.h" + +#include + +#include "lib/utils/context_manager_helpers.h" +#include "py/binary.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "shared-bindings/displayio/Bitmap.h" +#include "supervisor/shared/translate.h" + +void unpack_position(mp_obj_t position_obj, int16_t* x, int16_t* y) { + // TODO(tannewt): Support any value sequence such as bytearray or bytes. + mp_obj_tuple_t *position = MP_OBJ_TO_PTR(position_obj); + if (MP_OBJ_IS_TYPE(position_obj, &mp_type_tuple) && position->len == 2) { + *x = mp_obj_get_int(position->items[0]); + *y = mp_obj_get_int(position->items[1]); + } else if (position != mp_const_none) { + mp_raise_TypeError(translate("position must be 2-tuple")); + } +} + +//| .. currentmodule:: displayio +//| +//| :class:`Sprite` -- A particular copy of an image to display +//| ========================================================================== +//| +//| Position a particular image and palette combination. +//| +//| .. warning:: This will be changed before 4.0.0. Consider it very experimental. +//| +//| .. class:: Sprite(bitmap, *, palette, position, width, height) +//| +//| Create a Sprite object +//| +//| +STATIC mp_obj_t displayio_sprite_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { + mp_arg_check_num(n_args, n_kw, 1, 4, true); + mp_map_t kw_args; + mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); + enum { ARG_bitmap, ARG_palette, ARG_position, ARG_width, ARG_height }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_bitmap, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_palette, MP_ARG_OBJ | MP_ARG_KW_ONLY }, + { MP_QSTR_position, MP_ARG_OBJ | MP_ARG_KW_ONLY }, + { MP_QSTR_width, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, + { MP_QSTR_height, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = -1} }, + }; + 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 bitmap = args[ARG_bitmap].u_obj; + + uint16_t width; + uint16_t height; + if (MP_OBJ_IS_TYPE(bitmap, &displayio_bitmap_type)) { + displayio_bitmap_t* bmp = MP_OBJ_TO_PTR(bitmap); + width = bmp->width; + height = bmp->height; + } else { + mp_raise_TypeError(translate("unsupported bitmap type")); + } + int16_t x = 0; + int16_t y = 0; + mp_obj_t position_obj = args[ARG_position].u_obj; + unpack_position(position_obj, &x, &y); + + displayio_sprite_t *self = m_new_obj(displayio_sprite_t); + self->base.type = &displayio_sprite_type; + common_hal_displayio_sprite_construct(self, bitmap, args[ARG_palette].u_obj, + width, height, x, y); + return MP_OBJ_FROM_PTR(self); +} + +//| .. attribute:: position +//| +//| The position of the top-left corner of the sprite. +//| +STATIC mp_obj_t displayio_sprite_obj_get_position(mp_obj_t self_in) { + displayio_sprite_t *self = MP_OBJ_TO_PTR(self_in); + int16_t x; + int16_t y; + common_hal_displayio_sprite_get_position(self, &x, &y); + + mp_obj_t coords[2]; + coords[0] = mp_obj_new_int(x); + coords[1] = mp_obj_new_int(y); + + return mp_obj_new_tuple(2, coords); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_sprite_get_position_obj, displayio_sprite_obj_get_position); + +STATIC mp_obj_t displayio_sprite_obj_set_position(mp_obj_t self_in, mp_obj_t value) { + displayio_sprite_t *self = MP_OBJ_TO_PTR(self_in); + + int16_t x = 0; + int16_t y = 0; + unpack_position(value, &x, &y); + + common_hal_displayio_sprite_set_position(self, x, y); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(displayio_sprite_set_position_obj, displayio_sprite_obj_set_position); + +const mp_obj_property_t displayio_sprite_position_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_sprite_get_position_obj, + (mp_obj_t)&displayio_sprite_set_position_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +//| .. attribute:: palette +//| +//| The color palette of the sprite. +//| +STATIC mp_obj_t displayio_sprite_obj_get_palette(mp_obj_t self_in) { + displayio_sprite_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_displayio_sprite_get_palette(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_sprite_get_palette_obj, displayio_sprite_obj_get_palette); + +STATIC mp_obj_t displayio_sprite_obj_set_palette(mp_obj_t self_in, mp_obj_t palette_in) { + displayio_sprite_t *self = MP_OBJ_TO_PTR(self_in); + if (!MP_OBJ_IS_TYPE(palette_in, &displayio_palette_type)) { + mp_raise_TypeError(translate("palette must be displayio.Palette")); + } + displayio_palette_t *palette = MP_OBJ_TO_PTR(palette_in); + + common_hal_displayio_sprite_set_palette(self, palette); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(displayio_sprite_set_palette_obj, displayio_sprite_obj_set_palette); + +const mp_obj_property_t displayio_sprite_palette_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_sprite_get_palette_obj, + (mp_obj_t)&displayio_sprite_set_palette_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +STATIC const mp_rom_map_elem_t displayio_sprite_locals_dict_table[] = { + // Properties + { MP_ROM_QSTR(MP_QSTR_position), MP_ROM_PTR(&displayio_sprite_position_obj) }, + { MP_ROM_QSTR(MP_QSTR_palette), MP_ROM_PTR(&displayio_sprite_palette_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(displayio_sprite_locals_dict, displayio_sprite_locals_dict_table); + +const mp_obj_type_t displayio_sprite_type = { + { &mp_type_type }, + .name = MP_QSTR_Sprite, + .make_new = displayio_sprite_make_new, + .locals_dict = (mp_obj_dict_t*)&displayio_sprite_locals_dict, +}; diff --git a/shared-bindings/displayio/Sprite.h b/shared-bindings/displayio/Sprite.h new file mode 100644 index 0000000000..0bfa400446 --- /dev/null +++ b/shared-bindings/displayio/Sprite.h @@ -0,0 +1,43 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_SPRITE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_SPRITE_H + +#include "shared-module/displayio/Sprite.h" + +extern const mp_obj_type_t displayio_sprite_type; + +void common_hal_displayio_sprite_construct(displayio_sprite_t *self, mp_obj_t bitmap, + mp_obj_t palette, uint16_t width, uint16_t height, uint16_t x, uint16_t y); + +void common_hal_displayio_sprite_get_position(displayio_sprite_t *self, int16_t* x, int16_t* y); +void common_hal_displayio_sprite_set_position(displayio_sprite_t *self, int16_t x, int16_t y); + +displayio_palette_t* common_hal_displayio_sprite_get_palette(displayio_sprite_t *self); +void common_hal_displayio_sprite_set_palette(displayio_sprite_t *self, displayio_palette_t* palette); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_SPRITE_H diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c new file mode 100644 index 0000000000..73f12db955 --- /dev/null +++ b/shared-bindings/displayio/__init__.c @@ -0,0 +1,83 @@ +/* + * 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 + +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/displayio/__init__.h" +#include "shared-bindings/displayio/Bitmap.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/displayio/Group.h" +#include "shared-bindings/displayio/Palette.h" +#include "shared-bindings/displayio/Sprite.h" + +//| :mod:`displayio` --- Native display driving +//| ========================================================================= +//| +//| .. module:: displayio +//| :synopsis: Native helpers for driving displays +//| :platform: SAMD21, SAMD51 +//| +//| The `displayio` module contains classes to manage display output +//| including synchronizing with refresh rates and partial updating. It does +//| not include display initialization commands. It should live in a Python +//| driver for use when a display is connected to a board. It should also be +//| built into the board init when the board has the display on it. +//| +//| .. warning:: This will be changed before 4.0.0. Consider it very experimental. +//| +//| Libraries +//| +//| .. toctree:: +//| :maxdepth: 3 +//| +//| Bitmap +//| FourWire +//| Group +//| Palette +//| Sprite +//| +//| All libraries change hardware state but are never deinit +//| + +STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_displayio) }, + { MP_ROM_QSTR(MP_QSTR_Bitmap), MP_ROM_PTR(&displayio_bitmap_type) }, + { MP_ROM_QSTR(MP_QSTR_Group), MP_ROM_PTR(&displayio_group_type) }, + { MP_ROM_QSTR(MP_QSTR_Palette), MP_ROM_PTR(&displayio_palette_type) }, + { MP_ROM_QSTR(MP_QSTR_Sprite), MP_ROM_PTR(&displayio_sprite_type) }, + + { MP_ROM_QSTR(MP_QSTR_FourWire), MP_ROM_PTR(&displayio_fourwire_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(displayio_module_globals, displayio_module_globals_table); + +const mp_obj_module_t displayio_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&displayio_module_globals, +}; diff --git a/shared-bindings/displayio/__init__.h b/shared-bindings/displayio/__init__.h new file mode 100644 index 0000000000..a6663bf572 --- /dev/null +++ b/shared-bindings/displayio/__init__.h @@ -0,0 +1,34 @@ +/* + * 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO___INIT___H + +#include "py/obj.h" + +// Nothing now. + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO___INIT___H diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c new file mode 100644 index 0000000000..addc341a7e --- /dev/null +++ b/shared-module/displayio/Bitmap.c @@ -0,0 +1,101 @@ +/* + * This file is part of the Micro Python 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/Bitmap.h" + +#include + +#include "py/runtime.h" + +void common_hal_displayio_bitmap_construct(displayio_bitmap_t *self, uint32_t width, + uint32_t height, uint32_t bits_per_value) { + uint32_t row_width = width * bits_per_value; + // word align + if (row_width % 32 != 0) { + self->stride = (row_width / 32 + 1); + } else { + self->stride = row_width / 32; + } + self->width = width; + self->height = height; + self->data = m_malloc(self->stride * height * sizeof(uint32_t), false); + + self->bits_per_value = bits_per_value; + + if (bits_per_value > 8) { + mp_raise_NotImplementedError(translate("Only bit maps of 8 bit color or less are supported")); + } + + // Division and modulus can be slow because it has to handle any integer. We know bits_per_value + // is a power of two. We divide and mod by bits_per_value to compute the offset into the byte + // array. So, we can the offset computation to simplify to a shift for division and mask for mod. + + self->x_shift = 0; // Used to divide the index by the number of pixels per word. Its used in a + // shift which effectively divides by 2 ** x_shift. + uint32_t power_of_two = 1; + while (power_of_two < 32 / bits_per_value ) { + self->x_shift++; + power_of_two <<= 1; + } + self->x_mask = (1 << self->x_shift) - 1; // Used as a modulus on the x value + self->bitmask = (1 << bits_per_value) - 1; +} + +void common_hal_displayio_bitmap_load_row(displayio_bitmap_t *self, uint16_t y, uint8_t* data, uint16_t len) { + if (len != self->stride * sizeof(uint32_t)) { + mp_raise_ValueError(translate("row must be packed and word aligned")); + } + uint32_t* row_value = self->data + (y * self->stride); + // Do the memcpy ourselves since we may want to flip endianness. + for (uint32_t i = 0; i < self->stride; i++) { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" + uint32_t value = ((uint32_t *)data)[i]; + #pragma GCC diagnostic pop + if (self->bits_per_value < 16) { + value = ((value >> 24) & 0xff) | + ((value << 8) & 0xff0000) | + ((value >> 8) & 0xff00) | + ((value << 24) & 0xff000000); + } + *row_value = value; + row_value++; + } +} +uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *self, int16_t x, int16_t y) { + if (x >= self->width || x < 0 || y >= self->height || y < 0) { + return 0; + } + int32_t row_start = y * self->stride; + if (self->bits_per_value < 8) { + uint32_t word = self->data[row_start + (x >> self->x_shift)]; + + return (word >> (32 - ((x & self->x_mask) + 1) * self->bits_per_value)) & self->bitmask; + } else { + uint32_t bytes_per_value = self->bits_per_value / 8; + return self->data[row_start + x * bytes_per_value]; + } +} diff --git a/shared-module/displayio/Bitmap.h b/shared-module/displayio/Bitmap.h new file mode 100644 index 0000000000..781a4d12a3 --- /dev/null +++ b/shared-module/displayio/Bitmap.h @@ -0,0 +1,47 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_BITMAP_H +#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_BITMAP_H + +#include +#include + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + uint16_t width; + uint16_t height; + uint32_t* data; + uint16_t stride; // words + uint8_t bits_per_value; + uint8_t x_shift; + uint8_t x_mask; + uint16_t bitmask; +} displayio_bitmap_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_BITMAP_H diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c new file mode 100644 index 0000000000..885131d47c --- /dev/null +++ b/shared-module/displayio/Group.c @@ -0,0 +1,88 @@ +/* + * This file is part of the Micro Python 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/Group.h" + +#include "py/runtime.h" +#include "shared-bindings/displayio/Sprite.h" + +void common_hal_displayio_group_construct(displayio_group_t* self, uint32_t max_size) { + mp_obj_t* children = m_new(mp_obj_t, max_size); + displayio_group_construct(self, children, max_size); +} + +void common_hal_displayio_group_append(displayio_group_t* self, mp_obj_t layer) { + if (self->size == self->max_size) { + mp_raise_RuntimeError(translate("Group full")); + } + self->children[self->size] = layer; + self->size++; +} + +void displayio_group_construct(displayio_group_t* self, mp_obj_t* child_array, uint32_t max_size) { + self->x = 0; + self->y = 1; + self->children = child_array; + self->max_size = max_size; +} + +bool displayio_group_get_pixel(displayio_group_t *self, int16_t x, int16_t y, uint16_t* pixel) { + x -= self->x; + y -= self->y; + for (int32_t i = self->size - 1; i >= 0 ; i--) { + mp_obj_t layer = self->children[i]; + if (MP_OBJ_IS_TYPE(layer, &displayio_sprite_type)) { + if (displayio_sprite_get_pixel(layer, x, y, pixel)) { + return true; + } + } + // TODO: Tiled layer + } + return false; +} + +bool displayio_group_needs_refresh(displayio_group_t *self) { + for (int32_t i = self->size - 1; i >= 0 ; i--) { + mp_obj_t layer = self->children[i]; + if (MP_OBJ_IS_TYPE(layer, &displayio_sprite_type)) { + if (displayio_sprite_needs_refresh(layer)) { + return true; + } + } + // TODO: Tiled layer + } + return false; +} + +void displayio_group_finish_refresh(displayio_group_t *self) { + for (int32_t i = self->size - 1; i >= 0 ; i--) { + mp_obj_t layer = self->children[i]; + if (MP_OBJ_IS_TYPE(layer, &displayio_sprite_type)) { + displayio_sprite_finish_refresh(layer); + } + // TODO: Tiled layer + } +} diff --git a/shared-module/displayio/Group.h b/shared-module/displayio/Group.h new file mode 100644 index 0000000000..7f3e5646a6 --- /dev/null +++ b/shared-module/displayio/Group.h @@ -0,0 +1,53 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_GROUP_H +#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_GROUP_H + +#include +#include + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + int16_t x; + int16_t y; + uint16_t size; + uint16_t max_size; + mp_obj_t* children; +} displayio_group_t; + + +void common_hal_displayio_group_construct(displayio_group_t* self, uint32_t max_size); +void common_hal_displayio_group_append(displayio_group_t* self, mp_obj_t layer); + +void displayio_group_construct(displayio_group_t* self, mp_obj_t* child_array, uint32_t max_size); +bool displayio_group_get_pixel(displayio_group_t *group, int16_t x, int16_t y, uint16_t *pixel); +bool displayio_group_needs_refresh(displayio_group_t *self); +void displayio_group_finish_refresh(displayio_group_t *self); + +#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_GROUP_H diff --git a/shared-module/displayio/Palette.c b/shared-module/displayio/Palette.c new file mode 100644 index 0000000000..5f410d7869 --- /dev/null +++ b/shared-module/displayio/Palette.c @@ -0,0 +1,78 @@ +/* + * This file is part of the Micro Python 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/Palette.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); +} + +void common_hal_displayio_palette_make_opaque(displayio_palette_t* self, uint32_t palette_index) { + self->opaque[palette_index / 32] &= ~(0x1 << (palette_index % 32)); +} + +void common_hal_displayio_palette_make_transparent(displayio_palette_t* self, uint32_t palette_index) { + self->opaque[palette_index / 32] |= (0x1 << (palette_index % 32)); +} + +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 b5 = (color >> 19); + uint32_t g6 = (color >> 10) & 0x3f; + uint32_t r5 = (color >> 3) & 0x1f; + uint32_t packed = r5 << 11 | g6 << 5 | b5; + // swap bytes + packed = __builtin_bswap16(packed); + self->colors[palette_index / 2] = masked | packed << shift; + 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; + } + if ((self->opaque[palette_index / 32] & (0x1 << (palette_index % 32))) != 0) { + return false; + } + *color = (self->colors[palette_index / 2] >> (16 * (palette_index % 2))) & 0xffff; + + return true; +} + +bool displayio_palette_needs_refresh(displayio_palette_t *self) { + return self->needs_refresh; +} + +void displayio_palette_finish_refresh(displayio_palette_t *self) { + self->needs_refresh = false; +} diff --git a/shared-module/displayio/Palette.h b/shared-module/displayio/Palette.h new file mode 100644 index 0000000000..5a5f1d2874 --- /dev/null +++ b/shared-module/displayio/Palette.h @@ -0,0 +1,47 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_PALETTE_H +#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_PALETTE_H + +#include +#include + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + uint32_t* opaque; + uint32_t* colors; + uint8_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); +bool displayio_palette_needs_refresh(displayio_palette_t *self); +void displayio_palette_finish_refresh(displayio_palette_t *self); + +#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_PALLETE_H diff --git a/shared-module/displayio/Sprite.c b/shared-module/displayio/Sprite.c new file mode 100644 index 0000000000..b584c05690 --- /dev/null +++ b/shared-module/displayio/Sprite.c @@ -0,0 +1,90 @@ +/* + * This file is part of the Micro Python 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/Sprite.h" + + +#include "shared-bindings/displayio/Bitmap.h" + +void common_hal_displayio_sprite_construct(displayio_sprite_t *self, mp_obj_t bitmap, + mp_obj_t palette, uint16_t width, uint16_t height, uint16_t x, uint16_t y) { + self->width = width; + self->height = height; + self->bitmap = bitmap; + self->palette = palette; + self->x = x; + self->y = y; +} + +void common_hal_displayio_sprite_get_position(displayio_sprite_t *self, int16_t* x, int16_t* y) { + *x = self->x; + *y = self->y; +} + +void common_hal_displayio_sprite_set_position(displayio_sprite_t *self, int16_t x, int16_t y) { + self->x = x; + self->y = y; + self->needs_refresh = true; +} + + +displayio_palette_t* common_hal_displayio_sprite_get_palette(displayio_sprite_t *self) { + return self->palette; +} + +void common_hal_displayio_sprite_set_palette(displayio_sprite_t *self, displayio_palette_t* palette) { + self->palette = palette; + self->needs_refresh = true; +} + +bool displayio_sprite_get_pixel(displayio_sprite_t *self, int16_t x, int16_t y, uint16_t* pixel) { + x -= self->x; + y -= self->y; + if (y < 0 || y >= self->height || x >= self->width || x < 0) { + return false; + } + + uint32_t value = common_hal_displayio_bitmap_get_pixel(self->bitmap, x, y); + if (self->palette == mp_const_none) { + *pixel = value; + return true; + } else if (MP_OBJ_IS_TYPE(self->palette, &displayio_palette_type) && displayio_palette_get_color(self->palette, value, pixel)) { + return true; + } + + return false; +} + +bool displayio_sprite_needs_refresh(displayio_sprite_t *self) { + return self->needs_refresh || displayio_palette_needs_refresh(self->palette); +} + +void displayio_sprite_finish_refresh(displayio_sprite_t *self) { + self->needs_refresh = false; + displayio_palette_finish_refresh(self->palette); + // TODO(tannewt): We could double buffer changes to position and move them over here. + // That way they won't change during a refresh and tear. +} diff --git a/shared-module/displayio/Sprite.h b/shared-module/displayio/Sprite.h new file mode 100644 index 0000000000..213130af83 --- /dev/null +++ b/shared-module/displayio/Sprite.h @@ -0,0 +1,51 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_SPRITE_H +#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_SPRITE_H + +#include +#include + +#include "py/obj.h" +#include "shared-bindings/displayio/Palette.h" + +typedef struct { + mp_obj_base_t base; + mp_obj_t bitmap; + displayio_palette_t* palette; + uint16_t x; + uint16_t y; + uint16_t width; + uint16_t height; + bool needs_refresh; +} displayio_sprite_t; + +bool displayio_sprite_get_pixel(displayio_sprite_t *sprite, int16_t x, int16_t y, uint16_t *pixel); +bool displayio_sprite_needs_refresh(displayio_sprite_t *self); +void displayio_sprite_finish_refresh(displayio_sprite_t *self); + +#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_SPRITE_H diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c new file mode 100644 index 0000000000..df9c2963ab --- /dev/null +++ b/shared-module/displayio/__init__.c @@ -0,0 +1,80 @@ +#include "shared-bindings/displayio/FourWire.h" + +extern displayio_fourwire_obj_t board_display_obj; + +void start_region_update(displayio_fourwire_obj_t* display, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { + // TODO delegate between different display types + displayio_fourwire_start_region_update(display, x0, y0, x1, y1); +} + +void finish_region_update(displayio_fourwire_obj_t* display) { + // TODO delegate between different display types + displayio_fourwire_finish_region_update(display); +} + +void finish_refresh(displayio_fourwire_obj_t* display) { + // TODO delegate between different display types + displayio_fourwire_finish_refresh(display); +} + +bool frame_queued(displayio_fourwire_obj_t* display) { + // TODO delegate between different display types + return displayio_fourwire_frame_queued(display); +} + +bool refresh_queued(displayio_fourwire_obj_t* display) { + // TODO delegate between different display types + return displayio_fourwire_refresh_queued(display); +} + +bool send_pixels(displayio_fourwire_obj_t* display, uint32_t* pixels, uint32_t length) { + // TODO delegate between different display types + return displayio_fourwire_send_pixels(display, pixels, length); +} + +void displayio_refresh_display(void) { + displayio_fourwire_obj_t* display = &board_display_obj; + + if (!frame_queued(display)) { + return; + } + if (refresh_queued(display)) { + // We compute the pixels + uint16_t x0 = 0; + uint16_t y0 = 0; + uint16_t x1 = display->width; + uint16_t y1 = display->height; + size_t index = 0; + //size_t row_size = (x1 - x0); + uint16_t buffer_size = 256; + uint32_t buffer[buffer_size / 2]; + start_region_update(display, x0, y0, x1, y1); + for (uint16_t y = y0; y < y1; ++y) { + for (uint16_t x = x0; x < x1; ++x) { + uint16_t* pixel = &(((uint16_t*)buffer)[index]); + *pixel = 0; + if (display->current_group != NULL) { + displayio_group_get_pixel(display->current_group, x, y, pixel); + } + + + index += 1; + // The buffer is full, send it. + if (index >= buffer_size) { + if (!send_pixels(display, buffer, buffer_size / 2)) { + finish_region_update(display); + return; + } + index = 0; + } + } + } + // Send the remaining data. + if (index && !send_pixels(display, buffer, index * 2)) { + finish_region_update(display); + return; + } + finish_region_update(display); + } + finish_refresh(display); +} diff --git a/shared-module/displayio/__init__.h b/shared-module/displayio/__init__.h new file mode 100644 index 0000000000..556af430d5 --- /dev/null +++ b/shared-module/displayio/__init__.h @@ -0,0 +1,32 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO___INIT___H + +void displayio_refresh_display(void); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO___INIT___H diff --git a/shared-module/displayio/mipi_constants.h b/shared-module/displayio/mipi_constants.h new file mode 100644 index 0000000000..3cb7e4292f --- /dev/null +++ b/shared-module/displayio/mipi_constants.h @@ -0,0 +1,37 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_MIPI_CONSTANTS_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_MIPI_CONSTANTS_H + +// More info here: https://www.tonylabs.com/wp-content/uploads/MIPI_DCS_specification_v1.02.00.pdf +enum mipi_command { + MIPI_COMMAND_SET_COLUMN_ADDRESS = 0x2a, + MIPI_COMMAND_SET_PAGE_ADDRESS = 0x2b, + MIPI_COMMAND_WRITE_MEMORY_START = 0x2c, +}; + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_MIPI_CONSTANTS_H