forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfb.h
182 lines (160 loc) · 4.25 KB
/
cfb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
* Copyright (c) 2018 PHYTEC Messtechnik GmbH
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief Public Monochrome Character Framebuffer API
*/
#ifndef __CFB_H__
#define __CFB_H__
#include <device.h>
#include <drivers/display.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Display Drivers
* @addtogroup display_interfaces Display Drivers
* @{
* @}
*/
/**
* @brief Public Monochrome Character Framebuffer API
* @defgroup monochrome_character_framebuffer Monochrome Character Framebuffer
* @ingroup display_interfaces
* @{
*/
enum cfb_display_param {
CFB_DISPLAY_HEIGH = 0,
CFB_DISPLAY_WIDTH,
CFB_DISPLAY_PPT,
CFB_DISPLAY_ROWS,
CFB_DISPLAY_COLS,
};
enum cfb_font_caps {
CFB_FONT_MONO_VPACKED = BIT(0),
CFB_FONT_MONO_HPACKED = BIT(1),
CFB_FONT_MSB_FIRST = BIT(2),
};
struct cfb_font {
const void *data;
enum cfb_font_caps caps;
uint8_t width;
uint8_t height;
uint8_t first_char;
uint8_t last_char;
};
/**
* @brief Macro for creating a font entry.
*
* @param _name Name of the font entry.
* @param _width Width of the font in pixels
* @param _height Height of the font in pixels.
* @param _caps Font capabilities.
* @param _data Raw data of the font.
* @param _fc Character mapped to first font element.
* @param _lc Character mapped to last font element.
*/
#define FONT_ENTRY_DEFINE(_name, _width, _height, _caps, _data, _fc, _lc) \
static const Z_STRUCT_SECTION_ITERABLE(cfb_font, _name) = \
{ \
.data = _data, \
.caps = _caps, \
.width = _width, \
.height = _height, \
.first_char = _fc, \
.last_char = _lc, \
}
/**
* @brief Print a string into the framebuffer.
*
* @param dev Pointer to device structure for driver instance
* @param str String to print
* @param x Position in X direction of the beginning of the string
* @param y Position in Y direction of the beginning of the string
*
* @return 0 on success, negative value otherwise
*/
int cfb_print(const struct device *dev, char *str, uint16_t x, uint16_t y);
/**
* @brief Clear framebuffer.
*
* @param dev Pointer to device structure for driver instance
* @param clear_display Clear the display as well
*
* @return 0 on success, negative value otherwise
*/
int cfb_framebuffer_clear(const struct device *dev, bool clear_display);
/**
* @brief Invert Pixels.
*
* @param dev Pointer to device structure for driver instance
*
* @return 0 on success, negative value otherwise
*/
int cfb_framebuffer_invert(const struct device *dev);
/**
* @brief Finalize framebuffer and write it to display RAM,
* invert or reorder pixels if necessary.
*
* @param dev Pointer to device structure for driver instance
*
* @return 0 on success, negative value otherwise
*/
int cfb_framebuffer_finalize(const struct device *dev);
/**
* @brief Get display parameter.
*
* @param dev Pointer to device structure for driver instance
* @param cfb_display_param One of the display parameters
*
* @return Display parameter value
*/
int cfb_get_display_parameter(const struct device *dev,
enum cfb_display_param);
/**
* @brief Set font.
*
* @param dev Pointer to device structure for driver instance
* @param idx Font index
*
* @return 0 on success, negative value otherwise
*/
int cfb_framebuffer_set_font(const struct device *dev, uint8_t idx);
/**
* @brief Get font size.
*
* @param dev Pointer to device structure for driver instance
* @param idx Font index
* @param width Pointers to the variable where the font width will be stored.
* @param height Pointers to the variable where the font height will be stored.
*
* @return 0 on success, negative value otherwise
*/
int cfb_get_font_size(const struct device *dev, uint8_t idx, uint8_t *width,
uint8_t *height);
/**
* @brief Get number of fonts.
*
* @param dev Pointer to device structure for driver instance
*
* @return number of fonts
*/
int cfb_get_numof_fonts(const struct device *dev);
/**
* @brief Initialize Character Framebuffer.
*
* @param dev Pointer to device structure for driver instance
*
* @return 0 on success, negative value otherwise
*/
int cfb_framebuffer_init(const struct device *dev);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* __CFB_H__ */