microui  4.1.0
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.1.0
32  */
33 
34 // --------------------------------------------------------------------------------
35 // Includes
36 // --------------------------------------------------------------------------------
37 
38 /*
39  * @brief Includes right header file according the Architecture.
40  * - Architecture 7: include "trace.h"
41  * - Architecture 8: include "LLTRACE.h"
42  */
43 #define UI_LOG_LLTRACE __has_include("LLTRACE.h")
44 #if UI_LOG_LLTRACE == (0u)
45 #include <trace.h>
46 #else
47 #include <LLTRACE.h>
48 #endif
49 
50 // --------------------------------------------------------------------------------
51 // Defines
52 // --------------------------------------------------------------------------------
53 
54 /*
55  * @brief Identifies the log for the drawings (known by the MicroUI CCO and by the
56  * MicroUI Graphics Engine).
57  */
58 #define UI_LOG_DRAW (0)
59 
60 /*
61  * @brief Identifies the logs for the Buffer Refresh Strategies (BRS).
62  */
63 #define UI_LOG_BRS_NewDrawing (10) // New drawing region (%u,%u) to (%u,%u)
64 #define UI_LOG_BRS_FlushSingle (11) // Flush LCD (id=%u buffer=%p) single region (%u,%u) to (%u,%u)
65 #define UI_LOG_BRS_FlushMulti (12) // Flush LCD (id=%u buffer=%p) %u regions
66 #define UI_LOG_BRS_AddRegion (13) // Add region (%u,%u) to (%u,%u)
67 #define UI_LOG_BRS_RemoveRegion (14) // Remove region (%u,%u) to (%u,%u)
68 #define UI_LOG_BRS_RestoreRegion (15) // Restore region (%u,%u) to (%u,%u)
69 #define UI_LOG_BRS_ClearList (16) // Clear the list of regions
70 
71 /*
72  * @brief Compatibility of Architecture 7 with Architecture 8: use the prototypes
73  * of LLTRACE.h (Architecture 8).
74  */
75 #if UI_LOG_LLTRACE == (0u)
76 #define LLTRACE_record_event_void TRACE_record_event_void
77 #define LLTRACE_record_event_u32 TRACE_record_event_u32
78 #define LLTRACE_record_event_u32x2 TRACE_record_event_u32x2
79 #define LLTRACE_record_event_u32x3 TRACE_record_event_u32x3
80 #define LLTRACE_record_event_u32x4 TRACE_record_event_u32x4
81 #define LLTRACE_record_event_u32x5 TRACE_record_event_u32x5
82 #define LLTRACE_record_event_u32x6 TRACE_record_event_u32x6
83 #define LLTRACE_record_event_u32x7 TRACE_record_event_u32x7
84 #define LLTRACE_record_event_u32x8 TRACE_record_event_u32x8
85 #define LLTRACE_record_event_u32x9 TRACE_record_event_u32x9
86 #define LLTRACE_record_event_u32x10 TRACE_record_event_u32x10
87 #define LLTRACE_record_event_end TRACE_record_event_end
88 #define LLTRACE_record_event_end_u32 TRACE_record_event_end_u32
89 #endif // if UI_LOG_LLTRACE == (0u)
90 
91 // --------------------------------------------------------------------------------
92 // Fields
93 // --------------------------------------------------------------------------------
94 
95 /*
96  * @brief Identifies the MicroUI group to log an event.
97  */
98 extern int32_t LLUI_EVENT_group;
99 
100 /*
101  * @brief Identifies the offset in the MicroUI group to log an event.
102  */
103 extern int32_t LLUI_EVENT_offset;
104 
105 // --------------------------------------------------------------------------------
106 // EOF
107 // --------------------------------------------------------------------------------
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 #endif // UI_LOG_H