📄 12864串口.c
字号:
/******************************************************************
超声清洗系统-操作控制部分程序
台州市迈尔电子科技有限公司
网址:http://www.maier.zj.cn
邮箱:lmhtz@mail.tzptt.zj.cn
KEY.C file
作者:罗敏华
建立日期: 2007.04
修改日期: 2007.03.22
版本:V1.0
版权所有,盗版必究。
Copyright(C) Computer-lov 2007-2017
All rights reserved
*******************************************************************/
#include "includes.h"
//***********************************************************************
//hex to bcd 非压缩 OK
void hex_to_bcd(u08 hex_to_bcd_temp)
{
u08 temp;
hex_to_bcd_100=10;
hex_to_bcd_10=10;
hex_to_bcd_1=10;
hex_to_bcd_100 = hex_to_bcd_temp/100;
temp = hex_to_bcd_temp % 100;
hex_to_bcd_10 = temp/10;
hex_to_bcd_1 = temp % 10;
if (hex_to_bcd_100==0) hex_to_bcd_100=10;
if (hex_to_bcd_10==0)
{
if (hex_to_bcd_100==10) hex_to_bcd_10=10;
}
}
//***********************************************************************
//***********************************************************************
//按键操作处理 OK
unsigned char fkey(void)
{
key=0;
if (UpKey==0) key=1;
if (DownKey==0) key=2;
if (FunKey==0) key=3;
if (StartKey==0) key=4;
switch(key_state)
{
case 1:
if(key>0) key_state=2;
break;
case 2:
if(key>0)
{
switch(key)
{
case 3:
beep=1;beep_x=1;beep_temp=0;
menu++;
key_to_clr_time=0;
if (menu==2) if (temp_eer==1) menu++;
if (time_exte==0) if(menu==1) menu++;
con_disp (0x00,0x00,0x96,0x90,15);//------
con_disp (0x00,0x00,0x97,0x90,15);//
con_disp (0x00,0x00,0x8e,0x80,15);//
con_disp (0x00,0x00,0x8f,0x80,15);//清反白
con_disp (0x00,0x00,0x9c,0x90,15);//
con_disp (0x00,0x00,0x9d,0x90,15);//
con_disp (0x00,0x00,0x9e,0x90,15);//------
if(menu==4)
{
menu=0;
//-------------------------------------------------------------------------
//存储调整后的数据
stc_rw_inc++;
stc_eeprom_add=0x2800+stc_rw_inc;
EepromWrite(stc_eeprom_add,0x55);
stc_r_add=stc_rw_inc*3;
stc_eeprom_add=0x28ff-stc_r_add-2;
EepromWrite(stc_eeprom_add,time_data);
stc_eeprom_add++;
EepromWrite(stc_eeprom_add,temp_data);
stc_eeprom_add++;
EepromWrite(stc_eeprom_add,power_data);
//-------------------------------------------------------------------------
if (time_exte==1)
{
time_60s_data=time_data;
hex_to_bcd(time_60s_data);
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,14);
}
}
break;
//------------------------------------------------------------------------
case 1:
//------------------------------------------------------------------------
if(menu==1) //时间增加调节
{
key_to_clr_time=0;
time_data++;
if (time_data>100)
{
time_data=100;
hex_to_bcd(time_data);
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,11);
time_60s_data=time_data;
hex_to_bcd(time_60s_data);
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,14);
break;
}
beep=1;beep_x=1;beep_temp=0;
hex_to_bcd(time_data);
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,11);
time_60s_data=time_data;
hex_to_bcd(time_60s_data);
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,14);
break;
}
//----------------------------------------------------------------------
if(menu==2) //温度增加调节
{
key_to_clr_time=0;
temp_data++;
if (temp_data>100)
{
temp_data=100;
hex_to_bcd(temp_data);
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,12);
break;
}
beep=1;beep_x=1;beep_temp=0;
hex_to_bcd(temp_data);
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,12);
break;
}
//-------------------------------------------------------------------------
if(menu==3) //功率增加调节
{
key_to_clr_time=0;
power_data=power_data+10;
if (power_data>100)
{
power_data=100;
hex_to_bcd(power_data);
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,13);
break;
}
beep=1;beep_x=1;beep_temp=0;
hex_to_bcd(power_data);
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,13);
con_disp (0x00,0x00,0x8e,0x80,15);
con_disp (0x00,0x00,0x8f,0x80,15);
}
switch(power_data)
{
case 10:
th0_x1=0xe6; //定时器高位数值
tl0_x1=0xff;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 20:
th0_x1=0xe9; //定时器高位数值
tl0_x1=0x7f;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 30:
th0_x1=0xec; //定时器高位数值
tl0_x1=0x00;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 40:
th0_x1=0xee; //定时器高位数值
tl0_x1=0x7f;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 50:
th0_x1=0xf1; //定时器高位数值
tl0_x1=0x00;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 60:
th0_x1=0xf3; //定时器高位数值
tl0_x1=0x7f;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 70:
th0_x1=0xf6; //定时器高位数值
tl0_x1=0x00;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 80:
th0_x1=0xf8; //定时器高位数值
tl0_x1=0x80;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 90:
th0_x1=0xfb; //定时器高位数值
tl0_x1=0x00;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 100:
th0_x1=0xff; //定时器高位数值
tl0_x1=0x80;
power_to=1;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
}
break;
//---------------------------------------------------------------------------
case 2:
if(menu==1) //减少时间
{
key_to_clr_time=0;
time_data--;
if (time_data==0)
{
time_data=1;
hex_to_bcd(time_data); //温度设置数据
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,11);
time_60s_data=time_data;
hex_to_bcd(time_60s_data);
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,14);
break;
}
beep=1;beep_x=1;beep_temp=0;
hex_to_bcd(time_data); //温度设置数据
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,11);
time_60s_data=time_data;
hex_to_bcd(time_60s_data);
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,14);
break;
}
//---------------------------------------------------------------------------
if(menu==2) //减少温度
{
key_to_clr_time=0;
temp_data--;
if (temp_data==0)
{
temp_data=1;
hex_to_bcd(temp_data); //温度设置数据
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,12);
break;
}
beep=1;beep_x=1;beep_temp=0;
hex_to_bcd(temp_data); //温度设置数据
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,12);
break;
}
//---------------------------------------------------------------------------------------------
if(menu==3) //减少功率
{
key_to_clr_time=0;
power_to=0;
power_data=power_data-10;
if (power_data==0)
{
power_data=10;
hex_to_bcd(power_data); //温度设置数据
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,13);
break;
}
beep=1;beep_x=1;beep_temp=0;
hex_to_bcd(power_data); //温度设置数据
chn_disp_to(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,13);
}
switch(power_data)
{
case 10:
th0_x1=0xe6; //定时器高位数值
tl0_x1=0xff;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 20:
th0_x1=0xe9; //定时器高位数值
tl0_x1=0x7f;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 30:
th0_x1=0xec; //定时器高位数值
tl0_x1=0x00;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 40:
th0_x1=0xee; //定时器高位数值
tl0_x1=0x7f;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 50:
th0_x1=0xf1; //定时器高位数值
tl0_x1=0x00;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 60:
th0_x1=0xf3; //定时器高位数值
tl0_x1=0x7f;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 70:
th0_x1=0xf6; //定时器高位数值
tl0_x1=0x00;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 80:
th0_x1=0xf8; //定时器高位数值
tl0_x1=0x80;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 90:
th0_x1=0xfb; //定时器高位数值
tl0_x1=0x00;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
case 100:
th0_x1=0xff; //定时器高位数值
tl0_x1=0x80;
if (power_run==1)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
}
break;
}
break;
//------------------------------------------------------------------------
//启动按键处理
case 4:
key=4;
if (time_exte_b==0)
{
//-------------------------------------------------------------------
th0_xx=0xe6;//定时器高位数值
tl0_xx=0xff;
power_to=0;
power_out=1;
led_chao =! led_chao;
power_run =! power_run; //调功允许标志
beep=1;beep_x=1;beep_temp=0;
time_60s_b =! time_60s_b;
time_exte_b1=!time_exte_b1;
con_disp (0x00,0x00,0x94,0x90,15);
con_disp (0x00,0x00,0x95,0x90,15);
time_60s_data=time_data;
hex_to_bcd(time_60s_data);
chn_disp_to1(hex_to_bcd_100,hex_to_bcd_10,hex_to_bcd_1,14);
}
break;
//------------------------------------------------------------------------
}
key_state=3;
}
else
key_state=1;
break;
case 3:
if(key==0)
{
key_state=1;
}
key=0;
break;
}
return key;
}
//***********************************************************************
//***********************************************************************
//反白提示处理 OK
void play_t(void)
{
if (menu!=0)
{
if (play_time_temp==play_time)
{
play_time_temp=0;
if (play_t_y==0) //开反白处理
{
play_t_y=1;
switch(menu)
{
case 1: //时间调整反白
con_disp (0x00,0xff,0x97,0x90,15);
if (time_data>9) con_disp (0xff,0xff,0x97,0x90,15);
if (time_data>99) con_disp (0x00,0xff,0x96,0x90,15);
return;
//--------------------------------------------------------------------------
case 2: //温度调整反白
con_disp (0x00,0xff,0x8f,0x80,15);
if (temp_data>9) con_disp (0xff,0xff,0x8f,0x80,15);
if (temp_data>99) con_disp (0x00,0xff,0x8e,0x80,15);
return;
case 3: //功率调整反白
con_disp (0xff,0x00,0x9e,0x90,15);
if (power_data>9) con_disp (0xff,0xff,0x9d,0x90,15);
if (power_data>99) con_disp (0x00,0xff,0x9c,0x90,15);
return;
}
}
if (play_t_y==1) //关反白处理
{
play_t_y=0;
switch(menu)
{
case 1:
con_disp (0x00,0x00,0x96,0x90,15);
con_disp (0x00,0x00,0x97,0x90,15);
return;
case 2:
con_disp (0x00,0x00,0x8e,0x80,15);
con_disp (0x00,0x00,0x8f,0x80,15);
return;
case 3:
con_disp (0x00,0x00,0x9c,0x90,15);
con_disp (0x00,0x00,0x9d,0x90,15);
con_disp (0x00,0x00,0x9e,0x90,15);
return;
}
}
}
play_time_temp++;
}
return;
}
//***********************************************************************
//***********************************************************************
//蜂鸣器驱动
void beep_out(void)
{
if (beep_x>0)
{
if (Frebeep==0)
{
if (beep_temp>beep_time)
{
beep=0;
beep_temp=0;
beep_x--;
if (beep_x!=0) Frebeep=1;
return;
}
beep_temp++;
return;
}
if (beep_temp>beep_time)
{
beep=1;
beep_temp=0;
Frebeep=0;
return;
}
beep_temp++;
}
}
//***********************************************************************
//***********************************************************************
//调功处理
void power_tt(void)
{
if (power_run==1)
{
if (power_hq==1)
{
if(th0_x1<=th0_x)
{
th0_xx=th0_x1;
tl0_xx=tl0_x1;
th0_x=0xe6;
tl0_x=0xfF;
power_hq=0;
if (power_data>=100)
{
power_to=1;
return;
}
power_to=0;
return;
}
if (power_time_temp==power_time)
{
power_time_temp=0;
th0_xx=th0_x++;
return;
}
power_time_temp++;
return;
}
return;
}
power_hq=1;
th0_x=0xe6;
tl0_x=0xff;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -