docs: 重构系统层级为自下而上,剥离独立事件管理模块,全量校正GPIO引脚映射为原理图线标
This commit is contained in:
@@ -52,40 +52,40 @@
|
||||
### 2.1 五层软件架构模型
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
%% 5层立体依赖结构
|
||||
subgraph LayerApps ["1. 应用业务层 Applications"]
|
||||
graph BT
|
||||
%% 自下而上的 5 层软件依赖拓扑
|
||||
subgraph Layer5 ["5. 应用业务层 Applications"]
|
||||
ActiveApp["当前活跃应用 Foreground App"]
|
||||
BgApp["后台监测应用 Background App"]
|
||||
end
|
||||
|
||||
subgraph LayerAppMgr ["2. 应用管理层 APP Management"]
|
||||
subgraph Layer4 ["4. 应用管理层 APP Management"]
|
||||
AppManager["APP 管理器 StartApp / CloseApp"]
|
||||
Lifecycle["生命周期调度机"]
|
||||
end
|
||||
|
||||
subgraph LayerEvent ["3. 事件总线层 Event Layer"]
|
||||
subgraph Layer3 ["3. 事件管理与总线层 Event Layer"]
|
||||
EventDispatcher["事件分配器 Event Dispatcher"]
|
||||
EventQueue["事件环形缓冲区 EventQueue"]
|
||||
end
|
||||
|
||||
subgraph LayerDrivers ["4. 中断与驱动层 Drivers"]
|
||||
subgraph Layer2 ["2. 中断与驱动层 Drivers"]
|
||||
ExtInt["外部中断 KEY按键扫描 / RF解码"]
|
||||
TimeInt["时钟中断 Timer1 1ms时基"]
|
||||
ADC_Drv["ADC 电量采集"]
|
||||
LCD_Drv["LCD 屏幕绘制驱动"]
|
||||
end
|
||||
|
||||
subgraph LayerHW ["5. 硬件实体层 STC32 HW"]
|
||||
subgraph Layer1 ["1. 硬件实体层 STC32 HW"]
|
||||
MCU["STC32G 单片机核心"]
|
||||
end
|
||||
|
||||
%% 单向数据与控制交互
|
||||
LayerHW ===> LayerDrivers
|
||||
LayerDrivers ===>|异步推送事件| LayerEvent
|
||||
LayerEvent ===>|事件分发路由| LayerAppMgr
|
||||
LayerAppMgr ===>|生命周期回调与分发| LayerApps
|
||||
LayerApps ===>|调用显示/报警动作| LayerDrivers
|
||||
%% 单向数据与控制交互 (自下而上)
|
||||
MCU ===> Layer2
|
||||
Layer2 ===>|异步推送事件| Layer3
|
||||
Layer3 ===>|事件分发路由| Layer4
|
||||
Layer4 ===>|生命周期回调与分发| Layer5
|
||||
Layer5 ===>|调用显示/报警动作| Layer2
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -677,7 +677,7 @@
|
||||
|
||||
<!-- 1. 应用业务层 (Applications) -->
|
||||
<div class="layer-row apps-layer" id="layer-apps-row">
|
||||
<span class="layer-title-tag">1. 应用业务层 (Applications Layer) - 实现 OnStart, onRun, onClose, onEvent</span>
|
||||
<span class="layer-title-tag">5. 应用业务层 (Applications Layer) - 实现 OnStart, onRun, onClose, onEvent</span>
|
||||
<div class="module-card apps-node" id="ActiveApp" onclick="selectModule('ActiveApp')">
|
||||
<div class="module-title">ActiveApp</div>
|
||||
<div class="module-tag">当前前台应用</div>
|
||||
@@ -690,7 +690,7 @@
|
||||
|
||||
<!-- 2. 应用管理层 (APP Management) -->
|
||||
<div class="layer-row appmgr-layer" id="layer-appmgr-row">
|
||||
<span class="layer-title-tag">2. 应用管理层 (APP Management Layer) - 生命周期与页面管理</span>
|
||||
<span class="layer-title-tag">4. 应用管理层 (APP Management Layer) - 生命周期与页面管理</span>
|
||||
<div class="module-card appmgr-node" id="AppManager" onclick="selectModule('AppManager')">
|
||||
<div class="module-title">AppManager</div>
|
||||
<div class="module-tag">App 启动与关闭</div>
|
||||
@@ -701,9 +701,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3. 事件总线层 (Event Layer) -->
|
||||
<!-- 3. 事件总线与分配层 (Event & Dispatcher Layer) -->
|
||||
<div class="layer-row event-layer" id="layer-event-row">
|
||||
<span class="layer-title-tag">3. 事件总线层 (Event Layer) - 系统解耦消息总线</span>
|
||||
<span class="layer-title-tag">3. 事件总线与分配层 (Event & Dispatcher Layer) - 系统解耦消息总线</span>
|
||||
<div class="module-card event-node" id="EventQueue" onclick="selectModule('EventQueue')">
|
||||
<div class="module-title">EventQueue</div>
|
||||
<div class="module-tag">事件环形队列</div>
|
||||
@@ -716,7 +716,7 @@
|
||||
|
||||
<!-- 4. 中断与驱动层 (Drivers) -->
|
||||
<div class="layer-row drivers-layer" id="layer-drivers-row">
|
||||
<span class="layer-title-tag">4. 中断与驱动层 (Drivers Layer) - 中断捕获与硬件驱动</span>
|
||||
<span class="layer-title-tag">2. 中断与驱动层 (Drivers Layer) - 中断捕获与硬件驱动</span>
|
||||
<div class="module-card drivers-node" id="KEY" onclick="selectModule('KEY')">
|
||||
<div class="module-title">KEY (按键)</div>
|
||||
<div class="module-tag">外部中断与消抖</div>
|
||||
@@ -745,7 +745,7 @@
|
||||
|
||||
<!-- 5. 硬件实体层 (STC32 HW) -->
|
||||
<div class="layer-row hw-layer" id="layer-hw-row">
|
||||
<span class="layer-title-tag">5. 硬件实体层 (STC32 HW Layer) - MCU物理寄存器及引脚</span>
|
||||
<span class="layer-title-tag">1. 硬件实体层 (STC32 HW Layer) - MCU物理寄存器及引脚</span>
|
||||
<div class="module-card hw-node" id="MCU" onclick="selectModule('MCU')">
|
||||
<div class="module-title">STC32G MCU</div>
|
||||
<div class="module-tag">GPIO & Peripherals</div>
|
||||
@@ -953,11 +953,11 @@
|
||||
本工程手环固件采用 **事件驱动式的 App 生命周期框架**(Event-Driven App-Framework)。整个软件系统划分为五个层级:
|
||||
</p>
|
||||
<ul>
|
||||
<li><strong>1. 应用业务层 (Applications)</strong>:各个独立的业务(如时钟显示、配对管理、主动紧急求救)被封装为具有统一回调接口的 App 对象。各 App 不得直接竞争 CPU 时间片。</li>
|
||||
<li><strong>2. 应用管理层 (APP Management)</strong>:提供 `StartApp` / `CloseApp` 接口调度活跃 App,控制页面跳转及 App 生命周期钩子(OnStart、onRun、onClose、onEvent)的执行。</li>
|
||||
<li><strong>3. 事件总线层 (Event Layer)</strong>:提供数据解耦。底层中断产生物理事件(KeyEvent/RFEvent)后封装并压入环形事件队列。主循环从中 Pop 出事件,并调用活跃 App 的 `onEvent` 回调接口消费。</li>
|
||||
<li><strong>4. 中断与驱动层 (Drivers)</strong>:按键移位检测、RF解调算法、Timer1 定时器时基心跳、AMOLED 显示渲染、WS2812B 幻彩 LED 控制及马达振动波形时序。</li>
|
||||
<li><strong>5. 硬件实体层 (STC32 HW)</strong>:STC32G12K128 单片机的寄存器和 GPIO 引脚。</li>
|
||||
<li><strong>5. 应用业务层 (Applications)</strong>:各个独立的业务(如时钟显示、配对管理、主动紧急求救)被封装为具有统一回调接口的 App 对象。各 App 不得直接竞争 CPU 时间片。</li>
|
||||
<li><strong>4. 应用管理层 (APP Management)</strong>:提供 `StartApp` / `CloseApp` 接口调度活跃 App,控制页面跳转及 App 生命周期钩子(OnStart、onRun、onClose、onEvent)的执行。</li>
|
||||
<li><strong>3. 事件总线与分配层 (Event & Dispatcher Layer)</strong>:提供数据解耦。底层中断产生物理事件(KeyEvent/RFEvent)后封装并压入环形事件队列。主循环从中 Pop 出事件,并调用活跃 App 的 `onEvent` 回调接口消费。</li>
|
||||
<li><strong>2. 中断与驱动层 (Drivers)</strong>:按键移位检测、RF解调算法、Timer1 定时器时基心跳、AMOLED 显示渲染、WS2812B 幻彩 LED 控制及马达振动波形时序。</li>
|
||||
<li><strong>1. 硬件实体层 (STC32 HW)</strong>:STC32G12K128 单片机的寄存器和 GPIO 引脚。</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -1015,7 +1015,7 @@ typedef struct {
|
||||
ActiveApp: {
|
||||
title: "ActiveApp (前台活跃应用)",
|
||||
pin: "无物理引脚 (处于应用业务层)",
|
||||
level: "1. 应用业务层 (Applications)",
|
||||
level: "5. 应用业务层 (Applications)",
|
||||
hwsource: "App 管理生命周期注册",
|
||||
file: "App/main.c (WristbandApp 实体实例)",
|
||||
inputs: ["AppManager (被调用生命周期 OnStart/onRun/onClose/onEvent)"],
|
||||
@@ -1025,7 +1025,7 @@ typedef struct {
|
||||
BgApp: {
|
||||
title: "BgApp (后台监测应用)",
|
||||
pin: "无物理引脚 (处于应用业务层)",
|
||||
level: "1. 应用业务层 (Applications)",
|
||||
level: "5. 应用业务层 (Applications)",
|
||||
hwsource: "App 管理器后台轮询",
|
||||
file: "App/main.c (系统后台守护线程)",
|
||||
inputs: ["EventDispatcher (接收对码/报警事件)"],
|
||||
@@ -1035,7 +1035,7 @@ typedef struct {
|
||||
AppManager: {
|
||||
title: "AppManager (APP 管理器)",
|
||||
pin: "无物理引脚",
|
||||
level: "2. 应用管理层 (APP Management)",
|
||||
level: "4. 应用管理层 (APP Management)",
|
||||
hwsource: "App 业务层逻辑跳转",
|
||||
file: "App/main.c (StartApp / CloseApp)",
|
||||
inputs: ["ActiveApp (页面返回请求)", "BgApp (强制报警抢占)"],
|
||||
@@ -1045,7 +1045,7 @@ typedef struct {
|
||||
Lifecycle: {
|
||||
title: "Lifecycle (生命周期调度机)",
|
||||
pin: "无物理引脚",
|
||||
level: "2. 应用管理层 (APP Management)",
|
||||
level: "4. 应用管理层 (APP Management)",
|
||||
hwsource: "AppManager",
|
||||
file: "App/main.c (回调指针分发)",
|
||||
inputs: ["AppManager"],
|
||||
@@ -1055,7 +1055,7 @@ typedef struct {
|
||||
EventQueue: {
|
||||
title: "EventQueue (事件环形队列)",
|
||||
pin: "无物理引脚 (软件 FIFO 缓冲)",
|
||||
level: "3. 事件总线层 (Event Layer)",
|
||||
level: "3. 事件总线与分配层 (Event & Dispatcher Layer)",
|
||||
hwsource: "KEY / RF 中断驱动打包推送",
|
||||
file: "App/main.c (key_event_buf)",
|
||||
inputs: ["KEY (压入按键)", "RF (压入射频对码/报警)"],
|
||||
@@ -1065,7 +1065,7 @@ typedef struct {
|
||||
EventDispatcher: {
|
||||
title: "EventDispatcher (事件路由器)",
|
||||
pin: "无物理引脚",
|
||||
level: "3. 事件总线层 (Event Layer)",
|
||||
level: "3. 事件总线与分配层 (Event & Dispatcher Layer)",
|
||||
hwsource: "EventQueue 队列输出",
|
||||
file: "App/main.c (事件分发逻辑)",
|
||||
inputs: ["EventQueue (读取待分发事件)"],
|
||||
@@ -1095,7 +1095,7 @@ typedef struct {
|
||||
Timer1: {
|
||||
title: "Timer1 (定时器中断时基)",
|
||||
pin: "单片机内部 16位 定时器 1",
|
||||
level: "4. 中断与驱动层 (Drivers)",
|
||||
level: "2. 中断与驱动层 (Drivers)",
|
||||
hwsource: "MCU 24MHz 晶振时钟源",
|
||||
file: "App/main.c (Timer1_Isr)",
|
||||
inputs: ["MCU (内部主频脉冲)"],
|
||||
@@ -1105,7 +1105,7 @@ typedef struct {
|
||||
LCD: {
|
||||
title: "LCD DRV (Truly 屏幕绘制)",
|
||||
pin: "Pin 9-14 (P5.4-P3.1 SPI控制总线)",
|
||||
level: "4. 中断与驱动层 (Drivers)",
|
||||
level: "2. 中断与驱动层 (Drivers)",
|
||||
hwsource: "Truly 0.95寸 AMOLED 屏 (RM69310)",
|
||||
file: "Drivers/lcd.c, Drivers/lcd.h",
|
||||
inputs: ["ActiveApp (重绘渲染指令)"],
|
||||
@@ -1115,7 +1115,7 @@ typedef struct {
|
||||
LED: {
|
||||
title: "LED (WS2812B 幻彩级联驱动)",
|
||||
pin: "Pin 27 (P2.6 / LED_RGB 控制脚)",
|
||||
level: "4. 中断与驱动层 (Drivers)",
|
||||
level: "2. 中断与驱动层 (Drivers)",
|
||||
hwsource: "WS2812B 级联双彩色灯",
|
||||
file: "App/main.c (WS2812_WriteRGB)",
|
||||
inputs: ["ActiveApp (指示灯亮起请求)", "Timer1 (闪烁维持计数)"],
|
||||
@@ -1125,7 +1125,7 @@ typedef struct {
|
||||
MOTOR: {
|
||||
title: "MOTOR (马达异步震动驱动)",
|
||||
pin: "Pin 25 (P2.4 / MOTOR_PWM 脚)",
|
||||
level: "4. 中断与驱动层 (Drivers)",
|
||||
level: "2. 中断与驱动层 (Drivers)",
|
||||
hwsource: "振动马达驱动晶体管",
|
||||
file: "App/main.c (Motor_Start_Pattern)",
|
||||
inputs: ["ActiveApp (按键反馈/告警指令)", "Timer1 (1ms分频状态处理)"],
|
||||
@@ -1135,7 +1135,7 @@ typedef struct {
|
||||
MCU: {
|
||||
title: "STC32G MCU (单片机寄存器物理层)",
|
||||
pin: "Pin 1-32",
|
||||
level: "5. 硬件实体层 (STC32 HW)",
|
||||
level: "1. 硬件实体层 (STC32 HW)",
|
||||
hwsource: "物理硬件芯片",
|
||||
file: "Drivers/stc32g.h (底层寄存器声明)",
|
||||
inputs: ["外部物理信号沿跳变 / 电池电压"],
|
||||
|
||||
Reference in New Issue
Block a user