zancun
This commit is contained in:
parent
588f9429b1
commit
0975c9bb02
|
@ -5,7 +5,7 @@
|
||||||
"type": "mrs-debugger",
|
"type": "mrs-debugger",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "ble_bjq_ch303rct6_ml307",
|
"name": "ble_bjq_ch303rct6_ml307",
|
||||||
"cwd": "c:\\Users\\16586\\Desktop\\ble_-tyq_-bjq_-ch32-v303",
|
"cwd": "d:\\SXDT\\Project\\CH32\\ble_bjq_ch303rct6_ml307",
|
||||||
"openOCDCfg": {
|
"openOCDCfg": {
|
||||||
"useLocalOpenOCD": true,
|
"useLocalOpenOCD": true,
|
||||||
"executable": "c:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/openocd.exe",
|
"executable": "c:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/openocd.exe",
|
||||||
|
@ -39,8 +39,8 @@
|
||||||
"additionalCommands": []
|
"additionalCommands": []
|
||||||
},
|
},
|
||||||
"loadedFiles": {
|
"loadedFiles": {
|
||||||
"executableFile": "c:\\Users\\16586\\Desktop\\ble_-tyq_-bjq_-ch32-v303\\obj\\ble_bjq_ch303rct6_ml307.elf",
|
"executableFile": "d:\\SXDT\\Project\\CH32\\ble_bjq_ch303rct6_ml307\\obj\\ble_bjq_ch303rct6_ml307.elf",
|
||||||
"symbolFile": "c:\\Users\\16586\\Desktop\\ble_-tyq_-bjq_-ch32-v303\\obj\\ble_bjq_ch303rct6_ml307.elf",
|
"symbolFile": "d:\\SXDT\\Project\\CH32\\ble_bjq_ch303rct6_ml307\\obj\\ble_bjq_ch303rct6_ml307.elf",
|
||||||
"executableFileOffset": 0,
|
"executableFileOffset": 0,
|
||||||
"symbolFileOffset": 0
|
"symbolFileOffset": 0
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @Author: mbw
|
* @Author: mbw
|
||||||
* @Date: 2024-10-23 17:14:16
|
* @Date: 2024-10-23 17:14:16
|
||||||
* @LastEditors: mbw && 1600520629@qq.com
|
* @LastEditors: mbw && 1600520629@qq.com
|
||||||
* @LastEditTime: 2025-06-21 10:00:44
|
* @LastEditTime: 2025-06-23 13:13:56
|
||||||
* @FilePath: \ble_bjq_ch303rct6_ml307\applications\main.c
|
* @FilePath: \ble_bjq_ch303rct6_ml307\applications\main.c
|
||||||
* @Descrt_thread_
|
* @Descrt_thread_
|
||||||
*
|
*
|
||||||
|
@ -153,6 +153,7 @@ void Preheat_Timer_Callback(void *parameter)
|
||||||
LED_STOP(y);
|
LED_STOP(y);
|
||||||
LOG_D("预热完成");
|
LOG_D("预热完成");
|
||||||
preheat_flag = 1;
|
preheat_flag = 1;
|
||||||
|
|
||||||
if (g_Calibration_status == kSysGasCalibStatus)
|
if (g_Calibration_status == kSysGasCalibStatus)
|
||||||
{
|
{
|
||||||
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
Send_Laser_Alarm_Event(kNormalDetectionEvents);
|
||||||
|
@ -225,44 +226,46 @@ int APP_Calibration_Handle(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
uint8_t i = 0;
|
// uint8_t i = 0;
|
||||||
uint16_t gas_buf[20] = {0};
|
// uint16_t gas_buf[10] = {0};
|
||||||
rt_memset(gas_buf, 0, sizeof(gas_buf));
|
|
||||||
// 采集10s的ADC值
|
|
||||||
for (i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
gas_buf[i] = Get_Gas_VoltageInt1000x();
|
|
||||||
if ((gas_buf[i] == 0) || (gas_buf[i] >= 5000)) // (3.3*1.784*1000)
|
|
||||||
{
|
|
||||||
Send_Laser_Alarm_Event(kNotCalibratedEvent);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
rt_thread_mdelay(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 冒泡排序(升序)
|
// rt_memset(gas_buf, 0, sizeof(gas_buf));
|
||||||
for (i = 0; i < 10 - 1; i++)
|
// // 采集10s的ADC值
|
||||||
{
|
// for (i = 0; i < 10; i++)
|
||||||
for (int j = 0; j < 10 - i - 1; j++)
|
// {
|
||||||
{
|
// gas_buf[i] = Get_Gas_VoltageInt1000x();
|
||||||
if (gas_buf[j] > gas_buf[j + 1])
|
// if ((gas_buf[i] == 0) || (gas_buf[i] >= 5000)) // (3.3*1.784*1000)
|
||||||
{
|
// {
|
||||||
uint16_t temp = gas_buf[j];
|
// Send_Laser_Alarm_Event(kNotCalibratedEvent);
|
||||||
gas_buf[j] = gas_buf[j + 1];
|
// return 0;
|
||||||
gas_buf[j + 1] = temp;
|
// }
|
||||||
}
|
// rt_thread_mdelay(500);
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
// 使用索引 1~8 的8个值求平均(即去掉一个最小和一个最大)
|
// // 冒泡排序(升序)
|
||||||
uint32_t sum = 0;
|
// for (i = 0; i < 10 - 1; i++)
|
||||||
for (i = 1; i <= 8; i++)
|
// {
|
||||||
{
|
// for (int j = 0; j < 10 - i - 1; j++)
|
||||||
sum += gas_buf[i];
|
// {
|
||||||
}
|
// if (gas_buf[j] > gas_buf[j + 1])
|
||||||
gas_calibration_voltage = (uint16_t)((sum / 8.0f) - 85);
|
// {
|
||||||
|
// uint16_t temp = gas_buf[j];
|
||||||
|
// gas_buf[j] = gas_buf[j + 1];
|
||||||
|
// gas_buf[j + 1] = temp;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 使用索引 1~8 的8个值求平均(即去掉一个最小和一个最大)
|
||||||
|
// uint32_t sum = 0;
|
||||||
|
// for (i = 1; i <= 8; i++)
|
||||||
|
// {
|
||||||
|
// sum += gas_buf[i];
|
||||||
|
// }
|
||||||
|
// gas_calibration_voltage = (uint16_t)((sum / 8.0f) - 85);
|
||||||
|
|
||||||
|
gas_calibration_voltage = (Get_Gas_VoltageInt1000x() - 50); // 写入标定值
|
||||||
|
|
||||||
// 写入标定值
|
|
||||||
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; // 高字节
|
||||||
|
|
||||||
|
@ -458,7 +461,7 @@ int main(void)
|
||||||
rt_uint16_t voltage = Get_Gas_VoltageInt1000x();
|
rt_uint16_t voltage = Get_Gas_VoltageInt1000x();
|
||||||
if (Sensor_device.detection_flag == kSensorAlarm)
|
if (Sensor_device.detection_flag == kSensorAlarm)
|
||||||
{
|
{
|
||||||
if ((voltage > Sensor_device.alarm_value) && (voltage < MQ_VOLTAGE_HIGH_LIMIT))
|
if (voltage >= Sensor_device.alarm_value)
|
||||||
{
|
{
|
||||||
Send_Laser_Alarm_Event(kAlarmEvent);
|
Send_Laser_Alarm_Event(kAlarmEvent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,6 @@ static void Sensor_HandleAlarm(uint8_t count, uint8_t threshold)
|
||||||
alarm_flag = 1;
|
alarm_flag = 1;
|
||||||
Sensor_device.detection_flag = kSensorAlarm;
|
Sensor_device.detection_flag = kSensorAlarm;
|
||||||
Send_Laser_Alarm_Event(kAlarmEvent);
|
Send_Laser_Alarm_Event(kAlarmEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (alarm_flag == 1 && count == 0)
|
else if (alarm_flag == 1 && count == 0)
|
||||||
{
|
{
|
||||||
|
@ -89,6 +88,11 @@ static void Sensor_HandleAlarm(uint8_t count, uint8_t threshold)
|
||||||
Sensor_device.detection_flag = kSensorNormal;
|
Sensor_device.detection_flag = kSensorNormal;
|
||||||
Send_Laser_Alarm_Event(kAlarmRcyEvent);
|
Send_Laser_Alarm_Event(kAlarmRcyEvent);
|
||||||
}
|
}
|
||||||
|
else if ((Get_Gas_VoltageAdcInt1000x() < 1000) && (count == 0))
|
||||||
|
{
|
||||||
|
alarm_flag = 0;
|
||||||
|
Sensor_device.detection_flag = kSensorNormal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Sensor_HandleFault(uint8_t count, uint8_t threshold)
|
static void Sensor_HandleFault(uint8_t count, uint8_t threshold)
|
||||||
|
|
Loading…
Reference in New Issue