重构手环软件架构:实现动态挂载前后台 App 框架,解耦拆分源文件,并引入统一日志宏 xtell.h

This commit is contained in:
Antigravity IDE
2026-07-17 09:08:53 +08:00
parent 8fdbb32f42
commit c0d1fe74f5
18 changed files with 1380 additions and 1155 deletions

View File

@@ -1,6 +1,8 @@
#include "system.h"
#include "rgb.h"
#include "ui.h"
#include "clock.h"
#include "xtell.h"
#include "../Drivers/lcd.h"
#include "../Drivers/rf.h"
#include "app_manager.h"
@@ -268,7 +270,7 @@ void FormatHex(u32 val, char *buf)
*/
void Enter_Low_Power_Sleep(void)
{
Uart_SendString("[SYS] Entering low power sleep...\r\n");
XTELL_LOG("[SYS] Entering low power sleep...\r\n");
// 1. 关闭/熄灭 FCOB 灯条
RGB_Send(0, 0, 0, 0, 0, 0);
@@ -343,7 +345,7 @@ void Enter_Low_Power_Sleep(void)
EA = 1;
// 13. 向电源控制寄存器 PCON 写入 0x02使 MCU 核心进入 Power-Down 模式CPU 停止运转
Uart_SendString("[SYS] Entering Power-Down mode...\r\n");
XTELL_LOG("[SYS] Entering Power-Down mode...\r\n");
PCON |= 0x02; // 设定 PD 位,硬件立刻休眠挂起
// 唤醒后必须跟 _nop_() 空操作以占位和刷新指令流水线
@@ -388,20 +390,20 @@ void Wakeup_Restore(void)
// 打印日志,判断并告知调试串口具体是哪个物理源将手环唤醒的
if ((p0_wakeup_flag & 0x0E) || (p2_wakeup_flag & 0x40))
{
Uart_SendString("[WR] Woken by KEY (P0=");
Uart_SendHex8(p0_wakeup_flag);
Uart_SendString(", P2=");
Uart_SendHex8(p2_wakeup_flag);
Uart_SendString(")\r\n");
XTELL_LOG("[WR] Woken by KEY (P0=");
XTELL_LOG_HEX8(p0_wakeup_flag);
XTELL_LOG(", P2=");
XTELL_LOG_HEX8(p2_wakeup_flag);
XTELL_LOG(")\r\n");
}
else if ((p2_wakeup_flag & 0x02) || rf_wakeup_flag)
{
rf_wakeup_flag = 1; // 确认标记为射频解调唤醒
Uart_SendString("[WR] Woken by RF (P2.1)!\r\n");
XTELL_LOG("[WR] Woken by RF (P2.1)!\r\n");
}
else
{
Uart_SendString("[WR] Woken by TIMER/Other\r\n");
XTELL_LOG("[WR] Woken by TIMER/Other\r\n");
}
// 5. 【屏幕供电软启动】:
@@ -422,7 +424,7 @@ void Wakeup_Restore(void)
// 9. 更新运行状态为普通时钟,并强制调用时钟界面函数刷屏,返回工作状态
current_state = STATE_NORMAL;
UI_ShowClockPage(current_state, current_hour, current_min);
Uart_SendString("[SYS] Wakeup restored!\r\n");
XTELL_LOG("[SYS] Wakeup restored!\r\n");
}
/**