Files
VX5_KRO_GearPump/PressureMonitor.h
T
2026-09-14 17:08:21 +08:00

29 lines
744 B
C++

#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