?? lcm.c
字號:
#include <stdio.h>
//#include <at89x52.H>
#include <reg54.h>
#include <intrins.h>
#include "SystemEvent.h"
#include "ExtVar.h"
#include "function.h"
//extern idata unsigned int _Counter;
idata unsigned char _Idx;
idata unsigned char _px;
code char _CROM[]={" Cortez DTV"};
code char _PROM[]={"EVB v1 "};
code char _BinX[]={"Amtran"};
code char _Type[]={"2006"};
unsigned char ReadLCM(void);
void WriteLCMControl(unsigned char);
void WriteLCMData(unsigned char);
void PrintAChar(unsigned char,unsigned char);
void PrintAShortInt(unsigned char,unsigned char);
void PrintAInt(unsigned int,unsigned char);
void PrintAString(unsigned char *,int,unsigned char);
sbit _RS=P2^0x02;
sbit _RW=P2^0x01;
sbit _EN=P2^0x00;
//extern unsigned int _sec,_min,_hour;
//extern unsigned int _secx,_minx,_hourx;
void PrintAChar(unsigned char _stx,unsigned char _Offset){
while((ReadLCM()&0x80)==0x80);
WriteLCMControl(_Offset+0x80);
while((ReadLCM()&0x80)==0x80);
WriteLCMData(_stx);
while((ReadLCM()&0x80)==0x80);
}
void PrintTestPage(void){
// char buf[0x10];
// _Counter++;
while((ReadLCM()&0x80)==0x80);
_px=0;
PrintAString(_CROM,(sizeof(_CROM)-1),_px);
_px+=sizeof(_CROM)-2;
_px=0x0a;
PrintAString(_PROM,(sizeof(_PROM)-1),_px);
_px+=sizeof(_PROM)-2;
PrintAInt(0x05,_px);
_px+=5;
PrintAChar('F',_px);
}
void PrintAInt(unsigned int _XData,unsigned char _Offset){
unsigned int _ix;
unsigned int _XD,_XC;
unsigned char _jx;
_XD=_XData;
while((ReadLCM()&0x80)==0x80);
for(_ix=0;_ix<0x04;_ix++){
WriteLCMControl(_Offset+0x80+_ix);
while((ReadLCM()&0x80)==0x80);
_XC=(_XD&0xf000);
_jx=(unsigned char)(_XC>>12);
if(_jx>0x09){ _jx-=0x0a; _jx+='a'; }
else _jx+='0';
WriteLCMData(_jx);
while((ReadLCM()&0x80)==0x80);
_XD<<=4;
}
}
void PrintAShortInt(unsigned char _XData,unsigned char _Offset){
unsigned int _ix;
unsigned int _XD,_XC;
unsigned char _jx;
_XD=_XData;
while((ReadLCM()&0x80)==0x80);
for(_ix=0;_ix<0x02;_ix++){
WriteLCMControl(_Offset+0x80+_ix);
while((ReadLCM()&0x80)==0x80);
_XC=(_XD&0xf0);
_jx=(unsigned char)(_XC>>4);
if(_jx>0x09){ _jx-=0x0a; _jx+='a'; }
else _jx+='0';
WriteLCMData(_jx);
while((ReadLCM()&0x80)==0x80);
_XD<<=4;
}
}
void PrintAString(unsigned char *_stx,int _ax,unsigned char _Offset){
unsigned int _ix;
while((ReadLCM()&0x80)==0x80);
for(_ix=0;_ix<_ax;_ix++){
WriteLCMControl(_Offset+0x80+_ix);
while((ReadLCM()&0x80)==0x80);
WriteLCMData(*(_stx+_ix));
while((ReadLCM()&0x80)==0x80);
}
}
/*
void PrintAChar(unsigned char _stx,unsigned char _Offset){
while((ReadLCM()&0x80)==0x80);
WriteLCMControl(_Offset+0x80);
while((ReadLCM()&0x80)==0x80);
WriteLCMData(_stx);
while((ReadLCM()&0x80)==0x80);
}
*/
unsigned char ReadLCM(void){
unsigned char _xbuf;
_RS=0;
_RW=1;
_EN=1;
P0=0xff;
_xbuf=P0;
_EN=0;
_RS=1;
_RW=1;
return(_xbuf);
}
void WriteLCMControl(unsigned char _xbuf){
_RW=0;
_RS=0;
_EN=1;
P0=_xbuf;
_EN=0;
_RW=1;
_RS=1;
}
void WriteLCMData(unsigned char _xbuf){
_RW=0;
_RS=1;
_EN=1;
P0=_xbuf;
_EN=0;
_RW=1;
_RS=1;
}
void LCM_Init(void){
unsigned char _ix;
while((ReadLCM()&0x80)==0x80); // wait LCD busy
WriteLCMControl(0x38); // write LCM control mode
while((ReadLCM()&0x80)==0x80); // wait LCD busy
WriteLCMControl(0x0c); // write LCM control mode
while((ReadLCM()&0x80)==0x80); // wait LCD busy
WriteLCMControl(0x06); // write LCM control mode
while((ReadLCM()&0x80)==0x80); // wait LCD busy
for(_ix=0;_ix<20;_ix++){
WriteLCMData((unsigned char)_ix+0x80);
WriteLCMData((unsigned char)_ix+0xc0);
while( (ReadLCM()&0x80)==0x80);
}
WriteLCMControl(1);
// _px=0;
// PrintAString(_CROM,(sizeof(_CROM)-1),_px);
//_px=0x40;
// PrintAString(_BinX,(sizeof(_BinX)-1),_px);
_px=0x48;
// PrintAInt(0x1234,_px); // for test
PrintAShortInt(0x08,_px+6); // for test
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -