From 65062d0d5b21f838aa0043a15ce54cfab8d72c43 Mon Sep 17 00:00:00 2001
From: wujiazhi <1147861305@qq.com>
Date: Tue, 11 Jun 2024 14:23:53 +0800
Subject: [PATCH] 1.Fixed communication failure between MCU and wireless module 2.Fix the wrong judgment of alkaline lithium power
---
Soft/test_log.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/Soft/test_log.c b/Soft/test_log.c
new file mode 100644
index 0000000..d805597
--- /dev/null
+++ b/Soft/test_log.c
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include "test_log.h"
+#include "rtc.h"
+#include "sundry.h"
+
+static long long default_get_sys_time_ms(void)
+{
+ long long time_ms = 0;
+ time_ms = BCD_2_HEX_U8(calendar_g.Hour) * 60 * 60 * 1000 + BCD_2_HEX_U8(calendar_g.Minute) * 60 * 1000 +
+ BCD_2_HEX_U8(calendar_g.Second) * 1000;
+ return time_ms;
+}
+
+static get_sys_time_ms_def s_get_sys_time_ms = default_get_sys_time_ms;
+
+void log_time_register(get_sys_time_ms_def p_get_sys_time_ms)
+{
+ s_get_sys_time_ms = p_get_sys_time_ms;
+}
+
+void log_print(enum log_debug_type debug_type, const char *file, int line, const char *func, const char* fmt, ...)
+{
+#if LOG_PRINT_OPEN == 1
+ va_list ap;
+ char buf[LOG_BUF_SIZE] = {0};
+ long long time = s_get_sys_time_ms();
+
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+
+ switch(debug_type)
+ {
+ case DEBUG_NORMAL:
+ printf("<%lld ms>[%s:%d %s] %s", time, file, line, func, buf);
+ break;
+ case DEBUG_WARNING:
+ printf("\033[31m<%lld ms>[%s:%d %s] %s\033[0m", time, file, line, func, buf);
+ break;
+ case DEBUG_ERROR:
+ printf("\033[32m<%lld ms>[%s:%d %s] %s\033[0m", time, file, line, func, buf);
+ break;
+ default:break;
+ }
+#endif
+
+}
--
Gitblit v1.9.3