summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2018-09-06 14:49:49 -0700
committerScott Shawcroft <scott@tannewt.org>2018-09-06 14:49:49 -0700
commit1683eb913d5bfb4265df56bf286d9971185a3a82 (patch)
treee536c26b316b688e48abb8f7233e706f8832ba76
parent121903b6eeb9712cae86a24c5fe82cb7b144e504 (diff)
Minor tweaks based on feedback
-rw-r--r--locale/circuitpython.pot40
-rw-r--r--locale/en_US.po40
-rw-r--r--locale/es.po40
-rw-r--r--locale/fil.po82
-rw-r--r--locale/fr.po45
-rw-r--r--ports/atmel-samd/boards/hallowing_m0_express/board.c41
-rw-r--r--ports/atmel-samd/boards/hallowing_m0_express/pins.c2
-rw-r--r--ports/atmel-samd/common-hal/displayio/FourWire.c12
-rw-r--r--shared-bindings/displayio/Bitmap.h2
-rw-r--r--shared-bindings/displayio/Palette.c32
-rw-r--r--shared-bindings/displayio/Palette.h6
-rw-r--r--shared-bindings/displayio/Sprite.c7
-rw-r--r--shared-module/displayio/Bitmap.c21
-rw-r--r--shared-module/displayio/Palette.c28
-rw-r--r--shared-module/displayio/Palette.h4
-rw-r--r--shared-module/displayio/mipi_constants.h37
16 files changed, 291 insertions, 148 deletions
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index c7b7085b7..1d94dccae 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:49-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -2022,19 +2022,15 @@ msgstr ""
msgid "Unsupported pull value."
msgstr ""
-#: shared-bindings/displayio/Bitmap.c:66
-msgid "value_size must be power of two"
-msgstr ""
-
-#: shared-bindings/displayio/Bitmap.c:85
+#: shared-bindings/displayio/Bitmap.c:84
msgid "y should be an int"
msgstr ""
-#: shared-bindings/displayio/Bitmap.c:90
+#: 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:95
+#: shared-bindings/displayio/Bitmap.c:94
msgid "row data must be a buffer"
msgstr ""
@@ -2047,36 +2043,36 @@ msgstr ""
msgid "Group must have size at least 1"
msgstr ""
-#: shared-bindings/displayio/Palette.c:94
+#: 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:100
-msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGBA)"
+#: 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:104
+#: shared-bindings/displayio/Palette.c:106
msgid "color must be between 0x000000 and 0xffffff"
msgstr ""
-#: shared-bindings/displayio/Palette.c:108
+#: shared-bindings/displayio/Palette.c:110
msgid "color buffer must be a buffer or int"
msgstr ""
-#: shared-bindings/displayio/Palette.c:124
-#: shared-bindings/displayio/Palette.c:138
-msgid "value should be an int"
+#: 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:44
+#: shared-bindings/displayio/Sprite.c:45
msgid "position must be 2-tuple"
msgstr ""
-#: shared-bindings/displayio/Sprite.c:86
+#: shared-bindings/displayio/Sprite.c:87
msgid "unsupported bitmap type"
msgstr ""
-#: shared-bindings/displayio/Sprite.c:151
+#: shared-bindings/displayio/Sprite.c:152
msgid "palette must be displayio.Palette"
msgstr ""
@@ -2294,7 +2290,11 @@ msgstr ""
msgid "Cannot transfer without MOSI and MISO pins."
msgstr ""
-#: shared-module/displayio/Bitmap.c:60
+#: 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 ""
diff --git a/locale/en_US.po b/locale/en_US.po
index 78e32cc82..c310ea920 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:49-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -2022,19 +2022,15 @@ msgstr ""
msgid "Unsupported pull value."
msgstr ""
-#: shared-bindings/displayio/Bitmap.c:66
-msgid "value_size must be power of two"
-msgstr ""
-
-#: shared-bindings/displayio/Bitmap.c:85
+#: shared-bindings/displayio/Bitmap.c:84
msgid "y should be an int"
msgstr ""
-#: shared-bindings/displayio/Bitmap.c:90
+#: 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:95
+#: shared-bindings/displayio/Bitmap.c:94
msgid "row data must be a buffer"
msgstr ""
@@ -2047,36 +2043,36 @@ msgstr ""
msgid "Group must have size at least 1"
msgstr ""
-#: shared-bindings/displayio/Palette.c:94
+#: 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:100
-msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGBA)"
+#: 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:104
+#: shared-bindings/displayio/Palette.c:106
msgid "color must be between 0x000000 and 0xffffff"
msgstr ""
-#: shared-bindings/displayio/Palette.c:108
+#: shared-bindings/displayio/Palette.c:110
msgid "color buffer must be a buffer or int"
msgstr ""
-#: shared-bindings/displayio/Palette.c:124
-#: shared-bindings/displayio/Palette.c:138
-msgid "value should be an int"
+#: 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:44
+#: shared-bindings/displayio/Sprite.c:45
msgid "position must be 2-tuple"
msgstr ""
-#: shared-bindings/displayio/Sprite.c:86
+#: shared-bindings/displayio/Sprite.c:87
msgid "unsupported bitmap type"
msgstr ""
-#: shared-bindings/displayio/Sprite.c:151
+#: shared-bindings/displayio/Sprite.c:152
msgid "palette must be displayio.Palette"
msgstr ""
@@ -2294,7 +2290,11 @@ msgstr ""
msgid "Cannot transfer without MOSI and MISO pins."
msgstr ""
-#: shared-module/displayio/Bitmap.c:60
+#: 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 ""
diff --git a/locale/es.po b/locale/es.po
index c9de75c38..f7e0ed4e4 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:49-0700\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -2068,19 +2068,15 @@ msgstr ""
msgid "Unsupported pull value."
msgstr ""
-#: shared-bindings/displayio/Bitmap.c:66
-msgid "value_size must be power of two"
-msgstr ""
-
-#: shared-bindings/displayio/Bitmap.c:85
+#: shared-bindings/displayio/Bitmap.c:84
msgid "y should be an int"
msgstr ""
-#: shared-bindings/displayio/Bitmap.c:90
+#: 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:95
+#: shared-bindings/displayio/Bitmap.c:94
msgid "row data must be a buffer"
msgstr ""
@@ -2093,36 +2089,36 @@ msgstr ""
msgid "Group must have size at least 1"
msgstr ""
-#: shared-bindings/displayio/Palette.c:94
+#: 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:100
-msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGBA)"
+#: 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:104
+#: shared-bindings/displayio/Palette.c:106
msgid "color must be between 0x000000 and 0xffffff"
msgstr ""
-#: shared-bindings/displayio/Palette.c:108
+#: shared-bindings/displayio/Palette.c:110
msgid "color buffer must be a buffer or int"
msgstr ""
-#: shared-bindings/displayio/Palette.c:124
-#: shared-bindings/displayio/Palette.c:138
-msgid "value should be an int"
+#: 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:44
+#: shared-bindings/displayio/Sprite.c:45
msgid "position must be 2-tuple"
msgstr ""
-#: shared-bindings/displayio/Sprite.c:86
+#: shared-bindings/displayio/Sprite.c:87
msgid "unsupported bitmap type"
msgstr ""
-#: shared-bindings/displayio/Sprite.c:151
+#: shared-bindings/displayio/Sprite.c:152
msgid "palette must be displayio.Palette"
msgstr ""
@@ -2341,7 +2337,11 @@ msgstr ""
msgid "Cannot transfer without MOSI and MISO pins."
msgstr ""
-#: shared-module/displayio/Bitmap.c:60
+#: 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 ""
diff --git a/locale/fil.po b/locale/fil.po
index 7e8b9c7a3..8f681bcb4 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:49-0700\n"
"PO-Revision-Date: 2018-08-30 23:04-0700\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@@ -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 3bbd77969..740830e10 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:49-0700\n"
"PO-Revision-Date: 2018-08-14 11:01+0200\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@@ -2051,24 +2051,19 @@ 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:66
-#, fuzzy
-msgid "value_size must be power of two"
-msgstr "'len' doit être un multiple de 4"
-
-#: shared-bindings/displayio/Bitmap.c:85
+#: 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:90
+#: 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:95
+#: shared-bindings/displayio/Bitmap.c:94
#, fuzzy
msgid "row data must be a buffer"
msgstr "les constantes doivent être des entiers"
@@ -2083,44 +2078,44 @@ msgstr ""
msgid "Group must have size at least 1"
msgstr "Le tampon doit être de longueur au moins 1"
-#: shared-bindings/displayio/Palette.c:94
+#: 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:100
-msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGBA)"
+#: 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:104
+#: 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:108
+#: 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:124
-#: shared-bindings/displayio/Palette.c:138
+#: shared-bindings/displayio/Palette.c:123
+#: shared-bindings/displayio/Palette.c:137
#, fuzzy
-msgid "value should be an int"
+msgid "palette_index should be an int"
msgstr "Les valeurs du tableau doivent être des octets simples 'bytes'"
-#: shared-bindings/displayio/Sprite.c:44
+#: 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:86
+#: shared-bindings/displayio/Sprite.c:87
#, fuzzy
msgid "unsupported bitmap type"
msgstr "Débit non supporté"
-#: shared-bindings/displayio/Sprite.c:151
+#: shared-bindings/displayio/Sprite.c:152
#, fuzzy
msgid "palette must be displayio.Palette"
msgstr "la palette doit être longue de 32 octets"
@@ -2346,7 +2341,11 @@ 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:60
+#: 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 ""
@@ -2361,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/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c
index 85bcaabc7..b47c5fbb2 100644
--- a/ports/atmel-samd/boards/hallowing_m0_express/board.c
+++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c
@@ -27,14 +27,17 @@
#include "boards/board.h"
#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, // SWRESET
- 0x11, 0, // SLPOUT
+ 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,
@@ -60,36 +63,50 @@ uint8_t display_init_sequence[] = {
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, // _NORON
- 0x29, 0, // _DISPON
+ 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, &pin_PB22, &pin_PA28, &pin_PA01, &pin_PA27,
- 128, 128, 2, 0, 16, 0x2a, 0x2b, 0x2c);
+ &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 (*cmd == 0x01) {
- uint64_t start = ticks_ms;
- while (ticks_ms - start < 120) {}
- } else if (*cmd == 0x11) {
+ 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 < 500) {}
+ 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);
}
diff --git a/ports/atmel-samd/boards/hallowing_m0_express/pins.c b/ports/atmel-samd/boards/hallowing_m0_express/pins.c
index 28c3d6a5c..7d4afc7a4 100644
--- a/ports/atmel-samd/boards/hallowing_m0_express/pins.c
+++ b/ports/atmel-samd/boards/hallowing_m0_express/pins.c
@@ -58,6 +58,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ 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_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
index 033970c77..6c3b75a85 100644
--- a/ports/atmel-samd/common-hal/displayio/FourWire.c
+++ b/ports/atmel-samd/common-hal/displayio/FourWire.c
@@ -96,21 +96,17 @@ int32_t common_hal_displayio_fourwire_wait_for_frame(displayio_fourwire_obj_t* s
return 0;
}
-static uint16_t swap(uint16_t x) {
- return (x & 0x00ff) << 8 | x >> 8;
-}
-
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] = swap(x0 + self->colstart);
- data[1] = swap(x1-1 + self->colstart);
+ 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] = swap(y0 + 1 + self->rowstart);
- data[1] = swap(y1 + self->rowstart);
+ 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);
}
diff --git a/shared-bindings/displayio/Bitmap.h b/shared-bindings/displayio/Bitmap.h
index 2ae468481..b736f9459 100644
--- a/shared-bindings/displayio/Bitmap.h
+++ b/shared-bindings/displayio/Bitmap.h
@@ -32,7 +32,7 @@
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 value_size);
+ 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);
diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c
index 99963f131..21744f947 100644
--- a/shared-bindings/displayio/Palette.c
+++ b/shared-bindings/displayio/Palette.c
@@ -38,10 +38,10 @@
//| .. currentmodule:: displayio
//|
-//| :class:`Palette` -- Stores a mapping from bitmap pixel values to display colors
+//| :class:`Palette` -- Stores a mapping from bitmap pixel palette_indexes to display colors
//| ===============================================================================
//|
-//| Map a pixel value to a full color. Colors are transformed to the display's format internally to
+//| 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.
@@ -86,7 +86,7 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val
return MP_OBJ_NULL;
}
displayio_palette_t *self = MP_OBJ_TO_PTR(self_in);
- size_t index = mp_get_index(&displayio_palette_type, self->max_value, index_in, false);
+ size_t index = mp_get_index(&displayio_palette_type, self->color_count, index_in, false);
uint32_t color;
mp_int_t int_value;
@@ -99,7 +99,7 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val
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 (RGBA)"));
+ 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) {
@@ -113,30 +113,30 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val
return mp_const_none;
}
-//| .. method:: make_transparent(value)
+//| .. method:: make_transparent(palette_index)
//|
-STATIC mp_obj_t displayio_palette_obj_make_transparent(mp_obj_t self_in, mp_obj_t value_obj) {
+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 value;
- if (!mp_obj_get_int_maybe(value_obj, &value)) {
- mp_raise_ValueError(translate("value should be an int"));
+ 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, value);
+ 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(value)
+//| .. method:: make_opaque(palette_index)
//|
-STATIC mp_obj_t displayio_palette_obj_make_opaque(mp_obj_t self_in, mp_obj_t value_obj) {
+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 value;
- if (!mp_obj_get_int_maybe(value_obj, &value)) {
- mp_raise_ValueError(translate("value should be an int"));
+ 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, value);
+ 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);
diff --git a/shared-bindings/displayio/Palette.h b/shared-bindings/displayio/Palette.h
index fde6ab7d3..767fc7b63 100644
--- a/shared-bindings/displayio/Palette.h
+++ b/shared-bindings/displayio/Palette.h
@@ -32,9 +32,9 @@
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 value, uint32_t color);
+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 value);
-void common_hal_displayio_palette_make_transparent(displayio_palette_t* self, uint32_t value);
+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
index 25ea79f5c..223a8a394 100644
--- a/shared-bindings/displayio/Sprite.c
+++ b/shared-bindings/displayio/Sprite.c
@@ -35,7 +35,8 @@
#include "shared-bindings/displayio/Bitmap.h"
#include "supervisor/shared/translate.h"
-void parse_position(mp_obj_t position_obj, int16_t* x, int16_t* y) {
+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]);
@@ -88,7 +89,7 @@ STATIC mp_obj_t displayio_sprite_make_new(const mp_obj_type_t *type, size_t n_ar
int16_t x = 0;
int16_t y = 0;
mp_obj_t position_obj = args[ARG_position].u_obj;
- parse_position(position_obj, &x, &y);
+ unpack_position(position_obj, &x, &y);
displayio_sprite_t *self = m_new_obj(displayio_sprite_t);
self->base.type = &displayio_sprite_type;
@@ -120,7 +121,7 @@ STATIC mp_obj_t displayio_sprite_obj_set_position(mp_obj_t self_in, mp_obj_t val
int16_t x = 0;
int16_t y = 0;
- parse_position(value, &x, &y);
+ unpack_position(value, &x, &y);
common_hal_displayio_sprite_set_position(self, x, y);
diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c
index 453dc1c59..addc341a7 100644
--- a/shared-module/displayio/Bitmap.c
+++ b/shared-module/displayio/Bitmap.c
@@ -31,8 +31,8 @@
#include "py/runtime.h"
void common_hal_displayio_bitmap_construct(displayio_bitmap_t *self, uint32_t width,
- uint32_t height, uint32_t value_size) {
- uint32_t row_width = width * value_size;
+ 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);
@@ -43,16 +43,25 @@ void common_hal_displayio_bitmap_construct(displayio_bitmap_t *self, uint32_t wi
self->height = height;
self->data = m_malloc(self->stride * height * sizeof(uint32_t), false);
- self->bits_per_value = value_size;
+ self->bits_per_value = bits_per_value;
- self->x_shift = 0;
+ 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 / value_size ) {
+ 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 << value_size) - 1;
+ 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) {
diff --git a/shared-module/displayio/Palette.c b/shared-module/displayio/Palette.c
index e2ec6e057..5f410d786 100644
--- a/shared-module/displayio/Palette.c
+++ b/shared-module/displayio/Palette.c
@@ -27,7 +27,7 @@
#include "shared-bindings/displayio/Palette.h"
void common_hal_displayio_palette_construct(displayio_palette_t* self, uint16_t color_count) {
- self->max_value = 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) {
@@ -36,35 +36,35 @@ void common_hal_displayio_palette_construct(displayio_palette_t* self, uint16_t
self->opaque = (uint32_t *) m_malloc(opaque_byte_count, false);
}
-void common_hal_displayio_palette_make_opaque(displayio_palette_t* self, uint32_t value) {
- self->opaque[value / 32] &= ~(0x1 << (value % 32));
+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 value) {
- self->opaque[value / 32] |= (0x1 << (value % 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 value, uint32_t color) {
- uint32_t shift = (value % 2) * 16;
- uint32_t masked = self->colors[value / 2] & ~(0xffff << shift);
+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 = ((packed >> 8) & 0xff) | ((packed & 0xff) << 8);
- self->colors[value / 2] = masked | packed << shift;
+ 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 value, uint16_t* color) {
- if (value > self->max_value) {
+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[value / 32] & (0x1 << (value % 32))) != 0) {
+ if ((self->opaque[palette_index / 32] & (0x1 << (palette_index % 32))) != 0) {
return false;
}
- *color = (self->colors[value / 2] >> (16 * (value % 2))) & 0xffff;
+ *color = (self->colors[palette_index / 2] >> (16 * (palette_index % 2))) & 0xffff;
return true;
}
diff --git a/shared-module/displayio/Palette.h b/shared-module/displayio/Palette.h
index 22c737c9d..5a5f1d287 100644
--- a/shared-module/displayio/Palette.h
+++ b/shared-module/displayio/Palette.h
@@ -36,11 +36,11 @@ typedef struct {
mp_obj_base_t base;
uint32_t* opaque;
uint32_t* colors;
- uint8_t max_value;
+ uint8_t color_count;
bool needs_refresh;
} displayio_palette_t;
-bool displayio_palette_get_color(displayio_palette_t *palette, uint32_t value, uint16_t* color);
+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);
diff --git a/shared-module/displayio/mipi_constants.h b/shared-module/displayio/mipi_constants.h
new file mode 100644
index 000000000..3cb7e4292
--- /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