📄 keyboard.c
字号:
/**********************************************************/
/* */
/*文 件 名:Keyboard.c */
/*功 能:系统键盘输入处理文件 */
/*当前版本:V1.0 */
/*作 者:白广斌 */
/* */
/*授 权: */
/* */
/*开始日期:2007.10.04 */
/*完成日期:2007.10.04 */
/* */
/**********************************************************/
#include <avr/io.h>
#include <stdlib.h>
#include <ctype.h>
#include <avr/wdt.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <util/delay.h>
#include <Keyboard.h>
/*********************************************************************************************/
//函数名称:Date_Add(void)
//函数功能:日+1处理函数
//调用关系:被key_3_Processing()函数调用
//返 回 值:无
/*********************************************************************************************/
void Date_Add(void)
{
//31天的月份
if((SET_Month_Variable==1)||(SET_Month_Variable==3)||(SET_Month_Variable==5)||
(SET_Month_Variable==7)||(SET_Month_Variable==8)||(SET_Month_Variable==10)||
(SET_Month_Variable==12))
{
if(SET_Date_Variable>=31){SET_Date_Variable=1;goto LX;}
else{SET_Date_Variable++;goto LX;}
}
//30天的月份
if((SET_Month_Variable==4)||(SET_Month_Variable==6)||(SET_Month_Variable==9)||
(SET_Month_Variable==11))
{
if(SET_Date_Variable>=30){SET_Date_Variable=1;goto LX;}
else{SET_Date_Variable++;goto LX;}
}
//2月份 平闰年计算
if(SET_Month_Variable==2)
{
if((SET_Year_Variable%4==0)&&(SET_Year_Variable%100!=0)) //闰年
{
if(SET_Date_Variable>=29){SET_Date_Variable=1;goto LX;}
else{SET_Date_Variable++;goto LX;}
}
else //平年
{
if(SET_Year_Variable==2000)
{
if(SET_Date_Variable>=29){SET_Date_Variable=1;goto LX;}
else{SET_Date_Variable++;goto LX;}
}
else
{
if(SET_Date_Variable>=28){SET_Date_Variable=1;goto LX;}
else{SET_Date_Variable++;goto LX;}
}
}
}
LX: TIMER_Week=WeekComputer(SET_Year_Variable,SET_Month_Variable,SET_Date_Variable);
}
/*********************************************************************************************/
//函数名称:Date_Sub(void)
//函数功能:日-1处理函数
//调用关系:被key_4_Processing()函数调用
//返 回 值:无
/*********************************************************************************************/
void Date_Sub(void)
{
//31天的月份
if((SET_Month_Variable==1)||(SET_Month_Variable==3)||(SET_Month_Variable==5)||
(SET_Month_Variable==7)||(SET_Month_Variable==8)||(SET_Month_Variable==10)||
(SET_Month_Variable==12))
{
if(SET_Date_Variable<=1){SET_Date_Variable=31;goto LX;}
else{SET_Date_Variable--;goto LX;}
}
//30天的月份
if((SET_Month_Variable==4)||(SET_Month_Variable==6)||(SET_Month_Variable==9)||
(SET_Month_Variable==11))
{
if(SET_Date_Variable<=1){SET_Date_Variable=30;goto LX;}
else{SET_Date_Variable--;goto LX;}
}
//2月份 平闰年计算
if(SET_Month_Variable==2)
{
if((SET_Year_Variable%4==0)&&(SET_Year_Variable%100!=0)) //闰年
{
if(SET_Date_Variable<=1){SET_Date_Variable=29;goto LX;}
else{SET_Date_Variable--;goto LX;}
}
else //平年
{
if(SET_Year_Variable==2000)
{
if(SET_Date_Variable<=1){SET_Date_Variable=29;goto LX;}
else{SET_Date_Variable--;goto LX;}
}
else
{
if(SET_Date_Variable<=1){SET_Date_Variable=28;goto LX;}
else{SET_Date_Variable--;goto LX;}
}
}
}
LX: TIMER_Week=WeekComputer(SET_Year_Variable,SET_Month_Variable,SET_Date_Variable);
}
/*********************************************************************************************/
//函数名称:key_input(void)
//函数功能:键盘输入检测函数
//调用关系:被key_Input_Processing()函数调用
//返 回 值:键值
/*********************************************************************************************/
uchar key_input(void)
{
uchar x=255,i;
if(bit_is_set(PINE,PINE2)==0){for(i=0;i<10;i++)_delay_ms(8);if(bit_is_set(PINE,PINE2)==0){x=1;goto KB;}}
if(bit_is_set(PINE,PINE3)==0){for(i=0;i<10;i++)_delay_ms(8);if(bit_is_set(PINE,PINE3)==0){x=2;goto KB;}}
if(bit_is_set(PINE,PINE4)==0){for(i=0;i<10;i++)_delay_ms(8);if(bit_is_set(PINE,PINE4)==0){x=3;goto KB;}}
if(bit_is_set(PINE,PINE5)==0){for(i=0;i<10;i++)_delay_ms(8);if(bit_is_set(PINE,PINE5)==0){x=4;goto KB;}}
if(bit_is_set(PINE,PINE6)==0){for(i=0;i<10;i++)_delay_ms(8);if(bit_is_set(PINE,PINE6)==0){x=5;goto KB;}}
if(bit_is_set(PINE,PINE7)==0){for(i=0;i<10;i++)_delay_ms(8);if(bit_is_set(PINE,PINE7)==0){x=6;goto KB;}}
KB: return(x); //返回键值
}
/*********************************************************************************************/
//函数名称:key_Input_Processing(void)
//函数功能:键值输入处理函数
//调用关系:被main()函数调用
//返 回 值:无
/*********************************************************************************************/
void key_Input_Processing(void)
{
uchar KB;
KB=key_input();
/*进入键值判断处理*/
switch (KB)
{
case 1:
{
K1_key(); //K1键输入处理函数
break;
}
case 2:
{
K2_key(); //K2键输入处理函数
Master_Menu(Operation_Menu);
break;
}
case 3:
{
K3_key(); //K3键输入处理函数
Master_Menu(Operation_Menu);
break;
}
case 4:
{
K4_key(); //K4键输入处理函数
Master_Menu(Operation_Menu);
break;
}
case 5:
{
K5_key(); //K5键输入处理函数
break;
}
case 6:
{
K6_key(); //K6键输入处理函数
break;
}
default:
{
break;
}
}
}
/*********************************************************************************************/
//函数名称:K1_key()
//函数功能:K1键输入处理函数
//调用关系:被key_Input_Processing()函数调用
//返 回 值:无
/*********************************************************************************************/
void K1_key(void)
{
MenuNumber++;
if(MenuNumber>5){MenuNumber=1;}
Master_Menu(MenuNumber);
Password_Number[0]=10;
Password_Number[1]=10;
Password_Number[2]=10;
Password_Number[3]=10;
Password_Number[4]=10;
Password_Number[5]=10;
Password_OK=0;
SET_HH_Variable=((TIMER_Hour>>4)*10+(TIMER_Hour&0x0f)); //取小时
SET_MM_Variable=((TIMER_Minute>>4)*10+(TIMER_Minute&0x0f)); //取分钟
SET_SS_Variable=((TIMER_Second>>4)*10+(TIMER_Second&0x0f)); //取秒
SET_Year_Variable=(2000+(TIMER_Year>>4)*10+(TIMER_Year&0x0f)); //取年
SET_Month_Variable=((TIMER_Month>>4)*10+(TIMER_Month&0x0f)); //取月
SET_Date_Variable=((TIMER_Date>>4)*10+(TIMER_Date&0x0f)); //取日
wdt_reset();//喂狗,以免退出复位
eeprom_busy_wait();
Password_Cn=eeprom_read_byte(&Password_EEPROM); //密码计数器
eeprom_busy_wait();
SET_1_GTZJ_Parameter_1=eeprom_read_word(>ZJ_1_1_EEPROM); //调1#泵缸套原设置参数1
eeprom_busy_wait();
SET_1_GTZJ_Parameter_2=eeprom_read_word(>ZJ_1_2_EEPROM); //调1#泵缸套原设置参数2
eeprom_busy_wait();
SET_1_GTZJ_Parameter_3=eeprom_read_word(>ZJ_1_3_EEPROM); //调1#泵缸套原设置参数3
eeprom_busy_wait();
SET_2_GTZJ_Parameter_1=eeprom_read_word(>ZJ_2_1_EEPROM); //调2#泵缸套原设置参数1
eeprom_busy_wait();
SET_2_GTZJ_Parameter_2=eeprom_read_word(>ZJ_2_2_EEPROM); //调2#泵缸套原设置参数2
eeprom_busy_wait();
SET_2_GTZJ_Parameter_3=eeprom_read_word(>ZJ_2_3_EEPROM); //调2#泵缸套原设置参数3
}
/*********************************************************************************************/
//函数名称:K2_key()
//函数功能:K2键输入处理函数
//调用关系:被key_Input_Processing()函数调用
//返 回 值:无
/*********************************************************************************************/
void K2_key(void)
{
switch(Operation_Menu)
{
case 10://设置系统日期
{
Select_Bit++;
if(Select_Bit>2){Select_Bit=0;}
break;
}
case 11://设置系统时间
{
Select_Bit++;
if(Select_Bit>2){Select_Bit=0;}
break;
}
case 12://设置本机地址参数显示
{
//无可选择项,定义空操作
break;
}
case 13://密码认证对话框中的密码位选择操作
{
if(Password_OK==0)
{
Select_Bit++;
if(Select_Bit>5){Select_Bit=0;}
}
break;
}
case 14://缸套直径设置项循环选择显示
{
Select_Bit++;
if(Select_Bit>5){Select_Bit=0;}
break;
}
default:
{
Select_Bit=0;
if(Operation_Menu==0) //在监控界面下按K2键
{
MenuNumber=6; //为下一步确认键操作准备
ClearScreen();
LJLL_Clerr_Display(); //累计流量清零显示函数
}
break;
}
}
}
/*********************************************************************************************/
//函数名称:K3_key()
//函数功能:K3键输入处理函数
//调用关系:被key_Input_Processing()函数调用
//返 回 值:无
/*********************************************************************************************/
void K3_key(void)
{
switch(Operation_Menu)
{
case 10://设置系统日期
{
switch(Select_Bit)
{
case 0:
{
SET_Year_Variable++;
if(SET_Year_Variable>2099){SET_Year_Variable=2000;}
TIMER_Week=WeekComputer(SET_Year_Variable,SET_Month_Variable,SET_Date_Variable);
break;
}
case 1:
{
SET_Month_Variable++;
if(SET_Month_Variable>12){SET_Month_Variable=1;}
TIMER_Week=WeekComputer(SET_Year_Variable,SET_Month_Variable,SET_Date_Variable);
break;
}
case 2:
{
Date_Add();
break;
}
default:
{
break;
}
}
break;
}
case 11://设置系统时间
{
switch(Select_Bit)
{
case 0:
{
SET_HH_Variable++;
if(SET_HH_Variable>23){SET_HH_Variable=0;}
break;
}
case 1:
{
SET_MM_Variable++;
if(SET_MM_Variable>59){SET_MM_Variable=0;}
break;
}
case 2:
{
SET_SS_Variable++;
if(SET_SS_Variable>59){SET_SS_Variable=0;}
break;
}
default:
{
break;
}
}
break;
}
case 12://设置本机地址参数显示
{
if(Password_Cn<10){SET_Addr_Variable++;}
break;
}
case 13: //密码输入+1操作
{
switch(Select_Bit)
{
case 0:
{
Password_Number[0]++;
if(Password_Number[0]>9){Password_Number[0]=0;}
break;
}
case 1:
{
Password_Number[1]++;
if(Password_Number[1]>9){Password_Number[1]=0;}
break;
}
case 2:
{
Password_Number[2]++;
if(Password_Number[2]>9){Password_Number[2]=0;}
break;
}
case 3:
{
Password_Number[3]++;
if(Password_Number[3]>9){Password_Number[3]=0;}
break;
}
case 4:
{
Password_Number[4]++;
if(Password_Number[4]>9){Password_Number[4]=0;}
break;
}
case 5:
{
Password_Number[5]++;
if(Password_Number[5]>9){Password_Number[5]=0;}
break;
}
default:
{
break;
}
}
break;
}
case 14: //缸套参数+10操作
{
switch(Select_Bit)
{
case 0:
{
SET_1_GTZJ_Parameter_1+=10;
if(SET_1_GTZJ_Parameter_1>300){SET_1_GTZJ_Parameter_1=110;}
break;
}
case 1:
{
SET_1_GTZJ_Parameter_2+=10;
if(SET_1_GTZJ_Parameter_2>300){SET_1_GTZJ_Parameter_2=110;}
break;
}
case 2:
{
SET_1_GTZJ_Parameter_3+=10;
if(SET_1_GTZJ_Parameter_3>300){SET_1_GTZJ_Parameter_3=110;}
break;
}
case 3:
{
SET_2_GTZJ_Parameter_1+=10;
if(SET_2_GTZJ_Parameter_1>300){SET_2_GTZJ_Parameter_1=110;}
break;
}
case 4:
{
SET_2_GTZJ_Parameter_2+=10;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -