-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLVGL.Simulator.cpp
More file actions
373 lines (311 loc) · 9.08 KB
/
LVGL.Simulator.cpp
File metadata and controls
373 lines (311 loc) · 9.08 KB
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
/*
* PROJECT: LVGL PC Simulator using Visual Studio
* FILE: LVGL.Simulator.cpp
* PURPOSE: Implementation for LVGL ported to Windows Desktop
*
* LICENSE: The MIT License
*
* DEVELOPER: Mouri_Naruto (Mouri_Naruto AT Outlook.com)
*/
#include <Windows.h>
#include "resource.h"
#if _MSC_VER >= 1200
// Disable compilation warnings.
#pragma warning(push)
// nonstandard extension used : bit field types other than int
#pragma warning(disable:4214)
// 'conversion' conversion from 'type1' to 'type2', possible loss of data
#pragma warning(disable:4244)
#endif
#include "lvgl/lvgl.h"
#include "lvgl/examples/lv_examples.h"
#include "lv_demos/lv_demo.h"
#include "lv_drivers/win32drv/win32drv.h"
#include "lv_lib_freetype/lv_freetype.h"
#if _MSC_VER >= 1200
// Restore compilation warnings.
#pragma warning(pop)
#endif
lv_fs_res_t lv_win32_filesystem_driver_error_from_win32(
DWORD Error)
{
lv_fs_res_t res;
switch (Error)
{
case ERROR_SUCCESS:
res = LV_FS_RES_OK;
break;
case ERROR_BAD_UNIT:
case ERROR_NOT_READY:
case ERROR_CRC:
case ERROR_SEEK:
case ERROR_NOT_DOS_DISK:
case ERROR_WRITE_FAULT:
case ERROR_READ_FAULT:
case ERROR_GEN_FAILURE:
case ERROR_WRONG_DISK:
res = LV_FS_RES_HW_ERR;
break;
case ERROR_INVALID_HANDLE:
case ERROR_INVALID_TARGET_HANDLE:
res = LV_FS_RES_FS_ERR;
break;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
case ERROR_INVALID_DRIVE:
case ERROR_NO_MORE_FILES:
case ERROR_SECTOR_NOT_FOUND:
case ERROR_BAD_NETPATH:
case ERROR_BAD_NET_NAME:
case ERROR_BAD_PATHNAME:
case ERROR_FILENAME_EXCED_RANGE:
res = LV_FS_RES_NOT_EX;
break;
case ERROR_DISK_FULL:
res = LV_FS_RES_FULL;
break;
case ERROR_SHARING_VIOLATION:
case ERROR_LOCK_VIOLATION:
case ERROR_DRIVE_LOCKED:
res = LV_FS_RES_LOCKED;
break;
case ERROR_ACCESS_DENIED:
case ERROR_CURRENT_DIRECTORY:
case ERROR_WRITE_PROTECT:
case ERROR_NETWORK_ACCESS_DENIED:
case ERROR_CANNOT_MAKE:
case ERROR_FAIL_I24:
case ERROR_SEEK_ON_DEVICE:
case ERROR_NOT_LOCKED:
case ERROR_LOCK_FAILED:
res = LV_FS_RES_DENIED;
break;
case ERROR_BUSY:
res = LV_FS_RES_BUSY;
break;
case ERROR_TIMEOUT:
res = LV_FS_RES_TOUT;
break;
case ERROR_NOT_SAME_DEVICE:
case ERROR_DIRECT_ACCESS_HANDLE:
res = LV_FS_RES_NOT_IMP;
break;
case ERROR_TOO_MANY_OPEN_FILES:
case ERROR_ARENA_TRASHED:
case ERROR_NOT_ENOUGH_MEMORY:
case ERROR_INVALID_BLOCK:
case ERROR_OUT_OF_PAPER:
case ERROR_SHARING_BUFFER_EXCEEDED:
case ERROR_NOT_ENOUGH_QUOTA:
res = LV_FS_RES_OUT_OF_MEM;
break;
case ERROR_INVALID_FUNCTION:
case ERROR_INVALID_ACCESS:
case ERROR_INVALID_DATA:
case ERROR_BAD_COMMAND:
case ERROR_BAD_LENGTH:
case ERROR_INVALID_PARAMETER:
case ERROR_NEGATIVE_SEEK:
res = LV_FS_RES_INV_PARAM;
break;
default:
res = LV_FS_RES_UNKNOWN;
break;
}
return res;
}
//void* lv_win32_filesystem_driver_open_callback(
// lv_fs_drv_t* drv,
// const char* path,
// lv_fs_mode_t mode)
//{
// UNREFERENCED_PARAMETER(drv);
//
//
//
//}
//
//void fuck()
//{
// static lv_fs_drv_t filesystem_driver;
// lv_fs_drv_init(&filesystem_driver);
//
// filesystem_driver.letter;
// filesystem_driver.ready_cb;
//
// filesystem_driver.open_cb;
// filesystem_driver.close_cb;
// filesystem_driver.read_cb;
// filesystem_driver.write_cb;
// filesystem_driver.seek_cb;
// filesystem_driver.tell_cb;
//
// filesystem_driver.dir_open_cb;
// filesystem_driver.dir_read_cb;
// filesystem_driver.dir_close_cb;
//
// filesystem_driver.user_data;
//
// lv_fs_drv_register(&filesystem_driver);
//}
int main()
{
lv_init();
if (!lv_win32_init(
GetModuleHandleW(NULL),
SW_SHOW,
800,
480,
LoadIconW(GetModuleHandleW(NULL), MAKEINTRESOURCE(IDI_LVGL))))
{
return -1;
}
lv_win32_add_all_input_devices_to_group(NULL);
/*
* Demos, benchmarks, and tests.
*
* Uncomment any one (and only one) of the functions below to run that
* item.
*/
// ----------------------------------
// my application
// ----------------------------------
///*Init freetype library
// *Cache max 64 faces and 1 size*/
//lv_freetype_init(64, 1, 0);
///*Create a font*/
//static lv_ft_info_t info;
//info.name = "./lv_lib_freetype/arial.ttf";
//info.weight = 36;
//info.style = FT_FONT_STYLE_NORMAL;
//lv_ft_font_init(&info);
///*Create style with the new font*/
//static lv_style_t style;
//lv_style_init(&style);
//lv_style_set_text_font(&style, info.font);
///*Create a label with the new style*/
//lv_obj_t* label = lv_label_create(lv_scr_act());
//lv_obj_add_style(label, &style, 0);
//lv_label_set_text(label, "FreeType Arial Test");
// ----------------------------------
// Demos from lv_examples
// ----------------------------------
lv_demo_widgets(); // ok
// lv_demo_benchmark();
// lv_demo_keypad_encoder(); // ok
// lv_demo_music(); // removed from repository
// lv_demo_printer(); // removed from repository
// lv_demo_stress(); // ok
// ----------------------------------
// LVGL examples
// ----------------------------------
/*
* There are many examples of individual widgets found under the
* lvgl\exampless directory. Here are a few sample test functions.
* Look in that directory to find all the rest.
*/
// lv_ex_get_started_1();
// lv_ex_get_started_2();
// lv_ex_get_started_3();
// lv_example_flex_1();
// lv_example_flex_2();
// lv_example_flex_3();
// lv_example_flex_4();
// lv_example_flex_5();
// lv_example_flex_6(); // ok
// lv_example_grid_1();
// lv_example_grid_2();
// lv_example_grid_3();
// lv_example_grid_4();
// lv_example_grid_5();
// lv_example_grid_6();
// lv_port_disp_template();
// lv_port_fs_template();
// lv_port_indev_template();
// lv_example_scroll_1();
// lv_example_scroll_2();
// lv_example_scroll_3();
// lv_example_style_1();
// lv_example_style_2();
// lv_example_style_3();
// lv_example_style_4(); // ok
// lv_example_style_6(); // file has no source code
// lv_example_style_7();
// lv_example_style_8();
// lv_example_style_9();
// lv_example_style_10();
// lv_example_style_11(); // ok
// ----------------------------------
// LVGL widgets examples
// ----------------------------------
// lv_example_arc_1();
// lv_example_arc_2();
// lv_example_bar_1(); // ok
// lv_example_bar_2();
// lv_example_bar_3();
// lv_example_bar_4();
// lv_example_bar_5();
// lv_example_bar_6(); // issues
// lv_example_btn_1();
// lv_example_btn_2();
// lv_example_btn_3();
// lv_example_btnmatrix_1();
// lv_example_btnmatrix_2();
// lv_example_btnmatrix_3();
// lv_example_calendar_1();
// lv_example_canvas_1();
// lv_example_canvas_2();
// lv_example_chart_1(); // ok
// lv_example_chart_2(); // ok
// lv_example_chart_3(); // ok
// lv_example_chart_4(); // ok
// lv_example_chart_5(); // ok
// lv_example_chart_6(); // ok
// lv_example_checkbox_1();
// lv_example_colorwheel_1(); // ok
// lv_example_dropdown_1();
// lv_example_dropdown_2();
// lv_example_dropdown_3();
// lv_example_img_1();
// lv_example_img_2();
// lv_example_img_3();
// lv_example_img_4(); // ok
// lv_example_imgbtn_1();
// lv_example_keyboard_1(); // ok
// lv_example_label_1();
// lv_example_label_2(); // ok
// lv_example_led_1();
// lv_example_line_1();
// lv_example_list_1();
// lv_example_meter_1();
// lv_example_meter_2();
// lv_example_meter_3();
// lv_example_meter_4(); // ok
// lv_example_msgbox_1();
// lv_example_obj_1(); // ok
// lv_example_roller_1();
// lv_example_roller_2(); // ok
// lv_example_slider_1(); // ok
// lv_example_slider_2(); // issues
// lv_example_slider_3(); // issues
// lv_example_spinbox_1();
// lv_example_spinner_1(); // ok
// lv_example_switch_1(); // ok
// lv_example_table_1();
// lv_example_table_2(); // ok
// lv_example_tabview_1();
// lv_example_textarea_1(); // ok
// lv_example_textarea_2();
// lv_example_textarea_3(); // ok, but not all button have functions
// lv_example_tileview_1(); // ok
// lv_example_win_1(); // ok
// ----------------------------------
// Task handler loop
// ----------------------------------
while (!lv_win32_quit_signal)
{
lv_task_handler();
Sleep(1);
}
return 0;
}