From 0d6721e6e0a2cba0439b02044ec9ff18faaee3bf Mon Sep 17 00:00:00 2001 From: stark1898y <1658608470@qq.com> Date: Tue, 24 Jun 2025 16:29:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98=E4=B8=80=E4=B8=AA=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .template | 2 +- applications/main.c | 6 +++--- ble_bjq_ch303rct6_ml307.wvproj | 2 +- bsp/inc/bsp_mq.h | 2 +- bsp/src/bsp_hr.c | 10 +++++----- bsp/src/bsp_mq.c | 16 +++------------- 6 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.template b/.template index 412cf1d..05fefdd 100644 --- a/.template +++ b/.template @@ -20,4 +20,4 @@ Reset=true SDIPrintf=false Disable Power Output=false Clear CodeFlash=false -Disable Code-Protect=false \ No newline at end of file +Disable Code-Protect=true \ No newline at end of file diff --git a/applications/main.c b/applications/main.c index adfe899..4bd06a7 100644 --- a/applications/main.c +++ b/applications/main.c @@ -175,7 +175,7 @@ uint16_t Get_Stable_Reading(uint8_t cnt, uint32_t timeout_ms) uint16_t current; uint8_t stable_count = 0; uint16_t gas_buf[20] = {0};//传入的cnt不能大于这个数组大小 - uint16_t gas_value = 0; + // uint16_t gas_value = 0; uint32_t sum = 0; while ((rt_tick_get() - start) < timeout_ms) @@ -241,7 +241,7 @@ int APP_Calibration_Handle(void) Send_Laser_Alarm_Event(kNotCalibratedEvent); return RT_EOK; } - gas_calibration_voltage = Get_Stable_Reading(10, 10000); // 10s内连续10稳定,则认为其标定浓度稳定,进行标定 + gas_calibration_voltage = (Get_Stable_Reading(10, 10000) - 10); // 10s内连续10稳定,则认为其标定浓度稳定,进行标定 if ((gas_calibration_voltage == 0)||(gas_calibration_voltage >= 0xfff)) { LOG_D("标定超时,标定错误"); @@ -276,7 +276,7 @@ int main(void) BSP_SYS_Init(); work_duration = Flash_Get_WorkDuration(); LOG_D("工作时长:%d", work_duration); - // 读取历史记录总数 + // g_Calibration_status = Flash_Get_Calibration_State(); //这种方法,当纽扣电池没电,直接完蛋,但是5年应该能撑住 diff --git a/ble_bjq_ch303rct6_ml307.wvproj b/ble_bjq_ch303rct6_ml307.wvproj index 766de64..49043a4 100644 --- a/ble_bjq_ch303rct6_ml307.wvproj +++ b/ble_bjq_ch303rct6_ml307.wvproj @@ -779,7 +779,7 @@ "sdiPrintf": false, "disablepowerout": false, "clearcodeflash": false, - "disablecodeprotect": false, + "disablecodeprotect": true, "exepath": "", "exearguments": "" }, diff --git a/bsp/inc/bsp_mq.h b/bsp/inc/bsp_mq.h index 9589636..fadb132 100644 --- a/bsp/inc/bsp_mq.h +++ b/bsp/inc/bsp_mq.h @@ -44,7 +44,7 @@ #define MQ_VOLTAGE_RATIO (1.74F) // adc voltage 1000x -#define MQ_VOLTAGE_HIGH_LIMIT (4095U) +#define MQ_VOLTAGE_HIGH_LIMIT (4000U) #define MQ_VOLTAGE_LOW_LIMIT (100U) #define MQ_VOLTAGE_ALARM_DEFAULT (uint16_t)(2250U) diff --git a/bsp/src/bsp_hr.c b/bsp/src/bsp_hr.c index 8704428..fbf9b6a 100644 --- a/bsp/src/bsp_hr.c +++ b/bsp/src/bsp_hr.c @@ -460,8 +460,8 @@ int Process_Factor_Cmd(const char *rx_buff, size_t length) time_buf[5], time_buf[4], time_buf[3], cnt, imei, imsi, iccid); BSP_Hr_Send_Data(buf, rt_strlen(buf)); - - + + Flash_GetProductTimeLimit(&ReadLimitTime, kFactoryTimeId); if ((ReadLimitTime.Struct.year != 2000 + time_buf[5])&& (ReadLimitTime.Struct.month != time_buf[4])&& @@ -470,14 +470,14 @@ int Process_Factor_Cmd(const char *rx_buff, size_t length) RTC_GetTime(); Flash_SetProductTimeLimit(2000 + time_buf[5], time_buf[4], time_buf[3], RtcDateTime.hour, RtcDateTime.minute, RtcDateTime.second, kFactoryTimeId); Flash_SetProductTimeLimit(2000 + time_buf[5] + 8, time_buf[4], time_buf[3], RtcDateTime.hour, RtcDateTime.minute, RtcDateTime.second, kExpirationTimeId); - - } + + } } else { LOG_E("[%s] is not set\r\n", "factory time"); BSP_Hr_Send_Data("factory time is not set\r\n", rt_strlen("factory time is not set\r\n")); - } + } return RT_EOK; } // else if (rt_strcmp(cmd, factory_cmd2) == 0) // 比较接收到的字符串与 factory_cmd2 diff --git a/bsp/src/bsp_mq.c b/bsp/src/bsp_mq.c index b1ce5a5..66a7b32 100644 --- a/bsp/src/bsp_mq.c +++ b/bsp/src/bsp_mq.c @@ -8,16 +8,6 @@ * * Copyright (c) 2024 by yzy, All Rights Reserved. */ -/* - * @Author : yzy - * @Date : 2023-01-30 15:40:07 - * @LastEditors : stark1898y 1658608470@qq.com - * @LastEditTime : 2025-06-20 17:30:09 - * @FilePath : \JT-DT-YD1F01_RTT_Nano\bsp\src\bsp_mq.c - * @Description : - * - * Copyright (c) 2023 by yzy, All Rights Reserved. - */ #include "bsp_mq.h" #include "bsp_adc.h" #include "bsp_flash.h" @@ -92,7 +82,7 @@ static void Sensor_HandleAlarm(uint8_t count, uint8_t threshold) Sensor_device.detection_flag = kSensorNormal; Send_Laser_Alarm_Event(kAlarmRcyEvent); } - else + else { if ((Get_Gas_VoltageAdcInt1000x() < 1000) && (count == 0)) { @@ -130,11 +120,11 @@ static uint8_t Sensor_CheckData(void) if(alarm_flag)//检测到报警后的报警恢复,降低其阈值 { - alarm_status_buffer[index] = (((voltage > (Sensor_device.alarm_value - 200)) && (voltage < MQ_VOLTAGE_HIGH_LIMIT)) ? kSensorAlarm : kSensorNormal); + alarm_status_buffer[index] = (((voltage > (Sensor_device.alarm_value - 150)) && (voltage < MQ_VOLTAGE_HIGH_LIMIT)) ? kSensorAlarm : kSensorNormal); } 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);