压力监视等待初版

This commit is contained in:
2026-09-14 17:08:21 +08:00
parent 96c5fab758
commit 0bc587e989
5 changed files with 95 additions and 14 deletions
+29
View File
@@ -0,0 +1,29 @@
#ifndef PRESSUREMONITOR_H
#define PRESSUREMONITOR_H
class PressureMonitor
{
public:
PressureMonitor();
// 每个100ms tick 调用一次
// realtimePressure: 实时压力 (sysPara->status.PRESSURE)
// calibratedPressure: 标定压力 (sysPara->para.pressure)
// 返回 true 表示压力已持续稳定 3 秒
bool tick(float realtimePressure, float calibratedPressure);
// 重置监测器状态
void reset();
// 当前压力是否在 ±10% 范围内
bool isCurrentlyInRange() const;
// 当前连续稳定的 tick 计数
int stableTickCount() const;
private:
int m_stableTickCount;
static const int REQUIRED_STABLE_TICKS = 30; // 3秒 / 100ms = 30 ticks
};
#endif // PRESSUREMONITOR_H