📄 lcd_driver.h
字号:
/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File Name: config.h
** Last modified Date: 2004-09-17
** Last Version: 1.0
** Descriptions: User Configurable File
**
**------------------------------------------------------------------------------------------------------
** Created By: Chenmingji
** Created date: 2004-09-17
** Version: 1.0
** Descriptions: First version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#ifndef __LCD_DRIVER_H
#define __LCD_DRIVER_H
#define DATA (0xff<<2)
#define RD (1<<10)
#define WR (1<<11)
#define RS (1<<12)
#define RES (1<<13)
#define CS (1<<17)
void SendCommand(uint8 com)
{
IO0CLR = RS;
IO0SET = RD;
IO0PIN = (IO0PIN & 0xfffffc03 ) | (com << 2) ;
nop();nop();nop();
nop();nop();nop();
nop();nop();nop();
IO0CLR = WR;
nop();nop();nop();
nop();nop();nop();
nop();nop();nop();
IO0SET = WR;
}
void SendData(uint8 data)
{
IO0SET = RS;
IO0SET = RD;
IO0PIN = (IO0PIN & 0xfffffc03 ) | (data << 2) ;
nop();nop();nop();
nop();nop();nop();
nop();nop();nop();
IO0CLR = WR;
nop();nop();nop();
nop();nop();nop();
nop();nop();nop();
IO0SET = WR;
nop();
}
void InitializeLCD()
{
IO0CLR = CS;
IO0SET = RD;
IO0CLR = RES;
nop();
nop();
nop();nop();nop();
IO0SET = RES;
nop();nop();
nop();nop();nop();
nop();nop();nop();
nop();
SendCommand(0xe2);
SendCommand(0xa0);
SendCommand(0xc8);
SendCommand(0xa2);
SendCommand(0x24);
SendCommand(0x2f);
SendCommand(0x81);
SendCommand(0x29);
SendCommand(0x40);
SendCommand(0xa4);
SendCommand(0xa6);
SendCommand(0xac);
SendCommand(0x00);
SendCommand(0xaf);
}
void SetPage(uint8 page)
{
page = page & 0x0f;
page = page | 0xb0;
SendCommand(page);
}
void SetColumn(uint8 column)
{
uint8 temp;
temp = column;
column = column & 0x0f;
column = column | 0x00;
SendCommand(column);
temp = temp >> 4;
column = temp &0x0f;
column = column | 0x10;
SendCommand(column);
}
void ClearScreen()
{
uint32 i,j;
for(i=0;i<8;i++)
{
SetPage(i);
SetColumn(0);
for(j=0;j<128;j++)
SendData(0x00);
}
}
void DisplayPic(unsigned const char *pic)
{
uint32 i,j;
for(j=0;j<8;j++)
{
SetPage(j);
SetColumn(0);
for(i=0;i<128;i++)
SendData(pic[i+j*128]);
}
}
void ShowText(unsigned const char *pic_h,unsigned const char *pic_l,int text_start,int32 width)
{
int32 start;
uint8 i;
for(start=-122;start<width;start++)
{
SetPage(6);
SetColumn(3);
for(i=3;i<125;i++)
{
if(i+start+1>width||i+start+1<=0)SendData(0x01);
else SendData(pic_h[i+start+text_start]);
}
SetPage(7);
SetColumn(3);
for(i=3;i<125;i++)
{
if(i+start+1>width||i+start+1<=0)SendData(0x40);
else SendData(pic_l[i+start+text_start]);
}
DelayNS(15);
if(int_flag)
{
int_flag=0;
return;
}
}
}
void ShowNews(unsigned const char *pic_h,unsigned const char *pic_l,uint8 num)
{
int32 start=0,width=0;
switch(num)
{
case 1:start = 0;width=147;break;
case 2:start = 147;width=270;break;
case 3:start = 417;width=207;break;
case 4:start = 624;width=87;break;
case 5:start = 711;width=84;break;
case 6:start = 795;width=72;break;
case 7:start = 867;width=84;break;
case 8:start = 951;width=72;break;
case 9:start = 1023;width=84;break;
case 10:start = 1107;width=84;break;
case 11:start = 1191;width=84;break;
case 12:start = 1275;width=48;break;
case 13:start = 1323;width=84;break;
case 14:start = 1407;width=84;break;
case 15:start = 1491;width=84;break;
case 16:start = 1575;width=84;break;
case 17:start = 1659;width=96;break;
case 18:start = 1755;width=108;break;
}
ShowText(pic_h,pic_l,start,width);
}
#endif
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -