降低报警恢复阈值

This commit is contained in:
小马_666 2025-06-23 14:05:17 +08:00
parent d73d8433ab
commit bc59c44344
3 changed files with 11 additions and 10 deletions

View File

@ -82,6 +82,7 @@
"math.h": "c", "math.h": "c",
"ctime": "c", "ctime": "c",
"bsp_wdg.h": "c", "bsp_wdg.h": "c",
"rtdbg.h": "c" "rtdbg.h": "c",
"bsp_rng.h": "c"
} }
} }

View File

@ -44,7 +44,7 @@
#define MQ_VOLTAGE_RATIO (1.74F) #define MQ_VOLTAGE_RATIO (1.74F)
// adc voltage 1000x // adc voltage 1000x
#define MQ_VOLTAGE_HIGH_LIMIT (4096U) #define MQ_VOLTAGE_HIGH_LIMIT (4095U)
#define MQ_VOLTAGE_LOW_LIMIT (100U) #define MQ_VOLTAGE_LOW_LIMIT (100U)
#define MQ_VOLTAGE_ALARM_DEFAULT (uint16_t)(2250U) #define MQ_VOLTAGE_ALARM_DEFAULT (uint16_t)(2250U)

View File

@ -2,7 +2,7 @@
* @Author : stark1898y 1658608470@qq.com * @Author : stark1898y 1658608470@qq.com
* @Date : 2024-06-18 15:48:01 * @Date : 2024-06-18 15:48:01
* @LastEditors: mbw && 1600520629@qq.com * @LastEditors: mbw && 1600520629@qq.com
* @LastEditTime: 2025-06-23 13:55:13 * @LastEditTime: 2025-06-23 14:04:29
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\src\bsp_mq.c * @FilePath: \ble_bjq_ch303rct6_ml307\bsp\src\bsp_mq.c
* @Description : * @Description :
* *
@ -125,16 +125,16 @@ static uint8_t Sensor_CheckData(void)
static rt_uint8_t index = 0; static rt_uint8_t index = 0;
rt_uint16_t voltage = Get_Gas_VoltageAdcInt1000x(); rt_uint16_t voltage = Get_Gas_VoltageAdcInt1000x();
if(alarm_flag) if(alarm_flag)//检测到报警后的报警恢复,降低其阈值
{ {
alarm_status_buffer[index] = ((voltage > (Sensor_device.alarm_value - 500)) && (voltage < MQ_VOLTAGE_HIGH_LIMIT)) ? kSensorAlarm : kSensorNormal; alarm_status_buffer[index] = (((voltage > (Sensor_device.alarm_value - 500)) && (voltage < MQ_VOLTAGE_HIGH_LIMIT)) ? kSensorAlarm : kSensorNormal);
} }
else else
{ {
alarm_status_buffer[index] = ((voltage > Sensor_device.alarm_value) && (voltage < MQ_VOLTAGE_HIGH_LIMIT)) ? kSensorAlarm : kSensorNormal; alarm_status_buffer[index] = (((voltage > Sensor_device.alarm_value) && (voltage < MQ_VOLTAGE_HIGH_LIMIT)) ? kSensorAlarm : kSensorNormal);
} }
fault_buf[index] = ((voltage < MQ_VOLTAGE_LOW_LIMIT) || (voltage > MQ_VOLTAGE_HIGH_LIMIT)) ? kSensorFault : kSensorNormal; fault_buf[index] = (((voltage < MQ_VOLTAGE_LOW_LIMIT) || (voltage > MQ_VOLTAGE_HIGH_LIMIT)) ? kSensorFault : kSensorNormal);
index++; index++;
if (index >= SENSOR_SAMPLING_TIMS) if (index >= SENSOR_SAMPLING_TIMS)
{ {
@ -193,16 +193,16 @@ static void Sensor_detection_thread_entry(void *param)
while (1)//等待标定 while (1)//等待标定
{ {
calibration_flag = Flash_Get_Calibration_State(); calibration_flag = Flash_Get_Calibration_State();
if(calibration_flag == 1) if(calibration_flag == kSysGasCalibStatus)
break; break;
rt_thread_mdelay(1000); rt_thread_mdelay(1000);
Get_Gas_VoltageAdcInt1000x(); Get_Gas_VoltageAdcInt1000x();
} }
rt_uint16_t alarm_value = Flash_Get_SysCfg(kAlarmLValueId); // 获取系统报警阈值; rt_uint16_t alarm_value = Flash_Get_SysCfg(kAlarmLValueId); // 获取系统报警阈值;
if ((alarm_value > 4095)||(alarm_value < 300)) if ((alarm_value > 4095)||(alarm_value < 1000))
{ {
alarm_value = 3400; alarm_value = 2250;
} }
Sensor_device.alarm_value = alarm_value; Sensor_device.alarm_value = alarm_value;
LOG_D("报警阈值:%d", Sensor_device.alarm_value); LOG_D("报警阈值:%d", Sensor_device.alarm_value);