blob: 558b11cdcc73a12fa11ce966f8a6d58d13caf355 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/******************************************************************************
2*(C) Copyright 2014 Marvell International Ltd.
3* All Rights Reserved
4******************************************************************************/
5/* -------------------------------------------------------------------------------------------------------------------
6 *
7 * Filename: mgui_utils.h
8 *
9 * Authors: Tomer Eliyahu
10 *
11 * Description: mgui interface to ubus
12 *
13 * HISTORY:
14 * Nov 23, 2014 - Initial Version
15 *
16 * Notes:
17 *
18 ******************************************************************************/
19
20#ifndef __GUI_UTILS_H__
21#define __GUI_UTILS_H__
22
23#include "mgui_config.h"
24#include <time.h>
25
26
27
28#include "lvgl/asr_lvgl.h"
29
30#define MGUI_LOG_TAG "MGUI"
31#define LOG_BUF_SIZE 1024
32
33#define TRUE (1)
34#define FALSE (0)
35
36#ifndef ARRAY_SIZE
37#define ARRAY_SIZE(_A) (sizeof(_A) / sizeof((_A)[0]))
38#endif /* ARRAY_SIZE */
39
40#ifndef MIN
41#define MIN(x,y) ((x)<(y)?(x):(y))
42#endif
43
44#ifndef MAX
45#define MAX(x,y) ((x)>(y)?(x):(y))
46#endif
47
48#define UNUSED(x) ((void)(x))
49
50#ifdef MGUI_LOGCAT
51#include <include/log.h>
52#define MGUI_DMSG(fmt, args...) RDBGMSG("%s:%d: "fmt, __func__, __LINE__ , ##args)
53#define MGUI_EMSG(fmt, args...) RERRMSG("%s:%d: "fmt, __func__,__LINE__ , ##args)
54#define MGUI_WMSG(fmt, args...) RWARNMSG("%s:%d: "fmt, __func__,__LINE__, ##args)
55#define MGUI_IMSG(fmt, args...) RDPRINTF("%s:%d: "fmt, __func__,__LINE__, ##args)
56#define MASSERT(cond, args...) \
57 do {\
58 if (!(cond)) { \
59 RERRMSG("%s:%d: ASSERT !!!\n", __FILE__,__LINE__, ##args);\
60 fprintf(stderr, "%s:%d: ASSERT !!!\n", __FILE__,__LINE__);\
61 raise(SIGUSR1);\
62 }\
63 } while(0);
64
65#define MGUI_LOG_INIT() set_service_log_tag(MGUI_LOG_TAG);
66//#define MGUI_DEBUG RDBGMSG("%s:%d: HERE\n", __func__, __LINE__);
67#else
68//#define MGUI_DEBUG __mgui_log_print("%s:%d: HERE\n", __func__, __LINE__);
69#define MGUI_DMSG(fmt, args...) __mgui_log_print("%s:%d: DEBUG: "fmt, __func__, __LINE__, ##args)
70#define MGUI_EMSG(fmt, args...) __mgui_log_print("%s:%d: ERROR: "fmt, __func__, __LINE__, ##args)
71#define MGUI_WMSG(fmt, args...) __mgui_log_print("%s:%d: WARNING: "fmt, __func__, __LINE__, ##args)
72#define MGUI_IMSG(fmt, args...) __mgui_log_print("%s:%d: INFO: "fmt, __func__, __LINE__, ##args)
73#define MASSERT(cond, args...)\
74 do { \
75 if (!(cond)) { \
76 __mgui_log_print("%s:%d: ASSERT !!!\n", __FILE__,__LINE__, ##args); \
77 exit(1); \
78 } \
79 } while (0);
80#define MGUI_LOG_INIT()
81#endif
82
83int __mgui_log_print(const char *fmt, ...);
84
85
86static inline void set_time_string(char *time_str, const char *format, size_t size)
87{
88 time_t current_time;
89 struct tm *time_info;
90
91 time(&current_time);
92 time_info = localtime(&current_time);
93 strftime(time_str, size, format, time_info);
94}
95
96#endif //__GUI_UTILS_H__