Files
stc32g128k/App/app_manager.h

80 lines
2.9 KiB
C
Raw Normal View History

#ifndef __APP_MANAGER_H__
#define __APP_MANAGER_H__
#include "config.h"
// 动态挂载的 WristbandApp 控制块定义
typedef struct WristbandApp {
u8 app_id; // 应用唯一识别 ID
char *app_name; // 应用名称
void (*OnStart)(void); // 启动生命周期,进入前台时调用
void (*onRun)(void); // 轮询生命周期,主循环每次被调度
void (*onClose)(void); // 关闭生命周期,退出前台/后台时清理资源
EventResult (*onEvent)(SystemEvent *evt); // 事件处理生命周期,接收按键事件
} WristbandApp;
/**
* @brief
* @details NULL
*/
void AppManager_Init(void);
/**
* @brief
* @param app
* @return bit 1-0-
* @details
* 1. onClose()
* 2. fg_app app
* 3. app OnStart()
*/
bit AppManager_SwitchToForeground(WristbandApp *app);
/**
* @brief
* @param app
* @return bit 1-0-
* @details 3 onRun
*/
bit AppManager_AttachToBackground(WristbandApp *app);
/**
* @brief
* @param app
* @details onClose()
*/
void AppManager_DetachFromBackground(WristbandApp *app);
/**
* @brief
* @param evt
*/
void AppManager_DispatchEvent(SystemEvent evt);
/**
* @brief
* @details fg_app onRun() bg_apps onRun()
*/
void AppManager_RunActiveApp(void);
/**
* @brief ID
* @return u8 ID 255 (0xFF)
*/
u8 AppManager_GetActiveAppID(void);
// 兼容性接口声明
void AppManager_StartApp(AppID app_id);
// ====== 系统中各独立 App 实例的外包声明 (各 App 内部进行实体定义) ======
extern WristbandApp home_app;
extern WristbandApp menu_app;
extern WristbandApp set_clock_app;
extern WristbandApp pair_app;
extern WristbandApp ipc_bind_app;
extern WristbandApp alarm_app;
extern WristbandApp sos_app;
extern WristbandApp rf_monitor_app; // 后台射频监控应用
#endif // __APP_MANAGER_H__