zhunk 1 anno fa
parent
commit
2f13b97f17

+ 14 - 3
Application_cbd_apm32f1/applications/control.h

@@ -14,16 +14,26 @@
 #include "stdio.h"
 #include "stdio.h"
 #include <rtdevice.h>
 #include <rtdevice.h>
 //定制相关//////////////////////////////////////////////////////
 //定制相关//////////////////////////////////////////////////////
+
+
+
 #define LAMP_EN          0             //李新3灯管:0关闭,1打开
 #define LAMP_EN          0             //李新3灯管:0关闭,1打开
-#define PCB_V1           0
-#define SENSOR_EN        1              //温湿度:0关闭,1打开
+#define PCB_V1           0             //1-旧PCB,0-新PCB(模块化)
+#define MATCH_DEVICE     0             //比赛设备
+#define SENSOR_EN        1             //温湿度:0关闭,1打开
+
+#if MATCH_DEVICE == 1
+#define LAMP_CURRENT    800
+#else
+#define LAMP_CURRENT    400
+#endif
 ////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////
 #if LAMP_EN == 1
 #if LAMP_EN == 1
     #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
     #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
     #define VERSION_HK_2000W    "1.3led.40(2000W)"       //水稻
     #define VERSION_HK_2000W    "1.3led.40(2000W)"       //水稻
 #else
 #else
     #define VERSION_HK          "2.5.41(HK)"            //4.0海康-1200W
     #define VERSION_HK          "2.5.41(HK)"            //4.0海康-1200W
-    #define VERSION_HK_2000W    "2.14.4(2000W)"         //4.0水稻
+    #define VERSION_HK_2000W    "2.15.4(2000W)"         //4.0水稻
 #endif
 #endif
 
 
 #define VERSION_ZP          "1.45.1(ZP)"            //1.0转盘
 #define VERSION_ZP          "1.45.1(ZP)"            //1.0转盘
@@ -78,6 +88,7 @@ typedef struct  _packed
     uint8_t rain_status;     //雨控              0-正常 1-欠压
     uint8_t rain_status;     //雨控              0-正常 1-欠压
     uint8_t temp_status;     //温控              0-正常 1-温控
     uint8_t temp_status;     //温控              0-正常 1-温控
     uint8_t sun_status;      //光控              0-正常 1-光控
     uint8_t sun_status;      //光控              0-正常 1-光控
+    uint8_t lamp;            //灯管状态    0-正常 1-异常
     uint8_t ds;              //设备状态   0-关机 1-开机
     uint8_t ds;              //设备状态   0-关机 1-开机
     uint8_t work_status;     //工作状态   0-待机 1-工作
     uint8_t work_status;     //工作状态   0-待机 1-工作
     uint8_t work_done;       //工作结束   1-正常 0-工作已结束
     uint8_t work_done;       //工作结束   1-正常 0-工作已结束

+ 7 - 8
Application_cbd_apm32f1/applications/dtu_uart2.c

@@ -423,7 +423,7 @@ void setSystemTime(struct tm *timeinfo) {
 // 函数定义:判断数组中是否有大于 100 的元素
 // 函数定义:判断数组中是否有大于 100 的元素
 int hasElementGreaterThan400(uint16_t arr[], int size) {
 int hasElementGreaterThan400(uint16_t arr[], int size) {
     for (int i = 0; i < size; i++) {
     for (int i = 0; i < size; i++) {
-        if (arr[i] < 400) {
+        if (arr[i] < LAMP_CURRENT) {
             return 1; // 找到大于 100 的元素,返回 1
             return 1; // 找到大于 100 的元素,返回 1
         }
         }
     }
     }
@@ -432,7 +432,7 @@ int hasElementGreaterThan400(uint16_t arr[], int size) {
 
 
 int hasElementGreater_lessThan400(uint16_t arr[], int size) {
 int hasElementGreater_lessThan400(uint16_t arr[], int size) {
     for (int i = 0; i < size; i++) {
     for (int i = 0; i < size; i++) {
-        if (arr[i] > 400) {
+        if (arr[i] > LAMP_CURRENT) {
             return 1; // 找到大于 100 的元素,返回 1
             return 1; // 找到大于 100 的元素,返回 1
         }
         }
     }
     }
@@ -515,14 +515,14 @@ static void dtu_thread_entry_send(void *parameter)
                         record_current = 0;
                         record_current = 0;
                         if(hasElementGreaterThan400(current_arry, 10)==0)   //连续10条电流值大于400,灯管状态正常
                         if(hasElementGreaterThan400(current_arry, 10)==0)   //连续10条电流值大于400,灯管状态正常
                         {
                         {
-                            device_status.lamp_status = 0;
+                            device_status.lamp = 0;
                             lamp_sta_cnt = 0;
                             lamp_sta_cnt = 0;
                         }
                         }
                         if(hasElementGreater_lessThan400(current_arry,10)==0)   //连续10条电流值小于400,灯管状态异常
                         if(hasElementGreater_lessThan400(current_arry,10)==0)   //连续10条电流值小于400,灯管状态异常
                         {
                         {
                             lamp_sta_cnt++;
                             lamp_sta_cnt++;
                         }
                         }
-                        if(lamp_sta_cnt>=3) device_status.lamp_status = 1;
+                        if(lamp_sta_cnt>=3) device_status.lamp = 1;
                         memset(current_arry,0,sizeof(current_arry));
                         memset(current_arry,0,sizeof(current_arry));
                     }
                     }
                 }
                 }
@@ -970,7 +970,7 @@ char * makeJson()
     rt_sprintf(device_status.gps, "0");
     rt_sprintf(device_status.gps, "0");
 
 
     if(device_status.work_status==0) {
     if(device_status.work_status==0) {
-        device_status.lamp_status = 0;
+        device_status.lamp = 0;
     }
     }
     if(atoi(device_status.power)>5000)
     if(atoi(device_status.power)>5000)
         rt_sprintf(device_status.power,"0.01");
         rt_sprintf(device_status.power,"0.01");
@@ -1112,7 +1112,7 @@ char * makeJson()
         rt_sprintf(utos, "%d",device_status.bat_status);
         rt_sprintf(utos, "%d",device_status.bat_status);
         cJSON_AddStringToObject(pSubJson,"batStatus",utos);
         cJSON_AddStringToObject(pSubJson,"batStatus",utos);
         //灯管状态
         //灯管状态
-        rt_sprintf(utos, "%d",device_status.lamp_status);
+        rt_sprintf(utos, "%d",device_status.lamp);
         cJSON_AddStringToObject(pSubJson,"lamp",utos);
         cJSON_AddStringToObject(pSubJson,"lamp",utos);
         //上仓门状态 1-打开,0-关闭-(通道) 打开为落虫,关闭为排水
         //上仓门状态 1-打开,0-关闭-(通道) 打开为落虫,关闭为排水
         rt_sprintf(utos, "%d",device_status.up_status);
         rt_sprintf(utos, "%d",device_status.up_status);
@@ -1531,7 +1531,7 @@ int parseDtu(char *json_string)
           {
           {
               if(strstr(item_cmd->valuestring,"takephoto")!=RT_NULL)
               if(strstr(item_cmd->valuestring,"takephoto")!=RT_NULL)
               {
               {
-                #if 0
+                #if MATCH_DEVICE == 1
                 ctr_led(ON);
                 ctr_led(ON);
                 //发送拍照指令
                 //发送拍照指令
                 char *takephotojson = makeJson_takephoto();
                 char *takephotojson = makeJson_takephoto();
@@ -1642,7 +1642,6 @@ int parseDtu(char *json_string)
                       }
                       }
                       else
                       else
                       {
                       {
-
                           device_status.selfcheck_ws = 2;
                           device_status.selfcheck_ws = 2;
                       }
                       }
                       LOG_I("收到自检指令:%d",device_status.selfcheck_ws);
                       LOG_I("收到自检指令:%d",device_status.selfcheck_ws);

+ 2 - 2
Application_cbd_apm32f1/applications/hmi.c

@@ -370,7 +370,7 @@ static void HMI_Decode(void)
     }
     }
     //拍照
     //拍照
     else if(strstr(rx_buffer,"putTest.switchPhoto=1")!=NULL) {
     else if(strstr(rx_buffer,"putTest.switchPhoto=1")!=NULL) {
-        #if 0
+        #if MATCH_DEVICE == 1
         ctr_led(ON);
         ctr_led(ON);
         //发送拍照指令
         //发送拍照指令
         char *takephotojson = makeJson_takephoto();
         char *takephotojson = makeJson_takephoto();
@@ -382,7 +382,7 @@ static void HMI_Decode(void)
         #endif
         #endif
     }
     }
     else if (strstr(rx_buffer,"putTest.switchPic=1")!=NULL) {
     else if (strstr(rx_buffer,"putTest.switchPic=1")!=NULL) {
-        #if 0
+        #if MATCH_DEVICE == 1
         ctr_led(ON);
         ctr_led(ON);
         //发送拍照指令
         //发送拍照指令
         char *takephotojson = makeJson_takephoto();
         char *takephotojson = makeJson_takephoto();

+ 3 - 0
Application_cbd_apm32f1/readme.md

@@ -1,3 +1,6 @@
+# 2025-05-22 更新说明
+#define VERSION_HK_2000W    "2.15.4(2000W)"         //4.0水稻
+1. 修复偶发灯管状态显示异常问题,原因是和开关灯管状态的变量lamp_status冲突导致,解决:灯管状态使用单独的变量:lamp;
 # 2025-05-21 更新说明
 # 2025-05-21 更新说明
 #define VERSION_HK_2000W    "2.14.4(2000W)"         //4.0水稻
 #define VERSION_HK_2000W    "2.14.4(2000W)"         //4.0水稻
 1. 改进灯管检测,增加检测次数及检测间隔,提高准确度;
 1. 改进灯管检测,增加检测次数及检测间隔,提高准确度;