-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.html
405 lines (403 loc) · 47.8 KB
/
index.html
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.3"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>C++ wrapper for LVGL: lvglpp: a C++ wrapper for LVGL</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(document).ready(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">C++ wrapper for LVGL
</div>
</td>
<td> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.svg"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.3 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(document).ready(function(){initNavTree('index.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div><div class="header">
<div class="headertitle"><div class="title">lvglpp: a C++ wrapper for LVGL </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p ><a class="anchor" id="md_README"></a> This package contains a rather bushy wrapper for <a href="https://github.com/lvgl/lvgl">LVGL</a>. I originally needed to program a simple user interface, but I didn't want to write a GUI framework from scratch, and found LVGL rather nice. Only that it's written in C. So I started writing C++ classes for the part of the code I wanted to use, and then it got out of control. Now most of the library has some kind of wrapper class provided. I've tested nearly all examples on an ESP32 with a touch screen interface. You can find a working application <a href="https://github.com/vpaeder/esp_obs_commander">here</a>.</p>
<p >This is a work in progress. I will likely improve things as I use it, which will take between one day and forever. I of course welcome contributions.</p>
<p >At the time of writing, I use LVGL version 8.3.1 (available <a href="https://github.com/lvgl/lvgl">here</a>). Your C++ compiler must support C++17 or newer.</p>
<p >Note that I'm not part of the LVGL team. If you have requests related to LVGL itself, please ask them.</p>
<h1><a class="anchor" id="autotoc_md1"></a>
TL;DR</h1>
<p >See examples <a href="examples/">here</a> and docs in the <em>doc</em> folder (you need to clone the repository for that).</p>
<h1><a class="anchor" id="autotoc_md2"></a>
Structure</h1>
<p >I tried to mirror the directory structure of LVGL to some degree (with exceptions with <em>extra</em> and <em>hal</em> directories). A number of types that are defined in multiple files are compiled together as one (e.g. style, image, draw). I've put all the widgets (including extra ones) in the <em>widgets</em> directory.</p>
<p >My point was to provide functions that take a certain LVGL object type as first argument as a class method. For instance, all functions taking a <code>lv_obj_t*</code> as first argument end up as methods of the <code>Object</code> class. I tried to replace raw pointer args either with a C++ class instance passed by reference or a smart pointer.</p>
<p >There is a template class in <em><a class="el" href="lv__wrapper_8h.html" title="Thin C++ wrapper template classes around LVGL objects.">lv_wrapper.h</a></em>, <code>PointerWrapper<lv_class, lv_deleter></code>, to facilitate encapsulation. It stores a <code>unique_ptr</code> of type <code>lv_class</code> with custom deleter function <code>lv_deleter</code>. A number of LVGL types have an associated deleter function, which can be provided there. For widgets, there's a template class called <code>Widget<lv_allocator></code> that provides a constructor to nest objects.</p>
<p >Here is a list of classes with the corresponding link to LVGL: </p><table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">Class </th><th class="markdownTableHeadNone">File </th><th class="markdownTableHeadNone">Wrapped type </th><th class="markdownTableHeadNone">LVGL file(s) </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Display</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="display_8h.html" title="Header file for C++ wrapper for LVGL display driver. This is a base class made to connect a screen dr...">core/display.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_disp_t</code><br />
<code>lv_disp_drv_t</code> </td><td class="markdownTableBodyNone"><em>hal/lv_hal_disp.h</em><br />
<em>core/lv_disp.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Event</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="event_8h.html" title="Header file for C++ wrapper for LVGL events.">core/event.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_event_t</code> </td><td class="markdownTableBodyNone"><em>core/lv_event.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Group</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="group_8h.html" title="Header file for C++ wrapper for LVGL groups.">core/group.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_group_t</code> </td><td class="markdownTableBodyNone"><em>core/lv_group.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>InputDevice</code><br />
<code>PointerInputDevice</code><br />
<code>ButtonInputDevice</code><br />
<code>KeypadInputDevice</code><br />
<code>EncoderInputDevice</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="indev_8h.html" title="Implementation file for C++ wrapper for lv_indev_t objects.">core/indev.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_indev_t</code><br />
<code>lv_indev_drv_t</code> </td><td class="markdownTableBodyNone"><em>hal/lv_hal_indev.h</em><br />
<em>core/lv_indev.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Object</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="object_8h.html" title="Header file for C++ wrapper for lv_obj_t objects.">core/object.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_obj_t</code> </td><td class="markdownTableBodyNone"><em>core/lv_obj.h</em><br />
<em>core/lv_obj_draw.h</em><br />
<em>core/lv_obj_pos.h</em><br />
<em>core/lv_scroll.h</em><br />
<em>core/lv_obj_style.h</em><br />
<em>core/lv_obj_style_gen.h</em><br />
<em>core/lv_obj_tree.h</em><br />
<em>extra/layouts/flex/lv_flex.h</em><br />
<em>extra/layouts/grid/lv_grid.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Theme</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="theme_8h.html" title="Header file for C++ wrapper for LVGL themes.">core/theme.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_theme_t</code> </td><td class="markdownTableBodyNone"><em>core/lv_theme.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>RectangleDrawDescriptor</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="desc_8h.html" title="Header file for C++ wrapper for LVGL draw descriptors.">draw/desc.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_rect_dsc_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_rect.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>LabelDrawDescriptor</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="desc_8h.html" title="Header file for C++ wrapper for LVGL draw descriptors.">draw/desc.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_label_dsc_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_label.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>ImageDrawDescriptor</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="desc_8h.html" title="Header file for C++ wrapper for LVGL draw descriptors.">draw/desc.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_img_dsc_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_img.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>LineDrawDescriptor</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="desc_8h.html" title="Header file for C++ wrapper for LVGL draw descriptors.">draw/desc.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_line_dsc_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_line.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>ArcDrawDescriptor</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="desc_8h.html" title="Header file for C++ wrapper for LVGL draw descriptors.">draw/desc.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_arc_dsc_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_arc.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>ImageDecoder</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="draw_2image_8h.html" title="Header file for C++ wrapper for low-level image-handling LVGL objects, such as lv_img_decoder_t,...">draw/image.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_img_decoder_dsc_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_img_decoder.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>ImageHeader</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="draw_2image_8h.html" title="Header file for C++ wrapper for low-level image-handling LVGL objects, such as lv_img_decoder_t,...">draw/image.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_img_header_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_img_buf.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>ImageDescriptor</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="draw_2image_8h.html" title="Header file for C++ wrapper for low-level image-handling LVGL objects, such as lv_img_decoder_t,...">draw/image.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_img_dsc_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_img_buf.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>LineMask</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="mask_8h.html" title="Header file for C++ wrapper for image masking routines.">draw/mask.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_mask_line_param_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_mask.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>AngleMask</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="mask_8h.html" title="Header file for C++ wrapper for image masking routines.">draw/mask.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_mask_angle_param_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_mask.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>RadiusMask</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="mask_8h.html" title="Header file for C++ wrapper for image masking routines.">draw/mask.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_mask_radius_param_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_mask.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>FadeMask</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="mask_8h.html" title="Header file for C++ wrapper for image masking routines.">draw/mask.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_mask_fade_param_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_mask.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>MapMask</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="mask_8h.html" title="Header file for C++ wrapper for image masking routines.">draw/mask.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_mask_map_param_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_mask.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>PolygonMask</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="mask_8h.html" title="Header file for C++ wrapper for image masking routines.">draw/mask.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_draw_mask_polygon_param_t</code> </td><td class="markdownTableBodyNone"><em>draw/lv_draw_mask.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Font</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="font_8h.html" title="Header file for C++ wrapper for lv_font_t objects.">font/font.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_font_t</code> </td><td class="markdownTableBodyNone"><em>font/lv_font.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Animation</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="anim_8h.html" title="Header file for C++ wrapper for lv_anim_t and lv_anim_timeline_t objects.">misc/anim.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_anim_t</code> </td><td class="markdownTableBodyNone"><em>misc/lv_anim.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>AnimationTimeline</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="anim_8h.html" title="Header file for C++ wrapper for lv_anim_t and lv_anim_timeline_t objects.">misc/anim.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_anim_timeline_t</code> </td><td class="markdownTableBodyNone"><em>misc/lv_anim_timeline.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Area</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="area_8h.html" title="Header file for C++ wrapper for lv_area_t objects.">misc/area.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_area_t</code> </td><td class="markdownTableBodyNone"><em>misc/lv_area.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>FileSystem</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="fs_8h.html" title="Header file for C++ wrapper for LVGL file system functions.">misc/fs.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_fs_t</code> </td><td class="markdownTableBodyNone"><em>misc/lv_fs.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>File</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="fs_8h.html" title="Header file for C++ wrapper for LVGL file system functions.">misc/fs.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_fs_file_t</code> </td><td class="markdownTableBodyNone"><em>misc/lv_fs.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Directory</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="fs_8h.html" title="Header file for C++ wrapper for LVGL file system functions.">misc/fs.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_fs_dir_t</code> </td><td class="markdownTableBodyNone"><em>misc/lv_fs.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Style</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="style_8h.html" title="Header file for C++ wrapper for lv_style_t objects.">misc/style.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_style_t</code> </td><td class="markdownTableBodyNone"><em>misc/lv_style.h</em><br />
<em>misc/lv_style_gen.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Timer</code> </td><td class="markdownTableBodyNone"><em><a class="el" href="timer_8h.html" title="Header file for C++ wrapper for LVGL timer functions.">misc/timer.h</a></em> </td><td class="markdownTableBodyNone"><code>lv_timer_t</code> </td><td class="markdownTableBodyNone"><em>misc/lv_timer.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>AnimatedImage</code> </td><td class="markdownTableBodyNone"><em>widgets/animimg.h</em> </td><td class="markdownTableBodyNone"><code>lv_animimg_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/animimg/lv_animimg.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Arc</code> </td><td class="markdownTableBodyNone"><em>widgets/arc.h</em> </td><td class="markdownTableBodyNone"><code>lv_arc_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_arc.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Bar</code> </td><td class="markdownTableBodyNone"><em>widgets/bar.h</em> </td><td class="markdownTableBodyNone"><code>lv_bar_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_bar.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>ButtonMatrix</code> </td><td class="markdownTableBodyNone"><em>widgets/btnmatrix.h</em> </td><td class="markdownTableBodyNone"><code>lv_btnmatrix_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_btnmatrix.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Button</code> </td><td class="markdownTableBodyNone"><em>widgets/button.h</em> </td><td class="markdownTableBodyNone"><code>lv_btn_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_btn.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Calendar</code> </td><td class="markdownTableBodyNone"><em>widgets/calendar.h</em> </td><td class="markdownTableBodyNone"><code>lv_calendar_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/calendar/lv_calendar.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Canvas</code> </td><td class="markdownTableBodyNone"><em>widgets/canvas.h</em> </td><td class="markdownTableBodyNone"><code>lv_canvas_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_canvas.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Chart</code> </td><td class="markdownTableBodyNone"><em>widgets/chart.h</em> </td><td class="markdownTableBodyNone"><code>lv_chart_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/chart/lv_chart.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Checkbox</code> </td><td class="markdownTableBodyNone"><em>widgets/checkbox.h</em> </td><td class="markdownTableBodyNone"><code>lv_checkbox_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_checkbox.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>ColorWheel</code> </td><td class="markdownTableBodyNone"><em>widgets/colorwheel.h</em> </td><td class="markdownTableBodyNone"><code>lv_colorwheel_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/colorwheel/lv_colorwheel.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Dropdown</code> </td><td class="markdownTableBodyNone"><em>widgets/dropdown.h</em> </td><td class="markdownTableBodyNone"><code>lv_dropdown_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_dropdown.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Image</code> </td><td class="markdownTableBodyNone"><em>widgets/image.h</em> </td><td class="markdownTableBodyNone"><code>lv_image_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_img.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>ImageButton</code> </td><td class="markdownTableBodyNone"><em>widgets/imgbtn.h</em> </td><td class="markdownTableBodyNone"><code>lv_imgbtn_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/imgbtn/lv_imgbtn.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Keyboard</code> </td><td class="markdownTableBodyNone"><em>widgets/keyboard.h</em> </td><td class="markdownTableBodyNone"><code>lv_keyboard_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/keyboard/lv_keyboard.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Label</code> </td><td class="markdownTableBodyNone"><em>widgets/label.h</em> </td><td class="markdownTableBodyNone"><code>lv_label_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_label.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Led</code> </td><td class="markdownTableBodyNone"><em>widgets/led.h</em> </td><td class="markdownTableBodyNone"><code>lv_led_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/led/lv_led.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Line</code> </td><td class="markdownTableBodyNone"><em>widgets/line.h</em> </td><td class="markdownTableBodyNone"><code>lv_line_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_line.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>List</code> </td><td class="markdownTableBodyNone"><em>widgets/list.h</em> </td><td class="markdownTableBodyNone"><code>lv_list_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/list/lv_list.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Menu</code> </td><td class="markdownTableBodyNone"><em>widgets/menu.h</em> </td><td class="markdownTableBodyNone"><code>lv_menu_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/menu/lv_menu.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Meter</code> </td><td class="markdownTableBodyNone"><em>widgets/meter.h</em> </td><td class="markdownTableBodyNone"><code>lv_meter_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/meter/lv_meter.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>MessageBox</code> </td><td class="markdownTableBodyNone"><em>widgets/msgbox.h</em> </td><td class="markdownTableBodyNone"><code>lv_msgbox_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/msgbox/lv_msgbox.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Roller</code> </td><td class="markdownTableBodyNone"><em>widgets/roller.h</em> </td><td class="markdownTableBodyNone"><code>lv_roller_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_roller.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Slider</code> </td><td class="markdownTableBodyNone"><em>widgets/slider.h</em> </td><td class="markdownTableBodyNone"><code>lv_slider_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_slider.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Span</code> </td><td class="markdownTableBodyNone"><em>widgets/span.h</em> </td><td class="markdownTableBodyNone"><code>lv_span_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/span/lv_span.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Spinbox</code> </td><td class="markdownTableBodyNone"><em>widgets/spinbox.h</em> </td><td class="markdownTableBodyNone"><code>lv_spinbox_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/spinbox/lv_spinbox.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Spinner</code> </td><td class="markdownTableBodyNone"><em>widgets/spinner.h</em> </td><td class="markdownTableBodyNone"><code>lv_spinner_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/spinner/lv_spinner.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Switch</code> </td><td class="markdownTableBodyNone"><em>widgets/switch.h</em> </td><td class="markdownTableBodyNone"><code>lv_switch_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_switch.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Table</code> </td><td class="markdownTableBodyNone"><em>widgets/table.h</em> </td><td class="markdownTableBodyNone"><code>lv_table_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_table.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>Tabview</code> </td><td class="markdownTableBodyNone"><em>widgets/tabview.h</em> </td><td class="markdownTableBodyNone"><code>lv_tabview_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/tabview/lv_tabview.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>TextArea</code> </td><td class="markdownTableBodyNone"><em>widgets/textarea.h</em> </td><td class="markdownTableBodyNone"><code>lv_textarea_t</code> </td><td class="markdownTableBodyNone"><em>widgets/lv_textarea.h</em> </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>TileView</code> </td><td class="markdownTableBodyNone"><em>widgets/tileview.h</em> </td><td class="markdownTableBodyNone"><code>lv_tileview_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/tileview/lv_tileview.h</em> </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>Window</code> </td><td class="markdownTableBodyNone"><em>widgets/win.h</em> </td><td class="markdownTableBodyNone"><code>lv_win_t</code> </td><td class="markdownTableBodyNone"><em>extra/widgets/win/lv_win.h</em> </td></tr>
</table>
<p >I've included some useful functions that don't take a specific LVGL type as argument in namespaces. These are: </p><table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">Namespace </th><th class="markdownTableHeadNone">Content </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code><a class="el" href="namespacelvgl_1_1core_1_1obj.html" title="General functions involving objects.">lvgl::core::obj</a></code> </td><td class="markdownTableBodyNone">For now, contains the function <code>draw_part_check_type</code>, that allows checking the type of a drawable part. I may move other functions related to objects there in the future. </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code><a class="el" href="namespacelvgl_1_1draw_1_1mask.html" title="Contains general mask functions.">lvgl::draw::mask</a></code> </td><td class="markdownTableBodyNone">This contains functions about masks. </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code><a class="el" href="namespacelvgl_1_1misc_1_1color.html" title="Contains LVGL color functions.">lvgl::misc::color</a></code> </td><td class="markdownTableBodyNone">Since <code>lv_color_t</code> is a <code>uint32_t</code> with some coating, I found inefficient to build a class around it. Therefore, you'll find color functions in there. </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code><a class="el" href="namespacelvgl_1_1misc_1_1palette.html" title="Contains palette accessors.">lvgl::misc::palette</a></code> </td><td class="markdownTableBodyNone">Access to the three standard palettes is found here in a C++ way. </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code><a class="el" href="namespacelvgl_1_1misc_1_1txt.html" title="LVGL text functions.">lvgl::misc::txt</a></code> </td><td class="markdownTableBodyNone">This contains some of the text functions found in <code>lv_txt.h</code>. </td></tr>
</table>
<h1><a class="anchor" id="autotoc_md3"></a>
How to use</h1>
<p >First of all, you need LVGL in the include paths. As for lvglpp, unlike with LVGL, you need to include each header that corresponds to what you want to use. To illustrate what I mean, a typical program would be: </p><div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="lvglpp_8h.html">lvglpp/lvglpp.h</a>"</span> <span class="comment">// for init</span></div>
<div class="line"><span class="preprocessor">#include "<a class="code" href="display_8h.html">lvglpp/core/display.h</a>"</span> <span class="comment">// for Display</span></div>
<div class="line"><span class="preprocessor">#include "<a class="code" href="indev_8h.html">lvglpp/core/indev.h</a>"</span> <span class="comment">// for InputDevice</span></div>
<div class="line"><span class="preprocessor">#include "lvglpp/widgets/button.h"</span> <span class="comment">// for Button</span></div>
<div class="line"><span class="comment">// ... add includes for widgets your want to use here</span></div>
<div class="line"><span class="preprocessor">#include "<a class="code" href="style_8h.html">lvglpp/misc/style.h</a>"</span> <span class="comment">// for Style</span></div>
<div class="line"><span class="comment">// .. add includes for other classes you want to use (Animation, Timer, ...)</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using namespace </span>lvgl::core;</div>
<div class="line"><span class="keyword">using namespace </span><a class="code hl_namespace" href="namespacelvgl_1_1misc.html">lvgl::misc</a>;</div>
<div class="line"><span class="keyword">using namespace </span>lvgl::widgets;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> <a class="code hl_function" href="namespacelvgl_1_1misc_1_1palette.html#a53a968204c2b1dc74e4a443b8fe46850">main</a>() {</div>
<div class="line"> <span class="comment">// initialize LVGL</span></div>
<div class="line"> <a class="code hl_function" href="namespacelvgl.html#a15f3580a898142dd337d0ea6ecf65af7">lvgl::init</a>();</div>
<div class="line"> <span class="comment">// place here display and input device initialization;</span></div>
<div class="line"> <span class="comment">// read examples in examples/lvglpp directory to see how.</span></div>
<div class="line"> </div>
<div class="line"> <span class="comment">// create button on active display</span></div>
<div class="line"> <span class="keyword">auto</span> btn = Button(scr_act());</div>
<div class="line"> btn.center();</div>
<div class="line"> <span class="comment">// ... initialize more things ...</span></div>
<div class="line"> </div>
<div class="line"> <span class="comment">// main loop</span></div>
<div class="line"> <span class="keywordflow">for</span> (;;) {</div>
<div class="line"> <span class="comment">// I didn't implement ticks yet -> use base LVGL ones;</span></div>
<div class="line"> <span class="comment">// you need to call both of these to get LVGL to work, but</span></div>
<div class="line"> <span class="comment">// you should put them in two different threads, with lv_tick_inc</span></div>
<div class="line"> <span class="comment">// in a higher priority thread.</span></div>
<div class="line"> lv_tick_inc(10);</div>
<div class="line"> lv_task_handler();</div>
<div class="line"> <span class="comment">// add here a function to wait for 10ms</span></div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="ttc" id="adisplay_8h_html"><div class="ttname"><a href="display_8h.html">display.h</a></div><div class="ttdoc">Header file for C++ wrapper for LVGL display driver. This is a base class made to connect a screen dr...</div></div>
<div class="ttc" id="aindev_8h_html"><div class="ttname"><a href="indev_8h.html">indev.h</a></div><div class="ttdoc">Implementation file for C++ wrapper for lv_indev_t objects.</div></div>
<div class="ttc" id="alvglpp_8h_html"><div class="ttname"><a href="lvglpp_8h.html">lvglpp.h</a></div><div class="ttdoc">Base header for LVGL C++ wrapper.</div></div>
<div class="ttc" id="anamespacelvgl_1_1misc_1_1palette_html_a53a968204c2b1dc74e4a443b8fe46850"><div class="ttname"><a href="namespacelvgl_1_1misc_1_1palette.html#a53a968204c2b1dc74e4a443b8fe46850">lvgl::misc::palette::main</a></div><div class="ttdeci">lv_color_t main(Color p)</div><div class="ttdoc">Retrieves color from main palette.</div><div class="ttdef"><b>Definition:</b> color.cpp:74</div></div>
<div class="ttc" id="anamespacelvgl_1_1misc_html"><div class="ttname"><a href="namespacelvgl_1_1misc.html">lvgl::misc</a></div><div class="ttdoc">LVGL miscellaneous components.</div><div class="ttdef"><b>Definition:</b> object.h:10</div></div>
<div class="ttc" id="anamespacelvgl_html_a15f3580a898142dd337d0ea6ecf65af7"><div class="ttname"><a href="namespacelvgl.html#a15f3580a898142dd337d0ea6ecf65af7">lvgl::init</a></div><div class="ttdeci">void init()</div><div class="ttdoc">Initializes LVGL.</div><div class="ttdef"><b>Definition:</b> lvglpp.h:18</div></div>
<div class="ttc" id="astyle_8h_html"><div class="ttname"><a href="style_8h.html">style.h</a></div><div class="ttdoc">Header file for C++ wrapper for lv_style_t objects.</div></div>
</div><!-- fragment --><h2>Displays, input devices, filesystems</h2>
<p >I've included some basic examples in <em>examples/lvglpp</em>. Since I only tested my code with a rather basic display, I didn't write classes that make uses of callbacks for monochrome or special displays. However, it's possible to do it yourself in a simple way: </p><div class="fragment"><div class="line"><span class="keyword">class </span>CustomDisplay : <span class="keyword">public</span> Display {</div>
<div class="line"><span class="keyword">private</span>:</div>
<div class="line"> <span class="comment">// arguments should be the arguments of the callback without the 1st one (lv_disp_drv_t* drv)</span></div>
<div class="line"> <span class="keywordtype">void</span> callback_to_implement(arguments) {</div>
<div class="line"> <span class="comment">// Put here what your callback does.</span></div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line"> CustomDisplay(lv_coord_t hor_res, lv_coord_t ver_res, uint32_t fb_size)</div>
<div class="line"> : Display(hor_res, ver_res, fb_size) {</div>
<div class="line"> <span class="comment">// you need to link the callback with the display driver here</span></div>
<div class="line"> <span class="keyword">auto</span> cb = [](lv_disp_drv_t* drv, other arguments) {</div>
<div class="line"> <span class="keyword">auto</span> obj = <span class="keyword">reinterpret_cast<</span>CustomDisplay*<span class="keyword">></span>(drv->user_data);</div>
<div class="line"> obj->callback_to_implement(other arguments);</div>
<div class="line"> };</div>
<div class="line"> this->lv_disp_drv.callback_to_implement = cb;</div>
<div class="line"> this->update_driver();</div>
<div class="line"> }</div>
<div class="line">};</div>
</div><!-- fragment --><p >For input devices, I included specialized classes for each type of input device available. I didn't implement the <code>feedback_cb</code> callback though. If you need it, you can write a derived class following the same scheme as for displays.</p>
<p >There's also a commented example for a custom filesystem driver. It'd be possible to port the available drivers to C++ using this template. Note that this only makes sense if you need to access files directly (for images, you can just as well register a C driver that will be used under the hood).</p>
<h1><a class="anchor" id="autotoc_md4"></a>
Accessing managed object</h1>
<p >Through the <code>PointerWrapper</code> class, I provide several ways to access the managed LVGL object:</p><ul>
<li><code>raw()</code> returns a reference to the object;</li>
<li><code>raw_ptr()</code> returns a pointer to the object;</li>
<li>the dereference operator <code>*</code> (e.g. *obj) returns a reference to the object (equivalent to <code>raw()</code>);</li>
<li>the pointer-to-member operator <code>-></code> gives access to the object's structure (e.g. obj->coords for a wrapped <code>lv_obj_t*</code> will yield <code>coords</code> field of type <code>lv_area_t</code>).</li>
</ul>
<h1><a class="anchor" id="autotoc_md5"></a>
A note on callbacks and child objects</h1>
<p >A number of classes (e.g. objects, timers, animations) use callbacks for different purposes. To make them look C++-like, I used the <code>user_data</code> field, which (almost) every LVGL structure provides, to give access to the C++ callback (by storing a pointer to the class object containing the callback function, or a pointer to a structure containing the callback functions, or a pointer to the callback function itself). This avoids storing C++ objects in some kind of global storage, but comes with two limitations: 1) we cannot use the <code>user_data</code> field for anything else; 2) we need to re-instantiate a C++ object to feed the callback with, everytime the callback is called. In most cases, the additional complexity won't matter. Nonetheless, where speed matters, it's always possible to use raw C callbacks instead.</p>
<p >Another caveat comes with child objects. Several widgets, especially, provide functions to create elements. For instance, the <code>Tabview</code> class has a function <code>add_tab</code> that returns an <code>Object</code> giving access to the created tab. The <code>Tabview</code> instance manages the new tab and deletes it when it gets deleted. Therefore, it's important not to delete it otherwise. Since <code>Object</code> instances wrap a raw C pointer in a <code>unique_ptr</code>, this would happen if the tab object gets out of scope. Therefore, I introduced a property, <code>owns_ptr</code>, that can be set on construction, and tells if the object owns the wrapped pointer. If it doesn't, the pointer gets released in the object's destructor. One can also force releasing the wrapped pointer with <code>release_ptr</code>. This can be useful when defining complex objects with lots of children that won't need to be accessed after creation. This way, the C++ object can be deleted without affecting the element it has created, freeing memory. You'll find several examples that make use of this.</p>
<h1><a class="anchor" id="autotoc_md6"></a>
Caveats</h1>
<p >Because of the way wrappers are implemented, it is important to remember to store the elements that are displayed. If any instance of a C++ object gets out of scope, the wrapped element gets deleted too (unless you use <code>release_ptr</code> or it's a child element generated by a widget).</p>
<p >LVGL stores the relationship of objects and takes care of deleting children of objects getting deleted. This means that you can safely use <code>release_ptr</code> on sub-widgets. Conversely, nothing is stored about instances of other types, like styles, animations, timers, ... Therefore, you <b>must not</b> <code>release_ptr</code> one of those, of you won't have any possibility to free it up afterwards. For those, you should either provide some kind of storage (<code>std::vector</code>, class member variable, ...) or make them static.</p>
<p >The equivalent of <code>lv_obj_create</code> is the <code>Container</code> class, and not the <code>Object</code> class, which stores a <code>lv_obj_t</code> but doesn't initialize one. The distinction is made as I wanted to avoid this: <code>Object(Object & parent)</code>. This would be seen as the copy constructor by the compiler, which is unwise for a class as general as <code>Object</code>.</p>
<p >For C++-style callbacks, it is important to remember that any object obtained from within the callback by calling an accessor function (such as <code>Event::get_target</code>) creates a temporary object wrapping a raw pointer. This means that you cannot create derived classes that would carry data along. Every call to the callback gets fed with a newly created temporary object with, other than the raw pointer, default values. Moreover, you cannot pass data using the <code>user_data</code> field, as it is used internally to pass the C++-style callback. For such cases, you need to define a global variable to transfer data to or from the callback.</p>
<p >Just like LVGL, lvglpp is NOT thread-safe. Therefore, as for LVGL, it is necessary to prevent concurrent execution of <code>lv_task_handler()</code> and other functions (with the exception of callbacks called from within task handler, like events or timers). This is typically done with a mutex, like: </p><div class="fragment"><div class="line"><span class="preprocessor">#include <mutex></span></div>
<div class="line"><span class="preprocessor">#include <thread></span></div>
<div class="line">std::mutex mtx;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> task_handler_thread() {</div>
<div class="line"> <span class="keywordflow">for</span> (;;) {</div>
<div class="line"> {</div>
<div class="line"> <span class="keyword">const</span> std::lock_guard<std::mutex> lock(mtx);</div>
<div class="line"> lv_task_handler();</div>
<div class="line"> }</div>
<div class="line"> std::this_thread::sleep_for(std::chrono::milliseconds(10));</div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> another_thread() {</div>
<div class="line"> <span class="keywordflow">for</span> (;;) {</div>
<div class="line"> mtx.lock();</div>
<div class="line"> <span class="comment">// place code calling LVGL functions here</span></div>
<div class="line"> mtx.unlock();</div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment --><p> Be aware that objects that get deleted because they go out of scope must also be treated. The easiest way, if possible, is to create a <code>lock_guard</code> in the beginning of the scope. If you cannot do that, I suggest using the following method: </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> a_function(<span class="keyword">const</span> Object & parent) {</div>
<div class="line"> mtx.lock();</div>
<div class="line"> <span class="keyword">auto</span> cnt = std::make_unique<Container>(parent);</div>
<div class="line"> cnt->remove_style_all();</div>
<div class="line"> cnt->set_size(parent.get_width(), parent.get_height());</div>
<div class="line"> <span class="comment">// ... code that creates objects ...</span></div>
<div class="line"> <span class="keyword">auto</span> obj = AnyObjectType(*cnt);</div>
<div class="line"> <span class="comment">// ... </span></div>
<div class="line"> mtx.unlock();</div>
<div class="line"> <span class="comment">// a bit of safe code ...</span></div>
<div class="line"> <span class="comment">// ... time to terminate function</span></div>
<div class="line"> <span class="comment">// we remove cnt and its content in a safe way</span></div>
<div class="line"> mtx.lock();</div>
<div class="line"> cnt = <span class="keyword">nullptr</span>;</div>
<div class="line"> mtx.unlock();</div>
<div class="line">}</div>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md7"></a>
Footprint</h1>
<p >As lvglpp is essentially a layer over LVGL, it of course increases the memory footprint. However, most wrapper classes have only two member variables: a pointer to the wrapped object and a bool. This makes an overhead of 12 bytes per wrapped object. Several items need to store more content (e.g. Animation and ButtonMatrix) and will therefore need a little more space. Naturally, the binary size will also increase depending on the number of functions that are in use. I'll try to quantify these values at some point. If you're hunting for free bytes, I'd rather recommend to use the original library instead.</p>
<h1><a class="anchor" id="autotoc_md8"></a>
API documentation</h1>
<p >There is a documentation generated from docstrings in the <em>doc</em> folder. See <a href="doc/html/index.html">here</a>. You can re-generate the doc using doxygen in the project folder.</p>
<h1><a class="anchor" id="autotoc_md9"></a>
Examples</h1>
<p >I adapted most of the examples provided with LVGL. You'll find them in the <em>examples</em> folder <a href="examples/">here</a>. For examples that involve images, you need to include the appropriate files from LVGL examples. Don't forget to initialize LVGL and define a screen and an input device. </p>
</div></div><!-- PageDoc -->
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
</ul>
</div>
</body>
</html>