|
|
@@ -66,7 +66,7 @@ static rt_thread_t ctr_motor = RT_NULL;
|
|
|
rt_device_t serial; /*串口设备句柄*/
|
|
|
/* 消息队列控制块 */
|
|
|
static struct rt_messagequeue rx_mq;//接收数据消息队列
|
|
|
-static void HMI_Decode(char *cmd,uint8_t cmd_len);
|
|
|
+static void HMI_Decode(void);
|
|
|
static rt_err_t uart_input(rt_device_t dev, rt_size_t size);
|
|
|
static int HMI_uart4_init(void)
|
|
|
{
|
|
|
@@ -140,7 +140,7 @@ static void Hmi_thread_entry(void *parameter)
|
|
|
rx_buffer[rx_length] = '\0';
|
|
|
rt_kprintf("%s\n",rx_buffer);
|
|
|
//\r 对应的hex为0x0d,0x0a,占两个字节,屏幕发送的数据都以\r结尾
|
|
|
- HMI_Decode(rx_buffer,rx_length);
|
|
|
+ HMI_Decode();
|
|
|
}
|
|
|
/*********************************************************************************************************************/
|
|
|
//rt_kprintf("%04d-%02d-%02d %02d:%02d:%02d\n",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
|
@@ -150,7 +150,7 @@ static void Hmi_thread_entry(void *parameter)
|
|
|
/*******************************************************************************************/
|
|
|
|
|
|
/***************************** 解析从屏幕收到的数据 begin **********************************/
|
|
|
-static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
+static void HMI_Decode(void)
|
|
|
{
|
|
|
time_t now = time(RT_NULL);
|
|
|
static struct tm tm;
|
|
|
@@ -370,7 +370,7 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
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+8);
|
|
|
+ HMI_WRITE("rtc3=%d",tm.tm_hour);
|
|
|
HMI_WRITE("rtc4=%d",tm.tm_min);
|
|
|
HMI_WRITE("rtc5=%d",tm.tm_sec);
|
|
|
|
|
|
@@ -720,19 +720,19 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
strncpy(value_str,var,2);
|
|
|
if(atoi(value_str) > 0 && atoi(value_str) <60)
|
|
|
{
|
|
|
- #if LAMP_EN == 0
|
|
|
if(device_status.version_type!=6)
|
|
|
{
|
|
|
- device_status.sunBar=atoi(value_str);
|
|
|
- ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar));
|
|
|
+ #if LAMP_EN == 1
|
|
|
+ if(device_status.sunBar%3==0)
|
|
|
+ #endif
|
|
|
+ device_status.sunBar=atoi(value_str);
|
|
|
+ ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar));
|
|
|
}
|
|
|
else {
|
|
|
device_status.shake_sec = atoi(value_str);
|
|
|
ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec));
|
|
|
}
|
|
|
- #else
|
|
|
- rt_kprintf("光控定时设置失败!!!,三光源模式!!\n");
|
|
|
- #endif
|
|
|
+
|
|
|
// time_t now;
|
|
|
// time(&now);
|
|
|
// static struct tm nowstamp;
|
|
|
@@ -743,39 +743,41 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
// device_status.light_over_tim = device_status.sunBar * 3600 + nowstamp_num;
|
|
|
}
|
|
|
else {
|
|
|
- rt_kprintf("参数设置异常(光控时长):%d!!!%d",atoi(value_str));
|
|
|
+ LOG_E("参数设置异常(光控时长):%d!!!",atoi(value_str));
|
|
|
}
|
|
|
memset(value_str,0,sizeof(value_str));
|
|
|
//时控开始时间
|
|
|
strncpy(value_str,var+2,2);
|
|
|
if(atoi(value_str) >= 0 && atoi(value_str) < 24)
|
|
|
{
|
|
|
+ #if LAMP_EN == 0
|
|
|
device_status.startBar=atoi(value_str);
|
|
|
ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar));
|
|
|
+ #endif
|
|
|
}
|
|
|
else {
|
|
|
- rt_kprintf("参数设置异常(开始):%d!!!",atoi(value_str));
|
|
|
+ LOG_E("参数设置异常(开始):%d!!!",atoi(value_str));
|
|
|
}
|
|
|
memset(value_str,0,sizeof(value_str));
|
|
|
//
|
|
|
strncpy(value_str,var+4,2);
|
|
|
if(atoi(value_str) >= 0&& atoi(value_str) < 24)
|
|
|
{
|
|
|
+ #if LAMP_EN == 0
|
|
|
device_status.stopBar=atoi(value_str);
|
|
|
ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar));
|
|
|
+ #endif
|
|
|
}
|
|
|
else {
|
|
|
- rt_kprintf("参数设置异常(结束):%d!!!",atoi(value_str));
|
|
|
+ LOG_E("参数设置异常(结束):%d!!!",atoi(value_str));
|
|
|
}
|
|
|
memset(value_str,0,sizeof(value_str));
|
|
|
//
|
|
|
strncpy(value_str,var+6,2);
|
|
|
if(atoi(value_str) >= 0 && atoi(value_str) <= 1)
|
|
|
{
|
|
|
- #if LAMP_EN == 0
|
|
|
device_status.timeSwitch=atoi(value_str);
|
|
|
ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch));
|
|
|
- #endif
|
|
|
}
|
|
|
else {
|
|
|
if(device_status.version_type==6)
|
|
|
@@ -786,7 +788,7 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch));
|
|
|
}
|
|
|
else {
|
|
|
- rt_kprintf("参数设置异常(模式):%d!!!",atoi(value_str));
|
|
|
+ LOG_E("参数设置异常(模式):%d!!!",atoi(value_str));
|
|
|
}
|
|
|
}
|
|
|
//2022/06/23,add:
|
|
|
@@ -1113,6 +1115,23 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ //4.0-4800w
|
|
|
+ else if (strstr(rx_buffer,"SwversionV48")!=NULL) {
|
|
|
+ device_status.dtype = 3;
|
|
|
+ if(device_status.version_type != 48)
|
|
|
+ {
|
|
|
+ device_status.dtype = 3;
|
|
|
+ device_status.version_type = 48;
|
|
|
+ sprintf(device_status.driver, "%s",VERSION_HK_4800W);
|
|
|
+ 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)); //版本类型+
|
|
|
+ DTU_Write("SwversionV41");
|
|
|
+ MA_save();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
//水稻
|
|
|
else if (strstr(rx_buffer,"SwversionV4")!=NULL) {
|
|
|
device_status.dtype = 3;
|
|
|
@@ -1238,7 +1257,7 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
rt_uint16_t num_up_close = 200; //
|
|
|
rt_uint16_t num_down_open = 200; //
|
|
|
rt_uint16_t num_down_close = 200; //
|
|
|
- rt_uint16_t photo_led_sec = 450; //45S
|
|
|
+ rt_int16_t photo_led_sec = 900; //55S
|
|
|
/*孢子仪拍照数量*/
|
|
|
rt_uint16_t photo_setup = 0;
|
|
|
#if Color_EN ==1
|
|
|
@@ -1362,7 +1381,19 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
{
|
|
|
ctr_led(ON);
|
|
|
//打开补光灯
|
|
|
- if(photo_led_sec==400)
|
|
|
+ if(photo_led_sec==300&&device_status.version_type==48)
|
|
|
+ {
|
|
|
+ DTU_Write("takephoto.mp3");
|
|
|
+ //延时
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ LOG_I("测试拍照!");
|
|
|
+ Hk_Take_io();
|
|
|
+ char *takephotojson = makeJson_takephoto();
|
|
|
+ DTU_Write("%s",takephotojson);
|
|
|
+ rt_free(takephotojson);
|
|
|
+ }
|
|
|
+ //15S后执行拍照
|
|
|
+ else if (photo_led_sec==750&&device_status.version_type!=48)
|
|
|
{
|
|
|
DTU_Write("takephoto.mp3");
|
|
|
//延时
|
|
|
@@ -1374,10 +1405,17 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
rt_free(takephotojson);
|
|
|
}
|
|
|
photo_led_sec--;
|
|
|
- if(photo_led_sec==0)
|
|
|
+ if(photo_led_sec==0&&device_status.version_type==48) //4800W相机
|
|
|
{
|
|
|
ctr_led(OFF);
|
|
|
- photo_led_sec = 450;
|
|
|
+ photo_led_sec = 900;
|
|
|
+ device_status.photo_ws = 0;
|
|
|
+ HMI_WRITE("sysTest.switchPhoto.val=0");
|
|
|
+ HMI_WRITE("sysTest.switchFill.val=0");
|
|
|
+ }
|
|
|
+ else if (photo_led_sec==550&&device_status.version_type!=48) {
|
|
|
+ ctr_led(OFF);
|
|
|
+ photo_led_sec = 900;
|
|
|
device_status.photo_ws = 0;
|
|
|
HMI_WRITE("sysTest.switchPhoto.val=0");
|
|
|
HMI_WRITE("sysTest.switchFill.val=0");
|
|
|
@@ -1393,7 +1431,7 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
//打开补光灯
|
|
|
ctr_led(ON);
|
|
|
//电机向下运动
|
|
|
- ctr_Motor_Driver(1, 1, 1000000,300);
|
|
|
+ ctr_Motor_Driver(1, 1, 1000000,500);
|
|
|
rt_thread_delay(1000);
|
|
|
LOG_I("电机到达下方!!!");
|
|
|
Hk_Take_io();
|
|
|
@@ -1767,14 +1805,27 @@ void Check_ParamConfig(void)
|
|
|
}
|
|
|
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);
|
|
|
}
|
|
|
+ else if (device_status.version_type==48) {
|
|
|
+ rt_sprintf(device_status.driver, "%s",VERSION_HK_4800W);
|
|
|
+ }
|
|
|
/*定制三色光源*/
|
|
|
#if LAMP_EN == 1
|
|
|
- device_status.sunBar = 9;
|
|
|
- device_status.timeSwitch = 0;
|
|
|
+ if(device_status.sunBar%3!=0)
|
|
|
+ {
|
|
|
+ device_status.sunBar = 9;
|
|
|
+ }
|
|
|
+ device_status.timeSwitch = 1;
|
|
|
+ device_status.startBar = 20;
|
|
|
+ device_status.stopBar = 23;
|
|
|
#endif
|
|
|
LOG_I("SOFTWARE VERSION:%s-imei:%s--iccid:%s",device_status.driver,device_status.imei,device_status.iccid);
|
|
|
LOG_I("read flash paramconfis:%d-%s-%s",device_status.version_type,device_status.driver_bl,device_status.driver_compile);
|
|
|
@@ -1885,12 +1936,18 @@ void ResetParamDefault(void)
|
|
|
{
|
|
|
device_status.clt_time = 10; //收集时间
|
|
|
device_status.dattim = 20; //数据上传间隔
|
|
|
+ #if LAMP_EN == 0
|
|
|
device_status.startBar = 20; //定时开始时间
|
|
|
device_status.stopBar = 5; //定时结束时间
|
|
|
+ #endif
|
|
|
device_status.heattime = 10; //加热时间
|
|
|
device_status.shake_ws = 1; //针对开关
|
|
|
device_status.shake_sec = 1; //震动时间1-100ms
|
|
|
- device_status.sunBar = 9; //光控定时时长
|
|
|
+ #if LAMP_EN == 1
|
|
|
+ device_status.sunBar = 3; //光控定时时长
|
|
|
+ #else
|
|
|
+ device_status.sunBar = 9;
|
|
|
+ #endif
|
|
|
device_status.tph = 70; //高温保护阈值
|
|
|
device_status.tpl = -5; //低温保护阈值
|
|
|
device_status.timeSwitch = 0; //定时模式:光控
|
|
|
@@ -1930,12 +1987,18 @@ void ResetParamDefault_DC(void)
|
|
|
{
|
|
|
device_status.clt_time = 10; //收集时间
|
|
|
device_status.dattim = 20; //数据上传间隔
|
|
|
+ #if LAMP_EN == 0
|
|
|
device_status.startBar = 20; //定时开始时间
|
|
|
device_status.stopBar = 0; //定时结束时间
|
|
|
+ #endif
|
|
|
device_status.heattime = 10; //加热时间
|
|
|
device_status.shake_ws = 1; //针对开关
|
|
|
device_status.shake_sec = 1; //震动时间1-100ms
|
|
|
- device_status.sunBar = 4; //光控定时时长
|
|
|
+ #if LAMP_EN == 1
|
|
|
+ device_status.sunBar = 3; //光控定时时长
|
|
|
+ #else
|
|
|
+ device_status.sunBar = 4;
|
|
|
+ #endif
|
|
|
device_status.tph = 70; //高温保护阈值
|
|
|
device_status.tpl = -5; //低温保护阈值
|
|
|
device_status.timeSwitch = 0; //定时模式
|