Files
JBao_Magic_Box_FW/apps/usr_app/app_function.h
T
2026-08-25 14:59:39 +08:00

95 lines
2.6 KiB
C

/******************************************************************************
* @file app_function.h
* @brief 设备功能开关(DP0)+ 自动玩法(DP1)+ 手动点动(DP2)+ 按键动作
* @author cyWu <1917507415@qq.com>
* @date 2026.08.25
* @version V1.0.0
* @history
* - V1.0.0, 2026.08.25, cyWu, 从 usr_jb_main 拆出,状态收进 AppFunctionCtx_t
*
* @note 本模块决定“电机现在该不该转、转哪种”,会读 app_power/app_pair 的
* 状态作为阻塞条件(充电中/深睡中/配对中都不能转),也会触发
* app_led 的一次性提示灯(切模式闪、开机绿灯),但不会被它们反向依赖。
******************************************************************************/
#ifndef __APP_FUNCTION_H__
#define __APP_FUNCTION_H__
#include <stdint.h>
/**
* @brief 初始化功能模块状态(电机停,DP0=1 视调用方而定)
* @return 无
*/
void app_function_init(void);
/**
* @brief DP2 写入钩子:仅记录第 1 字节,真正执行在 app_function_poll
* @param cmd 0=空闲,1=顺时针,2=逆时针,3=停
* @return 无
*/
void app_function_dp_hand_write(uint8_t cmd);
/**
* @brief 跟随 APP 下发的 DP0/DP1,并处理 DP2 手动点动,每个业务 tick 调用一次
* @return 无
*/
void app_function_poll(void);
/**
* @brief 推进当前玩法节拍或手动刹车,每个业务 tick 调用一次
* @param dt 距上次调用的毫秒数
* @return 无
*/
void app_function_tick_1ms(uint16_t dt);
/**
* @brief 停手动 + 自动模式,并清 DP1(USB 插入 / 请求关机时用)
* @return 无
*/
void app_function_stop_all(void);
/**
* @brief 软关:电机停、DP0=0,等 APP/短按再开(USB 拔出 / APP 关时用)
* @return 无
*/
void app_function_soft_off(void);
/**
* @brief 上电默认开启功能(DP0=1),不带开机灯效提示
* @return 无
*/
void app_function_power_on_silent(void);
/**
* @brief 查询功能开关状态(DP0)
* @return 1=开,0=关
*/
uint8_t app_function_is_power_on(void);
/**
* @brief 查询手动点动是否进行中
* @return 1=进行中,0=空闲
*/
uint8_t app_function_is_hand_busy(void);
/**
* @brief 查询当前自动玩法编号
* @return 0=停转,1~6=对应玩法
*/
uint8_t app_function_play_mode(void);
/**
* @brief 业务层短按回调:由 key_manager 触发(key_manager.h 声明)
* @return 无
*/
void usr_on_key_short(void);
/**
* @brief 业务层长按 3s 回调:由 key_manager 触发(key_manager.h 声明)
* @return 无
*/
void usr_on_key_long(void);
#endif /* __APP_FUNCTION_H__ */