embox

Форк
0
/
display_port_stm32.c 
78 строк · 2.1 Кб
1
/**
2
 * @file
3
 * @brief LVGL display interface port
4
 * @defails Based on lv_drivers/display/fbdev.c
5
 *
6
 * @date 15.02.2021
7
 * @author Alexander Kalmuk
8
 */
9

10
#include <unistd.h>
11
#include <util/log.h>
12
#include <drivers/video/fb.h>
13

14
#if defined STM32F746xx || defined STM32F769xx
15
#include <stm32f7xx_hal.h>
16
#elif defined STM32H745xx
17
#include <stm32h7xx_hal.h>
18
#elif defined (STM32F429xx)
19
#include <stm32f4xx_hal.h>
20
#endif
21

22
#include "lvgl.h"
23

24
extern uint8_t *lv_fbp;
25
extern struct fb_var_screeninfo lv_vinfo;
26
extern struct fb_fix_screeninfo lv_finfo;
27

28
void lvgl_port_fbdev_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area,
29
	    lv_color_t *color_p) {
30
	int32_t act_x1, act_y1, act_x2, act_y2;
31
	long int location = 0;
32
	lv_coord_t w;
33

34
	if (lv_fbp == NULL ||
35
		    area->x2 < 0 ||
36
		    area->y2 < 0 ||
37
		    area->x1 > (int32_t)lv_vinfo.xres - 1 ||
38
		    area->y1 > (int32_t)lv_vinfo.yres - 1) {
39
		lv_disp_flush_ready(disp_drv);
40
		return;
41
	}
42

43
	/* Truncate the area to the screen */
44
	act_x1 = area->x1 < 0 ? 0 : area->x1;
45
	act_y1 = area->y1 < 0 ? 0 : area->y1;
46
	act_x2 = area->x2 > (int32_t)lv_vinfo.xres - 1 ? (int32_t)lv_vinfo.xres - 1 : area->x2;
47
	act_y2 = area->y2 > (int32_t)lv_vinfo.yres - 1 ? (int32_t)lv_vinfo.yres - 1 : area->y2;
48

49
	w = (act_x2 - act_x1 + 1);
50

51
	if (lv_vinfo.bits_per_pixel == 32 || lv_vinfo.bits_per_pixel == 24) {
52
		uint32_t * lv_fbp32 = (uint32_t *)lv_fbp;
53
		int32_t y;
54

55
		for(y = act_y1; y <= act_y2; y++) {
56
			location = (act_x1 + lv_vinfo.xoffset) + (y + lv_vinfo.yoffset) * lv_finfo.line_length / 4;
57
			memcpy(&lv_fbp32[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1) * 4);
58
			color_p += w;
59
		}
60
	} else if (lv_vinfo.bits_per_pixel == 16) {
61
		uint16_t * lv_fbp16 = (uint16_t *)lv_fbp;
62
		int32_t y;
63

64
		for(y = act_y1; y <= act_y2; y++) {
65
			location = (act_x1 + lv_vinfo.xoffset) + (y + lv_vinfo.yoffset) * lv_finfo.line_length / 2;
66
			memcpy(&lv_fbp16[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1) * 2);
67
			color_p += w;
68
		}
69
	} else {
70
		log_error("Unsupported bits_per_pixel=%d", lv_vinfo.bits_per_pixel);
71
	}
72

73
#if defined STM32F746xx || defined STM32F769xx || defined STM32H745xx
74
	SCB_CleanDCache();
75
#endif
76

77
	lv_disp_flush_ready(disp_drv);
78
}
79

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.