refactor(algorithm): 移除冗余头文件 移除不必要的stdint.h头文件引用,统一使用<cstdint> refactor(sys): 清理系统级头文件依赖 移除未使用的头文件引用,统一整型类型定义,优化初始 化过程中的GPIO配置
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
#ifndef _HEALTH_H
|
|
#define _HEALTH_H
|
|
|
|
#include <cstdint>
|
|
typedef int32_t q16_16_t; // Q16.16格式
|
|
// 定点数运算宏
|
|
#define Q16_16_ONE 65536 // 1.0 in Q16.16
|
|
#define FLOAT_TO_Q16_16(x) ((q16_16_t)((x) * Q16_16_ONE))
|
|
#define Q16_16_TO_FLOAT(x) ((float)(x) / Q16_16_ONE)
|
|
#define Q16_16_MUL(a, b) ((q16_16_t)(((int64_t)(a) * (b)) >> 16))
|
|
#define Q16_16_SQUARE(x) Q16_16_MUL((x), (x))
|
|
|
|
class ThermalController {
|
|
private:
|
|
u8 temperature;
|
|
u16 current_max;
|
|
|
|
q16_16_t thermalRate; // 热耗散系数(每单位时间散热比例)
|
|
q16_16_t recoveryRate; // 自然恢复率(散热到多少以下开始工作)
|
|
|
|
u32 thermal_value = 0;
|
|
u32 thermal_capacity = 3600000; // 热容量
|
|
|
|
u16 gapTimeMs = 10; // 单次计算间隔ms
|
|
u16 remainingTime10Ms = 0; // 过热冷却剩余ms
|
|
public:
|
|
ThermalController()
|
|
: thermalRate(FLOAT_TO_Q16_16(0.995f)),
|
|
recoveryRate(FLOAT_TO_Q16_16(0.33f)) {}
|
|
u32 update();
|
|
void reset() {
|
|
thermal_value = 0;
|
|
remainingTime10Ms = 0;
|
|
}
|
|
};
|
|
|
|
void angsens_MG_check(void);
|
|
void power_manage(void);
|
|
|
|
#endif
|