Merge pull request #1489 from tannewt/fix_palette_color

Fix palette color conversion
This commit is contained in:
Scott Shawcroft 2019-01-23 15:29:38 -08:00 committed by GitHub
commit 49581f9e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 10 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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 = {