zhunk пре 5 месеци
родитељ
комит
c32e13ee5e

+ 1 - 1
Application_cbd_apm32f1/applications/control.h

@@ -16,7 +16,7 @@
 //定制相关//////////////////////////////////////////////////////
 
 #define SENSOR_EN        0            //温湿度:0关闭,1打开
-
+#define RPS_EN           0            //雨控检测:0关闭,1打开
 
 ////////////////////////////////////////////////////////////////
 

+ 0 - 1
Application_cbd_apm32f1/applications/hmi.c

@@ -919,7 +919,6 @@ static void Ctr_Mortor_entry(void* parameter)
             ctr_RTU_DTU(ON);
         }
         #endif
-
         //拍照
         if(device_status.photo_ws ==2){
             ctr_led(ON);

+ 44 - 45
Application_cbd_apm32f1/applications/sht30_collect.c

@@ -142,61 +142,80 @@ int UART_485_INIT(void)
     return 0;
 }
 
-
-
 /* 入口函数 */
-static void sht30_collect_thread_entry(void *parameter)
+static void adc_collect_thread_entry(void *parameter)
 {
     static int checklightnum = 0;
     static int checknightnum = 0;
+    static int checkrain_num = 0;
+    static int checkrain_unlock = 0;
+    static unsigned int rain_value = 0;
+    static unsigned int light_value = 0;
+    const unsigned int log_freq = 100;  //100ms
+    static unsigned log_cnt = 0;
     while (1)
     {
-        if(Read_Light_Voltage()>500)
+        log_cnt ++;
+        rain_value= Read_Rain_Voltage();
+        light_value= Read_Light_Voltage();
+        if(light_value>500)
         {
             checklightnum++;
-            if(checklightnum==20)
+            if(checklightnum==1000)     //100s
             {
                 device_status.sun_status = 1;
-                device_status.C01 |= (1<<6);
                 checklightnum =0;
             }
-
         }
         else {
             checknightnum ++;
-            if(checknightnum==20)
+            if(checknightnum==1000)     //100s
             {
-                device_status.C01 &= ~(1<<6);
                 device_status.sun_status = 0;
                 checknightnum = 0;
             }
         }
-        //异常处理,参数丢失
-        if(device_status.tph==0){
-            device_status.tph = 70;
-            device_status.tpl = 5;
-            device_status.startBar = 9;    //定时开始时间
-            device_status.stopBar  = 17;     //定时结束时间
-        }
         //温控
         if(atoi(device_status.tempture)>=device_status.tph||atoi(device_status.tempture)<=device_status.tpl)
         {
-            device_status.C01 |= (1<<7);
             device_status.temp_status = 1;
         }
-        else if(atoi(device_status.tempture)>=(device_status.tpl+5)&&atoi(device_status.tempture)<=(device_status.tph-10))
-        {
-            device_status.C01 &= ~(1<<7);
+        else if(atoi(device_status.tempture)>=(device_status.tpl+5)&&atoi(device_status.tempture)<=(device_status.tph-10)) {
             device_status.temp_status = 0;
         }
-        LOG_I("光控计数:%d-%d",checklightnum,checknightnum);
-        rt_thread_mdelay(5000);
+        //雨控
+#if RPS_EN == 1
+        if(rain_value>250&&device_status.selfcheck_ws==0)
+        {
+            checkrain_num++;
+            if(checkrain_num>=10){
+                device_status.rain_status = 1;
+                checkrain_num = 0;
+                checkrain_unlock = 0;
+            }
+        }
+        else {
+            checkrain_unlock++;
+            checkrain_num = 0;
+            //雨控消抖,5分钟
+            if(checkrain_unlock==10*60*60)
+            {
+                checkrain_unlock = 0;
+                device_status.rain_status = 0;
+            }
+        }
+#endif
+        if(log_cnt==50){   //每5s打印
+            log_cnt = 0;
+            LOG_I("光控计数:light:%d-night:%d",checklightnum,checknightnum);
+            LOG_I("雨控计数:有:%d-无:%d",checkrain_num,checkrain_unlock);
+            LOG_I("雨控ADC值:%d 光控ADC值:%d",rain_value,light_value);
+        }
+        rt_thread_mdelay(log_freq);
     }
 }
-
 static void Power_ReadCheck(void *parameter)
 {
-    int rain_cnt = 0;
     int RV;
     MovingAverageFilter* filter = moving_average_filter_init(10);
     //MovingAverageFilter* filter_hi = moving_average_filter_init(10);
@@ -237,27 +256,7 @@ static void Power_ReadCheck(void *parameter)
                     device_status.heattem = 25;
                 }
             }
-            //雨控
-            if(Read_Rain_Voltage()>250&&device_status.selfcheck_ws==0)
-            {
-                device_status.C01 |= (1<<5);
-                device_status.rain_status = 1;
-                rain_cnt = 0;
-            }
-            else {
-                rain_cnt++;
-                //雨控消抖,1分钟
-                if(rain_cnt%10==0)
-                    LOG_D("rain_cnt:%d-value:%d",rain_cnt,Read_Rain_Voltage());
-                if(rain_cnt==600&&Read_Rain_Voltage()<250)  //5分钟
-                {
-                    rain_cnt = 0;
-                    device_status.rain_status = 0;
-                    device_status.C01 &= ~(1<<5);
-                }
-            }
         }
-
         //rt_sprintf(device_status.voltage,"%d.%02d",filter_voltage()/100,filter_voltage()%100);
         rt_uint16_t in_voltage_int = moving_average_filter_update(filter_v,Read_Real_Voltage());
         sprintf(device_status.voltage,"%d.%02d",in_voltage_int/100,in_voltage_int%100);
@@ -518,7 +517,7 @@ int Read_Ntc_Voltage(void)
 int sht30_collect(void)
 {
     /* 创建线程*/
-    tid1 = rt_thread_create("sht30_collect_thread",sht30_collect_thread_entry, RT_NULL,THREAD_STACK_SIZE,THREAD_PRIORITY, THREAD_TIMESLICE);
+    tid1 = rt_thread_create("adc_thread",adc_collect_thread_entry, RT_NULL,THREAD_STACK_SIZE,THREAD_PRIORITY, THREAD_TIMESLICE);
     tid2 = rt_thread_create("Power Check thread", Power_ReadCheck, RT_NULL, P_THREAD_STACK_SIZE, P_THREAD_PRIORITY, P_THREAD_TIMESCLICE);
     /* 如果获得线程控制块,启动这个线程 */
     if (tid1 != RT_NULL)

+ 3 - 0
Application_cbd_apm32f1/readme.md

@@ -1,3 +1,6 @@
+# 2026-06-04 更新说明
+	#版本:3.7.6
+	1、关闭雨控检测,优化雨控检测逻辑,增加消抖;
 # 2026-04-22 更新说明
 	#版本:3.6.6
 	计数只计算光栅触发计数;