microui  4.0.1
microui
ui_log.h
1 /*
2  * Copyright 2024 MicroEJ Corp. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be found with this software.
4  */
5 
6 #if !defined UI_LOG_H
7 #define UI_LOG_H
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 /*
13  * @brief Provides elements that allow to log some external events in the MicroUI event
14  * group.
15  *
16  * The MicroUI event group is identified by the global LLUI_EVENT_group. The events are
17  * 0-based and have to start at the offset LLUI_EVENT_offset.
18  *
19  * Notes:
20  * - The number of events is 100 (fixed by MicroUI).
21  * - The event 0 is reserved to log the drawings. It is used by the MicroUI CCO and by
22  * the MicroUI Graphics Engine (to log the internal drawings).
23  * - The events [10,20] are reserved to log the buffer refresh strategies (BRS) events.
24  *
25  * Example:
26  *
27  * #include "ui_log.h"
28  * LLTRACE_record_event_u32(LLUI_EVENT_group, LLUI_EVENT_offset + MY_EVENT_OFFSET, my_event_data);
29  *
30  * @author MicroEJ Developer Team
31  * @version 4.0.1
32  */
33 
34 // --------------------------------------------------------------------------------
35 // Includes
36 // --------------------------------------------------------------------------------
37 
38 
39 /*
40  * @brief Includes right header file according the Architecture.
41  * - Architecture 7: include "trace.h"
42  * - Architecture 8: include "LLTRACE.h"
43  */
44 #define UI_LOG_LLTRACE __has_include("LLTRACE.h")
45 #if UI_LOG_LLTRACE == (0u)
46 #include <trace.h>
47 #else
48 #include <LLTRACE.h>
49 #endif
50 
51 // --------------------------------------------------------------------------------
52 // Defines
53 // --------------------------------------------------------------------------------
54 
55 /*
56  * @brief Identifies the log for the drawings (known by the MicroUI CCO and by the
57  * MicroUI Graphics Engine).
58  */
59 #define UI_LOG_DRAW (0)
60 
61 /*
62  * @brief Identifies the logs for the Buffer Refresh Strategies (BRS).
63  */
64 #define UI_LOG_BRS_NewDrawing (10) // New drawing region (%u,%u) to (%u,%u)
65 #define UI_LOG_BRS_FlushSingle (11) // Flush LCD (id=%u buffer=%p) single region (%u,%u) to (%u,%u)
66 #define UI_LOG_BRS_FlushMulti (12) // Flush LCD (id=%u buffer=%p) %u regions
67 #define UI_LOG_BRS_AddRegion (13) // Add region (%u,%u) to (%u,%u)
68 #define UI_LOG_BRS_RemoveRegion (14) // Remove region (%u,%u) to (%u,%u)
69 #define UI_LOG_BRS_RestoreRegion (15) // Restore region (%u,%u) to (%u,%u)
70 #define UI_LOG_BRS_ClearList (16) // Clear the list of regions
71 
72 /*
73  * @brief Compatibility of Architecture 7 with Architecture 8: use the prototypes
74  * of LLTRACE.h (Architecture 8).
75  */
76 #if UI_LOG_LLTRACE == (0u)
77 #define LLTRACE_record_event_void TRACE_record_event_void
78 #define LLTRACE_record_event_u32 TRACE_record_event_u32
79 #define LLTRACE_record_event_u32x2 TRACE_record_event_u32x2
80 #define LLTRACE_record_event_u32x3 TRACE_record_event_u32x3
81 #define LLTRACE_record_event_u32x4 TRACE_record_event_u32x4
82 #define LLTRACE_record_event_u32x5 TRACE_record_event_u32x5
83 #define LLTRACE_record_event_u32x6 TRACE_record_event_u32x6
84 #define LLTRACE_record_event_u32x7 TRACE_record_event_u32x7
85 #define LLTRACE_record_event_u32x8 TRACE_record_event_u32x8
86 #define LLTRACE_record_event_u32x9 TRACE_record_event_u32x9
87 #define LLTRACE_record_event_u32x10 TRACE_record_event_u32x10
88 #define LLTRACE_record_event_end TRACE_record_event_end
89 #define LLTRACE_record_event_end_u32 TRACE_record_event_end_u32
90 #endif
91 
92 // --------------------------------------------------------------------------------
93 // Fields
94 // --------------------------------------------------------------------------------
95 
96 /*
97  * @brief Identifies the MicroUI group to log an event.
98  */
99 extern int32_t LLUI_EVENT_group;
100 
101 /*
102  * @brief Identifies the offset in the MicroUI group to log an event.
103  */
104 extern int32_t LLUI_EVENT_offset;
105 
106 // --------------------------------------------------------------------------------
107 // EOF
108 // --------------------------------------------------------------------------------
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 #endif // UI_LOG_H