void Soak(int day, int hour, int min) { if(Soak_Drain == 0 || soak_time_cur == NULL) { } else if(Soak_Drain == 1) // for Soak { if(soak_time_cur->start_hour == hour && soak_time_cur->start_min == min) { Motor_On(); Delay(30000); Motor_Off(); Soak_Drain = 2; // as soon as it starts to soak, Soak_Drain change to 2 } else if(soak_time_end_hour == hour && soak_time_end_min == min) { Motor_On(); Delay(20000); Motor_Off(); Soak_Drain = 0; } } else if(Soak_Drain == 2) // for Drain { if(soak_time_cur->end_hour == hour && soak_time_cur->end_min == min) { Motor_On(); Delay(20000); Motor_Off(); Soak_Drain = 1; // as soon as it starts to drain, Soak_Drain change to 1 soak_time_cur = soak_time_cur->next; } else if(soak_time_end_hour == hour && soak_time_end_min == min) { Motor_On(); Delay(30000); Motor_Off(); Soak_Drain = 0; } } }
void ADC_Task(void *parg) { u16 value[3]; u16 arg; float v; u16 G; u16 n; (void)parg; for(;;) { value[0]=Get_ADC();//读到的AD值 value[1]=Get_ADC(); value[2]=Get_ADC(); arg=(value[0]+value[1]+value[2])/3; v=(arg*5000)/65535;//转换成电压 G=(u16)(v/VPG);//计算重量,单位克,分辨率1g if(G==0) { Motor_On(1);//开启强振电机 Motor_On(2);//开启弱振电机 } else { if(G>=VALUE1)//前置重量 { Motor_Off(1);//关闭强振电机 if(G==VALUE2*0.99)//即将达到设定值 { Motor_Off(2);//关闭弱振电机 n++; prog2.per=n/VALUE3; LCD_DrawProg(prog2); } } prog1.per=G/VALUE2; LCD_DrawProg(prog1); } OSTimeDlyHMSM(0,0,0,250); } }
void Water(int day, int hour, int min, int sec) { if(water_time_cur->start_hour == hour && water_time_cur->start_min == min && water_time_cur->start_sec == sec) { Motor_On(); } else if(water_time_cur->end_hour == hour && water_time_cur->end_min == min && water_time_cur->end_sec == sec) { Motor_Off(); if(water_time_cur->next == NULL) { water_time_cur = water_time_head; } else { water_time_cur = water_time_cur->next; } } }