喷淋器 P0 功能实现
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
/******************************************************************************
|
||||
* @file app_function.c
|
||||
* @brief 功能总装:喷淋键启停、任务上下文落地配对/OTA(P0 版)
|
||||
* @author cyWu <1917507415@qq.com>
|
||||
* @date 2026.09.09
|
||||
* @version V1.0.0
|
||||
* @history
|
||||
* - V1.0.0, 2026.09.09, cyWu, P0 首次发布(无 VM/联动/计划;P1+ 再扩展)
|
||||
*
|
||||
* @note ⚠ 硬约束:写 flash(清绑定)、BLE 广播切换(配对/OTA)禁止在
|
||||
* 20ms 中断上下文直跑,一律 app_defer_request 后由本模块在
|
||||
* usr_timer_loop(任务上下文)落地。
|
||||
******************************************************************************/
|
||||
|
||||
#include "system/includes.h" /* 必须先于 app_main.h:u8/u16/u32 等类型由 SDK 定义 */
|
||||
#include "app_function.h"
|
||||
#include "app_pair.h"
|
||||
#include "app_defer.h"
|
||||
#include "app_led.h"
|
||||
#include "app_spray.h"
|
||||
#include "app_main.h"
|
||||
#include "usr_le_api.h"
|
||||
#include "jb_product.h"
|
||||
#include "board_pin.h"
|
||||
|
||||
#define LOG_TAG_CONST APP
|
||||
#define LOG_TAG "[APP_FUNC]"
|
||||
#define LOG_INFO_ENABLE
|
||||
#include "debug.h"
|
||||
|
||||
/**
|
||||
* @brief 初始化功能模块
|
||||
* @return 无
|
||||
*/
|
||||
void app_function_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 任务上下文周期处理(配对 / OTA / 写 VM 只准在此落地)
|
||||
* @return 无
|
||||
*/
|
||||
void app_function_loop(void)
|
||||
{
|
||||
if (app_defer_take(APP_DEFER_OTA)) {
|
||||
app_defer_cancel(APP_DEFER_PAIR);
|
||||
usr_app_ota_init();
|
||||
app_led_request_ota();
|
||||
log_info("pair key hold 12s -> ota\n");
|
||||
} else if (app_defer_take(APP_DEFER_PAIR)) {
|
||||
usr_goto_pair_mode();
|
||||
app_pair_start();
|
||||
app_led_clear_pair_hint();
|
||||
log_info("pair key released after 5s -> pair\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 同步 DP1 = 喷淋作业态(整轮含间隔等待为 1)
|
||||
* @return 无
|
||||
*/
|
||||
void app_function_poll(void)
|
||||
{
|
||||
#if BOARD_SPRAY_ENABLE
|
||||
gDevData.spray_switch = app_spray_is_running();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 喷淋键短按:空闲用上次有效配置开一轮,作业中立刻停(OTA 中忽略)
|
||||
* @return 无
|
||||
*/
|
||||
void usr_on_key_short(void)
|
||||
{
|
||||
if (app_led_is_ota()) {
|
||||
return; /* OTA 进行中忽略(规格书 5.3) */
|
||||
}
|
||||
if (app_spray_is_running()) {
|
||||
app_spray_stop();
|
||||
log_info("spray key short -> stop\n");
|
||||
} else {
|
||||
app_spray_start();
|
||||
log_info("spray key short -> start\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 配网键按住满 5s:红灯 100ms 快闪提示(不碰绿灯,不清绑定)
|
||||
* @return 无
|
||||
*/
|
||||
void usr_on_key_pair_hint(void)
|
||||
{
|
||||
if (app_led_is_ota() || app_pair_is_active()) {
|
||||
return; /* OTA / 配对会话中忽略再次 5s(规格书 5.3) */
|
||||
}
|
||||
app_led_hint_pair();
|
||||
log_info("pair key hold 5s, red fast blink (release to pair, keep to 12s ota)\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 配网键按满 5s 后松手:置配对标志(清绑定在任务上下文)
|
||||
* @return 无
|
||||
*/
|
||||
void usr_on_key_pair_start(void)
|
||||
{
|
||||
if (app_led_is_ota() || app_pair_is_active()) {
|
||||
return; /* OTA / 配对会话中忽略(规格书 5.3) */
|
||||
}
|
||||
app_defer_request(APP_DEFER_PAIR);
|
||||
log_info("pair key 5s released, pair pending\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 配网键按住满 12s:置 OTA 标志(BLE 切换在任务上下文)
|
||||
* @return 无
|
||||
*/
|
||||
void usr_on_key_ota_start(void)
|
||||
{
|
||||
if (app_led_is_ota() || app_pair_is_active()) {
|
||||
return; /* OTA / 配对会话中忽略(规格书 5.3) */
|
||||
}
|
||||
app_defer_request(APP_DEFER_OTA);
|
||||
log_info("pair key hold 12s, ota pending\n");
|
||||
}
|
||||
Reference in New Issue
Block a user