|
|
@@ -292,6 +292,9 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
}
|
|
|
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);
|
|
|
@@ -304,13 +307,14 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
//更新工作状态
|
|
|
HMI_WRITE("workSta.work_sta.val=%d",device_status.work_status);
|
|
|
//箱内温度-外壳
|
|
|
- HMI_WRITE("workSta.box_tmp.txt=\"%s\"",device_status.tempture);
|
|
|
- HMI_WRITE("temHum.box_tmp.txt=\"%s\"",device_status.tempture);
|
|
|
+ HMI_WRITE("workSta.box_tmp.txt=\"%d.%d\"",Get_Temprate()/100,Get_Temprate()%100);
|
|
|
+ HMI_WRITE("temHum.box_tmp.txt=\"%d.%d\"",Get_Temprate()/100,Get_Temprate()%100);
|
|
|
//制冷开关
|
|
|
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);
|
|
|
@@ -331,6 +335,8 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
HMI_WRITE("clockSet.end1.val=%d",device_status.collecting_sh2);
|
|
|
//采集结束时间2
|
|
|
HMI_WRITE("clockSet.end2.val=%d",device_status.collecting_eh2);
|
|
|
+ //数据上传间隔
|
|
|
+ HMI_WRITE("sysSet.datt.val=%d",device_status.dattim);
|
|
|
}
|
|
|
/**********************************吸虫塔*********************************/
|
|
|
if(device_status.version_type==6)
|
|
|
@@ -395,12 +401,12 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
//转盘复位
|
|
|
else if (strstr(rx_buffer,"turn_init")!=NULL) {
|
|
|
LOG_I("转仓复位!");
|
|
|
- ctr_turn(0);
|
|
|
+ ctr_turn(0,0);
|
|
|
}
|
|
|
//转盘
|
|
|
else if (strstr(rx_buffer,"turn")!=NULL) {
|
|
|
LOG_I("转仓!");
|
|
|
- ctr_turn(90);
|
|
|
+ ctr_turn(90,0);
|
|
|
}
|
|
|
//打开电磁阀
|
|
|
else if (strstr(rx_buffer,"putTest.switchDrop=1")!=NULL) {
|
|
|
@@ -504,6 +510,16 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
pwm_off(2, 0);
|
|
|
pwm_off(3,0);
|
|
|
}
|
|
|
+ else if (strstr(rx_buffer,"putTest.switchAutotest=1")!=NULL)
|
|
|
+ {
|
|
|
+ LOG_I("开始一键测试!!!");
|
|
|
+ device_status.auto_test_sw=1;
|
|
|
+ }
|
|
|
+ else if (strstr(rx_buffer,"putTest.switchAutotest=1")!=NULL)
|
|
|
+ {
|
|
|
+ LOG_I("停止一键测试!!!");
|
|
|
+ device_status.auto_test_sw=0;
|
|
|
+ }
|
|
|
//清扫
|
|
|
else if (strstr(rx_buffer,"clear")!=NULL) {
|
|
|
rt_kprintf("\n清扫!\n");
|
|
|
@@ -619,10 +635,11 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
device_status.shake_sec = *((int *)var); //滴液时间
|
|
|
ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec));
|
|
|
var+=4;
|
|
|
- device_status.culture_time = *((int *)var); //培养时间
|
|
|
- ef_set_env_blob("culture_time", &device_status.culture_time, sizeof(device_status.culture_time));
|
|
|
+ device_status.cul_time = *((int *)var); //培养时间
|
|
|
+ ef_set_env_blob("cul_time", &device_status.cul_time, sizeof(device_status.cul_time));
|
|
|
MA_save();
|
|
|
- LOG_I("参数已保存:%d-%d-%d-%d-%d-%d",device_status.collecting_sh1,device_status.collecting_eh1,device_status.collecting_sh2,device_status.collecting_eh2,device_status.shake_sec,device_status.culture_time);
|
|
|
+ LOG_I("参数已保存:%d-%d-%d-%d-%d-%d",device_status.collecting_sh1,device_status.collecting_eh1,device_status.collecting_sh2,device_status.collecting_eh2,device_status.shake_sec,device_status.cul_time);
|
|
|
+ return;
|
|
|
}
|
|
|
char value_str[10];
|
|
|
memset(value_str,0,sizeof(value_str));
|
|
|
@@ -714,6 +731,30 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
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) {
|
|
|
+ if(device_status.dtype==7)
|
|
|
+ {
|
|
|
+ LOG_I("系统设置,孢子仪!");
|
|
|
+ var = strstr(rx_buffer,"=");
|
|
|
+ var ++;
|
|
|
+ device_status.cold_sw = *((int *)var); //制冷开关
|
|
|
+ ef_set_env_blob("cold_sw", &device_status.cold_sw, sizeof(device_status.cold_sw));
|
|
|
+ var+=4;
|
|
|
+ device_status.vol = *((int *)var); //音量
|
|
|
+ var+=4;
|
|
|
+ device_status.heatvalue = *((int *)var); //设定培养温度
|
|
|
+ ef_set_env_blob("heatvalue", &device_status.heatvalue, sizeof(device_status.heatvalue));
|
|
|
+ var+=4;
|
|
|
+ device_status.dattim = *((int *)var); //数据上传间隔
|
|
|
+ ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim));
|
|
|
+ var+=4;
|
|
|
+ device_status.thsp = *((int *)var); //自动熄屏
|
|
|
+ ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
|
|
|
+ MA_save();
|
|
|
+ LOG_I("制冷开关:%d",device_status.cold_sw);
|
|
|
+ LOG_I("系统设置已保存:\n自动熄屏-%d\n音量-%d\n培养温度-%d\n数据上传间隔-%d",device_status.thsp,device_status.vol,device_status.heatvalue,device_status.dattim);
|
|
|
+ MA_save();
|
|
|
+ return;
|
|
|
+ }
|
|
|
char clt_time_str[3],heattime_str[3],heatvale_str[4],vol_str[4],thsp_str[5];
|
|
|
rt_kprintf("系统设置!\n");
|
|
|
var = strstr(rx_buffer,"=");
|
|
|
@@ -1090,7 +1131,8 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
rt_uint16_t num_down_open = 200; //
|
|
|
rt_uint16_t num_down_close = 200; //
|
|
|
rt_uint16_t photo_led_sec = 450; //45S
|
|
|
-
|
|
|
+ /*孢子仪拍照数量*/
|
|
|
+ rt_uint16_t photo_setup = 0;
|
|
|
while(1)
|
|
|
{
|
|
|
time_t time_reset12V;
|
|
|
@@ -1206,6 +1248,7 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
{
|
|
|
SunTest();
|
|
|
}
|
|
|
+ //拍照
|
|
|
if(device_status.photo_ws==1)
|
|
|
{
|
|
|
ctr_led(ON);
|
|
|
@@ -1215,7 +1258,7 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
DTU_Write("takephoto.mp3");
|
|
|
//延时
|
|
|
rt_thread_delay(1000);
|
|
|
- rt_kprintf("\n测试拍照!\n");
|
|
|
+ LOG_I("测试拍照!");
|
|
|
Hk_Take_io();
|
|
|
char *takephotojson = makeJson_takephoto();
|
|
|
DTU_Write("%s",takephotojson);
|
|
|
@@ -1231,8 +1274,130 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
HMI_WRITE("sysTest.switchFill.val=0");
|
|
|
}
|
|
|
}
|
|
|
+ /*对焦拍照*/
|
|
|
+ if(device_status.autotakepic==1)
|
|
|
+ {
|
|
|
+ DTU_Write("autotakephoto");
|
|
|
+ //打开补光灯
|
|
|
+ ctr_led(ON);
|
|
|
+ //电机向下运动
|
|
|
+ ctr_Motor_Driver(1, 1, 500000,200);
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ LOG_I("电机到达下方!!!");
|
|
|
+ Hk_Take_io();
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ LOG_I("电机开始向上!!!");
|
|
|
+ rt_pin_write(Motor_EN, 1);
|
|
|
+ rt_pin_write(Motor_DIR, 0);
|
|
|
+ beep_set(500000, 500000/5); //2kzh - 50%
|
|
|
+ while(rt_pin_read(LIMIT_UP)==1)
|
|
|
+ {
|
|
|
+ rt_thread_delay(10);
|
|
|
+ photo_setup++;
|
|
|
+ rt_pin_write(Motor_EN, 0); //驱动器失能
|
|
|
+ Hk_Take_io();
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ rt_pin_write(Motor_EN, 1); //驱动器使能
|
|
|
+ if(photo_setup>300)
|
|
|
+ {
|
|
|
+ ctr_led(OFF);
|
|
|
+ device_status.autotakepic=0;
|
|
|
+ rt_pin_write(Motor_EN, 0); //驱动器失能
|
|
|
+ beep_set(500000, 0); //2kzh - 50%
|
|
|
+ HMI_WRITE("sysTest.switchAutopic.val=%d",0);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ LOG_I("对焦拍照:%d",photo_setup);
|
|
|
+ }
|
|
|
+ ctr_led(OFF);
|
|
|
+ rt_pin_write(Motor_EN, 0); //驱动器失能
|
|
|
+ beep_set(500000, 0); //2kzh - 50%
|
|
|
+ HMI_WRITE("sysTest.switchAutopic.val=%d",0);
|
|
|
+ char w_temp[20];
|
|
|
+ rt_sprintf(w_temp,"%s%d","autoTakePhoto success!!!",photo_setup);
|
|
|
+ char *autotake_warn = makeJson_Warn(w_temp, "Motor");
|
|
|
+ DTU_Write("%s",autotake_warn);
|
|
|
+ rt_free(autotake_warn);
|
|
|
+ device_status.autotakepic=0;
|
|
|
+ photo_setup = 0;
|
|
|
+ HMI_WRITE("sysTest.switchAutopic.val=%d",0);
|
|
|
+ DTU_Write("takephotodone");
|
|
|
+ }
|
|
|
+ if(device_status.fsl_sw==1)
|
|
|
+ {
|
|
|
+ ctr_Petroleum_jelly(10);
|
|
|
+ }
|
|
|
+ //一键测试
|
|
|
+ if(device_status.auto_test_sw==1)
|
|
|
+ {
|
|
|
+ //转盘复位
|
|
|
+ LOG_I("转盘复位!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ ctr_turn(0,0);
|
|
|
+ //转90
|
|
|
+ LOG_I("第一次转盘!!!");
|
|
|
+ ctr_turn(90,0);
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ //推杆电机:测试粘附:
|
|
|
+ LOG_I("涂凡士林!!!");
|
|
|
+ ctr_Petroleum_jelly(10);
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ //转90
|
|
|
+ LOG_I("第二次转盘!!!");
|
|
|
+ ctr_turn(90,0);
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ //采集,打开风机
|
|
|
+ LOG_I("采集,打开风机!!!");
|
|
|
+ ctr_Collect_Fan(ON);
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ LOG_I("采集结束,关闭风机!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ ctr_Collect_Fan(OFF);
|
|
|
+ //散热
|
|
|
+ LOG_I("打开散热!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ ctr_Cool_Fan(ON);
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ LOG_I("关闭散热!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ ctr_Cool_Fan(OFF);
|
|
|
+ //转90
|
|
|
+ LOG_I("第三次转盘!!!");
|
|
|
+ ctr_turn(90,0);
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ //滴液
|
|
|
+ LOG_I("开始滴液!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ ctr_shake(ON,device_status.shake_sec);
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ LOG_I("停止滴液!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ //加热
|
|
|
+ LOG_I("开始加热!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ ctr_Heat(ON);
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ LOG_I("停止加热!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ ctr_Heat(OFF);
|
|
|
+ //制冷
|
|
|
+ LOG_I("开始制冷!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ ctr_Cold(ON);
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ LOG_I("停止制冷!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ ctr_Cold(OFF);
|
|
|
+ //转90
|
|
|
+ LOG_I("第四次转盘!!!");
|
|
|
+ ctr_turn(90,0);
|
|
|
+ LOG_I("打开补光灯!!!");
|
|
|
+ rt_thread_delay(2000);
|
|
|
+ ctr_led(ON);
|
|
|
+ device_status.autotakepic=1;
|
|
|
+ device_status.auto_test_sw=0;
|
|
|
+ }
|
|
|
rt_thread_delay(100);
|
|
|
- //rt_kprintf("action num is:%d%d%d",num_up_open,num_up_close,num_down_open,num_down_close,num_clear);
|
|
|
}
|
|
|
}
|
|
|
/*屏幕写数据*/
|
|
|
@@ -1318,6 +1483,16 @@ void Check_ParamConfig(void)
|
|
|
device_status.dattim = 20; //数据上传间隔
|
|
|
device_status.ds = 1; //设备状态
|
|
|
device_status.update_flag = 0;
|
|
|
+ /*孢子仪*/
|
|
|
+ device_status.collecting_sh1 = 9;
|
|
|
+ device_status.collecting_eh1 = 10;
|
|
|
+ device_status.collecting_sh2 = 14;
|
|
|
+ device_status.collecting_eh2 = 16;
|
|
|
+ device_status.cold_sw = 0;
|
|
|
+ device_status.heat_sw =0;
|
|
|
+ device_status.cul_time = 1;
|
|
|
+ device_status.run_sta = 0;
|
|
|
+
|
|
|
sprintf(device_status.driver, "%s",VERSION_HK);
|
|
|
rt_sprintf(device_status.tempture, "26");
|
|
|
rt_sprintf(device_status.humidity, "31");
|
|
|
@@ -1343,6 +1518,14 @@ void Check_ParamConfig(void)
|
|
|
ef_set_env_blob("env_h",&device_status.humidity,sizeof(device_status.humidity)); //湿度
|
|
|
ef_set_env_blob("platform",&device_status.mqttcfg1,sizeof(device_status.mqttcfg1)); //上传平台
|
|
|
|
|
|
+ ef_set_env_blob("cul_time",&device_status.cul_time,sizeof(device_status.cul_time)); //采集时间
|
|
|
+ ef_set_env_blob("cold_sw",&device_status.cold_sw,sizeof(device_status.cold_sw)); //制冷开关
|
|
|
+ ef_set_env_blob("heat_sw",&device_status.heat_sw,sizeof(device_status.heat_sw)); //加热开关
|
|
|
+ ef_set_env_blob("collecting_sh1",&device_status.collecting_sh1,sizeof(device_status.collecting_sh1)); //风机开关
|
|
|
+ ef_set_env_blob("collecting_eh1",&device_status.collecting_eh1,sizeof(device_status.collecting_eh1)); //采集时间
|
|
|
+ ef_set_env_blob("collecting_sh2",&device_status.collecting_sh2,sizeof(device_status.collecting_sh2)); //采集时间
|
|
|
+ ef_set_env_blob("collecting_eh2",&device_status.collecting_eh2,sizeof(device_status.collecting_eh2)); //采集时间
|
|
|
+ ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta)); //
|
|
|
LOG_I("SOFTWARE VERSION:%s",device_status.driver);
|
|
|
LOG_I("Default paramconf is:");
|
|
|
LOG_I("stime:%d",device_status.iSave);
|
|
|
@@ -1387,6 +1570,15 @@ void Check_ParamConfig(void)
|
|
|
ef_get_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type),NULL); //版本类型
|
|
|
ef_get_env_blob("driver_bl",&device_status.driver_bl,sizeof(device_status.driver_bl),NULL); //BL版本号 进BL的时候存储到FLASH
|
|
|
ef_get_env_blob("platform",&device_status.mqttcfg1,sizeof(device_status.mqttcfg1),NULL); //平台地址
|
|
|
+ /*孢子仪*/
|
|
|
+ ef_get_env_blob("cul_time",&device_status.cul_time,sizeof(device_status.cul_time),NULL); //培养时间
|
|
|
+ ef_get_env_blob("cold_sw",&device_status.cold_sw,sizeof(device_status.cold_sw),NULL); //制冷开关
|
|
|
+ ef_get_env_blob("heat_sw",&device_status.heat_sw,sizeof(device_status.heat_sw),NULL); //加热开关
|
|
|
+ ef_get_env_blob("collecting_sh1",&device_status.collecting_sh1,sizeof(device_status.collecting_sh1),NULL); //采集开始1
|
|
|
+ ef_get_env_blob("collecting_eh1",&device_status.collecting_eh1,sizeof(device_status.collecting_eh1),NULL); //采集结束1
|
|
|
+ ef_get_env_blob("collecting_sh2",&device_status.collecting_sh2,sizeof(device_status.collecting_sh2),NULL); //采集开始2
|
|
|
+ ef_get_env_blob("collecting_eh2",&device_status.collecting_eh2,sizeof(device_status.collecting_eh2),NULL); //采集结束2
|
|
|
+ ef_get_env_blob("run_sta",&device_status.run_sta,sizeof(device_status.run_sta),NULL); //运行状态
|
|
|
device_status.light_over_tim = device_status.sunBar * 3600; //光控计数
|
|
|
device_status.work_done = 0;
|
|
|
//工作完成标志位
|
|
|
@@ -1439,10 +1631,7 @@ void Check_ParamConfig(void)
|
|
|
else if (device_status.version_type==30) {
|
|
|
rt_sprintf(device_status.driver, "%s",VERSION_Robot);
|
|
|
}
|
|
|
- if(device_status.iccid[0]!=8)
|
|
|
- {
|
|
|
- rt_sprintf(device_status.iccid,"87654321000000000000");
|
|
|
- }
|
|
|
+ /*定制三色光源*/
|
|
|
#if LAMP_EN == 1
|
|
|
device_status.sunBar = 9;
|
|
|
device_status.timeSwitch = 0;
|
|
|
@@ -1466,10 +1655,9 @@ void Check_ParamConfig(void)
|
|
|
LOG_I("数据上传间隔:%d",device_status.dattim);
|
|
|
LOG_I("温湿度数据:%d-%d",atoi(device_status.tempture),atoi(device_status.humidity));
|
|
|
LOG_I("上传平台:%s",device_status.mqttcfg1);
|
|
|
+ LOG_I("孢子仪运行状态:%d",device_status.run_sta);
|
|
|
}
|
|
|
- LOG_I("当前时间:%04d-%02d-%02d %02d:%02d:%02d",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
|
//RTC时间判断,如果当前年份小于2020,提示需要设置时间,切换为光控
|
|
|
-
|
|
|
if(device_status.update_flag==1)
|
|
|
{
|
|
|
device_status.update_flag = 0;
|