-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
lvgl.hpp
103 lines (76 loc) · 2.59 KB
/
lvgl.hpp
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
//
// Copyright (c) 2019 plan44.ch / Lukas Zeller, Zurich, Switzerland
//
// Author: Lukas Zeller <[email protected]>
//
// This file is part of p44utils.
//
// p44utils is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// p44utils is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with p44utils. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef __p44utils__lvgl__
#define __p44utils__lvgl__
#ifndef ENABLE_LVGL
// We assume that including this file in a build usually means that LittlevGL support is actually needed.
// Still, ENABLE_LVGL can be set to 0 to create build variants w/o removing the file from the project/makefile
#define ENABLE_LVGL 1
#endif
#if ENABLE_LVGL
#include "p44utils_common.hpp"
#include "lvgl/lvgl.h"
#if defined(__APPLE__)
// test&debugging build on MacOS, using SDL2 for graphics
// - littlevGL
#include "lv_drivers/display/monitor.h"
#include "lv_drivers/indev/mouse.h"
#else
// target platform build
// - littlevGL
#include "lv_drivers/display/fbdev.h"
#include "lv_drivers/indev/evdev.h"
#endif
#ifndef MOUSE_CURSOR_SUPPORT
#define MOUSE_CURSOR_SUPPORT 1
#endif
#ifndef ENABLE_IMAGE_SUPPORT
#define ENABLE_IMAGE_SUPPORT 1
#endif
using namespace std;
namespace p44 {
// singleton wrapper for LittlevGL
class LvGL
{
lv_disp_t *dispdev; ///< the display device
lv_indev_t *pointer_indev; ///< the input device for pointer (touch, mouse)
lv_indev_t *keyboard_indev; ///< the input device for keyboard
MLTicket lvglTicket; ///< the display tasks timer
bool showCursor; ///< set if a cursor should be shown (for debug)
lv_disp_buf_t disp_buf; ///< the display buffer descriptors
lv_color_t *buf1; ///< the buffer
uint32_t lastActivity; ///< for activity detection
SimpleCB taskCallback; ///< called when detecting user activity
#if LV_USE_FILESYSTEM
lv_fs_drv_t pf_fs_drv;
#endif
LvGL();
~LvGL();
public:
static LvGL& lvgl();
void init(bool aShowCursor);
void setTaskCallback(SimpleCB aCallback);
private:
void lvglTask(MLTimer &aTimer, MLMicroSeconds aNow);
};
} // namespace p44
#endif // ENABLE_LVGL
#endif // __p44utils__lvgl__