150 lines
2.5 KiB
C
150 lines
2.5 KiB
C
/******************************************************************************
|
||
* @file app_runrec.c
|
||
* @brief CBR1 31 天运行记录骨架(P0:BOARD_RUNREC_ENABLE=0)
|
||
* @author cyWu <1917507415@qq.com>
|
||
* @date 2026.09.04
|
||
* @version V1.0.0,P2 填充实现(接口见 app_runrec.h)
|
||
******************************************************************************/
|
||
|
||
#include "system/includes.h"
|
||
#include "app_runrec.h"
|
||
#include "app_relay.h"
|
||
#include "board_pin.h"
|
||
|
||
#define LOG_TAG_CONST APP
|
||
#define LOG_TAG "[RUNREC]"
|
||
#define LOG_INFO_ENABLE
|
||
#include "debug.h"
|
||
|
||
static void runrec_disabled_once(void)
|
||
{
|
||
static uint8_t s_logged;
|
||
|
||
if (!s_logged) {
|
||
s_logged = 1;
|
||
log_info("app_runrec disabled (P2)\n");
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @brief 初始化
|
||
* @return 无
|
||
*/
|
||
void app_runrec_init(void)
|
||
{
|
||
#if BOARD_RUNREC_ENABLE
|
||
/* P2: 先灌 VM,未对时只加 slot0 */
|
||
#else
|
||
runrec_disabled_once();
|
||
#endif
|
||
}
|
||
|
||
/**
|
||
* @brief 20ms 节拍:实际吸合才累计
|
||
* @param dt 距上次调用的毫秒数
|
||
* @return 无
|
||
*/
|
||
void app_runrec_tick(uint16_t dt)
|
||
{
|
||
#if BOARD_RUNREC_ENABLE
|
||
if (app_relay_get_actual()) {
|
||
/* P2: s_pend_ms += dt; 满 600s → mark_dirty */
|
||
}
|
||
#else
|
||
(void)dt;
|
||
#endif
|
||
}
|
||
|
||
/**
|
||
* @brief 500ms 任务上下文:跨天旋转 + 灌 DP17
|
||
* @return 无
|
||
*/
|
||
void app_runrec_rotate_if_needed(void)
|
||
{
|
||
#if BOARD_RUNREC_ENABLE
|
||
/* P2 */
|
||
#else
|
||
runrec_disabled_once();
|
||
#endif
|
||
}
|
||
|
||
/**
|
||
* @brief 读某天秒数
|
||
* @param day 0~30
|
||
* @return 秒(P0 全 0)
|
||
*/
|
||
uint32_t app_runrec_get(uint8_t day)
|
||
{
|
||
#if BOARD_RUNREC_ENABLE
|
||
(void)day;
|
||
return 0;
|
||
#else
|
||
(void)day;
|
||
return 0;
|
||
#endif
|
||
}
|
||
|
||
/**
|
||
* @brief 打包 124B
|
||
* @param out 输出缓冲
|
||
* @return 无
|
||
*/
|
||
void app_runrec_pack(uint8_t *out)
|
||
{
|
||
#if BOARD_RUNREC_ENABLE
|
||
(void)out;
|
||
#else
|
||
(void)out;
|
||
#endif
|
||
}
|
||
|
||
/**
|
||
* @brief 解包 124B
|
||
* @param in 输入缓冲
|
||
* @return 无
|
||
*/
|
||
void app_runrec_unpack(const uint8_t *in)
|
||
{
|
||
#if BOARD_RUNREC_ENABLE
|
||
(void)in;
|
||
#else
|
||
(void)in;
|
||
#endif
|
||
}
|
||
|
||
/**
|
||
* @brief slot[0] 日期
|
||
* @return 日期
|
||
*/
|
||
uint32_t app_runrec_get_slot0_date(void)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
/**
|
||
* @brief 设置 slot[0] 日期
|
||
* @param ymd yyyymmdd
|
||
* @return 无
|
||
*/
|
||
void app_runrec_set_slot0_date(uint32_t ymd)
|
||
{
|
||
#if BOARD_RUNREC_ENABLE
|
||
(void)ymd;
|
||
#else
|
||
(void)ymd;
|
||
#endif
|
||
}
|
||
|
||
/**
|
||
* @brief 清零(出厂重置)
|
||
* @return 无
|
||
*/
|
||
void app_runrec_reset(void)
|
||
{
|
||
#if BOARD_RUNREC_ENABLE
|
||
/* P2: 全 0 + 日期清 */
|
||
#else
|
||
runrec_disabled_once();
|
||
#endif
|
||
}
|