Skip to content

Commit 89658e3

Browse files
committed
fbdev: implement 32 bit conversion to 16 bit display
1 parent 0f5f84f commit 89658e3

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

0 commit comments

Comments
 (0)