#include < reg52.h >
/*****************************预定义**************************************/
#define uchar unsigned char
#define uint unsigned int
/***************************12864管脚配置****************************/
#define port P0
sbit rs=P2^0;
sbit rw=P2^1;
sbit e=P2^2;
sbit cs1=P2^3;
sbit cs2=P2^4;
uchar old1=1,old2=1,old3,old4,old5,old6; //原始密码000000
unsigned char PassWord[6];
uchar new1,new2,new3,new4,new5,new6; //每次MCU采集到的密码输入
uchar a=16,b=16,c=16,d=16,e1=16,f=16; //送入数码管显示的变量
uchar wei,key,temp;
bit allow,ok,wanbi,retry,close; //各个状态位
sbit beep=P1^6;
sbit jdq=P1^7;
uchar code data_shuju1[50][16] = {//阴码、列行、逆向
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,
/*-- 文字: * --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
/*************************************************************************/
uchar code data_shuju[50][32] = {//阴码、列行、逆向
/*-- 文字: 请 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x42,0xCC,0x00,0x00,0x44,0x54,0x54,0x54,0x7F,0x54,0x54,0x54,0x44,0x40,0x00,
0x00,0x00,0x7F,0x20,0x10,0x00,0xFF,0x15,0x15,0x15,0x55,0x95,0x7F,0x00,0x00,0x00,
/*-- 文字: 输 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x88,0x68,0x1F,0xC8,0x08,0x10,0xC8,0x54,0x52,0xD1,0x12,0x94,0x08,0xD0,0x10,0x00,
0x09,0x19,0x09,0xFF,0x05,0x00,0xFF,0x12,0x92,0xFF,0x00,0x5F,0x80,0x7F,0x00,0x00,
/*-- 文字: 入 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x01,0xE2,0x1C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x03,0x0C,0x30,0x40,0x80,0x80,0x00,
/*-- 文字: 密 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x8C,0x44,0x04,0xE4,0x04,0x95,0xA6,0x44,0x24,0x14,0x84,0x44,0x94,0x0C,0x00,
0x02,0x02,0x7A,0x41,0x41,0x43,0x42,0x7E,0x42,0x42,0x42,0x43,0xF8,0x00,0x00,0x00,
/*-- 文字: 码 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x84,0xE4,0x5C,0x44,0xC4,0x00,0x02,0xF2,0x82,0x82,0x82,0xFE,0x80,0x80,0x00,
0x02,0x01,0x7F,0x10,0x10,0x3F,0x00,0x08,0x08,0x08,0x08,0x48,0x88,0x40,0x3F,0x00,
/*-- 文字: 正 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x02,0x02,0xC2,0x02,0x02,0x02,0xFE,0x82,0x82,0x82,0x82,0x82,0x02,0x00,0x00,
0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
/*-- 文字: 确 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x84,0xE4,0x5C,0x44,0xC4,0x20,0x10,0xE8,0x27,0x24,0xE4,0x34,0x2C,0xE0,0x00,
0x02,0x01,0x7F,0x10,0x10,0x3F,0x80,0x60,0x1F,0x09,0x09,0x3F,0x49,0x89,0x7F,0x00,
/*-- 文字: 错 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x30,0xEF,0x24,0x64,0x48,0x48,0x7F,0x48,0x48,0x48,0x7F,0x48,0x48,0x40,0x00,
0x01,0x01,0x7F,0x21,0x11,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x00,0x00,
/*-- 文字: 误 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x42,0xCC,0x00,0x00,0x80,0x9E,0x92,0x92,0x92,0x92,0x92,0x9E,0x80,0x00,0x00,
0x00,0x00,0x7F,0x20,0x94,0x84,0x44,0x24,0x14,0x0F,0x14,0x24,0x44,0x84,0x84,0x00,
};
/********************************************************************************************
* 函数名称:Lcd_Display_On()
* 功 能:LCD显示开
* 入口参数:无
* 出口参数:无
*********************************************************************************************/
void Lcd_Display_On()
{
port=0x3f;
rs=0;
rw=0;
e=1;
e=0;
}
/********************************************************************************************
* 函数名称:Lcd_Display_Off()
* 功 能:LCD显示关
* 入口参数:无
* 出口参数:无
*********************************************************************************************/
void Lcd_Display_Off()
{
port=0x3e;
rs=0;
rw=0;
e=1;
e=0;
}
/********************************************************************************************
* 函数名称:Lcd_Set_X(uchar x)
* 功 能:LCD设置X坐标
* 入口参数:x
* 出口参数:无
*********************************************************************************************/
void Lcd_Set_X(uchar x)
{
port=0xb8|x;
rs=0;
rw=0;
e=1;
e=0;
}
/********************************************************************************************
* 函数名称:Lcd_Set_Y(uchar y)
* 功 能:LCD设置Y坐标
* 入口参数:y
* 出口参数:无
*********************************************************************************************/
void Lcd_Set_Y(uchar y)
{
port=0x40|y;
rs=0;
rw=0;
e=1;
e=0;
}
/********************************************************************************************
* 函数名称:Lcd_Set_X_Y(uchar x, uchar y )
* 功 能:LCD设置x y坐标
* 入口参数:x y
* 出口参数:无
*********************************************************************************************/
void Lcd_Set_X_Y(uchar x, uchar y)
{
if( y<64 )
{ cs1=1; cs2=0; Lcd_Set_Y( y ); }
else
{ cs1=0; cs2=1; Lcd_Set_Y( y-64 ); }
Lcd_Set_X( x);
}
/********************************************************************************************
* 函数名称:Lcd_Write_Command()
* 功 能:写指令代码
* 入口参数:无
* 出口参数:无
*********************************************************************************************/
void Lcd_Write_Command(uchar temp)
{
port=temp;
rs=0;
rw=0;
e=1;
e=0;
}
/********************************************************************************************
* 函数名称:Lcd_Write_Byte()
* 功 能:写数据
* 入口参数:无
* 出口参数:无
*********************************************************************************************/
void Lcd_Write_Byte(uchar temp)
{
port=temp;
rs=1;
rw=0;
e=1;
e=0;
}
/****************************************************************************
*名称:Lcd_Character_16X8( bit bit_flag, uchar x, uchar y, uchar code *point )
*功能:显示16X8字符(字母)
*入口参数:
*出口参数:
*说明:bit_flag = 1 正常显示 bit_flag = 0 黑白反相显示
****************************************************************************/
void Lcd_Character_16X8( bit bit_flag, uchar x, uchar y, uchar code *point )
{
uchar i , j,temp;
temp=y;
if( bit_flag )
{
for( i=0; i<2; i++ )
{
x+=i;
y=temp;
for( j=0;j<8;j++ )
{
Lcd_Set_X_Y( x, y ); y++;
Lcd_Write_Byte( point[ i*8 + j] );
}
}
}
else
{
for( i = 0; i < 2; i++ )
{
x += i;
y = temp;
for( j = 0; j < 8; j++ )
{
Lcd_Set_X_Y( x, y ); y++;
Lcd_Write_Byte( ~point[ i * 8 + j ] );
}
}
}
}
/****************************************************************************
* 名称:Lcd_Character_16X16( bit bit_flag, uchar x, uchar y, uchar code *point )
* 功能:显示16*16字符(汉字)
* 入口参数:x y d