Skip to content

Commit 4dfc586

Browse files
committed
displayio: swap colors in palettes too
.. change the in-rom palette to be in RGB565 order
1 parent 75c35c8 commit 4dfc586

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

shared-module/displayio/Palette.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ bool displayio_palette_get_color(displayio_palette_t *self, const _displayio_col
8383
} else if (colorspace->grayscale) {
8484
*color = self->colors[palette_index].luma >> (8 - colorspace->depth);
8585
} else {
86-
*color = self->colors[palette_index].rgb565;
86+
uint16_t packed = self->colors[palette_index].rgb565;
87+
if (colorspace->reverse_bytes_in_word) {
88+
// swap bytes
89+
packed = __builtin_bswap16(packed);
90+
}
91+
*color = packed;
8792
}
8893

8994
return true;

supervisor/shared/display.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,28 +169,28 @@ _displayio_color_t blinka_colors[7] = {
169169
},
170170
{
171171
.rgb888 = 0x8428bc,
172-
.rgb565 = 0x7889,
172+
.rgb565 = 0x8978,
173173
.luma = 0xff, // We cheat the luma here. It is actually 0x60
174174
.hue = 184,
175175
.chroma = 148
176176
},
177177
{
178178
.rgb888 = 0xff89bc,
179-
.rgb565 = 0xB8FC,
179+
.rgb565 = 0xFCB8,
180180
.luma = 0xb5,
181181
.hue = 222,
182182
.chroma = 118
183183
},
184184
{
185185
.rgb888 = 0x7beffe,
186-
.rgb565 = 0x9F86,
186+
.rgb565 = 0x869F,
187187
.luma = 0xe0,
188188
.hue = 124,
189189
.chroma = 131
190190
},
191191
{
192192
.rgb888 = 0x51395f,
193-
.rgb565 = 0x0D5A,
193+
.rgb565 = 0x5A0D,
194194
.luma = 0x47,
195195
.hue = 185,
196196
.chroma = 38
@@ -203,7 +203,7 @@ _displayio_color_t blinka_colors[7] = {
203203
},
204204
{
205205
.rgb888 = 0x0736a0,
206-
.rgb565 = 0xf501,
206+
.rgb565 = 0x01f5,
207207
.luma = 0x44,
208208
.hue = 147,
209209
.chroma = 153

0 commit comments

Comments
 (0)