1 /*
2 * Copyright (c) 2019 Jan Van Winkel <jan.van_winkel@dxplore.eu>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/kernel.h>
8 #include <lvgl.h>
9 #include "lvgl_display.h"
10
lvgl_flush_cb_32bit(lv_disp_drv_t * disp_drv,const lv_area_t * area,lv_color_t * color_p)11 void lvgl_flush_cb_32bit(lv_disp_drv_t *disp_drv,
12 const lv_area_t *area, lv_color_t *color_p)
13 {
14 struct lvgl_disp_data *data =
15 (struct lvgl_disp_data *)disp_drv->user_data;
16 uint16_t w = area->x2 - area->x1 + 1;
17 uint16_t h = area->y2 - area->y1 + 1;
18 struct display_buffer_descriptor desc;
19
20 desc.buf_size = w * 4U * h;
21 desc.width = w;
22 desc.pitch = w;
23 desc.height = h;
24 display_write(data->display_dev, area->x1, area->y1, &desc,
25 (void *) color_p);
26
27 lv_disp_flush_ready(disp_drv);
28 }
29
30 #ifndef CONFIG_LV_COLOR_DEPTH_32
lvgl_set_px_cb_32bit(lv_disp_drv_t * disp_drv,uint8_t * buf,lv_coord_t buf_w,lv_coord_t x,lv_coord_t y,lv_color_t color,lv_opa_t opa)31 void lvgl_set_px_cb_32bit(lv_disp_drv_t *disp_drv,
32 uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
33 lv_color_t color, lv_opa_t opa)
34 {
35 uint32_t *buf_xy = (uint32_t *)(buf + x * 4U + y * 4U * buf_w);
36
37 if (opa == LV_OPA_COVER) {
38 /* Do not mix if not required */
39 *buf_xy = lv_color_to32(color);
40 } else {
41 lv_color_t bg_color = *((lv_color_t *)buf_xy);
42 *buf_xy = lv_color_to32(lv_color_mix(color, bg_color, opa));
43 }
44 }
45 #endif
46