Skip to content

Commit b316dac

Browse files
Finomniscfriedt
authored andcommitted
samples: drivers: display: Add support for AL_88 color
Renders three different shades of gray in each corner, with one corner continually changing color. Signed-off-by: Martin Stumpf <[email protected]>
1 parent 4da9a89 commit b316dac

File tree

1 file changed

+33
-0
lines changed
  • samples/drivers/display/src

1 file changed

+33
-0
lines changed

samples/drivers/display/src/main.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,34 @@ static inline void fill_buffer_l_8(enum corner corner, uint8_t grey, uint8_t *bu
165165
}
166166
}
167167

168+
static void fill_buffer_al_88(enum corner corner, uint8_t grey, uint8_t *buf,
169+
size_t buf_size)
170+
{
171+
uint16_t color;
172+
173+
switch (corner) {
174+
case TOP_LEFT:
175+
color = 0xFF00u;
176+
break;
177+
case TOP_RIGHT:
178+
color = 0xFFFFu;
179+
break;
180+
case BOTTOM_RIGHT:
181+
color = 0xFF88u;
182+
break;
183+
case BOTTOM_LEFT:
184+
color = 0xFF00u | grey;
185+
break;
186+
default:
187+
color = 0;
188+
break;
189+
}
190+
191+
for (size_t idx = 0; idx < buf_size; idx += 2) {
192+
*((uint16_t *)(buf + idx)) = color;
193+
}
194+
}
195+
168196
static inline void fill_buffer_mono01(enum corner corner, uint8_t grey,
169197
uint8_t *buf, size_t buf_size)
170198
{
@@ -273,6 +301,11 @@ int main(void)
273301
bg_color = 0xFFu;
274302
fill_buffer_fnc = fill_buffer_l_8;
275303
break;
304+
case PIXEL_FORMAT_AL_88:
305+
bg_color = 0x00u;
306+
fill_buffer_fnc = fill_buffer_al_88;
307+
buf_size *= 2;
308+
break;
276309
case PIXEL_FORMAT_MONO01:
277310
bg_color = 0xFFu;
278311
fill_buffer_fnc = fill_buffer_mono01;

0 commit comments

Comments
 (0)