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

+ 4 - 4
Application_CBD/.settings/projcfg.ini

@@ -1,9 +1,9 @@
 #RT-Thread Studio Project Configuration
-#Fri Dec 27 10:56:04 CST 2024
-mcu_name=STM32F103RETX
+#Mon Mar 03 14:45:57 CST 2025
 output_project_path=D\:\\RT-ThreadStudio\\workspace\\IOT_CBD_BZY_CTRL
-hardware_adapter=ST-LINK
-selected_rtt_version=v4.0.2
+mcu_name=STM32F103RETX
+hardware_adapter=J-Link
 mcu_base_nano_proj=false
+selected_rtt_version=v4.0.2
 project_base_bsp=false
 cfg_version=v2.0

+ 2 - 2
Application_cbd_apm32f1/applications/control.h

@@ -25,8 +25,8 @@
     #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
     #define VERSION_HK_2000W    "1.3led.40(2000W)"       //水稻
 #else
-    #define VERSION_HK          "2.0.41(HK)"            //4.0海康-1200W
-    #define VERSION_HK_2000W    "2.0.4(2000W)"         //4.0水稻
+    #define VERSION_HK          "2.1.41(HK)"            //4.0海康-1200W
+    #define VERSION_HK_2000W    "2.1.4(2000W)"         //4.0水稻
 #endif
 
 #define VERSION_ZP          "1.45.1(ZP)"            //1.0转盘

+ 23 - 11
Application_cbd_apm32f1/applications/hmi.c

@@ -134,7 +134,7 @@ static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
     if ( result == -RT_EFULL)
     {
         /* 消息队列满 */
-        LOG_I("hmi message queue full!\n");
+        LOG_E("hmi message queue full!\n");
     }
     return result;
 }
@@ -947,7 +947,6 @@ static void HMI_Decode(void)
         rt_free(json_temp);
         rt_thread_delay(2000);
         MA_save();
-        rt_free(var);
         rt_kprintf("工作时间参数已保存:模式-%d,光控时间-%d,时控开始时间-%d,时控结束时间-%d\n",device_status.timeSwitch,device_status.sunBar,device_status.startBar,device_status.stopBar);
     }
     else if (strstr(rx_buffer,"saveSystemSet")!=NULL) {
@@ -1024,34 +1023,36 @@ static void HMI_Decode(void)
         strncpy(heattime_str,var+2,2);
         if(atoi(heattime_str)>0 && atoi(heattime_str) <= 30)
         {
-            rt_kprintf("加热时间:%d\n",atoi(heattime_str));
             device_status.heattime = atoi(heattime_str); //加热时间
+            LOG_I("设置加热时间:%d",atoi(heattime_str));
             ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime));
         }
         strncpy(heatvale_str,var+4,3);
         if(atoi(heatvale_str) > 0 && atoi(heatvale_str) <= 130)
         {
             device_status.heatvalue=atoi(heatvale_str);
+            LOG_I("设置加热温度:%d",device_status.heatvalue);
             ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
         }
         strncpy(vol_str,var+7,3);
         if(atoi(vol_str)>0&&atoi(vol_str)<8)
         {
             device_status.vol = atoi(vol_str);   //音量
-            DTU_Write("volume=");
+            LOG_I("设置音量:%d",device_status.vol);
+            //DTU_Write("volume=");
         }
         strncpy(thsp_str,var+10,4);
         if(atoi(thsp_str)>0&&atoi(thsp_str)<3600)
         {
             device_status.thsp = atoi(thsp_str);  //熄屏时间
+            LOG_I("设置熄屏时间:%d",device_status.thsp);
         }
         else {
-            rt_kprintf("参数设置失败!!!\n");
+            LOG_E("参数设置失败!!!");
         }
         rt_thread_delay(1000);
         MA_save();
-        rt_free(var);
-        rt_kprintf("系统设置已保存:收集时间-%d,加热时间-%d,加热温度-%d,音量-%d,自动关屏-%d\n",device_status.clt_time,device_status.heattime,device_status.heatvalue,device_status.vol,device_status.thsp);
+        //rt_kprintf("系统设置已保存:收集时间-%d,加热时间-%d,加热温度-%d,音量-%d,自动关屏-%d\n",device_status.clt_time,device_status.heattime,device_status.heatvalue,device_status.vol,device_status.thsp);
     }
     else if (strstr(rx_buffer,"rtc_h=")!=NULL) {
         char rtc_h[2];
@@ -1099,7 +1100,6 @@ static void HMI_Decode(void)
         else {
             rt_kprintf("设置失败!!!\n");
         }
-        rt_free(var);
         rt_kprintf("数据上传设置:%d\n",device_status.dattim);
     }
     //光控测试
@@ -1123,7 +1123,7 @@ static void HMI_Decode(void)
         else {
             LOG_E("设置失败!!!");
         }
-        rt_free(var);
+
         LOG_D("震动时间设置:%d",device_status.shake_sec);
     }
     //切换大数据平台
@@ -1852,7 +1852,7 @@ static void Ctr_Mortor_entry(void* parameter)
 int Hmi_Fresh(void)
 {
     //初始化串口4
-    HMI_uart4_init();
+    //HMI_uart4_init();
     rt_err_t ret = RT_EOK;
     /* 初始化消息队列 */
     rt_mq_init(&rx_mq, "rx_mq",
@@ -2203,6 +2203,18 @@ void Check_ParamConfig(void)
         if(device_status.version_type==6) device_status.timeSwitch = 1;
         DTU_Write("%s",makeJson_Warn("turnon", "device_stm32"));
         rt_thread_delay(1000);
+        if(device_status.dtype!=7&&device_status.version_type!=30)
+        {
+            Workstatus_check();
+        }
+
+        /********************/
+        //工作流程
+        if(device_status.version_type!=30)
+        {
+            Work_Loop_Task();
+        }
+
 #endif
     }
 }
@@ -2417,4 +2429,4 @@ void Debug_log_OFF(void)
 MSH_CMD_EXPORT(Debug_log_ON,Debug_log_ON);
 MSH_CMD_EXPORT(Debug_log_OFF,Debug_log_OFF);
 //
-//INIT_BOARD_EXPORT(HMI_uart4_init);
+INIT_BOARD_EXPORT(HMI_uart4_init);

+ 14 - 17
Application_cbd_apm32f1/applications/sht30_collect.c

@@ -64,10 +64,10 @@ int Read_Heat_Current(void);
 
 // 定义滑动平均滤波器结构体
 typedef struct {
-    float* buffer;
+    rt_uint16_t* buffer;
     int bufferSize;
     int currentIndex;
-    float sum;
+    rt_uint16_t sum;
 } MovingAverageFilter;
 
 // 初始化滑动平均滤波器
@@ -77,7 +77,7 @@ MovingAverageFilter* moving_average_filter_init(int size) {
         return NULL;
     }
 
-    filter->buffer = (float*)calloc(size, sizeof(float));
+    filter->buffer = (rt_uint16_t*)calloc(size, sizeof(rt_uint16_t));
     if (filter->buffer == NULL) {
         free(filter);
         return NULL;
@@ -91,7 +91,7 @@ MovingAverageFilter* moving_average_filter_init(int size) {
 }
 
 // 更新滑动平均滤波器
-float moving_average_filter_update(MovingAverageFilter* filter, float newValue) {
+rt_uint16_t moving_average_filter_update(MovingAverageFilter* filter, rt_uint16_t newValue) {
     filter->sum -= filter->buffer[filter->currentIndex];
     filter->buffer[filter->currentIndex] = newValue;
     filter->sum += newValue;
@@ -195,21 +195,20 @@ static void Power_ReadCheck(void *parameter)
     rt_thread_delay(1000);
     while(1)
     {
-        sprintf(device_status.power,"%.2f",(float)(moving_average_filter_update(filter, (float)Read_Real_Current())-2465)/0.4);
+        rt_uint16_t _24v_current_int = moving_average_filter_update(filter,Read_Real_Current());
+        sprintf(device_status.power,"%.2f",(float)(_24v_current_int-2430)/0.4);
         //消除误差
-        if(Read_Heat_Current()-2465<10)
+        if(Read_Heat_Current()-2450<10)
         {
             sprintf(device_status.heat_power,"%.f",0.0);
         }
         else
         {
-            sprintf(device_status.heat_power,"%.2f",(float)(moving_average_filter_update(filter_hi, Read_Heat_Current())-2465)/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)(_heat_current_int-2450)/0.1);     //2481-2465
         }
+
         //LOG_I("负载电流:%s,加热电流:%s",device_status.power,device_status.heat_power);
-        if(device_status.selfcheck_ws==2)
-        {
-            //HMI_WRITE("sysSet.va0.txt=\"%s\"",device_status.power);
-        }
         if (Read_Real_Voltage()/100<12)
         {
             //关闭外设
@@ -229,7 +228,7 @@ static void Power_ReadCheck(void *parameter)
             HMI_WRITE("sleep=%d",1);
             #endif
             bat_cnt++;
-        }else if(atof(device_status.voltage)>24.0)    //大于24.0V,解除欠压
+        }else if(atof(device_status.voltage)>=24.0)    //大于24.0V,解除欠压
         {
             bat_cnt = 0;
             device_status.C01 &= ~(1<<4);
@@ -316,16 +315,14 @@ static void Power_ReadCheck(void *parameter)
             device_status.C01 |= (1<<4);
             device_status.bat_status = 1; //欠压
         }
-        #if ROBOT_EN == 0
+
         //rt_sprintf(device_status.voltage,"%d.%02d",filter_voltage()/100,filter_voltage()%100);
-        sprintf(device_status.voltage,"%.2f",(float)(moving_average_filter_update(filter_v, (float)Read_Real_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);
         //LOG_D("voltage is:%sV",device_status.voltage);
         sprintf(device_status.fuse_voltage, "%d.%02d",Read_Fuse_Voltage()/100,Read_Fuse_Voltage()%100);
-        #endif
         rt_thread_mdelay(10);
     }
-    moving_average_filter_free(filter);
-    moving_average_filter_free(filter_v);
 }
 /*读取电流值*/
 int Read_Real_Current(void)