📄 lcd19264.c
字号:
#include "GloblDef.h"
#include "LCD19264.h"
#include "zhiku.h"
//#include "main.h"
#define LcdIo P1
sfr P4 = 0xE8;
sbit CLK164 = P4^0 ;
sbit DATA164 = P4^0 ;
sbit DI = P4^0 ;
sbit RW =P4^1 ;
sbit E = P4^2 ;
sbit CS1 =P4^3 ;
sbit CS2 =P3^3 ;
sbit RESET =P3^4 ;
//延时
void DelayL(BYTE m)
{
while(m--);
}
/*----------------------------------------------------------------------------------------------------*/
//状态检查
void SCs(BYTE a)
{
switch(a)
{
case 0:
CS1 = 0;
CS2 = 0;
break;
case 1:
CS1 = 1;
CS2 = 0;
break;
case 2:
CS1 = 0;
CS2 = 1;
break;
case 3:
CS1 = 1;
CS2 = 1;
break;
default :
break;
}
}
void SendIO(BYTE IOdata)
{
BYTE i;
for(i=0;i<8;i++)
{
CLK164 = 0;
DATA164 = IOdata & 0x80; //(0x80即十进制的128, 二进制的10000000 按位发送)
CLK164 = 1;
IOdata <<=1 ;
}
}
void WData(BYTE ddata,BYTE a)
{
SCs(a); //选择片
// BusyC() ;
DelayL(10);
LcdIo =ddata;
DI = 1;
RW = 0;
E = 1;
E = 0;
SCs(0);//清除片选
}
//写指令
void WCommand(BYTE command,BYTE a)
{
SCs(a);//选择片
// BusyC() ;
DelayL(10);
LcdIo =command;
DI = 0;
RW = 0;
E = 1;
E = 0;
SCs(0);
}
//清除显示
void CleanLcm(void)
{
BYTE i,j,k;
BYTE tempX,tempY;
for(i=1;i<3;i++)
{ ;
tempX = 0xb8;
tempY = 0x40;
for(j=0;j<8;j++)
{
WCommand(tempX,i); //X地址
tempX++ ;
WCommand(tempY,i); //y地址
for(k=0;k<64;k++)
WData(0x00,i);
}
}
}
//初始化
void InitLcm(void)
{
BYTE i;
DelayL(200);
E = 0;
RESET = 0;
DelayL(255);
RESET = 1;
DelayL(255);
for(i=1;i<3;i++)
{
WCommand(0x3E,3);
WCommand(0xc0,3);
}
}
void CloseLcm(void)
{
BYTE i;
for(i=1;i<3;i++)
{
WCommand(0x3E,3);
}
}
void OpenLcm(void)
{
BYTE i;
for(i=1;i<3;i++)
{
WCommand(0x3f,3);
}
}
void ShowAsc(BYTE Line,BYTE Column , BYTE ASCII)
{
BYTE i;
BYTE tempX,tempY;
tempX = 0xb8;
tempY = 0x40;
tempX += (Line*2);
tempY += (Column*8);
if(Column > 7)
{
WCommand(tempX,2);
WCommand(tempY-64,2);
for(i=0;i<8;i++)WData(AscCode[ASCII][i],2);
WCommand(tempX+1,2);
WCommand(tempY-64,2);
for(i=0;i<8;i++)WData(AscCode[ASCII][i+8],2) ;
}
else
{
WCommand(tempX,1);
WCommand(tempY,1);
for(i=0;i<8;i++)WData(AscCode[ASCII][i],1);
WCommand(tempX+1,1);
WCommand(tempY,1);
for(i=0;i<8;i++)WData(AscCode[ASCII][i+8],1) ;
}
}
void ShowHZ(BYTE Line,BYTE Column , BYTE ASCII)
{
BYTE i;
BYTE tempX,tempY;
tempX = 0xb8;
tempY = 0x40;
tempX += (Line*2);
tempY += (Column*8);
if(Column > 7)
{
WCommand(tempX,2);
WCommand(tempY-64,2);
for(i=0;i<16;i++)WData(LOGOHZ[ASCII][i],2);
WCommand(tempX+1,2);
WCommand(tempY-64,2);
for(i=0;i<16;i++)WData(LOGOHZ[ASCII][i+16],2) ;
}
else
{
if(Column == 7)
{
WCommand(tempX,1);
WCommand(tempY,1);
for(i=0;i<8;i++)WData(LOGOHZ[ASCII][i],1);
WCommand(tempX,2);
WCommand(tempY-63,2);
for(i=0;i<8;i++)WData(LOGOHZ[ASCII][i+8],2);
WCommand(tempX+1,1);
WCommand(tempY,1);
for(i=0;i<8;i++)WData(LOGOHZ[ASCII][i+16],1) ;
WCommand(tempX,2);
WCommand(tempY-63,2);
for(i=0;i<8;i++)WData(LOGOHZ[ASCII][i+24],2);
}
else
{
WCommand(tempX,1);
WCommand(tempY,1);
for(i=0;i<16;i++)WData(LOGOHZ[ASCII][i],1);
WCommand(tempX+1,1);
WCommand(tempY,1);
for(i=0;i<16;i++)WData(LOGOHZ[ASCII][i+16],1) ;
}
}
}
void ShowHZP(BYTE Line,BYTE Column , BYTE DT_XDATA *p)
{
BYTE i;
BYTE tempX,tempY;
tempX = 0xb8;
tempY = 0x40;
tempX += (Line*2);
tempY += (Column*8);
if(Column > 7)
{
WCommand(tempX,2);
WCommand(tempY-64,2);
for(i=0;i<16;i++)WData(p[i],2);
WCommand(tempX+1,2);
WCommand(tempY-64,2);
for(i=0;i<16;i++)WData(p[i+16],2) ;
}
else
{
if(Column == 7)
{
WCommand(tempX,1);
WCommand(tempY,1);
for(i=0;i<8;i++)WData(p[i],1);
WCommand(tempX,2);
WCommand(tempY-63,2);
for(i=0;i<8;i++)WData(p[i+8],2);
WCommand(tempX+1,1);
WCommand(tempY,1);
for(i=0;i<8;i++)WData(p[i+16],1) ;
WCommand(tempX,2);
WCommand(tempY-63,2);
for(i=0;i<8;i++)WData(p[i+24],2);
}
else
{
WCommand(tempX,1);
WCommand(tempY,1);
for(i=0;i<16;i++)WData(p[i],1);
WCommand(tempX+1,1);
WCommand(tempY,1);
for(i=0;i<16;i++)WData(p[i+16],1) ;
}
}
}
void ShowLOGO(void)
{
BYTE i,j;
INT16 k;
BYTE tempX,tempY;
tempX = 0xb8;
tempY = 0x40;
CloseLcm();
for(j=0,k=0;j<4 ;j++)
{
WCommand(j+0xb8,3);
WCommand(0x40,3);
for(i=0;i<120;i++)
{
if(i>63) WData(LOGOBMP[k++],2) ;
else WData(LOGOBMP[k++],1) ;
}
}
for(i=0;i<7;i++)
{
ShowHZ(2,2*i,i);//网络数据采集器
}
//TP-DC07 ver.1.0
ShowAsc(3,0,'T'-0x21);
ShowAsc(3,1,'P'-0x21);
ShowAsc(3,2,'-'-0x21);
ShowAsc(3,3,'D'-0x21);
ShowAsc(3,4,'C'-0x21);
ShowAsc(3,5,'0'-0x21);
ShowAsc(3,6,'7'-0x21);
ShowAsc(3,8,'v'-0x21);
ShowAsc(3,9,'e'-0x21);
ShowAsc(3,10,'r'-0x21);
ShowAsc(3,11,'.'-0x21);
ShowAsc(3,12,'1'-0x21);
ShowAsc(3,13,'.'-0x21);
ShowAsc(3,14,'0'-0x21);
OpenLcm();
}
void ShowIPADDR(void)
{
CloseLcm();
CleanLcm();
//IP 地址:
ShowAsc(0,0,'I'-0x21);
ShowAsc(0,1,'P'-0x21);
ShowHZ(0,4,7);//地
ShowHZ(0,6,8);//址
ShowAsc(0,8,':'-0x21);
//子网掩码:
ShowHZ(1,0,12);//子
ShowHZ(1,2,0);//网
ShowHZ(1,4,13);//掩
ShowHZ(1,6,14);//码
ShowAsc(1,8,':'-0x21);
//默认网关:
ShowHZ(2,0,9);//默
ShowHZ(2,2,10);//认
ShowHZ(2,4,0);//网
ShowHZ(2,6,11);//关
ShowAsc(2,8,':'-0x21);
OpenLcm();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -