Files
JBao_Heat_Lamp_FW/apps/usr_app/app_runrec.h
T

81 lines
2.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/******************************************************************************
* @file app_runrec.h
* @brief CBR0 31 天运行记录(第 13.1 节,DP20 RO,124B):实际吸合计秒
* @author cyWu <1917507415@qq.com>
* @date 2026.09.04
* @version V1.0.0P0 = 骨架(BOARD_RUNREC_ENABLE=0P2 填充)
*
* @note 什么叫在运行:过零后继电器**实际已吸合**app_relay_get_actual()==1)。
* 日期轴:未对时只往 slot[0] 加不旋转;对时后按本地日历左移。
* 落盘:每累计 600s 写一次 VM;跨天立刻写。
******************************************************************************/
#ifndef __APP_RUNREC_H__
#define __APP_RUNREC_H__
#include <stdint.h>
#include "board_pin.h"
#define APP_RUNREC_PACK_LEN (BOARD_RUN_RECORD_DAYS * 4u) /**< 124B */
/**
* @brief 初始化(未对时:只往 slot0 加,不旋转)
* @return 无
*/
void app_runrec_init(void);
/**
* @brief 20ms 节拍:继电器实际吸合则累计秒,满 10 分钟打脏(不写 flash)
* @param dt 距上次调用的毫秒数
* @return 无
*/
void app_runrec_tick(uint16_t dt);
/**
* @brief 500ms 任务上下文:收下 pending 秒并灌 DP20;对时后跨天左移旋转
* @return 无
*/
void app_runrec_rotate_if_needed(void);
/**
* @brief 读某天秒数(0=今天)
* @param day 0~30
* @return 秒
*/
uint32_t app_runrec_get(uint8_t day);
/**
* @brief 打包 124B(每格 uint32 大端),灌 gDevData.run_record
* @param out 输出缓冲(≥124B
* @return 无
*/
void app_runrec_pack(uint8_t *out);
/**
* @brief 从 VM 解包 124Buint32 大端)
* @param in 输入缓冲
* @return 无
*/
void app_runrec_unpack(const uint8_t *in);
/**
* @brief slot[0] 对应本地日期(yyyymmdd 打包)
* @return 日期
*/
uint32_t app_runrec_get_slot0_date(void);
/**
* @brief 设置 slot[0] 日期(对时/旋转后写回)
* @param ymd yyyymmdd
* @return 无
*/
void app_runrec_set_slot0_date(uint32_t ymd);
/**
* @brief 清零 31 天记录与日期(出厂重置)
* @return 无
*/
void app_runrec_reset(void);
#endif /* __APP_RUNREC_H__ */