Firmware SDK
twr_gfx.h
1 #ifndef _TWR_GFX_H
2 #define _TWR_GFX_H
3 
4 #include <twr_common.h>
5 #include <twr_font_common.h>
6 
10 
12 
13 typedef struct
14 {
15  int width;
16  int height;
17 
19 
21 
22 typedef struct
23 {
25  bool (*is_ready)(void *self);
26 
28  void (*clear)(void *self);
29 
31  void (*draw_pixel)(void *self, int left, int top, uint32_t color);
32 
34  uint32_t (*get_pixel)(void *self, int left, int top);
35 
37  bool (*update)(void *self);
38 
40  twr_gfx_caps_t (*get_caps)(void *self);
41 
43 
45 
46 typedef enum
47 {
50 
53 
56 
59 
61 
62 typedef enum
63 {
66 
69 
72 
75 
77 
79 
80 typedef struct
81 {
82  void *_display;
83  const twr_gfx_driver_t *_driver;
84  twr_gfx_rotation_t _rotation;
85  const twr_font_t *_font;
86  twr_gfx_caps_t _caps;
87 
88 } twr_gfx_t;
89 
92 
93 void twr_gfx_init(twr_gfx_t *self, void *display, const twr_gfx_driver_t *driver);
94 
99 
101 
104 
106 
109 
110 void twr_gfx_clear(twr_gfx_t *self);
111 
115 
116 void twr_gfx_set_font(twr_gfx_t *self, const twr_font_t *font);
117 
121 
123 
127 
129 
135 
136 void twr_gfx_draw_pixel(twr_gfx_t *self, int x, int y, uint32_t color);
137 
145 
146 int twr_gfx_draw_char(twr_gfx_t *self, int left, int top, uint8_t ch, uint32_t color);
147 
151 
152 int twr_gfx_calc_char_width(twr_gfx_t *self, uint8_t ch);
153 
161 
162 int twr_gfx_draw_string(twr_gfx_t *self, int left, int top, char *str, uint32_t color);
163 
168 
169 int twr_gfx_calc_string_width(twr_gfx_t *self, char *str);
170 
179 
180 int twr_gfx_printf(twr_gfx_t *self, int left, int top, uint32_t color, char *format, ...);
181 
189 
190 void twr_gfx_draw_line(twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color);
191 
199 
200 void twr_gfx_draw_rectangle(twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color);
201 
209 
210 void twr_gfx_draw_fill_rectangle(twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color);
211 
219 
220 void twr_gfx_draw_fill_rectangle_dithering(twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color);
221 
231 void twr_gfx_draw_fill_rectangle_dithering_color(twr_gfx_t *self, int x0, int y0, int x1, int y1, uint16_t pattern, uint32_t color_fg, uint32_t color_bg);
232 
239 
240 void twr_gfx_draw_circle(twr_gfx_t *self, int x0, int y0, int radius, uint32_t color);
241 
248 
249 void twr_gfx_draw_fill_circle(twr_gfx_t *self, int x0, int y0, int radius, uint32_t color);
250 
258 
259 void twr_gfx_draw_round_corner(twr_gfx_t *self, int x0, int y0, int radius, twr_gfx_round_corner_t corner, uint32_t color);
260 
268 
269 void twr_gfx_draw_fill_round_corner(twr_gfx_t *self, int x0, int y0, int radius, twr_gfx_round_corner_t corner, uint32_t color);
270 
275 
276 bool twr_gfx_update(twr_gfx_t *self);
277 
279 
280 #endif // _TWR_GFX_H
void twr_gfx_draw_fill_round_corner(twr_gfx_t *self, int x0, int y0, int radius, twr_gfx_round_corner_t corner, uint32_t color)
Lcd draw fill round corner, using Midpoint circle algorithm.
Definition: twr_gfx.c:442
void twr_gfx_draw_rectangle(twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color)
Display draw rectangle.
Definition: twr_gfx.c:278
void twr_gfx_draw_fill_rectangle(twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color)
Display draw fill rectangle.
Definition: twr_gfx.c:286
void twr_gfx_draw_round_corner(twr_gfx_t *self, int x0, int y0, int radius, twr_gfx_round_corner_t corner, uint32_t color)
Lcd draw round corner, using Midpoint circle algorithm.
Definition: twr_gfx.c:393
void twr_gfx_draw_line(twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color)
Display draw line.
Definition: twr_gfx.c:188
void twr_gfx_set_font(twr_gfx_t *self, const twr_font_t *font)
Set font.
Definition: twr_gfx.c:27
twr_gfx_caps_t twr_gfx_get_caps(twr_gfx_t *self)
Get Display capabilities.
Definition: twr_gfx.c:17
void twr_gfx_set_rotation(twr_gfx_t *self, twr_gfx_rotation_t rotation)
Set rotation.
Definition: twr_gfx.c:32
int twr_gfx_draw_char(twr_gfx_t *self, int left, int top, uint8_t ch, uint32_t color)
Display draw char.
Definition: twr_gfx.c:86
void twr_gfx_init(twr_gfx_t *self, void *display, const twr_gfx_driver_t *driver)
Initialize button.
Definition: twr_gfx.c:3
twr_gfx_rotation_t twr_gfx_get_rotation(twr_gfx_t *self)
Get rotation.
Definition: twr_gfx.c:37
bool twr_gfx_display_is_ready(twr_gfx_t *self)
Check if display driver is ready for commands.
Definition: twr_gfx.c:12
int twr_gfx_calc_string_width(twr_gfx_t *self, char *str)
Calc width string.
Definition: twr_gfx.c:162
void twr_gfx_draw_fill_rectangle_dithering_color(twr_gfx_t *self, int x0, int y0, int x1, int y1, uint16_t pattern, uint32_t color_fg, uint32_t color_bg)
Display draw fill rectangle with a dithering pattern defined in the pattern parameter,...
Definition: twr_gfx.c:313
void twr_gfx_draw_fill_rectangle_dithering(twr_gfx_t *self, int x0, int y0, int x1, int y1, uint32_t color)
Display draw fill rectangle with a dithering pattern defined in the color parameter.
Definition: twr_gfx.c:298
void twr_gfx_draw_circle(twr_gfx_t *self, int x0, int y0, int radius, uint32_t color)
Lcd draw circle, using Midpoint circle algorithm.
Definition: twr_gfx.c:328
twr_gfx_rotation_t
Rotation.
Definition: twr_gfx.h:47
void twr_gfx_draw_pixel(twr_gfx_t *self, int x, int y, uint32_t color)
Draw pixel.
Definition: twr_gfx.c:42
void twr_gfx_clear(twr_gfx_t *self)
Clear.
Definition: twr_gfx.c:22
twr_gfx_round_corner_t
Definition: twr_gfx.h:63
int twr_gfx_draw_string(twr_gfx_t *self, int left, int top, char *str, uint32_t color)
Display draw string.
Definition: twr_gfx.c:152
void twr_gfx_draw_fill_circle(twr_gfx_t *self, int x0, int y0, int radius, uint32_t color)
Lcd draw fill circle, using Midpoint circle algorithm.
Definition: twr_gfx.c:363
int twr_gfx_printf(twr_gfx_t *self, int left, int top, uint32_t color, char *format,...)
Display string.
Definition: twr_gfx.c:173
bool twr_gfx_update(twr_gfx_t *self)
Display update, send data.
Definition: twr_gfx.c:491
int twr_gfx_calc_char_width(twr_gfx_t *self, uint8_t ch)
Calc width character.
Definition: twr_gfx.c:132
@ TWR_GFX_ROTATION_270
Rotation 270 degrees.
Definition: twr_gfx.h:58
@ TWR_GFX_ROTATION_180
Rotation 180 degrees.
Definition: twr_gfx.h:55
@ TWR_GFX_ROTATION_90
Rotation 90 degrees.
Definition: twr_gfx.h:52
@ TWR_GFX_ROTATION_0
Rotation 0 degrees.
Definition: twr_gfx.h:49
@ TWR_GFX_ROUND_CORNER_RIGHT_TOP
Round corner right top.
Definition: twr_gfx.h:65
@ TWR_GFX_ROUND_CORNER_LEFT_TOP
Round corner left top.
Definition: twr_gfx.h:74
@ TWR_GFX_ROUND_CORNER_RIGHT_BOTTOM
Round corner right bottom.
Definition: twr_gfx.h:68
@ TWR_GFX_ROUND_CORNER_LEFT_BOTTOM
Round corner left bottom.
Definition: twr_gfx.h:71
Display size.
Definition: twr_gfx.h:14
Display driver interface.
Definition: twr_gfx.h:23
Instance.
Definition: twr_gfx.h:81