📄 mmi.c
字号:
/*************************************************************************
文件名 :mmi.c
作 者:eleclike
修改日期:2008-9-9
版 本:v1.00
版权说明:本程序只供学习使用,未经作者许可,不得用于其它任何用途
备 注:该模块处理人机交互,包括按键,闹钟、显示时间,LED指示等
**************************************************************************/
#include "Mmi.h"
//"ds12887.c"中定义
extern uchar Second;
extern uchar AlarmEnable;
//"main.c"中定义 本模块中用作延时
extern void DeelDisplay(void);
uchar KeyValue=0xff; //键盘值,若为0XFF,则未按下键盘
/*********************************************************
函数名称:DynamicDisplay()
函数功能:动态显示函数
入口参数:需要显示的时钟参数
出口参数:无
备 注:显示的方式为月日、时分、年星期
*********************************************************/
void DynamicDisplay(uchar dt2,uchar dt1)
{
PtData = (dt2>>4) | 0x10; //送数据dt2高四位至第1个数码管
Delay(250);
PtData = (dt2&0x0f) | 0x20; //送数据dt2低四位至第2个数码管
Delay(250);
PtData = (dt1>>4) | 0x40; //送数据dt1高四位至第3个数码管
Delay(250);
PtData = (dt1&0x0f) | 0x80; //送数据dt1低四位至第4个数码管
Delay(250);
}
/*********************************************************
函数名称:ReadKey()
函数功能:读取键盘的值
入口参数:无
出口参数:无
备 注:
*********************************************************/
void ReadKey(void)
{
KEY1=1;KEY2=1; //将需要读取的端口置一
KEY3=1;KEY4=1;
KeyValue= P3 & 0x33;
if(KeyValue != 0x33)
{
DeelDisplay(); //使用显示来延时
DeelDisplay();
DeelDisplay();
DeelDisplay();
DeelDisplay();
KEY1=1;KEY2=1;
KEY3=1;KEY4=1;
KeyValue = P3 & 0x33; //读取键值
if(KeyValue != 0x33)
{
DeelDisplay(); //使用显示来延时
DeelDisplay();
DeelDisplay();
DeelDisplay();
DeelDisplay();
KeyValue = P3 & 0x33;
AlarmEnable = 0; //任何按键将停止闹钟报警声
}
else
KeyValue = 0xff; //若无按键,置按键值无效
}
else
KeyValue = 0xff;
}
/*********************************************************
函数名称:SecondLedShine()
函数功能:表示秒的LED闪烁
入口参数:无
出口参数:无
备 注:
*********************************************************/
void SecondLedShine(void)
{
if(Second%2==0)
SecondLedOn();
else
SecondLedOff();
}
/*********************************************************
函数名称:AlarmLedShine()
函数功能:闹钟LED闪烁
入口参数:无
出口参数:无
备 注:
*********************************************************/
void AlarmLedShine(void)
{
if(Second%2==0)
AlarmLedOn();
else
AlarmLedOff();
}
/*********************************************************
函数名称:AlarmBellShine()
函数功能:闹钟蜂鸣器间断发声
入口参数:无
出口参数:无
备 注:
*********************************************************/
void AlarmBellShine(void)
{
if(Second%2==0)
AlarmBellOn();
else
AlarmBellOff();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -