From a1144bbba8367323018f6b21930ae52ceb8c6bb2 Mon Sep 17 00:00:00 2001
From: ShallowGreen123 <2608653986@qq.com>
Date: Wed, 21 Sep 2022 23:33:18 +0800
Subject: [PATCH] feat: add log related files.
---
LVGL.Simulator/.clang-format | 1 +
LVGL.Simulator/.vscode/settings.json | 5 +++-
LVGL.Simulator/LVGL.Simulator.vcxproj | 2 ++
LVGL.Simulator/LVGL.Simulator.vcxproj.filters | 9 ++++++
LVGL.Simulator/lvgl_mydemo/.clang-format | 18 ++++++++++--
LVGL.Simulator/lvgl_mydemo/assert/inc_format | 29 +++++++++++++++++++
LVGL.Simulator/lvgl_mydemo/assert/src_format | 24 +++++++++++++++
LVGL.Simulator/lvgl_mydemo/lvgl_app.c | 25 +++++++++++++++-
LVGL.Simulator/lvgl_mydemo/lvgl_app.h | 16 +++-------
.../lvgl_mydemo/screen/gui_main_scr.c | 11 ++++++-
.../lvgl_mydemo/screen/gui_test1_scr.c | 11 ++++++-
11 files changed, 133 insertions(+), 18 deletions(-)
create mode 100644 LVGL.Simulator/.clang-format
create mode 100644 LVGL.Simulator/lvgl_mydemo/assert/inc_format
create mode 100644 LVGL.Simulator/lvgl_mydemo/assert/src_format
diff --git a/LVGL.Simulator/.clang-format b/LVGL.Simulator/.clang-format
new file mode 100644
index 0000000..378e853
--- /dev/null
+++ b/LVGL.Simulator/.clang-format
@@ -0,0 +1 @@
+DisFormate : true
\ No newline at end of file
diff --git a/LVGL.Simulator/.vscode/settings.json b/LVGL.Simulator/.vscode/settings.json
index 47ae8d9..83b189b 100644
--- a/LVGL.Simulator/.vscode/settings.json
+++ b/LVGL.Simulator/.vscode/settings.json
@@ -1,7 +1,10 @@
{
"files.associations": {
"scr_mgr.h": "c",
- "gui_main_scr.h": "c"
+ "gui_main_scr.h": "c",
+ "stdio.h": "c",
+ "gui_log.h": "c",
+ "lvgl.h": "c"
},
"C_Cpp.errorSquiggles": "Disabled"
}
\ No newline at end of file
diff --git a/LVGL.Simulator/LVGL.Simulator.vcxproj b/LVGL.Simulator/LVGL.Simulator.vcxproj
index 31e5cae..c95fd7b 100644
--- a/LVGL.Simulator/LVGL.Simulator.vcxproj
+++ b/LVGL.Simulator/LVGL.Simulator.vcxproj
@@ -55,6 +55,8 @@
+
+
diff --git a/LVGL.Simulator/LVGL.Simulator.vcxproj.filters b/LVGL.Simulator/LVGL.Simulator.vcxproj.filters
index c3c8acb..5aa0528 100644
--- a/LVGL.Simulator/LVGL.Simulator.vcxproj.filters
+++ b/LVGL.Simulator/LVGL.Simulator.vcxproj.filters
@@ -48,6 +48,12 @@
lvgl_mydemo\srceen
+
+ lvgl_mydemo\log
+
+
+ lvgl_mydemo\log
+
@@ -80,5 +86,8 @@
{5aec906d-b671-4778-9999-6dcadc840600}
+
+ {7c5bcdd0-7a51-46f7-804e-ed1f4371645d}
+
\ No newline at end of file
diff --git a/LVGL.Simulator/lvgl_mydemo/.clang-format b/LVGL.Simulator/lvgl_mydemo/.clang-format
index c0b4f0e..32c871c 100644
--- a/LVGL.Simulator/lvgl_mydemo/.clang-format
+++ b/LVGL.Simulator/lvgl_mydemo/.clang-format
@@ -96,6 +96,16 @@ BreakBeforeBinaryOperators: NonAssignment
# Allman(总是在大括号前换行), GNU(总是在大括号前换行,并对于控制语句的大括号增加额外的缩进), WebKit(在函数前换行), Custom
# 注:这里认为语句块也属于函数
BreakBeforeBraces: Custom
+BraceWrapping:
+ AfterEnum: false
+ AfterStruct: false
+ AfterUnion: false
+ AfterCaseLabel: false
+ AfterClass: true
+ AfterFunction: true
+ SplitEmptyFunction: false
+ AfterNamespace: false
+ AfterExternBlock: false
# 在三元运算符前换行
BreakBeforeTernaryOperators: false
@@ -133,7 +143,8 @@ FixNamespaceComments: true
# 缩进case标签
IndentCaseLabels: false
-IndentPPDirectives: None
+# Possible values: None\AfterHash\BeforeHash
+IndentPPDirectives: AfterHash
# 缩进宽度
IndentWidth: 4
@@ -219,7 +230,7 @@ IndentCaseLabels: true
#三元运算符将放置在换行符之后
BreakBeforeTernaryOperators: true
-BreakBeforeBraces: Attach
+BreakBeforeBraces: Custom
AllowShortCaseLabelsOnASingleLine: false
@@ -230,6 +241,9 @@ AlignTrailingComments: true
AlignOperands: AlignAfterOperator
#对齐宏
+# They can also be read as a whole for compatibility.
+# The choices are:
+# - None - Consecutive - AcrossEmptyLines - AcrossComments - AcrossEmptyLinesAndComments
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
#对齐连续等号
AlignConsecutiveAssignments: AcrossEmptyLines
diff --git a/LVGL.Simulator/lvgl_mydemo/assert/inc_format b/LVGL.Simulator/lvgl_mydemo/assert/inc_format
new file mode 100644
index 0000000..91571e3
--- /dev/null
+++ b/LVGL.Simulator/lvgl_mydemo/assert/inc_format
@@ -0,0 +1,29 @@
+#ifndef INC_FORMAT_H
+#define INC_FORMAT_H
+
+/*********************************************************************************
+ * INCLUDES
+ * *******************************************************************************/
+
+/*********************************************************************************
+ * DEFINES
+ * *******************************************************************************/
+#ifdef __INC_FORMAT_C__
+# define DEF_EXTERN
+#else
+# define DEF_EXTERN extern
+#endif
+
+/*********************************************************************************
+ * MACROS
+ * *******************************************************************************/
+
+/*********************************************************************************
+ * TYPEDEFS
+ * *******************************************************************************/
+
+/*********************************************************************************
+ * GLOBAL PROTOTYPES
+ * *******************************************************************************/
+
+#endif /* INC_FORMAT_H */
\ No newline at end of file
diff --git a/LVGL.Simulator/lvgl_mydemo/assert/src_format b/LVGL.Simulator/lvgl_mydemo/assert/src_format
new file mode 100644
index 0000000..b8315c2
--- /dev/null
+++ b/LVGL.Simulator/lvgl_mydemo/assert/src_format
@@ -0,0 +1,24 @@
+
+/*********************************************************************************
+ * INCLUDES
+ * *******************************************************************************/
+
+/*********************************************************************************
+ * DEFINES
+ * *******************************************************************************/
+
+/*********************************************************************************
+ * MACROS
+ * *******************************************************************************/
+
+/*********************************************************************************
+ * TYPEDEFS
+ * *******************************************************************************/
+
+/*********************************************************************************
+ * STATIC FUNCTION
+ * *******************************************************************************/
+
+/*********************************************************************************
+ * GLOBAL FUNCTION
+ * *******************************************************************************/
\ No newline at end of file
diff --git a/LVGL.Simulator/lvgl_mydemo/lvgl_app.c b/LVGL.Simulator/lvgl_mydemo/lvgl_app.c
index 9932225..9ef29dd 100644
--- a/LVGL.Simulator/lvgl_mydemo/lvgl_app.c
+++ b/LVGL.Simulator/lvgl_mydemo/lvgl_app.c
@@ -29,14 +29,37 @@
/*********************************************************************************
* STATIC FUNCTION
* *******************************************************************************/
+static void log_write_timer_cb(lv_timer_t *t)
+{
+ LV_UNUSED(t);
+ TRACE_V("Hello wrold!");
+ TRACE_D("Hello wrold!");
+ TRACE_I("Hello wrold!");
+ TRACE_E("Hello wrold!");
+ TRACE_W("Hello wrold!");
+
+ Lib_TraceProc();
+}
+
+static bool log_write_to_file(LIB_TRACE_ITEM_HANDLE_T *item)
+{
+ TRACE_D("item info = %s", item->Buf);
+ return true;
+}
/*********************************************************************************
* GLOBAL FUNCTION
* *******************************************************************************/
-void lvgl_app_init(void) {
+void lvgl_app_init(void)
+{
+ Lib_TraceInit();
+ Lib_TraceRegistWriter(log_write_to_file);
+
DataModelInit();
ScrMgrInit();
ScrMgrSwitchScr(GUI_MIAN_SCR_ID, true);
+
+ lv_timer_create(log_write_timer_cb, 3000, NULL);
}
diff --git a/LVGL.Simulator/lvgl_mydemo/lvgl_app.h b/LVGL.Simulator/lvgl_mydemo/lvgl_app.h
index 9b9e991..0eb2dea 100644
--- a/LVGL.Simulator/lvgl_mydemo/lvgl_app.h
+++ b/LVGL.Simulator/lvgl_mydemo/lvgl_app.h
@@ -2,20 +2,11 @@
* FilePath : lvgl_app.h
* Author : GX.Duan
* Date : 2022-08-07 15:20:41
- * LastEditTime : 2022-09-10 15:58:18
+ * LastEditTime : 2022-09-21 22:03:59
* LastEditors : ShallowGreen123 2608653986@qq.com
* Copyright (c): 2022 by GX.Duan, All Rights Reserved.
* Github : https://github.com/ShallowGreen123/lvgl_mydemo
************************************************************************/
-/************************************************************************
- * FilePath : lvgl_app.h
- * Author : GX.Duan
- * Date : 2022-08-07
- * LastEditTime : 2022-08-19
- * LastEditors : ShallowGreen123 2608653986@qq.com
- * Copyright (c): by GX.Duan, All Rights Reserved.
- * Github : https://github.com/ShallowGreen123/lvgl_mydemo
- ************************************************************************/
#ifndef LV_DEMO_INIT_H
#define LV_DEMO_INIT_H
@@ -24,6 +15,7 @@
* *******************************************************************************/
#include "../lvgl/lvgl.h"
#include
+#include "log/gui_log.h"
#include "data/dataModel.h"
#include "screen/gui_scr_mgr.h"
@@ -34,9 +26,9 @@ extern "C" {
* DEFINES
* *******************************************************************************/
#ifdef __LVGL_APP_C__
-#define DEF_EXTERN
+# define DEF_EXTERN
#else
-#define DEF_EXTERN extern
+# define DEF_EXTERN extern
#endif
/*********************************************************************************
diff --git a/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.c b/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.c
index 10c9b86..3f0f376 100644
--- a/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.c
+++ b/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.c
@@ -1,3 +1,12 @@
+/************************************************************************
+ * FilePath : gui_main_scr.c
+ * Author : GX.Duan
+ * Date : 2022-08-19 00:25:00
+ * LastEditTime : 2022-09-21 22:11:15
+ * LastEditors : ShallowGreen123 2608653986@qq.com
+ * Copyright (c): 2022 by GX.Duan, All Rights Reserved.
+ * Github : https://github.com/ShallowGreen123/lvgl_mydemo
+ ************************************************************************/
/************************************************************************
* FilePath : gui_main_scr.c
* Author : GX.Duan
@@ -38,7 +47,7 @@ void swithc_btn_event_cb(lv_event_t *e) {
lv_obj_t *obj = lv_event_get_target(e);
if (obj == switch_btn) {
- printf("Screen 1 switch_btn is pressed!\n");
+ TRACE_I("Screen 1 switch_btn is pressed!");
ScrMgrPushScr(GUI_TEST1_SCR_ID, true);
}
}
diff --git a/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.c b/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.c
index 4985c3e..3c2787b 100644
--- a/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.c
+++ b/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.c
@@ -1,3 +1,12 @@
+/************************************************************************
+ * FilePath : gui_test1_scr.c
+ * Author : GX.Duan
+ * Date : 2022-09-10 17:10:59
+ * LastEditTime : 2022-09-21 22:46:10
+ * LastEditors : ShallowGreen123 2608653986@qq.com
+ * Copyright (c): 2022 by GX.Duan, All Rights Reserved.
+ * Github : https://github.com/ShallowGreen123/lvgl_mydemo
+ ************************************************************************/
/************************************************************************
* FilePath : gui_test1_scr.c
* Author : GX.Duan
@@ -39,7 +48,7 @@ void test1_btn_event_cb(lv_event_t *e) {
lv_obj_t *obj = lv_event_get_target(e);
if (obj == test1_btn) {
- printf("Screen 2 test1_btn is pressed!\n");
+ TRACE_I("Screen 2 test1_btn is pressed!");
ScrMgrPopScr(true);
}
}