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