1 /**
2  * @file lv_global.h
3  *
4  */
5 
6 #ifndef LV_GLOBAL_H
7 #define LV_GLOBAL_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "../lv_conf_internal.h"
17 
18 #include "../misc/lv_types.h"
19 #include "../draw/lv_draw.h"
20 #if LV_USE_DRAW_SW
21 #include "../draw/sw/lv_draw_sw.h"
22 #endif
23 #include "../misc/lv_anim.h"
24 #include "../misc/lv_area.h"
25 #include "../misc/lv_color_op.h"
26 #include "../misc/lv_ll.h"
27 #include "../misc/lv_log.h"
28 #include "../misc/lv_style.h"
29 #include "../misc/lv_timer.h"
30 #include "../osal/lv_os.h"
31 #include "../others/sysmon/lv_sysmon.h"
32 #include "../stdlib/builtin/lv_tlsf.h"
33 
34 #if LV_USE_FONT_COMPRESSED
35 #include "../font/lv_font_fmt_txt_private.h"
36 #endif
37 
38 #include "../tick/lv_tick.h"
39 #include "../layouts/lv_layout.h"
40 
41 #include "../misc/lv_types.h"
42 
43 #include "../misc/lv_timer_private.h"
44 #include "../misc/lv_anim_private.h"
45 #include "../tick/lv_tick_private.h"
46 #include "../draw/lv_draw_buf_private.h"
47 #include "../draw/lv_draw_private.h"
48 #include "../draw/sw/lv_draw_sw_private.h"
49 #include "../draw/sw/lv_draw_sw_mask_private.h"
50 #include "../stdlib/builtin/lv_tlsf_private.h"
51 #include "../others/sysmon/lv_sysmon_private.h"
52 #include "../layouts/lv_layout_private.h"
53 
54 /*********************
55  *      DEFINES
56  *********************/
57 #define ZERO_MEM_SENTINEL  0xa1b2c3d4
58 
59 /**********************
60  *      TYPEDEFS
61  **********************/
62 
63 #if LV_USE_SPAN != 0
64 struct _snippet_stack;
65 #endif
66 
67 #if LV_USE_FREETYPE
68 struct _lv_freetype_context_t;
69 #endif
70 
71 #if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN
72 struct _lv_profiler_builtin_ctx_t;
73 #endif
74 
75 #if LV_USE_NUTTX
76 struct _lv_nuttx_ctx_t;
77 #endif
78 
79 typedef struct _lv_global_t {
80     bool inited;
81     bool deinit_in_progress;     /**< Can be used e.g. in the LV_EVENT_DELETE to deinit the drivers too */
82 
83     lv_ll_t disp_ll;
84     lv_display_t * disp_refresh;
85     lv_display_t * disp_default;
86 
87     lv_ll_t style_trans_ll;
88     bool style_refresh;
89     uint32_t style_custom_table_size;
90     uint32_t style_last_custom_prop_id;
91     uint8_t * style_custom_prop_flag_lookup_table;
92 
93     lv_ll_t group_ll;
94     lv_group_t * group_default;
95 
96     lv_ll_t indev_ll;
97     lv_indev_t * indev_active;
98     lv_obj_t * indev_obj_active;
99 
100     uint32_t layout_count;
101     lv_layout_dsc_t * layout_list;
102     bool layout_update_mutex;
103 
104     uint32_t memory_zero;
105     uint32_t math_rand_seed;
106 
107     lv_event_t * event_header;
108     uint32_t event_last_register_id;
109 
110     lv_timer_state_t timer_state;
111     lv_anim_state_t anim_state;
112     lv_tick_state_t tick_state;
113 
114     lv_draw_buf_handlers_t draw_buf_handlers;
115     lv_draw_buf_handlers_t font_draw_buf_handlers;
116     lv_draw_buf_handlers_t image_cache_draw_buf_handlers;  /**< Ensure that all assigned draw buffers
117                                                             * can be managed by image cache. */
118 
119     lv_ll_t img_decoder_ll;
120 
121     lv_cache_t * img_cache;
122     lv_cache_t * img_header_cache;
123 
124     lv_draw_global_info_t draw_info;
125 #if defined(LV_DRAW_SW_SHADOW_CACHE_SIZE) && LV_DRAW_SW_SHADOW_CACHE_SIZE > 0
126     lv_draw_sw_shadow_cache_t sw_shadow_cache;
127 #endif
128 #if LV_DRAW_SW_COMPLEX
129     lv_draw_sw_mask_radius_circle_dsc_arr_t sw_circle_cache;
130 #endif
131 
132 #if LV_USE_LOG
133     lv_log_print_g_cb_t custom_log_print_cb;
134 #endif
135 
136 #if LV_USE_LOG && LV_LOG_USE_TIMESTAMP
137     uint32_t log_last_log_time;
138 #endif
139 
140 #if LV_USE_THEME_SIMPLE
141     void * theme_simple;
142 #endif
143 
144 #if LV_USE_THEME_DEFAULT
145     void * theme_default;
146 #endif
147 
148 #if LV_USE_THEME_MONO
149     void * theme_mono;
150 #endif
151 
152 #if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
153     lv_tlsf_state_t tlsf_state;
154 #endif
155 
156     lv_ll_t fsdrv_ll;
157 #if LV_USE_FS_STDIO != '\0'
158     lv_fs_drv_t stdio_fs_drv;
159 #endif
160 #if LV_USE_FS_POSIX
161     lv_fs_drv_t posix_fs_drv;
162 #endif
163 
164 #if LV_USE_FS_FATFS
165     lv_fs_drv_t fatfs_fs_drv;
166 #endif
167 
168 #if LV_USE_FS_WIN32 != '\0'
169     lv_fs_drv_t win32_fs_drv;
170 #endif
171 
172 #if LV_USE_FS_UEFI
173     lv_fs_drv_t uefi_fs_drv;
174 #endif
175 
176 #if LV_USE_FS_LITTLEFS
177     lv_fs_drv_t littlefs_fs_drv;
178 #endif
179 
180 #if LV_USE_FS_ARDUINO_ESP_LITTLEFS
181     lv_fs_drv_t arduino_esp_littlefs_fs_drv;
182 #endif
183 
184 #if LV_USE_FS_ARDUINO_SD
185     lv_fs_drv_t arduino_sd_fs_drv;
186 #endif
187 
188 #if LV_USE_FREETYPE
189     struct _lv_freetype_context_t * ft_context;
190 #endif
191 
192 #if LV_USE_FONT_COMPRESSED
193     lv_font_fmt_rle_t font_fmt_rle;
194 #endif
195 
196 #if LV_USE_SPAN != 0
197     struct _snippet_stack * span_snippet_stack;
198 #endif
199 
200 #if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN
201     struct _lv_profiler_builtin_ctx_t * profiler_context;
202 #endif
203 
204 #if LV_USE_FILE_EXPLORER != 0
205     lv_style_t fe_list_button_style;
206 #endif
207 
208 #if LV_USE_MEM_MONITOR
209     lv_sysmon_backend_data_t sysmon_mem;
210 #endif
211 
212 #if LV_USE_IME_PINYIN != 0
213     size_t ime_cand_len;
214 #endif
215 
216 #if LV_USE_OBJ_ID_BUILTIN
217     void * objid_array;
218     uint32_t objid_count;
219 #endif
220 
221 #if LV_USE_NUTTX
222     struct _lv_nuttx_ctx_t * nuttx_ctx;
223 #endif
224 
225 #if LV_USE_OS != LV_OS_NONE
226     lv_mutex_t lv_general_mutex;
227 #endif
228 
229 #if LV_USE_OS == LV_OS_FREERTOS
230     uint32_t freertos_idle_time_sum;
231     uint32_t freertos_non_idle_time_sum;
232     uint32_t freertos_task_switch_timestamp;
233     bool freertos_idle_task_running;
234 #endif
235 
236 #if LV_USE_EVDEV
237     lv_evdev_discovery_t * evdev_discovery;
238 #endif
239 
240     void * user_data;
241 } lv_global_t;
242 
243 /**********************
244  *      MACROS
245  **********************/
246 
247 #if LV_ENABLE_GLOBAL_CUSTOM
248 #include LV_GLOBAL_CUSTOM_INCLUDE
249 
250 #ifndef LV_GLOBAL_CUSTOM
251 #define LV_GLOBAL_CUSTOM() lv_global_default()
252 #endif
253 #define LV_GLOBAL_DEFAULT() LV_GLOBAL_CUSTOM()
254 #else
255 LV_ATTRIBUTE_EXTERN_DATA extern lv_global_t lv_global;
256 #define LV_GLOBAL_DEFAULT() (&lv_global)
257 #endif
258 
259 /**********************
260  * GLOBAL PROTOTYPES
261  **********************/
262 #if LV_ENABLE_GLOBAL_CUSTOM
263 /**
264  * Get the default global object for current thread
265  * @return  pointer to the default global object
266  */
267 lv_global_t * lv_global_default(void);
268 #endif
269 #ifdef __cplusplus
270 } /*extern "C"*/
271 #endif
272 
273 #endif /*LV_GLOBAL_H*/
274