Skip to content

Commit c1c9a6d

Browse files
committed
fbdev: implement 32 bit conversion to 16 bit display
1 parent bc0650b commit c1c9a6d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lv_drivers/display/fbdev.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,33 @@ void fbdev_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color
191191
}
192192
/*16 bit per pixel*/
193193
else if(vinfo.bits_per_pixel == 16) {
194+
#if LV_COLOR_DEPTH == 32
195+
uint16_t * fbp16 = (uint16_t *)fbp;
196+
int32_t y;
197+
int32_t x;
198+
for(y = act_y1; y <= act_y2; y++) {
199+
for(x = act_x1; x <= act_x2; x++) {
200+
location = (x + vinfo.xoffset) + (y + vinfo.yoffset) * finfo.line_length / 2;
201+
fbp16[location] = (uint16_t)(
202+
// R, and 3 bits from G
203+
((color_p->ch.red & 0xf8) | (color_p->ch.green >> 5)) << 8
204+
// 3 bits from G, and B
205+
| ((color_p->ch.green & 0x1c) << 3) | (color_p->ch.blue >> 3)
206+
);
207+
color_p++;
208+
}
209+
210+
color_p += area->x2 - act_x2;
211+
}
212+
#else
194213
uint16_t * fbp16 = (uint16_t *)fbp;
195214
int32_t y;
196215
for(y = act_y1; y <= act_y2; y++) {
197216
location = (act_x1 + vinfo.xoffset) + (y + vinfo.yoffset) * finfo.line_length / 2;
198217
memcpy(&fbp16[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1) * 2);
199218
color_p += w;
200219
}
220+
#endif
201221
}
202222
/*8 bit per pixel*/
203223
else if(vinfo.bits_per_pixel == 8) {

0 commit comments

Comments
 (0)