📄 icc(atmega16).c
字号:
if((f2.bit.powered==1)||(f1.bit.tested==1))
{
if(f6.bit.key_start_push==0)
{
if(!CHKBIT(PINC,key_in))
f6.bit.key_start_push=1;
}
else
{
if(CHKBIT(PINC,key_in))
{
f6.bit.key_start_push=0;
f0.bit.k_start_pushed=1;
key_num=k_start;f3.bit.buzed=1;
}
}
}
if(!CHKBIT(PINC,key_in))
f2.bit.k_test3=1;
else f2.bit.k_test3=0;
}
void check_k_cycle(void)
{
if((f2.bit.powered==1)&&(f2.bit.started==0))
{
if(f6.bit.key_cycle_push==0)
{
if(!CHKBIT(PINC,key_in))
f6.bit.key_cycle_push=1;
}
else
{
if(CHKBIT(PINC,key_in))
{
f6.bit.key_cycle_push=0;
f0.bit.k_cycle_pushed=1;
key_num=k_cycle;f3.bit.set=1;f3.bit.buzed=1;
}
}
}
}
void check_k_fab(void)
{
if((f2.bit.powered==1)&&(f2.bit.started==0))
{
if(f6.bit.key_fab_push==0)
{
if(!CHKBIT(PINC,key_in))
f6.bit.key_fab_push=1;
}
else
{
if(CHKBIT(PINC,key_in))
{
f6.bit.key_fab_push=0;
f0.bit.k_fab_pushed=1;
key_num=k_fab;f3.bit.set=1;f3.bit.buzed=1;
}
}
}
}
void check_k_temp(void)
{
if((f2.bit.powered==1)&&(f2.bit.started==0))
{
if(f6.bit.key_temp_push==0)
{
if(!CHKBIT(PINC,key_in))
f6.bit.key_temp_push=1;
}
else
{
if(CHKBIT(PINC,key_in))
{
f6.bit.key_temp_push=0;
f0.bit.k_temp_pushed=1;
key_num=k_temp;f3.bit.set=1;f3.bit.buzed=1;
}
}
}
}
void check_k_extrinse(void)
{
if((f2.bit.powered==1)&&(f2.bit.started==0))
{
if(f6.bit.key_extrinse_push==0)
{
if(!CHKBIT(PINC,key_in))
f6.bit.key_extrinse_push=1;
}
else
{
if(CHKBIT(PINC,key_in))
{
f6.bit.key_extrinse_push=0;
f0.bit.k_extrinse_pushed=1;
key_num=k_extrinse;f3.bit.set=1;f3.bit.buzed=1;
}
}
}
else
{
if(!CHKBIT(PINC,key_in))
f2.bit.k_test2=1;
else f2.bit.k_test2=0;
}
}
void check_k_delay(void)
{
if((f2.bit.powered==1)&&(f2.bit.started==0))
{
if(f6.bit.key_delay_push==0)
{
if(!CHKBIT(PINC,key_in))
f6.bit.key_delay_push=1;
}
else
{
if(CHKBIT(PINC,key_in))
{
f6.bit.key_delay_push=0;
f0.bit.k_delay_pushed=1;
key_num=k_delay;f3.bit.set=1;f3.bit.buzed=1;
}
}
}
else
{
if(!CHKBIT(PINC,key_in))
f2.bit.k_test1=1;
else f2.bit.k_test1=0;
}
}
void process_key(void)
{
//-----------------------------------------
if(key_num==k_power)
{
key_num=0;
k_power_count++;
if(k_power_count==1)
{
f2.bit.powered=1;
//-------------------POWER ON默认程序:热洗冷漂,化纤,主洗+漂洗+脱水
f7.bit.wash_prog6=1;
f9.bit.huaxian_sel=1;
f9.bit.h_c_sel=1;
flag_wash=flag_rinse=flag_spin=1;
main_wash_time=86;
water_temp=60;
}
else
{
k_start_count=0;//清START记数
k_power_count=0;
f2.bit.powered=0;
}
}
//-----------------------------------------
if(f1.bit.tested==0)
{
if(key_num==k_start)
{
key_num=0;
k_start_count++;
if(k_start_count==1)
f2.bit.started=1;
else
{
k_start_count=0;
f2.bit.started=0;
}
}
}
else //测试
{
if(f11.bit.test_prog_end==0)
{
if(key_num==k_start) {key_num=0;test_count++;}
}
}
if(key_num==k_fab)
{
key_num=0;
f9.byte=0;
k_cycle_count=0;
f7.byte=f5.byte=0;
flag_prewash=0;
flag_wash=flag_rinse=flag_spin=1;
k_fab_count++;
if(k_fab_count==1)
{
f9.bit.mianma_sel=1;
f9.bit.h_h_sel=1;
water_temp=90;
main_wash_time=106;
}
if(k_fab_count==2)
{
f9.bit.huaxian_sel=1;
f9.bit.h_c_sel=1;
water_temp=60;
main_wash_time=86;
}
if(k_fab_count==3)
{
f9.bit.sinong_sel=1;
f9.bit.h_c_sel=1;
water_temp=60;
main_wash_time=66;
}
if(k_fab_count==4)
{
f9.bit.maoliao_sel=1;
f9.bit.w_w_sel=1;
water_temp=45;
main_wash_time=46;
}
if(k_fab_count>=5)
{
k_fab_count=1;
f9.bit.mianma_sel=1;
f9.bit.h_h_sel=1;
water_temp=90;
main_wash_time=86;
}
}
///-----------------------------------------
if(f9.bit.mianma_sel==1)
{
if(key_num==k_cycle)
{
key_num=0;
flag_extrinse=0;
f7.byte=f5.byte=0;
flag_prewash=flag_wash=flag_rinse=flag_spin=0;
k_cycle_count++;
if(k_cycle_count==1)
{
main_wash_time=120;
f7.bit.wash_prog2=1;
flag_prewash=flag_wash=flag_rinse=flag_spin=1;
}
else if(k_cycle_count==2)
{
main_wash_time=8;
f7.bit.wash_prog3=1;
flag_spin=1;
}
else if(k_cycle_count==3)
{
main_wash_time=21;
f7.bit.wash_prog4=1;
flag_rinse=flag_spin=1;
}
else if(k_cycle_count==4)
{
main_wash_time=98;
f7.bit.wash_prog5=1;
flag_wash=flag_rinse=1;
}
else if(k_cycle_count>4)
{
k_cycle_count=0;
main_wash_time=106;
f7.bit.wash_prog1=1;
flag_wash=flag_rinse=flag_spin=1;
}
}
else if(key_num==k_temp)//--------------------------------
{
key_num=0;
f9.bit.h_h_sel=f9.bit.h_c_sel=f9.bit.w_w_sel=f9.bit.c_c_sel=0;
k_temp_count++;
if(k_temp_count==1) {f9.bit.h_h_sel=1;water_temp=90;}
if(k_temp_count==2) {f9.bit.h_c_sel=1;water_temp=60;}
if(k_temp_count==3) {f9.bit.w_w_sel=1;water_temp=45;}
if(k_temp_count==4) {f9.bit.c_c_sel=1;}
if(k_temp_count>=5)
{k_temp_count=1;f9.bit.h_h_sel=1;water_temp=90;}
}
}
//---------------------------------------
else if(f9.bit.sinong_sel==1)
{
if(key_num==k_cycle)
{
key_num=0;
flag_extrinse=0;
f7.byte=f5.byte=0;
flag_prewash=flag_wash=flag_rinse=flag_spin=0;
k_cycle_count++;
if(k_cycle_count==1)
{
main_wash_time=8;
f7.bit.wash_prog3=1;
flag_spin=1;
}
else if(k_cycle_count==2)
{
main_wash_time=21;
f7.bit.wash_prog4=1;
flag_rinse=flag_spin=1;
}
else if(k_cycle_count==3)
{
main_wash_time=58;
f5.bit.wash_prog12=1;
flag_wash=flag_rinse=1;
}
else if(k_cycle_count>3)
{
k_cycle_count=0;
main_wash_time=66;
f5.bit.wash_prog9=1;
flag_wash=flag_rinse=flag_spin=1;
}
}
else if(key_num==k_temp)//----------------------------
{
key_num=0;
f9.bit.h_h_sel=f9.bit.h_c_sel=f9.bit.w_w_sel=f9.bit.c_c_sel=0;
k_temp_count++;
if(k_temp_count==1) {f9.bit.h_c_sel=1;water_temp=60;}
if(k_temp_count==2) {f9.bit.w_w_sel=1;water_temp=45;}
if(k_temp_count==3) {f9.bit.c_c_sel=1;}
if(k_temp_count>=4)
{k_temp_count=1;f9.bit.h_c_sel=1;water_temp=60;}
}
}
//---------------------------
else if(f9.bit.huaxian_sel==1)
{
if(key_num==k_cycle)
{
key_num=0;
flag_extrinse=0;
f7.byte=f5.byte=0;
flag_prewash=flag_wash=flag_rinse=flag_spin=0;
k_cycle_count++;
if(k_cycle_count==1)
{
main_wash_time=100;
f7.bit.wash_prog7=1;
flag_prewash=flag_wash=flag_rinse=flag_spin=1;
}
else if(k_cycle_count==2)
{
main_wash_time=8;
f5.bit.wash_prog10=1;
flag_spin=1;
}
else if(k_cycle_count==3)
{
main_wash_time=21;
f5.bit.wash_prog11=1;
flag_rinse=flag_spin=1;
}
else if(k_cycle_count==4)
{
main_wash_time=78;
f7.bit.wash_prog8=1;
flag_wash=flag_rinse=1;
}
else if(k_cycle_count>4)
{
k_cycle_count=0;
main_wash_time=86;
f7.bit.wash_prog6=1;
flag_wash=flag_rinse=flag_spin=1;
}
}
else if(key_num==k_temp)//----------------------------
{
key_num=0;
k_temp_count++;
f9.bit.h_c_sel=f9.bit.h_h_sel=f9.bit.w_w_sel=f9.bit.c_c_sel=0;
if(k_temp_count==1) {f9.bit.h_c_sel=1;water_temp=60;}
if(k_temp_count==2) {f9.bit.w_w_sel=1;water_temp=45;}
if(k_temp_count==3) {f9.bit.c_c_sel=1;}
if(k_temp_count>=4)
{k_temp_count=1;f9.bit.h_c_sel=1;water_temp=60;}
}
}
//---------------------------
else if(f9.bit.maoliao_sel==1)
{
if(key_num==k_cycle)
{
key_num=0;
flag_extrinse=0;
f7.byte=f5.byte=0;
flag_prewash=flag_wash=flag_rinse=flag_spin=0;
k_cycle_count++;
if(k_cycle_count==1)
{
main_wash_time=8;
f5.bit.wash_prog14=1;
flag_spin=1;
}
else if(k_cycle_count==2)
{
main_wash_time=21;
f5.bit.wash_prog15=1;
flag_rinse=flag_spin=1;
}
else if(k_cycle_count==3)
{
main_wash_time=38;
f5.bit.wash_prog16=1;
flag_wash=flag_rinse=1;
}
else if(k_cycle_count>3)
{
k_cycle_count=0;
main_wash_time=46;
f5.bit.wash_prog13=1;
flag_wash=flag_rinse=flag_spin=1;
}
}
else if(key_num==k_temp)//----------------------------
{
key_num=0;
f9.bit.h_c_sel=f9.bit.h_h_sel=f9.bit.w_w_sel=f9.bit.c_c_sel=0;
k_temp_count++;
if(k_temp_count==1) {f9.bit.w_w_sel=1;water_temp=45;}
if(k_temp_count==2) f9.bit.c_c_sel=1;
if(k_temp_count>2)
{k_temp_count=1;f9.bit.w_w_sel=1;water_temp=45;}// 是否选择没温度。
}
}
///-----------------------------------------
if(key_num==k_extrinse)
{
key_num=0;
k_extrinse_count++;
if(k_extrinse_count==1)
{
if((flag_spin>=1)&&(flag_prewash==0)&&(flag_wash==0)&&(flag_rinse==0))
flag_extrinse=0;
else if(flag_rinse==2)
{flag_rinse=1;flag_extrinse=1;;main_wash_time+=8;}
else {flag_extrinse=1;main_wash_time+=8;}
}
else
{
k_extrinse_count=0;
if(flag_extrinse==1)
{flag_extrinse=0;main_wash_time-=8;}
}
}
///-----------------------------------------
if(key_num==k_delay)
{
key_num=0;
flag_time=1;
time_data++;
if(time_data>24)
{
time_data=0;
flag_time=0;
}
}
///-----------------------------------------
if(f2.bit.started==1)
{
f3.bit.set=0;
if(flag_time>=1) flag_time=2;
}
}
void check_water1(void)
{
if(!CHKBIT(PINB,water1))
{
water1_off_count++;
if(water1_off_count>=3)
{
f1.bit.water1ed=0;
water1_off_count=0;
}
}
else {water1_off_count=0;
if(CHKBIT(PINB,water1))
{
water1_on_count++;
if(water1_on_count>=18)
{
f1.bit.water1ed=1;
water1_on_count=0;
}
}
else water1_on_count=0;
}
}
void check_water2(void)
{
if(!CHKBIT(PINB,water2))
{
water2_off_count++;
if(water2_off_count>=3)
{
f1.bit.water2ed=0;
water2_off_count=0;
}
}
else {water2_off_count=0;
if(CHKBIT(PINB,water2))
{
water2_on_count++;
if(water2_on_count>=18)
{
f1.bit.water2ed=1;
water2_on_count=0;
}
}
else water2_on_count=0;
}
}
void check_door(void)
{
if(!CHKBIT(PINB,door_in))
{
door_on_count++;
if(door_on_count>=4)
{
f1.bit.doored=1;
door_on_count=0;
}
}
else door_on_count=0;
if(CHKBIT(PINB,door_in))
{
door_off_count++;
if(door_off_count>=18)
{
f1.bit.doored=0;
door_off_count=0;
}
}
else door_off_count=0;
}
void check_switch(void)
{
check_water1();
check_water2();
check_door();
}
void enter_water_err(void) //按START键取消
{
if(f10.bit.enter_water_erred=0)
{
if((CHKBIT(PORTB,bumpa))||(CHKBIT(PORTD,bumpb))||(CHKBIT(PORTD,bumpc))||(CHKBIT(PORTD,bumph)))
{
enter_water_count++;
if(enter_water_count>480)
{
enter_water_count=0;
if(f1.bit.water1ed==0)
f10.bit.enter_water_erred=1;
}
}
}
}
void drain_err(void)
{
if(f10.bit.drain_erred==0)
{
if(CHKBIT(PIND,drain))//排水泵启动
{
drain_count++;
if(drain_count>240)
{
drain_count=0;
if(f1.bit.water1ed==1)
f10.bit.drain_erred=1;
}
}
}
}
void overflow_err(void)
{
if(f10.bit.overflow_erred==0)
{
if(f1.bit.water2ed==1)
{
overflow_count++;
if(overflow_count>2)
{
overflow_count=0;
f10.bit.overflow_erred=1;
}
}
}
}
void door_lock_err(void)
{
if( f10.bit.door_lock_erred==0)
{
if((f11.bit.test_prog_end==0)||(f3.bit.prog_end==0))//程序未结束
{
door_lock_count++;
if(door_lock_count>10)
{
door_lock_count=0;
if(f1.bit.doored==1)
f10.bit.door_lock_erred=0;
else f10.bit.door_lock_erred=1;
}
}
else f10.bit.door_lock_erred=0;
}
else
{
if(f1.bit.doored==1)
f10.bit.door_lock_erred=0;
}
}
void rise_temp_err(void)
{
if(f10.bit.rise_temp_erred==0)
{
water_temp1=fact_water_temp;
rise_temp_count++;
if(rise_temp_count>900)
{
rise_temp_count=0;
water_temp2=fact_water_temp;
if((water_temp2-water_temp1)<1)
{
if((f3.bit.prog_end==1)||(f11.bit.test_prog_end==1)) // 冷洗冷漂程序结束后报警
f10.bit.rise_temp_erred=1;
}
}
}
}
void abnormality_temp_err(void)
{
if(f10.bit.abnormality_temp_erred==0)
{
if((fact_water_temp>90)&&(f9.bit.mianma_sel==1))
f10.bit.abnormality_temp_erred=1;
if((fact_water_temp>60)&&(f9.bit.sinong_sel==1))
f10.bit.abnormality_temp_erred=1;
if((fact_water_temp>60)&&(f9.bit.huaxian_sel==1))
f10.bit.abnormality_temp_erred=1;
if((fact_water_temp>45)&&(f9.bit.maoliao_sel==1))
f10.bit.abnormality_temp_erred=1;
}
}
void sensor_err(void)
{
if(f10.bit.sensor_erred==0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -