calibration.h 953 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef __CALIBRATION_H__
  2. #define __CALIBRATION_H__
  3. #include <main.h>
  4. #include <stdint.h>
  5. #include <stdbool.h>
  6. #define CALIBRATION_POINTS_MAX 20 //标定组数
  7. typedef struct {
  8. float cap_value; // 电容值(精确到小数点后3位)
  9. float oil_water_ratio; // 对应的油水比例(0.0~100.0)
  10. } CalibrationPoint;
  11. typedef struct {
  12. CalibrationPoint points[CALIBRATION_POINTS_MAX];
  13. uint8_t count; // 有效点数
  14. } CalibrationTable;
  15. extern CalibrationTable g_calibrationTable;
  16. // 初始化标定模块(通常在系统启动时调用)
  17. void Calibration_Init(void);
  18. // 设置标定点
  19. bool Calibration_SetPoint(uint8_t index, float cap, float ratio);
  20. // 获取标定点
  21. bool Calibration_GetPoint(uint8_t index, float *cap, float *ratio);
  22. // 根据电容值计算油水比例(分段线性插值,返回1位小数)
  23. float Calibration_ComputeRatio(float cap);
  24. // Flash 存储
  25. #endif // __CALIBRATION_H__