|
|
@@ -130,28 +130,63 @@ static void sht30_collect_thread_entry(void *parameter)
|
|
|
{
|
|
|
static int checklightnum = 0;
|
|
|
static int checknightnum = 0;
|
|
|
+ static int rain_on_num = 0;
|
|
|
+ static int rain_off_num = 0;
|
|
|
while (1)
|
|
|
{
|
|
|
if(Read_Light_Voltage()>500)
|
|
|
{
|
|
|
checklightnum++;
|
|
|
- if(checklightnum==20)
|
|
|
+ if(checklightnum==1000)
|
|
|
{
|
|
|
device_status.sun_status = 1;
|
|
|
device_status.C01 |= (1<<6);
|
|
|
- checklightnum =0;
|
|
|
+ checklightnum = 0;
|
|
|
+ checknightnum = 0;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
checknightnum ++;
|
|
|
- if(checknightnum==20)
|
|
|
+ if(checknightnum==1000)
|
|
|
{
|
|
|
device_status.C01 &= ~(1<<6);
|
|
|
device_status.sun_status = 0;
|
|
|
checknightnum = 0;
|
|
|
+ checklightnum = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //雨控
|
|
|
+ if(Read_Rain_Voltage()>250&&device_status.selfcheck_ws==0)
|
|
|
+ {
|
|
|
+ rain_on_num ++;
|
|
|
+ if(rain_on_num==1)
|
|
|
+ {
|
|
|
+ LOG_W("雨控触发值:%d",Read_Rain_Voltage());
|
|
|
+ device_status.C01 |= (1<<5);
|
|
|
+ device_status.rain_status = 1;
|
|
|
+ device_status.ctr_up_motor = 2; //关闭上仓门
|
|
|
+ ctr_lamp(OFF,1);
|
|
|
+ ctr_lamp(OFF,2);
|
|
|
+ ctr_lamp(OFF,3);
|
|
|
+ rain_on_num = 0;
|
|
|
+ rain_off_num = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rain_off_num ++;
|
|
|
+ if(rain_off_num==10*60*60){ //1个小时后解除雨控
|
|
|
+ device_status.rain_status = 0;
|
|
|
+ device_status.C01 &= ~(1<<5);
|
|
|
+ rain_on_num = 0;
|
|
|
+ rain_off_num = 0;
|
|
|
+ }
|
|
|
+ if(rain_off_num%100==0){
|
|
|
+ LOG_I("雨控解除计数:3600-%d",rain_off_num);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//温控
|
|
|
if(atoi(device_status.tempture)>=device_status.tph||atoi(device_status.tempture)<=device_status.tpl)
|
|
|
{
|
|
|
@@ -163,13 +198,12 @@ static void sht30_collect_thread_entry(void *parameter)
|
|
|
device_status.C01 &= ~(1<<7);
|
|
|
device_status.temp_status = 0;
|
|
|
}
|
|
|
- LOG_I("光控计数:%d-%d",checklightnum,checknightnum);
|
|
|
- rt_thread_mdelay(5000);
|
|
|
+
|
|
|
+ rt_thread_mdelay(100);
|
|
|
}
|
|
|
}
|
|
|
static void Power_ReadCheck(void *parameter)
|
|
|
{
|
|
|
- int rain_cnt = 0;
|
|
|
int bat_cnt = 0;
|
|
|
int RV;
|
|
|
MovingAverageFilter* filter = moving_average_filter_init(10);
|
|
|
@@ -271,28 +305,6 @@ 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;
|
|
|
- device_status.ctr_up_motor = 2; //关闭上仓门
|
|
|
- ctr_lamp(OFF,1);
|
|
|
- ctr_lamp(OFF,2);
|
|
|
- ctr_lamp(OFF,3);
|
|
|
- rain_cnt = 0;
|
|
|
- }
|
|
|
- else {
|
|
|
- rain_cnt++;
|
|
|
- //雨控消抖,1分钟
|
|
|
- if(rain_cnt==3000&&Read_Rain_Voltage()<250)
|
|
|
- {
|
|
|
- LOG_W("雨控触发值:%d",Read_Rain_Voltage());
|
|
|
- rain_cnt = 0;
|
|
|
- device_status.rain_status = 2;
|
|
|
- device_status.C01 &= ~(1<<5);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
if(bat_cnt>=15){ //持续10s
|
|
|
bat_cnt = 0;
|