📄 复件 lcd19264.c
字号:
unsigned long temp1;
unsigned char temp2;
unsigned char temp3;
// IOSET1 |= (1<<LCDCS1) | (1<<LCDCS3);
// IOCLR1 |= (1<<LCDCS2)|(1<<LCDCOMMAND);
IOCLR1 |= (1<<LCDCS1) | (1<<LCDCS3) |(1<<LCDCOMMAND);
IOSET1 |= (1<<LCDCS2);
IOSET0 |= (1<<LCDRD);
IODIR0 &= 0xFFFF00FF;
do
{
IOSET0 |= 1<<LCDOE; /* LCDOE =1 active */
temp1 = IOPIN0;
IOCLR0 |= 1<<LCDOE; /* LCDOE =0 not active */
temp2 = 0x01;
temp3 = (unsigned char) (temp1 >> 8);
nStatus = 0;
for(i=0;i<8;i++)
{
if(temp3 & temp2 == 1) nStatus |= (1<<(7-i));
temp2 = temp2 << 1;
}
}while(nStatus & 0x80);
IOSET1 |= (1<<LCDDATA) ;
IOCLR0 |= (1<<LCDWR);
IODIR0 |= 0x0000FF00;
temp2 = 0x01;
for(i=8;i<16;i++)
{
if(nData & temp2 ==0) IOCLR0 |= (1<<(23-i));
else IOSET0 |= (1<<(23-i));
temp2 = temp2<<1;
}
IOSET0 |= 1<<LCDOE; /* LCDOE =1 active */
IOCLR0 |= 1<<LCDOE; /* LCDOE =0 not active */
}
void WriteRightCommand(unsigned char nCommand)
{
unsigned char nStatus,i;
unsigned long temp1;
unsigned char temp2;
unsigned char temp3;
// IOSET1 |= (1<<LCDCS1) | (1<<LCDCS2);
// IOCLR1 |= (1<<LCDCS3) | (1<<LCDCOMMAND);
IOCLR1 |= (1<<LCDCS1) | (1<<LCDCS2) | (1<<LCDCOMMAND);
IOSET1 |= (1<<LCDCS3);
IOSET0 |= (1<<LCDRD);
IODIR0 &= 0xFFFF00FF;
do
{
IOSET0 |= 1<<LCDOE; /* LCDOE =1 active */
temp1 = IOPIN0;
IOCLR0 |= 1<<LCDOE; /* LCDOE =0 not active */
temp2 = 0x01;
temp3 = (unsigned char) (temp1 >> 8);
nStatus = 0;
for(i=0;i<8;i++)
{
if(temp3 & temp2 == 1) nStatus |= (1<<(7-i));
temp2 = temp2 << 1;
}
}while(nStatus & 0x80);
IOCLR0 |= (1<<LCDWR);
IODIR0 |= 0x0000FF00;
temp2 = 0x01;
for(i=8;i<16;i++)
{
if(nCommand & temp2 ==0) IOCLR0 |= (1<<(23-i));
else IOSET0 |= (1<<(23-i));
temp2 = temp2<<1;
}
IOSET0 |= 1<<LCDOE; /* LCDOE =1 active */
IOCLR0 |= 1<<LCDOE; /* LCDOE =0 not active */
}
void WriteRightData(unsigned char nData)
{
unsigned char nStatus,i;
unsigned long temp1;
unsigned char temp2;
unsigned char temp3;
// IOSET1 |= (1<<LCDCS1) | (1<<LCDCS2);
// IOCLR1 |= (1<<LCDCS3)|(1<<LCDCOMMAND);
IOCLR1 |= (1<<LCDCS1) | (1<<LCDCS2) |(1<<LCDCOMMAND);
IOSET1 |= (1<<LCDCS3);
IOSET0 |= (1<<LCDRD);
IODIR0 &= 0xFFFF00FF;
do
{
IOSET0 |= 1<<LCDOE; /* LCDOE =1 active */
temp1 = IOPIN0;
IOCLR0 |= 1<<LCDOE; /* LCDOE =0 not active */
temp2 = 0x01;
temp3 = (unsigned char) (temp1 >> 8);
nStatus = 0;
for(i=0;i<8;i++)
{
if(temp3 & temp2 == 1) nStatus |= (1<<(7-i));
temp2 = temp2 << 1;
}
}while(nStatus & 0x80);
IOSET1 |= (1<<LCDDATA) ;
IOSET0 |= (1<<LCDWR);
IODIR0 |= 0x0000FF00;
temp2 = 0x01;
for(i=8;i<16;i++)
{
if(nData & temp2 ==0) IOCLR0 |= (1<<(23-i));
else IOSET0 |= (1<<(23-i));
temp2 = temp2<<1;
}
IOSET0 |= 1<<LCDOE; /* LCDOE =1 active */
IOCLR0 |= 1<<LCDOE; /* LCDOE =0 not active */
}
void Clear_Lcd(void)
{
unsigned char i,j;
//unsigned char nStatus;
//unsigned long temp1;
WriteLeftCommand(0xC0); // 设置起始行行号为0
putstr("WriteLeftCommand(0xC0)!\n");
/*
WriteMiddleCommand(0xC0);
putstr("WriteMiddleCommand(0xC0);!\n");
WriteRightCommand(0xC0);
putstr("WriteRightCommand(0xC0);!\n");
*/
WriteLeftCommand(0x3F); //开显示
putstr("WriteLeftCommand(0x3F);!\n");
/*
WriteMiddleCommand(0x3F);
putstr("WriteMiddleCommand(0x3f);!\n");
WriteRightCommand(0x3F);
putstr("WriteRightCommand(0x3f);!\n");
*/
while(1)
{
for(i=0;i<2;i++)
{
for(j=0;j<16;j++)
{
WriteLeftCommand(i | 0xB8);
WriteLeftCommand(j | 0x40);
// WriteLeftData(0x00);
WriteLeftData(0x25);
puthex((ReadLeftData() >> 4) & 0x0F); puthex(ReadLeftData() & 0x0F); putstr("\n");
}
}
}
/* for(i=0;i<8;i++)
{
for(j=0;j<64;j++)
{
WriteMiddleCommand(i | 0xB8);
WriteMiddleCommand(j | 0x40);
// WriteMiddleData(0x00);
WriteMiddleData(0xff);
}
}
for(i=0;i<8;i++)
{
for(j=0;j<64;j++)
{
WriteRightCommand(i | 0xB8);
WriteRightCommand(j | 0x40);
// WriteRightData(0x00);
WriteRightData(0xff);
}
}*/
}
void ShowData(unsigned char xPos,unsigned char yPos,unsigned char nData)
{
unsigned char xNum;
xNum = xPos/64;
switch(xNum)
{
case 0:
WriteLeftCommand(yPos/8 | 0xB8);
WriteLeftCommand((xPos-64*xNum) | 0x40);
WriteLeftData(nData);
break;
case 1:
WriteMiddleCommand(yPos/8 | 0xB8);
WriteMiddleCommand((xPos-64*xNum) | 0x40);
WriteMiddleData(nData);
break;
case 2:
WriteRightCommand(yPos/8 | 0xB8);
WriteRightCommand((xPos-64*xNum) | 0x40);
WriteRightData(nData);
break;
}
}
/* 显示数字 */
void ShowNum(unsigned char xOrigin,unsigned char yOrigin,unsigned char ndata)
{
unsigned char i,j,xpos,ypos;
for(i=0;i<8;i++)
{
xpos = xOrigin+i;
for(j=0;j<2;j++)
{
ypos = yOrigin+j*8;
ShowData(xpos,ypos,NumCode[ndata][j*8+i]);
}
}
}
/* 显示汉字 */
void ShowHZ(unsigned char xOrigin, unsigned char yOrigin, unsigned char nIndex)
{
unsigned char i,j,xpos,ypos;
for(i=0;i<16;i++)
{
xpos = xOrigin + i;
for(j=0;j<2;j++)
{
ypos = yOrigin+j*8;
ShowData(xpos,ypos,HZCode[nIndex][j*16+i]);
}
}
}
/* 显示欢迎界面 */
/*
恒茂科技
ZL-1型
卷染机恒张力控制系统
0512-63564002
*/
void ShowWelcomeLog(void)
{
unsigned long x;
Clear_Lcd();
/* 第一行: 恒茂科技 */
x = 64;
ShowHZ(x, 0, 28); x += 16;
ShowHZ(x, 0, 29); x += 16;
ShowHZ(x, 0, 30); x += 16;
ShowHZ(x, 0, 31);
/* 第二行: ZL-1型 */
x = 72;
ShowHZ(x, 16, 32); x += 16;
ShowHZ(x, 16, 33); x += 16;
ShowHZ(x, 16, 34);
/* 第三行: 卷染机恒张力控制系统 */
x = 16;
ShowHZ(x, 32, 35); x += 16;
ShowHZ(x, 32, 36); x += 16;
ShowHZ(x, 32, 37); x += 16;
ShowHZ(x, 32, 28); x += 16;
ShowHZ(x, 32, 38); x += 16;
ShowHZ(x, 32, 39); x += 16;
ShowHZ(x, 32, 40); x += 16;
ShowHZ(x, 32, 41); x += 16;
ShowHZ(x, 32, 42); x += 16;
ShowHZ(x, 32, 43);
/* 第四行: 0512-63564002 */
x = 40;
ShowNum(x, 48, 0); x += 8;
ShowNum(x, 48, 5); x += 8;
ShowNum(x, 48, 1); x += 8;
ShowNum(x, 48, 2); x += 8;
ShowHZ(x, 48, 44); x += 16;
ShowNum(x, 48, 6); x += 8;
ShowNum(x, 48, 3); x += 8;
ShowNum(x, 48, 5); x += 8;
ShowNum(x, 48, 6); x += 8;
ShowNum(x, 48, 4); x += 8;
ShowNum(x, 48, 0); x += 8;
ShowNum(x, 48, 0); x += 8;
ShowNum(x, 48, 2); x += 8;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -