#define uchar unsigned char
#define uint unsigned int
uchar Page;
uchar Col,cc=0,dd=0;
bdata char com_data;
sbit mos_bit=com_data^7;
void wtcom(void);
/********************引脚定义***根据自己实际线路修改*************/
sbit E = P3^7;
sbit RW = P3^6;
sbit RS = P3^5;
sbit CSL = P3^4;
sbit CSM = P3^3;
sbit CSR = P3^2;
//=============19264 Demo Program===========================
void BusyL(void)
{
CSL= 0;
CSM= 1;
CSR= 1;
wtcom();
}
void BusyM(void)
{
CSL= 1;
CSM= 0;
CSR= 1;
wtcom();
}
void BusyR(void)
{
CSL= 1;
CSM= 1;
CSR= 0;
wtcom();
}
//===============================================================
void wtcom(void)
{
RS = 0;
RW = 1;
P1 = 0xFF;
E = 1;
_nop_();
while(P1 & 0x80); //Status Read Bit7 = BUSY
E = 0;
_nop_();
}
void Locatexy(void)
{
unsigned char x,y;
switch (Col&0xc0) /* col.and.0xC0 */
{
case 0: {BusyL();break;}
case 0x40:{BusyM();break;}
case 0x80:{BusyR();break;}
}
x = Col&0x3F|0x40; /* col.and.0x3f.or.Set Y Address*/
y = Page&0x07|0xB8; /* row.and.0x07.or.set Page */
wtcom(); /* waitting for enable */
RS = 0;
RW = 0;
P1 = y;
E = 1;
_nop_();
E = 0;
_nop_();
wtcom(); /* waitting for enable */
RS = 0;
RW = 0;
P1 = x;
E = 1;
_nop_();
E = 0;
_nop_();
}
/***************************/
/*写指令 */
/***************************/
void WriteCommandL( unsigned char CommandByte )
{
BusyL();
P1 = CommandByte;
RS = 0;
RW = 0;
E = 1;
_nop_();
E = 0;
_nop_();
}
void WriteCommandM( unsigned char CommandByte )
{
BusyM();
P1 = CommandByte;
RS = 0;
RW = 0;
E = 1;
_nop_();
E = 0;
_nop_();
}
void WriteCommandR( unsigned char CommandByte )
{
BusyR();
P1 = CommandByte;
RS = 0;
RW = 0;
E = 1;
_nop_();
E = 0;
_nop_();
}
/***************************/
/*读数据 */
/***************************/
unsigned char ReadData( void )
{
unsigned char DataByte;
Locatexy();
RS = 1;
RW = 1;
P1 = 0xFF;
E = 1;
_nop_();
DataByte = P1;
E = 0;
_nop_();
return DataByte;
}
/***************************/
/*写数据 */
/***************************/
void WriteData( unsigned char DataByte )
{
Locatexy();
RS = 1;
RW = 0;
P1 = DataByte;
E = 1;
_nop_();
E = 0;
_nop_();
}
void LcmClear( void )
{
Page = 0;
Col = 0;
for(Page=0
age<8
age++)
for(Col=0;Col<192;Col++)
WriteData(0);
}
void LcmReverseBMP( void )
{
unsigned char temp;
Page = 0;
Col = 0;
for(Page=0
age<8
age++)
{
for(Col=0;Col<192;Col++)
{
temp = ReadData(); //空读一次
temp = ReadData();
temp = ~temp;
WriteData(temp);
}
}
}
void fandisplay(unsigned int start_page, unsigned int end_page,unsigned int start_col,unsigned int end_col)
{
unsigned char temp;
Page = 0;
Col = 0;
for(Page=start_page
age<end_page
age++)
{
for(Col=start_col;Col<end_col;Col++)
{
temp = ReadData(); //空读一次
temp = ReadData();
temp = ~temp;
WriteData(temp);
}
}
}
//=============延时函数===========1ms==========================
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=120;y>0;y--);
}
//*********************LCM图片显示**************************//
/*
函数名:display
函数功能:在指定位置 输出图像显示、
数说明:start_page LCM开始显示页 end_page LCM
结束显示页 start_col LCM开始显示的列
end_col LCM结束显示的列 DATE数据指针 指向要输出图像的首地址
*/
void display(unsigned int start_page, unsigned int end_page,unsigned int start_col,unsigned int end_col,char *DATE)
{
for(Page=start_page
age<end_page
age++)
for(Col=start_col;Col<end_col;Col++){
WriteData(*DATE);
DATE++;}
}
void display_Clear(unsigned int start_page, unsigned int end_page,unsigned int start_col,unsigned int end_col)
{
for(Page=start_page
age<end_page
age++)
for(Col=start_col;Col<end_col;Col++)
WriteData(0x00);
}
void display_xlina(unsigned int start_page, unsigned int end_page,unsigned int start_col,unsigned int end_col)
{
for(Page=start_page;Page<end_page;Page++)
for(Col=start_col;Col<end_col;Col++){
WriteData(0x80);
}
}
void display_ylina(unsigned int start_page, unsigned int end_page,unsigned int start_col,unsigned int end_col)
{
for(Page=start_page;Page<end_page;Page++)
for(Col=start_col;Col<end_col;Col++){
WriteData(0xff);
}
}