sbit MOSI=P2^7; //數(shù)據(jù)輸入
sbit ISD_INT=P3^3; //、、中斷
/********************************************************************/
uint count,addata;
uchar results[7];
uint counts[4];
uchar ncount,counter,flag,select,ys,adress,vv,oo,aa;
uchar pp[24]={0,0x0a,0x14,0x1e,0x28,0x32,0x3c,0x46,0x50,0x5a,0x64,0x6e,0x78,0x82,0x8c,0x96,0xa0,0xaa,0xb4,0xbe,0xc8,0xd2,0xdc,0xe6}; //0-230
/*******************************************************************/
void LCD12864_busy(void)
{
bit BF = 0;
LCD12864_EN=0;
LCD12864_DIN=0;
LCD12864_CLK=1;
LCD12864_IO=0xff; //單片機(jī)讀數(shù)據(jù)之前必須先置高位
do
{
LCD12864_EN=1;
BF=LCD12864_IO&0x80;
LCD12864_EN=0;
} while(BF);
}
/*******************************************************************/
// 寫入命令
/*******************************************************************/
void LCD12864_command(unsigned char command)
{
LCD12864_busy();
LCD12864_EN=0;
LCD12864_DIN=0;
LCD12864_CLK=0;
LCD12864_EN=1;
LCD12864_IO=command;
LCD12864_EN=0;
}
/*******************************************************************/
// 寫入一字節(jié)數(shù)據(jù)
/*******************************************************************/
void LCD12864_data(unsigned char dat)
{
LCD12864_busy();
LCD12864_EN=0;
LCD12864_DIN=1;
LCD12864_CLK=0;
LCD12864_EN=1;
LCD12864_IO=dat;
LCD12864_EN=0;
}
void LCD12864_char(unsigned char dat)
{
if((dat>=0)&&(dat<=9))
dat|=0x30;
LCD12864_data(dat);
}
/*******************************************************************/
// 設(shè)置顯示位置 X(1~8),Y(1~4)
/*******************************************************************/
void LCD12864_address(unsigned char line,unsigned char row)
{
switch(row)
{
case 1:LCD12864_command(0x7f + line);
break;
case 2:LCD12864_command(0x8f + line);
break;
case 3:LCD12864_command(0x87 + line);
break;
case 4:LCD12864_command(0x97 + line);
default:
break;
}
}
/*******************************************************************/
// 在指定位置顯示字符串
/*******************************************************************/
void LCD12864_string(unsigned char row,unsigned char line,unsigned char *s)
{
unsigned char LCD12864_temp;
LCD12864_address(row,line);
LCD12864_temp=*s;
while(LCD12864_temp != 0x00)
{
LCD12864_data(LCD12864_temp);
LCD12864_temp=*(++s);
}
}





