Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_hal/lv_hal_disp.h
1476 views
1
/**
2
* @file hal_disp.h
3
*
4
* @description Display Driver HAL interface header file
5
*
6
*/
7
8
#ifndef HAL_DISP_H
9
#define HAL_DISP_H
10
11
#ifdef __cplusplus
12
extern "C" {
13
#endif
14
15
/*********************
16
* INCLUDES
17
*********************/
18
#include <stdint.h>
19
#include "lv_hal.h"
20
#include "../lv_misc/lv_color.h"
21
#include "../lv_misc/lv_area.h"
22
23
/*********************
24
* DEFINES
25
*********************/
26
27
/**********************
28
* TYPEDEFS
29
**********************/
30
31
/**
32
* Display Driver structure to be registered by HAL
33
*/
34
typedef struct _disp_drv_t {
35
/*Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished*/
36
void (*disp_flush)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
37
38
/*Fill an area with a color on the display*/
39
void (*disp_fill)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
40
41
/*Write pixel map (e.g. image) to the display*/
42
void (*disp_map)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
43
44
/*Optional interface functions to use GPU*/
45
#if USE_LV_GPU
46
/*Blend two memories using opacity (GPU only)*/
47
void (*mem_blend)(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
48
49
/*Fill a memory with a color (GPU only)*/
50
void (*mem_fill)(lv_color_t * dest, uint32_t length, lv_color_t color);
51
#endif
52
53
#if LV_VDB_SIZE
54
/*Optional: Set a pixel in a buffer according to the requirements of the display*/
55
void (*vdb_wr)(uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa);
56
#endif
57
} lv_disp_drv_t;
58
59
typedef struct _disp_t {
60
lv_disp_drv_t driver;
61
struct _disp_t *next;
62
} lv_disp_t;
63
64
/**********************
65
* GLOBAL PROTOTYPES
66
**********************/
67
68
/**
69
* Initialize a display driver with default values.
70
* It is used to surly have known values in the fields ant not memory junk.
71
* After it you can set the fields.
72
* @param driver pointer to driver variable to initialize
73
*/
74
void lv_disp_drv_init(lv_disp_drv_t *driver);
75
76
/**
77
* Register an initialized display driver.
78
* Automatically set the first display as active.
79
* @param driver pointer to an initialized 'lv_disp_drv_t' variable (can be local variable)
80
* @return pointer to the new display or NULL on error
81
*/
82
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver);
83
84
/**
85
* Set the active display
86
* @param disp pointer to a display (return value of 'lv_disp_register')
87
*/
88
void lv_disp_set_active(lv_disp_t * disp);
89
90
/**
91
* Get a pointer to the active display
92
* @return pointer to the active display
93
*/
94
lv_disp_t * lv_disp_get_active(void);
95
96
/**
97
* Get the next display.
98
* @param disp pointer to the current display. NULL to initialize.
99
* @return the next display or NULL if no more. Give the first display when the parameter is NULL
100
*/
101
lv_disp_t * lv_disp_next(lv_disp_t * disp);
102
103
/**
104
* Fill a rectangular area with a color on the active display
105
* @param x1 left coordinate of the rectangle
106
* @param x2 right coordinate of the rectangle
107
* @param y1 top coordinate of the rectangle
108
* @param y2 bottom coordinate of the rectangle
109
* @param color_p pointer to an array of colors
110
*/
111
void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p);
112
113
/**
114
* Fill a rectangular area with a color on the active display
115
* @param x1 left coordinate of the rectangle
116
* @param x2 right coordinate of the rectangle
117
* @param y1 top coordinate of the rectangle
118
* @param y2 bottom coordinate of the rectangle
119
* @param color fill color
120
*/
121
void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
122
123
/**
124
* Put a color map to a rectangular area on the active display
125
* @param x1 left coordinate of the rectangle
126
* @param x2 right coordinate of the rectangle
127
* @param y1 top coordinate of the rectangle
128
* @param y2 bottom coordinate of the rectangle
129
* @param color_map pointer to an array of colors
130
*/
131
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map);
132
133
#if USE_LV_GPU
134
/**
135
* Blend pixels to a destination memory from a source memory
136
* In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available)
137
* @param dest a memory address. Blend 'src' here.
138
* @param src pointer to pixel map. Blend it to 'dest'.
139
* @param length number of pixels in 'src'
140
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
141
*/
142
void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
143
144
/**
145
* Fill a memory with a color (GPUs may support it)
146
* In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available)
147
* @param dest a memory address. Copy 'src' here.
148
* @param src pointer to pixel map. Copy it to 'dest'.
149
* @param length number of pixels in 'src'
150
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
151
*/
152
void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color);
153
/**
154
* Shows if memory blending (by GPU) is supported or not
155
* @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver
156
*/
157
bool lv_disp_is_mem_blend_supported(void);
158
159
/**
160
* Shows if memory fill (by GPU) is supported or not
161
* @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver
162
*/
163
bool lv_disp_is_mem_fill_supported(void);
164
#endif
165
/**********************
166
* MACROS
167
**********************/
168
169
#ifdef __cplusplus
170
} /* extern "C" */
171
#endif
172
173
#endif
174
175