zhunk 1 год назад
Родитель
Сommit
43c962eb87

BIN
Application_cbd_apm32f1/.settings/.rtmenus


+ 43 - 324
Application_cbd_apm32f1/applications/control.c

@@ -39,9 +39,6 @@ rt_thread_t tid_ctr = RT_NULL;
 rt_thread_t tid_heat = RT_NULL;
 
 /***************************************************************************/
-
-
-
 int thread_delete_workloop(void)
 {
     rt_err_t result;
@@ -614,71 +611,7 @@ Output:         NULL
 Return:         NULL
 Others:         NULL
 *************************************************/
-void ctr_develop(void)
-{
-    rt_kprintf("===============开始培养=================:%d\n",device_status.cul_time);
-    //已经培养的时间-分钟
-    device_status.stay_time = 0;
-    rt_uint32_t ii = 0;
 
-    while(device_status.develop_flag==1)
-    {
-        float stayedtime = 0.01;
-        char stayed[5];
-        stayedtime = (float)device_status.stay_time / 60.0;
-        sprintf(stayed,"%0.02f",stayedtime);
-        HMI_WRITE("workSta.staytime.txt=\"%s\"",stayed);
-        ii++;
-        LOG_I("developing...................................%d\n",ii);
-        LOG_I("============================设定的培养温度:%d\n",device_status.heatvalue);
-        LOG_I("============================培养仓实时温度:%d\n",device_status.pre_temp);
-        if(device_status.pre_temp<(device_status.heatvalue-5))
-        {
-            //未制冷
-            if(device_status.cold_status==0)
-            {
-                ctr_Heat(ON);
-            }
-        }
-        else
-        {
-            ctr_Heat(OFF);
-        }
-        LOG_I("============================制冷开关:%d\n",device_status.cold_sw);
-        if(device_status.cold_sw==1)
-        {
-            if(device_status.pre_temp>(device_status.heatvalue-10))
-            {
-                if(device_status.heat_status==0)
-                {
-                    ctr_Cold(ON);
-                }
-            }
-            else
-            {
-                ctr_Cold(OFF);
-            }
-        }
-        if(ii%60==0)
-        {
-            device_status.stay_time++;
-            if(device_status.stay_time / 60 == device_status.cul_time) device_status.develop_flag = 0;
-            LOG_I("developed...................................%d分钟\n",device_status.stay_time);
-        }
-        if(device_status.box_temp>35)
-        {
-            ctr_Cool_Fan(ON);
-        }
-        else if (device_status.box_temp<30)
-        {
-            ctr_Cool_Fan(OFF);
-        }
-        rt_thread_delay(1000);
-    }
-    ctr_Cold(OFF);
-    ctr_Heat(OFF);
-    LOG_I("=========!!!培养完成!!!==========");
-}
 /*上仓门*/
 uint8_t ctr_cangmen_up(uint8_t status_up)
 {
@@ -2042,229 +1975,6 @@ void WorkCheck(void)
     rt_thread_delay(1000);
 }
 
-void WorkTask_BZY(void)
-{
-    if(device_status.ds==1)
-    {
-        //时间段判断
-        //先判断第一个时间段
-        time_t now;
-        time(&now);
-        static struct tm now_stamp;       //现在
-        static struct tm cul_sh1_stamp;   //开始1
-        static struct tm cul_eh1_stamp;   //结束1
-        static struct tm cul_sh2_stamp;   //开始2
-        static struct tm cul_eh2_stamp;   //结束2
-        static struct tm cul_sh3_stamp;   //开始3
-        static struct tm cul_eh3_stamp;   //结束3
-        now_stamp = *localtime(&now);
-        //获取定时开始的时间戳
-        cul_sh1_stamp = *localtime(&now);
-        cul_sh1_stamp.tm_hour = device_status.collecting_sh1;
-        cul_sh1_stamp.tm_min = 0;
-        cul_sh1_stamp.tm_sec = 0;
-        cul_sh2_stamp = *localtime(&now);
-        cul_sh2_stamp.tm_hour = device_status.collecting_sh2;
-        cul_sh2_stamp.tm_min = 0;
-        cul_sh2_stamp.tm_sec = 0;
-        cul_sh3_stamp = *localtime(&now);
-        cul_sh3_stamp.tm_hour = device_status.collecting_sh3;
-        cul_sh3_stamp.tm_min = 0;
-        cul_sh3_stamp.tm_sec = 0;
-        //获取定时结束的时间戳
-        cul_eh1_stamp = *localtime(&now);
-        cul_eh1_stamp.tm_hour = device_status.collecting_eh1;
-        cul_eh1_stamp.tm_min = 0;
-        cul_eh1_stamp.tm_sec = 0;
-        cul_eh2_stamp = *localtime(&now);
-        cul_eh2_stamp.tm_hour = device_status.collecting_eh2;
-        cul_eh2_stamp.tm_min = 0;
-        cul_eh2_stamp.tm_sec = 0;
-        cul_eh3_stamp = *localtime(&now);
-        cul_eh3_stamp.tm_hour = device_status.collecting_eh3;
-        cul_eh3_stamp.tm_min = 0;
-        cul_eh3_stamp.tm_sec = 0;
-        LOG_I("采集时间1-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_sh1_stamp.tm_year+1900,cul_sh1_stamp.tm_mon+1,cul_sh1_stamp.tm_mday,cul_sh1_stamp.tm_hour,cul_sh1_stamp.tm_min,cul_sh1_stamp.tm_sec);
-        LOG_I("采集时间2-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_sh2_stamp.tm_year+1900,cul_sh2_stamp.tm_mon+1,cul_sh2_stamp.tm_mday,cul_sh2_stamp.tm_hour,cul_sh2_stamp.tm_min,cul_sh2_stamp.tm_sec);
-        LOG_I("采集时间3-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_sh3_stamp.tm_year+1900,cul_sh3_stamp.tm_mon+1,cul_sh3_stamp.tm_mday,cul_sh3_stamp.tm_hour,cul_sh3_stamp.tm_min,cul_sh3_stamp.tm_sec);
-        LOG_I("结束时间1-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_eh1_stamp.tm_year+1900,cul_eh1_stamp.tm_mon+1,cul_eh1_stamp.tm_mday,cul_eh1_stamp.tm_hour,cul_eh1_stamp.tm_min,cul_eh1_stamp.tm_sec);
-        LOG_I("结束时间2-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_eh2_stamp.tm_year+1900,cul_eh2_stamp.tm_mon+1,cul_eh2_stamp.tm_mday,cul_eh2_stamp.tm_hour,cul_eh2_stamp.tm_min,cul_eh2_stamp.tm_sec);
-        LOG_I("结束时间3-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_eh3_stamp.tm_year+1900,cul_eh3_stamp.tm_mon+1,cul_eh3_stamp.tm_mday,cul_eh3_stamp.tm_hour,cul_eh3_stamp.tm_min,cul_eh3_stamp.tm_sec);
-        //此处判断,一个一个时间段判断,判断当前时间是否大于开始时间:
-        //当前时间戳小于第一段开始时间戳
-        if(difftime(mktime(&now_stamp), mktime(&cul_sh1_stamp)) < 0)
-        {
-            time_t now;
-            time(&now);
-            cul_sh1_stamp = *localtime(&now);
-            cul_sh1_stamp.tm_hour = device_status.collecting_sh1;
-            cul_sh1_stamp.tm_min = 0;
-            cul_sh1_stamp.tm_sec = 0;
-            now_stamp = *localtime(&now);
-            LOG_I("======收集时间1:%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_sh1_stamp.tm_year+1900,cul_sh1_stamp.tm_mon+1,cul_sh1_stamp.tm_mday,cul_sh1_stamp.tm_hour,cul_sh1_stamp.tm_min,cul_sh1_stamp.tm_sec);
-            LOG_I("======未到收集时间1:%04d年%02d月%02d日%02d时%02d分%02d秒.",now_stamp.tm_year+1900,now_stamp.tm_mon+1,now_stamp.tm_mday,now_stamp.tm_hour,now_stamp.tm_min,now_stamp.tm_sec);
-            LOG_D("run_sta:%d",device_status.run_sta);
-        }
-        //当前时间戳小于第二段结束 时间戳并且大于第1段结束时间戳
-        if(difftime(mktime(&now_stamp), mktime(&cul_sh2_stamp)) < 0&&difftime(mktime(&now_stamp), mktime(&cul_eh1_stamp)) > 0)
-        {
-            time_t now;
-            time(&now);
-            cul_sh2_stamp = *localtime(&now);
-            cul_sh2_stamp.tm_hour = device_status.collecting_sh2;
-            cul_sh2_stamp.tm_min = 0;
-            cul_sh2_stamp.tm_sec = 0;
-            now_stamp = *localtime(&now);
-            LOG_I("==============收集时间2:%04d年%02d月%02d日%02d时%02d分%02d秒.\n",cul_sh2_stamp.tm_year+1900,cul_sh2_stamp.tm_mon+1,cul_sh2_stamp.tm_mday,cul_sh2_stamp.tm_hour,cul_sh2_stamp.tm_min,cul_sh2_stamp.tm_sec);
-            LOG_I("==============未到收集时间2:%04d年%02d月%02d日%02d时%02d分%02d秒.\n",now_stamp.tm_year+1900,now_stamp.tm_mon+1,now_stamp.tm_mday,now_stamp.tm_hour,now_stamp.tm_min,now_stamp.tm_sec);
-            LOG_D("run_sta:%d",device_status.run_sta);
-        }
-        //如果当前 时间戳大于开始时间戳并且小于 结束时间戳
-        if(difftime(mktime(&now_stamp), mktime(&cul_sh1_stamp)) >= 0&&difftime(mktime(&now_stamp), mktime(&cul_eh2_stamp)) < 0)
-        {
-
-            //转盘到涂凡士林位置
-            if(device_status.run_sta==0)
-            {
-                LOG_I("start to collect!!!");
-                DTU_Write("collect.mp3");
-                ctr_turn(90,4);
-                rt_thread_delay(2000);
-                //涂凡士林
-                ctr_Petroleum_jelly(10);
-                rt_thread_delay(5000);
-            }
-
-            /*转盘到采集位置*/
-            if(device_status.run_sta==4)
-            ctr_turn(90,1);
-
-            //只有开始和结束时刻不同的时间段,才有效
-            if((difftime(mktime(&cul_eh1_stamp), mktime(&now_stamp)) > 0)||(difftime(mktime(&cul_eh2_stamp), mktime(&now_stamp)) > 0))
-            {
-                if((difftime(mktime(&cul_eh1_stamp), mktime(&now_stamp)) > 0)&& difftime(mktime(&now_stamp),mktime(&cul_sh1_stamp)) > 0)
-                {
-                    device_status.work_status = 1;
-                    ctr_Collect_Fan(ON);
-                    //当前时间戳小于第一段结束时间戳
-                    while(difftime(mktime(&cul_eh1_stamp), mktime(&now_stamp))>0)
-                    {
-                        time(&now);
-                        now_stamp = *localtime(&now);
-                        cul_eh1_stamp = *localtime(&now);
-                        cul_eh1_stamp.tm_hour = device_status.collecting_eh1;
-                        cul_eh1_stamp.tm_min = 0;
-                        cul_eh1_stamp.tm_sec = 0;
-                        if(device_status.run_sta!=1) break;
-                        LOG_I("1===========采集风机启动,正在收集.....%d-%d",mktime(&now_stamp),mktime(&cul_eh1_stamp));
-                        rt_thread_mdelay(10000);
-                    }
-                }
-                else {
-                    device_status.work_status=0;
-                    ctr_Collect_Fan(OFF);
-                    LOG_I("未到收集1时间!");
-                }
-                if(difftime(mktime(&cul_eh2_stamp), mktime(&now_stamp)) > 0 && difftime(mktime(&now_stamp),mktime(&cul_sh2_stamp)) > 0)
-                {
-                    device_status.work_status = 1;
-                    ctr_Collect_Fan(ON);
-                    while(difftime(mktime(&cul_eh2_stamp), mktime(&now_stamp))>0)
-                    {
-                        time(&now);
-                        now_stamp = *localtime(&now);
-                        cul_eh2_stamp = *localtime(&now);
-                        cul_eh2_stamp.tm_hour = device_status.collecting_eh2;
-                        cul_eh2_stamp.tm_min = 0;
-                        cul_eh2_stamp.tm_sec = 0;
-                        if(device_status.run_sta!=1) break;
-                        LOG_I("2===========采集风机启动,正在收集.....%d-%d",mktime(&now_stamp),mktime(&cul_eh2_stamp));
-                        rt_thread_mdelay(10000);
-                    }
-                }
-                else {
-                    device_status.work_status=0;
-                    ctr_Collect_Fan(OFF);
-                    LOG_I("未到收集2时间!");
-                }
-            }
-            else
-            {
-                LOG_I("this collect time is 0s,The wait time cannot be negative!");
-            }
-        }
-        if(device_status.run_sta==2)
-        {
-            ctr_Collect_Fan(OFF);
-            device_status.develop_flag = 1;
-            device_status.work_status = 2;
-            ctr_develop();                  //培养
-            ctr_turn(90,3);
-        }
-        if(device_status.run_sta==3)
-        {
-            ctr_Collect_Fan(OFF);
-            device_status.work_status = 3;
-            device_status.autotakepic=1;    //对焦拍照
-        }
-        //在培养之前再次确认时间戳
-        time(&now);
-        now_stamp = *localtime(&now);
-        cul_eh2_stamp = *localtime(&now);
-        cul_eh2_stamp.tm_hour = device_status.collecting_eh2;
-        cul_eh2_stamp.tm_min = 0;
-        cul_eh2_stamp.tm_sec = 0;
-        //当前时间戳大于收集结束时间戳并且run_sta==1
-        if(device_status.run_sta==1 && difftime(mktime(&now_stamp), mktime(&cul_eh2_stamp)) > 0)
-        {
-            ctr_Collect_Fan(OFF);
-            LOG_I("===============collect ok,turn to drop!!!");
-            device_status.develop_flag=1;
-            device_status.work_status=2;    //现在是培养
-            DTU_Write("develop.mp3");
-            if(device_status.run_sta==1)
-            ctr_turn(90,2);                 /*转盘到培养位置*/
-            rt_thread_delay(1000);
-            ctr_shake(ON,device_status.shake_sec);
-            rt_thread_delay(1000);
-            ctr_develop();                  //培养
-            if(device_status.run_sta==2)
-            ctr_turn(90,3);                 /*转盘到拍照位置*/
-            rt_thread_delay(1000);
-            device_status.work_status=3;    //现在是拍照
-            device_status.autotakepic=1;    //对焦拍照
-            while(device_status.autotakepic==0)
-            {
-                rt_thread_delay(1000);
-                LOG_I("正在对焦拍照............");
-            }
-            device_status.work_status = 0;  //待机
-            DTU_Write("wait.mp3");
-            LOG_I("=====================work finished==================");
-         }
-        rt_thread_delay(1000);
-    }
-    device_status.work_status = 0;          //待机
-    LOG_W("==================!!!设备已待机!!!===================");
-}
-
-
-void WorkTask_BZYV2(void)
-{
-    //打开采集风机
-    ctr_Collect_Fan(ON);
-    //打开胶带步进电机
-
-    //等待采集结束
-
-    //拍照
-
-    //打开相机供电
-    //打开补光灯
-    //滑台归位
-    //滑台启动
-}
-
 //工作任务流程s
 void WorkTask(void)
 {
@@ -2347,7 +2057,6 @@ void WorkTask(void)
                     ctr_Fan_PUT(OFF);
                 #endif
                 rt_kprintf("正在收集.....剩余时间:%d分-%d秒\n",device_status.clt_time,clt_time);
-                HMI_WRITE("workSta.g0.txt=\"正在收集.....剩余时间:%d分-%d秒\"",device_status.clt_time,clt_time);
                 //如果触发异常
                 if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
                 {
@@ -2360,7 +2069,6 @@ void WorkTask(void)
                     ctr_Fan_IN(OFF);
                     #endif
                     rt_kprintf("异常退出!!!\n");
-                    HMI_WRITE("workSta.g0.txt=\"异常退出\"");
                     break;
                 }
                 if(device_status.timeSwitch==0&&device_status.sun_status==1)
@@ -2374,7 +2082,6 @@ void WorkTask(void)
                     ctr_Fan_IN(OFF);
                     #endif
                     rt_kprintf("异常退出!!!\n");
-                    HMI_WRITE("workSta.g0.txt=\"异常退出\"");
                     break;
                 }
             }
@@ -2390,7 +2097,6 @@ void WorkTask(void)
                 ctr_Fan_IN(OFF);
                 #endif
                 rt_kprintf("异常退出!!!\n");
-                HMI_WRITE("workSta.g0.txt=\"异常退出\"");
                 break;
             }
             if(device_status.timeSwitch==0&&device_status.sun_status==1)
@@ -2404,7 +2110,6 @@ void WorkTask(void)
                 ctr_Fan_IN(OFF);
                 #endif
                 rt_kprintf("异常退出!!!\n");
-                HMI_WRITE("workSta.g0.txt=\"异常退出\"");
                 break;
             }
             #if 0//LAMP_EN == 0
@@ -2413,7 +2118,6 @@ void WorkTask(void)
             //4.关闭上仓门
             device_status.ctr_up_motor = 2;
             rt_kprintf("关闭上仓门!!!\n");
-            HMI_WRITE("workSta.g0.txt=\"关闭上仓门!\"");
             while(device_status.ctr_up_motor!=0)
             {
                 rt_thread_delay(100);
@@ -2447,7 +2151,6 @@ void WorkTask(void)
             {
                 rt_thread_delay(100);
                 rt_kprintf("等待下仓门打开!!!\n");
-                HMI_WRITE("workSta.g0.txt=\"等待下仓门打开!\"");
             }
             rt_thread_delay(3000);
             //关闭下仓门
@@ -2456,11 +2159,9 @@ void WorkTask(void)
             {
                 rt_thread_delay(100);
                 rt_kprintf("等待下仓门关闭!!!\n");
-                HMI_WRITE("workSta.g0.txt=\"等待下仓门关闭!\"");
             }
             //2022-04-12add:
              LOG_I("打开上仓门!!!");
-             HMI_WRITE("workSta.g0.txt=\"打开上仓门!\"");
              device_status.ctr_up_motor = 1;
             if(device_status.version_type==4||device_status.version_type==41)
             {
@@ -2468,7 +2169,6 @@ void WorkTask(void)
                 ctr_shake(ON, device_status.shake_sec);
                 //补光&&拍照
                 LOG_I("拍照!!!");
-                HMI_WRITE("workSta.g0.txt=\"拍照!\"");
                 ctr_led(ON);
                 HK_TakePhoto();
                 //清扫
@@ -2494,24 +2194,45 @@ void WorkTask(void)
 
         }
    }
-        if(device_status.bat_status == 1 || device_status.temp_status == 1 || device_status.rain_status==1 || device_status.ds==0)
-        {
-            rt_kprintf("-------------------not work--------------------\n");
-            device_status.work_status = 0;
-        }
-        //工作结束
-        if(device_status.work_done==0&&device_status.work_status==0)
-        {
-            DTU_Write("workdone");
-            HMI_WRITE("workSta.g0.txt=\"工作任务已完成!\"");
-            if (device_status.version_type==1) {
-                turnzp();  //2024-03-21 :开机不再转仓
-            }
-            ResetInit();
-            clt_time = 0;
+    if(device_status.bat_status == 1 || device_status.temp_status == 1 || device_status.rain_status==1 || device_status.ds==0)
+    {
+        LOG_I("-------------------not work--------------------");
+        device_status.work_status = 0;
+    }
+    //工作结束
+    if(device_status.work_done==0&&device_status.work_status==0)
+    {
+        DTU_Write("workdone");
+        if (device_status.version_type==1) {
+            turnzp();  //2024-03-21 :开机不再转仓
         }
-        rt_kprintf("***not work-device status:%d\n",device_status.ds);
+        ResetInit();
+        clt_time = 0;
+    }
+    rt_kprintf("***not work-device status:%d\n",device_status.ds);
+}
+
+void WorkTask_CB5(void)
+{
+    while(device_status.work_status==1&&device_status.temp_status==0&&device_status.bat_status==0&&device_status.rain_status==0&&device_status.ds==1)
+    {
+        //打开灯管
+        ctr_lamp(ON,1);
+        //推杆电机打开,导流板到落虫通道
+        //发送串口消息,通知yolo是被及相机采集模块启动,定期将模块的运行状态展示到屏幕上
+        //收到益虫信号->
+        //收到害虫信号->
+    }
+    device_status.work_status = 0;
+    //工作结束
+    if(device_status.work_done==0&&device_status.work_status==0)
+    {
+        DTU_Write("workdone");
+        ResetInit();
+    }
+    LOG_I("WorkTask_CB5 sleeping......");
 }
+
 /* 入口函数-工作状态检测 */
 static void Work_status_thread_entry(void *parameter)
 {
@@ -2541,10 +2262,6 @@ static void Work_Loop_thread_entry(void *parameter)
     ResetInit();
     while(1)
     {
-        if(device_status.dtype==7)
-        {
-            WorkTask_BZY();
-        }
         if(device_status.version_type!=6&&device_status.dtype==3)
         {
             WorkTask();
@@ -2553,6 +2270,10 @@ static void Work_Loop_thread_entry(void *parameter)
         {
             WorkTask_XCT();
         }
+        if(device_status.version_type==5)
+        {
+
+        }
         rt_thread_delay(1000);
     }
 }
@@ -2640,7 +2361,6 @@ static void Control_Clear_thread_entry(void *parameter)
 /*入口函数加热*/
 static void Control_Heat_thread_entry(void *parameter)
 {
-    uint16_t var_clear = 0;
     while(1)
     {
         if(device_status.work_status==1&&device_status.heat_sw==1)
@@ -2725,19 +2445,18 @@ int Workstatus_check(void)
 /*工作流程线程*/
 int Work_Loop_Task(void)
 {
-    rt_err_t result_loop;
+    rt_err_t result_loop = 0;
     /* 创建线程*/
     tid_workloop = rt_thread_create("work_loop_thread",
                                 Work_Loop_thread_entry, RT_NULL,
                                 WORK_LOOP_THREAD_STACK_SIZE,       //2048
                                 WORK_LOOP_THREAD_PRIORITY,         //12
                                 WORK_LOOP_THREAD_TIMESLICE);       //5
-    #if Color_EN == 0
+
     if(tid_workloop!=RT_NULL)
     {
         result_loop = rt_thread_startup(tid_workloop);
     }
-    #endif
     return result_loop;
 }
 MSH_CMD_EXPORT(HardWare_Check,HardWare_Check<ON|OFF>);

+ 3 - 13
Application_cbd_apm32f1/applications/control.h

@@ -16,27 +16,19 @@
 //定制相关//////////////////////////////////////////////////////
 #define LAMP_EN          0             //李新3灯管:0关闭,1打开
 #define SENSOR_EN        1              //温湿度:0关闭,1打开
-#define ROBOT_EN         0              //机器人
-#define Color_EN         0              //定制色诱
-#define BZYV2_EN         0              //孢子仪2.0
-#define BOOT_ERR         1              //1-新bootloader,0-旧bootloader()2023年9月份之前的设备升级需要设置为0
 ////////////////////////////////////////////////////////////////
 #if LAMP_EN == 1
     #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
     #define VERSION_HK_2000W    "1.3led.40(2000W)"       //水稻
 #else
-    #define VERSION_HK          "2.1.41(HK)"            //4.0海康-1200W
-    #define VERSION_HK_2000W    "2.1.4(2000W)"         //4.0水稻
+    #define VERSION_HK          "2.2.41(HK)"            //4.0海康-1200W
+    #define VERSION_HK_2000W    "2.3.4(2000W)"         //4.0水稻
 #endif
 
 #define VERSION_ZP          "1.45.1(ZP)"            //1.0转盘
 #define VERSION_GK          "1.41.1(GK)"            //1.0高空
+#define VERSION_V5          "2.0.5(HK)"             //5.0
 
-#define VERSION_XCT         "1.13.6(HK)"            //吸虫塔-海康
-#define VERSION_V5          "1.2.5(HK)"             //5.0
-#define VERSION_Robot       "1.0(robot)"            //展厅机器人
-
-#define VERSION_BZY         "2.60"                   //孢子仪
 
 
 /*********************************************************************/
@@ -117,10 +109,8 @@ typedef struct  _packed
     uint8_t heat_sta;        //加热报警0-正常,1-异常
     uint8_t led_sta;         //补光灯报警0-正常,1-异常
     uint8_t selfcheck_ws;    //自检开关1-北大荒,2-标配
-    #if BOOT_ERR == 1
     uint8_t gps_inuse;
     uint8_t gps_view;
-    #endif
     uint16_t dattim;         //数据上传间隔
     uint16_t shake_sec;      //震动时间
     uint16_t thsp;           //息屏时间

+ 21 - 23
Application_cbd_apm32f1/applications/dtu_uart2.c

@@ -86,28 +86,32 @@ static int DTU_uart2_init(void)
         }
         return RT_EOK;
 }
+
+
+
 /*数据发送*/
 void DTU_Write(char *fmt, ...)
 {
-    const char dtu_conf[4] = {device_status.vol,0x00,0x00,0x00};
-    va_list arg;
-    static char dtu_str[800];
+    //static const char dtu_conf[4] = {device_status.vol,0x00,0x00,0x00};
+    va_list ap;
+    static char dtu_str[1024];
     rt_size_t str_length;
-    va_start(arg,fmt);
-    str_length = rt_vsnprintf(dtu_str, sizeof(dtu_str) - 1, fmt, arg);
-    if (str_length > 800 - 1)
-        str_length = 800 - 1;
+    va_start(ap,fmt);
+    //str_length = rt_vsnprintf(dtu_str, sizeof(dtu_str) - 1, fmt, arg);
+    str_length = rt_vsnprintf(dtu_str, sizeof(dtu_str) - 4, fmt, ap);
+    va_end(ap);
+    if (str_length > 1024 - 4)
+        str_length = 1024 - 4;
     rt_device_write(dtuserial, 0, dtu_str, str_length);
-    if(strstr(dtu_str,"volume")!=RT_NULL)
-    {
-        rt_device_write(dtuserial,0,dtu_conf,4);
-    }
-    else if (strstr(dtu_str,"reset")!=RT_NULL) {
-        const char dtu_conf[4] = {7,0x00,0x00,0x00};
-        rt_device_write(dtuserial,0,dtu_conf,4);
-    }
-    va_end(arg);
-    memset(dtu_str,'\0',sizeof(dtu_str));
+    rt_thread_mdelay(10);
+//    if(strstr(dtu_str,"volume")!=RT_NULL)
+//    {
+//        rt_device_write(dtuserial,0,dtu_conf,4);
+//    }
+//    else if (strstr(dtu_str,"reset")!=RT_NULL) {
+//        const char dtu_conf[4] = {7,0x00,0x00,0x00};
+//        rt_device_write(dtuserial,0,dtu_conf,4);
+//    }
 }
 /* 接收数据回调函数 */
 static rt_err_t dtu_input(rt_device_t dev, rt_size_t size)
@@ -739,12 +743,6 @@ char * makeJson()
     else if (device_status.version_type==5) {
         rt_sprintf(device_status.driver,"%s-%s",VERSION_V5,device_status.driver_4g);
     }
-    else if (device_status.version_type==6) {
-        rt_sprintf(device_status.driver,"%s-%s",VERSION_XCT,device_status.driver_4g);
-    }
-    else if (device_status.version_type==7) {
-        rt_sprintf(device_status.driver,"%s-%s",VERSION_BZY,device_status.driver_4g);
-    }
     if(device_status.sensor_485_sta!=0)
     {
         if(strstr(device_status.driver,"485")==RT_NULL)

+ 17 - 155
Application_cbd_apm32f1/applications/hmi.c

@@ -80,7 +80,7 @@ static int HMI_uart4_init(void)
     config.stop_bits = STOP_BITS_1;     //停止位1
     #ifdef RT_USING_SERIAL_V2
     config.rx_bufsz = 512;
-    config.tx_bufsz = 128;
+    config.tx_bufsz = 1024;
     #else
     config.bufsz = 512;                 //缓冲区128字节
     #endif
@@ -109,18 +109,20 @@ void HMI_WRITE(char *fmt, ...)
 {
     va_list ap;
     //末尾需要拼接的3个ff
-    const char hmi_hex[3]={0xff,0xff,0xff};
+    static const char hmi_hex[3]={0xff,0xff,0xff};
     static char str[MAX_SIZE];
-    memset(str,'\0',sizeof(str));
+    //memset(str,'\0',sizeof(str));
     rt_size_t str_length;
     va_start(ap,fmt);
-    str_length = rt_vsnprintf(str, sizeof(str) - 1, fmt, ap);
-    if (str_length > MAX_SIZE - 1)
-        str_length = MAX_SIZE - 1;
-
-    rt_device_write(serial, 0, str, str_length);
+    // 预留3字节空间给 hmi_hex
+    str_length = rt_vsnprintf(str, sizeof(str) - 3, fmt, ap);
     va_end(ap);
-    rt_device_write(serial, 0,hmi_hex,3);
+    if (str_length > MAX_SIZE - 3)
+        str_length = MAX_SIZE - 3;
+    // 追加三个 0xff
+    memcpy(str + str_length, hmi_hex, sizeof(hmi_hex));
+    rt_device_write(serial, 0, str, str_length + sizeof(hmi_hex));
+    rt_thread_mdelay(5);    //2025-0308
 }
 /* 接收数据回调函数 */
 static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
@@ -197,12 +199,12 @@ void Start_timer_Uart2(void)
 /***************************** 解析从屏幕收到的数据 begin **********************************/
 static void HMI_Decode(void)
 {
+
     time_t now = time(RT_NULL);
     static struct tm tm;
     gmtime_r(&now, &tm);
-    char *json_temp;
-    char *var=NULL;
-    rt_free(var);
+    static char *json_temp;
+    static char *var;
     if(device_status.refresh_num==0)  device_status.refresh_num = 10;
     if(strstr(rx_buffer,"getFullData") != NULL){
         char *readinfo =  makeJson_ReadInfo();
@@ -258,8 +260,7 @@ static void HMI_Decode(void)
             //更新电压
             HMI_WRITE("workSta.vbat.txt=\"%s\"",device_status.voltage);
             //更新电流
-             HMI_WRITE("workSta.power.txt=\"%s\"",device_status.power);
-
+            HMI_WRITE("workSta.power.txt=\"%s\"",device_status.power);
             //更新温湿度数据
             HMI_WRITE("workSta.envHum.val=%d",atoi(device_status.humidity));
             HMI_WRITE("workSta.envTem.val=%d",atoi(device_status.tempture));
@@ -295,7 +296,6 @@ static void HMI_Decode(void)
             HMI_WRITE("sysSet.jheat.val=%d",device_status.heatvalue);
             //更新加热状态
             HMI_WRITE("workSta.heatStatus.val=%d",device_status.heat_status);
-
             //更新密码
             HMI_WRITE("inputPasswd.pwdData.txt=\"8888\"");
             //更新时间设置中的参数
@@ -323,13 +323,11 @@ static void HMI_Decode(void)
         }
         HMI_WRITE("menu.cam_sta.val=%d",device_status.camsta);
 
-        #if BOOT_ERR == 1
         if(atoi(device_status.gps)==1){
             HMI_WRITE("menu.gps_state.txt=\"定位成功:(%s)%d/%d\"",device_status.gps_state,device_status.gps_inuse,device_status.gps_view);
         }else if(atoi(device_status.gps)==2){
             HMI_WRITE("menu.gps_state.txt=\"定位成功:(基站)\"");
         }
-        #endif
 
         //更新联网状态
         if(atoi(device_status.net)==1)
@@ -346,94 +344,6 @@ static void HMI_Decode(void)
             HMI_WRITE("menu.net.val=1");
             HMI_WRITE("workSta.net.val=2");
         }
-        if(device_status.dtype==7)
-        {
-            //更新温湿度数据
-            HMI_WRITE("workSta.env_hum.txt=\"%s\"",device_status.humidity);
-            HMI_WRITE("workSta.env_tem.txt=\"%s\"",device_status.tempture);
-            HMI_WRITE("workSta.on_off.val=%d",device_status.ds);
-            HMI_WRITE("workSta.work_sta.val=%d",device_status.work_status);
-            HMI_WRITE("workSta.collect_fan.val=%d",device_status.collect_fan_status);
-            //更新电池状态
-            HMI_WRITE("workSta.bat_sta.val=%d",device_status.bat_status);
-            //更新散热风机状态
-            HMI_WRITE("workSta.cool_fan.val=%d",device_status.cool_fan_status);
-            //更新开关状态
-            HMI_WRITE("workSta.on_off.val=%d",device_status.ds);
-            //更新工作状态
-            HMI_WRITE("workSta.work_sta.val=%d",device_status.work_status);
-            //箱内温度-外壳
-            HMI_WRITE("workSta.box_tmp.txt=\"%d\"",device_status.box_temp);
-            HMI_WRITE("temHum.box_tmp.txt=\"%d\"",device_status.box_temp);
-            //制冷开关
-            HMI_WRITE("workSta.cold_sw.val=%d",device_status.cold_sw);
-            HMI_WRITE("sysSet.cold_sw.val=%d",device_status.cold_sw);
-            //制冷状态
-            HMI_WRITE("workSta.cold_sta.val=%d",device_status.cold_status);
-            HMI_WRITE("sysSet.cold_sw.val=%d",device_status.cold_sw);
-            //培养温度
-            HMI_WRITE("workSta.set_temp.val=%d",device_status.heatvalue);
-            HMI_WRITE("sysSet.keep.val=%d",device_status.heatvalue);
-            //数据上传间隔
-            HMI_WRITE("sysSet.datt.val=%d",device_status.dattim);
-            HMI_WRITE("sysSet.lcd_time.val=%d",device_status.thsp*60);
-            //当前温度-培养仓
-            HMI_WRITE("workSta.pre_temp.val=%d",device_status.pre_temp);
-            //设定培养时间
-            HMI_WRITE("workSta.cul_time.val=%d",device_status.cul_time);
-            HMI_WRITE("clockSet.stay.val=%d",device_status.cul_time);
-            //已培养时间
-            if(device_status.develop_flag==0)
-            HMI_WRITE("workSta.staytime.txt=\"0\"");
-            //滴液时间
-            HMI_WRITE("clockSet.drop.val=%d",device_status.shake_sec);
-            //采集开始时间1
-            HMI_WRITE("clockSet.start1.val=%d",device_status.collecting_sh1);
-            //采集开始时间2
-            HMI_WRITE("clockSet.start2.val=%d",device_status.collecting_sh2);
-            //采集结束时间1
-            HMI_WRITE("clockSet.end1.val=%d",device_status.collecting_eh1);
-            //采集结束时间2
-            HMI_WRITE("clockSet.end2.val=%d",device_status.collecting_eh2);
-            if(device_status.autotakepic==0) HMI_WRITE("sysTest.auto_flag.txt=\"\"");
-        }
-        /**********************************吸虫塔*********************************/
-        if(device_status.version_type==6)
-        {
-            HMI_WRITE("menu.equipid.txt=\"%s\"",device_status.imei);
-            //更新电压
-            HMI_WRITE("menu.vbat.txt=\"%sV\"",device_status.voltage);
-            //工作状态
-            HMI_WRITE("menu.worksta.val=%d",device_status.work_status);
-            //网卡0状态
-            HMI_WRITE("menu.eth0_sta.val=%d",device_status.link_sta);
-            //更新电流
-             HMI_WRITE("menu.power.txt=\"%smA\"",device_status.power);
-            //更新温湿度数据
-            HMI_WRITE("menu.envHum.txt=\"%s%RH\"",device_status.humidity);
-            HMI_WRITE("menu.envTem.txt=\"%s℃\"",device_status.tempture);
-            HMI_WRITE("uploadSet.st.val=%d",device_status.startBar);
-            HMI_WRITE("uploadSet.et.val=%d",device_status.stopBar);
-            HMI_WRITE("menu.board_temp.txt=\"%d.%d℃\"",Get_Temprate()/100,Get_Temprate()%100);
-            //数据上传间隔
-            HMI_WRITE("menu.datt.val=%d",device_status.dattim);
-            //SIM卡状态
-            HMI_WRITE("menu.bt0.val=%d",atoi(device_status.sim));
-            //更新震动时间
-            HMI_WRITE("menu.shake_sec.val=%d",device_status.shake_sec);
-            //校准屏幕的RTC
-            HMI_WRITE("rtc0=%d",tm.tm_year+1900);
-            HMI_WRITE("rtc1=%d",tm.tm_mon+1);
-            HMI_WRITE("rtc2=%d",tm.tm_mday);
-            HMI_WRITE("rtc3=%d",tm.tm_hour);
-            HMI_WRITE("rtc4=%d",tm.tm_min);
-            HMI_WRITE("rtc5=%d",tm.tm_sec);
-
-            //更新熄屏时间
-            HMI_WRITE("thsp=%d",device_status.thsp);
-        }
-
-
         /**********************************************************************/
     }
     else if (strstr(rx_buffer,"getClockData")!=NULL) {
@@ -609,6 +519,7 @@ static void HMI_Decode(void)
         ctr_lamp(ON,2);
         ctr_lamp(ON,3);
         #endif
+        DTU_Write("{\"cmd\":\"workstart\"}");
     }
 
     //关闭灯管
@@ -1288,39 +1199,7 @@ static void HMI_Decode(void)
             MA_save();
         }
     }
-    //吸虫塔
-    else if (strstr(rx_buffer,"SwversionV6")!=NULL) {
-        device_status.dtype = 3;
-        if(device_status.version_type != 6)
-        {
-            device_status.version_type = 6;
-            sprintf(device_status.driver, "%s",VERSION_XCT);
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
-            ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
-            MA_save();
-        }
-    }
-    else if (strstr(rx_buffer,"SwversionV30")!=NULL) {
-        if(device_status.version_type != 30)
-        {
-            device_status.version_type = 30;
-            sprintf(device_status.driver, "%s",VERSION_Robot);
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
-            MA_save();
-        }
-    }
-    else if((strstr(rx_buffer,"SwversionV7")!=NULL)) {
-        if(device_status.dtype!=7)
-        {
-            LOG_D("设置版本类型:7");
-            device_status.dtype = 7;
-            device_status.version_type = 7;
-            ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //设备类型
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
-            DTU_Write("SwversionV7");
-            MA_save();
-        }
-    }
+
     else if (strstr(rx_buffer,"putTest.switchFAN_PU=1")!=NULL) {
         ctr_Fan_PUT(ON);
     }
@@ -2082,23 +1961,6 @@ void Check_ParamConfig(void)
         else if (device_status.version_type==5) {
             rt_sprintf(device_status.driver, "%s",VERSION_V5);
         }
-        else if (device_status.version_type==6)
-        {
-            //打开相机供电;
-            ctr_Camera_Power(ON);
-            rt_sprintf(device_status.driver, "%s",VERSION_XCT);
-        }
-        else if (device_status.version_type==7) {
-            rt_sprintf(device_status.driver, "%s",VERSION_BZY);
-            //异常处理:20230331,修复第一段开始时间等于第二段结束时间的情况
-            if(device_status.collecting_eh1==device_status.collecting_eh2&&device_status.collecting_sh2!=device_status.collecting_eh2)
-            {
-                device_status.collecting_eh2 = device_status.collecting_sh2 + 2;
-            }
-        }
-        else if (device_status.version_type==30) {
-            rt_sprintf(device_status.driver, "%s",VERSION_Robot);
-        }
         /*定制三色光源*/
         #if LAMP_EN == 1
             if(device_status.sunBar%3!=0)

+ 1 - 1
Application_cbd_apm32f1/applications/hmi.h

@@ -15,7 +15,7 @@
 
 
 #define UART_NAME "uart4"  /*串口设备名称*/
-#define MAX_SIZE 512
+#define MAX_SIZE 1024
 #define HMI_UART_RXBUFFER_SIZE 512  //
 extern rt_device_t serial;   /*串口设备句柄*/
 extern uint8_t dbg_flag;

+ 3 - 3
Application_cbd_apm32f1/applications/sht30_collect.c

@@ -190,7 +190,7 @@ static void Power_ReadCheck(void *parameter)
     int bat_cnt = 0;
     int RV;
     MovingAverageFilter* filter = moving_average_filter_init(10);
-    MovingAverageFilter* filter_hi = moving_average_filter_init(10);
+    //MovingAverageFilter* filter_hi = moving_average_filter_init(10);
     MovingAverageFilter* filter_v = moving_average_filter_init(10);
     rt_thread_delay(1000);
     while(1)
@@ -204,8 +204,8 @@ static void Power_ReadCheck(void *parameter)
         }
         else
         {
-            rt_uint16_t _heat_current_int = moving_average_filter_update(filter_hi,Read_Heat_Current());
-            sprintf(device_status.heat_power,"%.2f",(float)(_heat_current_int-2450)/0.1);     //2481-2465
+            //rt_uint16_t _heat_current_int = moving_average_filter_update(filter_hi,Read_Heat_Current());
+            sprintf(device_status.heat_power,"%.2f",(float)(Read_Heat_Current()-2450)/0.1);     //2481-2465
         }
 
         //LOG_I("负载电流:%s,加热电流:%s",device_status.power,device_status.heat_power);

+ 2 - 2
Application_cbd_apm32f1/drivers/board.h

@@ -83,8 +83,8 @@ extern "C"
 #define BSP_USING_UART4         //屏幕
 #define BSP_UART4_TX_PIN       "PC10"
 #define BSP_UART4_RX_PIN       "PC11"
-#define BSP_UART4_RX_BUFSIZE   128
-#define BSP_UART4_TX_BUFSIZE   512
+#define BSP_UART4_RX_BUFSIZE   512
+#define BSP_UART4_TX_BUFSIZE   1024
 
 #define BSP_USING_UART5         //485
 #define BSP_UART5_TX_PIN       "PC12"