将标定值从fabs改为abs整数绝对值
This commit is contained in:
parent
85ec85f8d5
commit
faf02abe81
|
@ -176,8 +176,9 @@ uint16_t Get_Stable_Reading(uint8_t cnt, uint32_t timeout_ms)
|
||||||
while ((rt_tick_get() - start) < timeout_ms)
|
while ((rt_tick_get() - start) < timeout_ms)
|
||||||
{
|
{
|
||||||
current = Get_Gas_VoltageAdcInt1000x();
|
current = Get_Gas_VoltageAdcInt1000x();
|
||||||
|
|
||||||
uint16_t diff = fabs(current - last); // 差值
|
uint16_t diff = abs(current - last); // 差值
|
||||||
|
|
||||||
if (diff < STABLE_THRESHOLD)
|
if (diff < STABLE_THRESHOLD)
|
||||||
{
|
{
|
||||||
stable_count++;
|
stable_count++;
|
||||||
|
@ -288,16 +289,17 @@ int APP_Calibration_Handle(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
calibration_buf[0] = gas_calibration_voltage & 0xFF; // 低字节
|
calibration_buf[0] = (gas_calibration_voltage & 0xFF); // 低字节
|
||||||
calibration_buf[1] = (gas_calibration_voltage >> 8) & 0xFF; // 高字节
|
calibration_buf[1] = ((gas_calibration_voltage >> 8) & 0xFF); // 高字节
|
||||||
LOG_D("calibration_buf[0] = %X calibration_buf[1] = %X", calibration_buf[0], calibration_buf[1]);
|
LOG_D("calibration_buf[0] = %X calibration_buf[1] = %X", calibration_buf[0], calibration_buf[1]);
|
||||||
Flash_Sys_Cfg(kAlarmLValueId, calibration_buf, 2);
|
Flash_Sys_Cfg(kAlarmLValueId, calibration_buf, 2);
|
||||||
LOG_D("标定完成");
|
LOG_D("标定完成");
|
||||||
Calibration_flag = 0;
|
Calibration_flag = 0;
|
||||||
Flash_Set_Calibration_State(kSysGasCalibStatus);
|
Flash_Set_Calibration_State(kSysGasCalibStatus);
|
||||||
g_Calibration_status = kSysGasCalibStatus;
|
g_Calibration_status = kSysGasCalibStatus;
|
||||||
|
|
||||||
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
||||||
return 0;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue