#include "reg51.h"
#include "intrins.h"
#include "absaCC.h"
#include ".\inc\ASCII816.h" //标准ASCII码库
#include ".\inc\HzTable.h" //自制的汉字库
#include ".\inc\menu.h"</P><P> //自制的菜单库
sbit LCD12232_A0=P3^3;
sbit LCD12232_RW=P3^1; //读写
sbit LCD12232_E1=P3^5; //片选1(Master)
sbit LCD12232_E2=P3^4; //片选2(slave)
#define LCD12232_DATA P1 //数据口
void ClearScreen(void);
/*----------------------------------------------------------------------------
调用方式:void OutMI(unsigned char i)
函数说明:发指令i到主窗口。(内函数,私有,用户不直接调用)
------------------------------------------------------------------------------*/
void OutMI(unsigned char i)
{
LCD12232_E2=0; //确认
LCD12232_A0=0;
LCD12232_RW=1;
LCD12232_E1=1; _nop_();
LCD12232_DATA = i;
while( LCD12232_DATA & 0x80 ); //busy?
LCD12232_E1=0; _nop_();</P><P>LCD12232_RW=0;
LCD12232_E1=1; _nop_();</P><P>LCD12232_DATA=i;_nop_();
LCD12232_E1=0; _nop_();
}
/*------------------------------------------------------------------------------
调用方式:void OutMD(unsigned char i)
函数说明:发数据i到主窗口。(内函数,私有,用户不直接调用)
-------------------------------------------------------------------------------*/
void OutMD(unsigned char i)
{
LCD12232_E2=0; //确
LCD12232_A0=0;
LCD12232_RW=1;
LCD12232_E1=1; _nop_();
LCD12232_DATA = i;
while( LCD12232_DATA & 0x80 );
LCD12232_E1=0; _nop_();LCD12232_A0=1;
LCD12232_RW=0;
LCD12232_E1=1; _nop_();
LCD12232_DATA=i; _nop_();
LCD12232_E1=0; _nop_();
}
*------------------------------------------------------------------------------
调用方式:void OutSI(unsigned char i)
函数说明:发指令i到从窗口。(内函数,私有,用户不直接调用)
-------------------------------------------------------------------------------*/
void OutSI(unsigned char i)
{
LCD12232_E1=0; //确认
LCD12232_A0=0;
LCD12232_RW=1;
LCD12232_E2=1; _nop_();
LCD12232_DATA = i;
while( LCD12232_DATA & 0x80 );
LCD12232_E2=0; _nop_();
LCD12232_RW=0;
LCD12232_E2=1; _nop_();
LCD12232_DATA=i; _nop_();
LCD12232_E2=0; _nop_();
}
/*------------------------------------------------------------------------------
调用方式:void OutSD(unsigned char i)
函数说明:发数据i到从窗口。(内函数,私有,用户不直接调用)
-------------------------------------------------------------------------------*/
void OutSD(unsigned char i)
{
LCD12232_E1=0; //确认
LCD12232_A0=0;
LCD12232_RW=1;
LCD12232_E2=1; _nop_();
LCD12232_DATA =i;
while( LCD12232_DATA & 0x80 );
LCD12232_E2=0; _nop_();
LCD12232_A0=1;
LCD12232_RW=0;
LCD12232_E2=1; _nop_();
LCD12232_DATA=i; _nop_();
LCD12232_E2=0; _nop_();
}</P><P>/*--------------------------------------------------------------------------------------------------*/
//显示8*8点阵
//字模被竖着切分
//lin:行(0-3), column: 列(0-14)
//address : 字模区首地址
void Show88(unsigned char lin,unsigned char column,unsigned int address)
{
unsigned char i,j;</P><P> if( column > 14) return;</P><P></P><P> if( column < 7 ) //8*8点阵都在左屏(Master)
{ OutMI( 0xB8 | lin); //设置显示行
OutMI( column*8 ); //设置显示列
for(i=0; i<8 ; i++ ) { OutMD( CBYTE[address+i] ); }
}
if( column == 7) //8*8点阵,前6个在左屏(Master),后两个在右屏(Slave)
{ OutMI( 0xB8 | lin); //设置显示行
OutMI( column*8 ); //左屏
for(i=0; i<6 ; i++ )
{ OutMD( CBYTE[address+i] ); }</P><P> OutSI( 0xB8 | lin); //设置显示行
OutSI( 0 ); //右屏
for(i=0; i<3 ; i++ ) { OutSD( CBYTE[address+i+5] ); }
}
if( column > 7) //8*8点阵都在右屏(Slave)
{ OutSI( 0xB8 | lin); //设置显示行
OutSI( column*8-61 );
for(i=0; i<8 ; i++ ) { OutSD( CBYTE[address+i] ); }
}
}</P><P>/*------------------------------------------------------------------------------------------------*/
//显示8*16字符
//旋转90度:字模被竖着切分
//lin:行(0-3), column: 列(0-15)
//character:字符代码(标准ASCII码)
void ShowChar(unsigned char lin,unsigned char column,unsigned char character)
{ lin=lin<<1;
Show88(lin ,column,ASCII816[character-0x20] );
Show88(lin+1,column,ASCII816[character-0x20]+8 );
}
/*----------------------------------------------------------------------------------------------*/
//显示一个汉字
//旋转90度:字模被竖着切分
//lin:行(0-3), column: 列(0-7)
//hzcode: 汉字代码(自定义的)
//uchar code HZtable
void ShowHZ(unsigned char lin,unsigned char column,unsigned int hzcode)
{
lin=lin<<1; //lin*2
Show88(lin,column,HZTable[hzcode]);
Show88(lin,column+1,HZTable[hzcode]+8);
Show88(lin+1,column,HZTable[hzcode]+16);
Show88(lin+1,column+1,HZTable[hzcode]+24);
}
////////////////////////////////////////////////////////////////////////</P><P>
/*------------------------------------------------------------------------------
调用方式:void LcdIni(void)
函数说明:12232点阵液晶初始化,开机后仅调用一次。
------------------------------------------------------------------------------*/
void InitLCD(void)
{
OutMI(0XE2);OutSI(0XE2);//复位
OutMI(0XAE);OutSI(0XAE);//POWER SAVE
OutMI(0XA4);OutSI(0XA4);//动态驱动
OutMI(0XA9);OutSI(0XA9);//1/32占空比
OutMI(0XA0);OutSI(0XA0);//时钟线输出
OutMI(0XEE);OutSI(0XEE);//写模式
OutMI(0XC0);OutMI(0X00);//显示起始行为0,列地址为0
OutSI(0XC0);OutSI(0X00);//显示起始行为0,列地址为0
OutMI(0XAF);OutSI(0XAF); //开显示
ClearScreen();
}</P><P>/*------------------------------------------------------------------------------
调用方式:void clrscr(void)
函数说明:清屏
------------------------------------------------------------------------------*/
void clrscr(void)
{
unsigned char i;
unsigned char page;
for( page=0;page<2; page ++)
{
for(i=0;i<5;i++) ShowChar( page,i,' ');
}
}///////////////////////////////////////////////////////////////////////
/*------------------------------------------------------------------------------
调用方式:void SetPage(unsigned char page0,unsigned char page1)
函数说明:同时设置主从显示页为0-3页。(内函数,私有,用户不直接调用)