diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-01-23 15:29:38 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-23 15:29:38 -0800 |
| commit | 49581f9e1cbe8446b9fc3a44f6176ff3f5285b4b (patch) | |
| tree | 8efaddb56d5ff95c4cca0e9e9b1692d2683b1cfa | |
| parent | 07a4cc0c48cc7e530c3f90f83e7ea7888fa3e6cc (diff) | |
| parent | b2f2abcb228be2bb4601a1373a307d98483ec274 (diff) | |
Merge pull request #1489 from tannewt/fix_palette_color
Fix palette color conversion
| -rw-r--r-- | shared-module/displayio/Display.c | 10 | ||||
| -rw-r--r-- | shared-module/displayio/Palette.c | 4 | ||||
| -rw-r--r-- | shared-module/displayio/__init__.c | 4 |
3 files changed, 8 insertions, 10 deletions
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index f75f0392f..7946111b7 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -29,6 +29,7 @@ #include "py/runtime.h" #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/time/__init__.h" #include <stdint.h> @@ -73,18 +74,15 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t *data = cmd + 2; self->send(self->bus, true, cmd, 1); self->send(self->bus, false, data, data_size); + uint16_t delay_length_ms = 10; if (delay) { data_size++; - uint16_t delay_length_ms = *(cmd + 1 + data_size); + 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) {} } + common_hal_time_delay_ms(delay_length_ms); i += 2 + data_size; } self->end_transaction(self->bus); diff --git a/shared-module/displayio/Palette.c b/shared-module/displayio/Palette.c index 5f410d786..e810be875 100644 --- a/shared-module/displayio/Palette.c +++ b/shared-module/displayio/Palette.c @@ -47,9 +47,9 @@ void common_hal_displayio_palette_make_transparent(displayio_palette_t* self, ui 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 r5 = (color >> 19); uint32_t g6 = (color >> 10) & 0x3f; - uint32_t r5 = (color >> 3) & 0x1f; + uint32_t b5 = (color >> 3) & 0x1f; uint32_t packed = r5 << 11 | g6 << 5 | b5; // swap bytes packed = __builtin_bswap16(packed); diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index 59a5cf398..c86e48a12 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -99,8 +99,8 @@ displayio_bitmap_t blinka_bitmap = { uint32_t blinka_transparency[1] = {0x80000000}; -// TODO(tannewt): Fix these colors -uint32_t blinka_colors[8] = {0x91780000, 0x879FFC98, 0xffff0000, 0x0000f501, +// These colors are RGB 565 with the bytes swapped. +uint32_t blinka_colors[8] = {0x78890000, 0x9F86B8FC, 0xffff0D5A, 0x0000f501, 0x00000000, 0x00000000, 0x00000000, 0x00000000}; displayio_palette_t blinka_palette = { |
