📄 key.c~rf487040.tmp
字号:
#include "msp430X16x.h"
#include "KEY.h"
#include "LCDdriver.h"
#include "PCF8563.h"
#include "stdbool.h"
unsigned char flagA,flagB,flagC,flagD;
bool K2_Value,K3_Value;
static unsigned int K1_Count=0;
bool K4_Value;
static unsigned char Count;
/*
static unsigned char PCF_time[6]={ //将数据暂存于PCF_time
0x18,//秒(vl、00~59BCD码)
0x28,//分(-、00~59BCD码)
0x22,//时(-、-、00~23BCD码)
0x26,//日(-、-、01~31BCD码)
0x06,//世纪月(c、-、-、01~12BCD码)
0x08,//年(00~99BCD码)
};
*/
//void Interrupt_Key_Port();
//void Intrrupt_Key_Pro();
//延时子程序
void Delay_Interrupt_MS(char ms){
uint i;
while(ms--){
for(i=0; i<800;i++);
}
}
/*
void Interrupt_Key_Port()
{
// P2SEL=0x00;//P2口所有引脚设置为一般的IO口
// P5SEL=0x00;//P5口所有引脚设置为一般的IO口
// P2DIR=0xFF;//P2口所有引脚设置为输出方向
// P5DIR=0x7F;//P5口所有引脚设置为输出方向
// P4DIR=0XFF;
// P4SEL=0X00;
P1DIR=0x00;
P1SEL=0X00; // 所有引脚为一般引脚
//P1OUT=0X00; //所有引脚为输入引脚
P1IE|=0xf0;
P1IES|=0xf0;
}
*/
void Lcd_Fill_Area_AllWhite()
{
Fill_Area(16,16,2,16,0);
Fill_Area(16,48,2,16,0);
Fill_Area(16,80,2,16,0);
Fill_Area(32,16,2,16,0);
Fill_Area(32,48,2,16,0);
Fill_Area(32,80,2,16,0);
}
void Lcd_Fill_Area_AllBlack()
{
Fill_Area(16,16,2,16,1);
Fill_Area(16,48,2,16,1);
Fill_Area(16,80,2,16,1);
Fill_Area(32,16,2,16,1);
Fill_Area(32,48,2,16,1);
Fill_Area(32,80,2,16,1);
}
void Intrrupt_Key_Pro()
{
uchar i;
if(flagA&0x01)
{
// 得到K1_Count 的值将之放到相应用的LCD12864的显示位置.
Count=K1_Count%6; //是总数年的和才会显示正确
switch(Count)
{
case 0: Fill_Area(16,16,2,16,1); break;//黑背景
case 1: Fill_Area(16,48,2,16,1); break;
case 2: Fill_Area(16,80,2,16,1); break;
case 3: Fill_Area(32,16,2,16,1); break;
case 4: Fill_Area(32,48,2,16,1); break;
case 5: Fill_Area(32,80,2,16,1); break;
default:
Fill_Area(16,16,2,16,1); //默认为'年'字背景为黑
}
flagA=0x00;
}
GetTime();
if(flagB&0x02)
{
//得到K2_Value的真值.
if(K2_Value)
{
//GetTime();
switch(Count)
{
case 0: //将值加工1后再写入到PCF8563
{
PCF_time[Count]=PCF_time[Count]+1;
SetTime();
}
case 1:
{
PCF_time[Count]=PCF_time[Count]+1;
SetTime();
}
case 2:
{
PCF_time[Count]=PCF_time[Count]+1;
SetTime();
}
case 3:
{
PCF_time[Count]=PCF_time[Count]+1;
SetTime();
}
case 4:
{
PCF_time[Count]=PCF_time[Count]+1;
SetTime();
}
case 5:
{
PCF_time[Count]=PCF_time[Count]+1;
SetTime();
}
default:
}
K2_Value=false;
}
flagB=0x00;
}
if(flagC&0x04)
{
//得到K3_Value的真值
if(K3_Value)
{
switch(Count) //值减1后再从新设置
{
case 0:
{
PCF_time[Count]=PCF_time[Count]-1;
SetTime();
} break;
case 1:
{
PCF_time[Count]=PCF_time[Count]-1;
SetTime();
} break;
case 2:
{
PCF_time[Count]=PCF_time[Count]-1;
SetTime();
} break;
case 3:
{
PCF_time[Count]=PCF_time[Count]-1;
SetTime();
} break;
case 4:
{
PCF_time[Count]=PCF_time[Count]-1;
SetTime();
} break;
case 5:
{
PCF_time[Count]=PCF_time[Count]-1;
SetTime();
} break;
default :
}
K3_Value=false;
}
flagC=0x00;
}
if(flagD&0x08)
{
//WriteCommand(0x90);
//for(i=0;i<16;i++) WriteData(Data4[i]);
//得到K4_Value的真值 确认后将所有黑幕 清除
if(K4_Value)
{
Lcd_Fill_Area_AllWhite();
K4_Value=false;
}
flagD=0x00;
}
}
#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR(void)
{
Delay_Interrupt_MS(56);
if((P1IFG&BIT4)) //向下
{
flagA=0x01;
//flagC=0x00;
K1_Count++;
P1IFG&=~BIT4;
}
else if((P1IFG&BIT5)) //增大
{
flagB=0x02;
//flagD=0x00;
K2_Value=true;
P1IFG&=~BIT5;
}
else if(P1IFG&BIT6) //减少
{
flagC=0x04;
//flagA=0x00;
K3_Value=true;
P1IFG&=~BIT6;
}
else if(P1IFG&BIT7) // 确认.
{
flagD=0x08;
//flagB=0x00;
K4_Value=true;
P1IFG&=~BIT7;
}
else
{
P4OUT &=~BIT1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -