文章详情

中文液晶模块 240128 RA8822主控 样例程序

日期:2019-07-22 16:12
浏览次数:198
摘要:RA8822是一款带中文字库的液晶模块驱动控制器,广泛应用于液晶模块的驱动控制,利来手机国际光电HG2401288采用了这种主控IC。

RA8822是一款带中文字库的液晶模块驱动控制器,广泛应用于液晶模块的驱动控制,利来手机国际光电HG2401288采用了这种主控IC。

中文液晶模块 240128 RA8822主控 样例程序:

//本程序为HG2401288 模块的基本驱动程序
//程序的显示结果为:

//“

//利来手机国际光电科技有限公司 ”

//“

//HG2401288

#include<stdio.h>
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint  unsigned int
#define lcd_bus  P1

//sbit _CS=P3^2;
sbit _CS=P3^3;
sbit    RS=P3^4;
sbit _WR=P3^0;
sbit _RD=P3^1;
sbit _RST=P3^5;
sbit    buzy=P3^6;
sbit    x=P3^3;

//----------------------------
//忙
//----------------------------
void busy()
{
while(buzy==1);
}
//----------------------------
//延时子程序
//----------------------------
void Delay(uint m)
{
uint i;
uint j;
for(i=0;i<m;i++)
for(j=0;j<109;j++);
}
//----------------------------
//写入寄存器地址或参数
//----------------------------
void writecom(uchar command)
{
busy();
lcd_bus =command;
_CS=0;
RS=0;
_WR=0;
_WR=1;
RS=1;
_CS=1;
}
//----------------------------
//写入数据
//----------------------------
void writedat(uchar ddata)
{
busy();
lcd_bus =ddata;
_CS =0;
RS=1;
_WR=0;
_nop_();_nop_();_nop_(); _nop_();
_WR=1;
RS=0;
_CS=1;
}
//----------------------------
//显示文本
//----------------------------
void ShowText(uchar *text)
{
while(*text>0)
{
writedat(*text);
text++;
}}
/**********************************************
  地址定义 ,x为一个字节,y为一行
********************************************/
void xy(uchar x,uchar y)
{
  uchar i;
  writecom(0x60);writecom(0x3f&x);
  writecom(0x70);writecom(0xff&y);
  _nop_();
}
//----------------------------
//显示文本
//----------------------------
void writeText(uchar x,uchar y,uchar *text)
{
xy(x,y);
while(*text>0)
{
writedat(*text);
text++; Delay(100);
}
}
void writeText1(uchar x,uchar y,uchar *text)
{
xy(x,y);
while(*text>0)
{
writedat(*text);
text++; 
}
}
/*********************************************
 初始化
**********************************************/
void Init()
{
_RST= 0;
buzy=1;
Delay(25);
buzy=0;
_RST= 1;
Delay(100);
writecom(0x00);writecom(0xcd);  //开电源,文本模式,开显示,不闪烁,不反白
writecom(0x01);writecom(0xf1);    // CLK_OUT 致能控制, 高触发,4M
writecom(0x02);writecom(0x10);    //60ns的读取速度
writecom(0x03);writecom(0x80);    //byte正常,com and seg不卷动
writecom(0x10);writecom(0x68);    //中英问对齐,字体正常
writecom(0x11);writecom(0x10);    // 光标高度为一,行距为0
writecom(0x12);writecom(0x91);    //水平移动,选择DDRAM1,

writecom(0x20);writecom(0x1d);    // 工作窗右边 29*8=232
writecom(0x30);writecom(0x7f);    // 工作窗低边 127
writecom(0x40);writecom(0x00);    // 工作窗左边 00
writecom(0x50);writecom(0x00);    // 工作窗顶边 00
writecom(0x21);writecom(0x1d);    // 显示窗右边 29*8=232
writecom(0x31);writecom(0x80);     // 显示窗低边 127
writecom(0x41);writecom(0x00);     // 显示窗左边 00
writecom(0x51);writecom(0x00);     // 显示窗顶边 00

//writecom(0x80);writecom(0x33);   //光标闪烁时间设定,默认值
writecom(0x81);writecom(0x40);   //  刷新频率 ,默认值
//writecom(0x81);writecom(0x00);   //  刷新频率
//writecom(0x91);writecom(0x00);   //  刷新频率 ,默认值
//writecom(0xd0);writecom(0x00);  //LCD 亮度控制(DAC 功能)
//writecom(0x90);writecom(0x0a);
writecom(0x90);writecom(0x12);   //XCK 讯号周期

//writecom(0xf0);writecom(0x08);    //**命令  ,*好不用
//writecom(0xe0);writecom(0x00);
}
//----------------------------
//清屏
//----------------------------
void CleanScreen1(uchar m)
{
uchar i,j;
writecom(0x00);writecom(0xc5);  //开电源,图形模式,开显示,不闪烁,不反白
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x00);
for(i=0;i<1;i++)
{ for(j=0;j<1;j++)
writedat(m);
}
Delay(500);
writecom(0x00);writecom(0xcd); //开电源,文本模式,开显示,不闪烁,不反白
}
//----------------------------
//清屏
//----------------------------
void CleanScreen(uchar m)
{
uchar i,j;
writecom(0x00);writecom(0xc5);  //开电源,图形模式,开显示,不闪烁,不反白
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x00);
for(i=0;i<128;i++)
{for(j=0;j<30;j++)
writedat(m);
}
Delay(500);
writecom(0x00);writecom(0xcd); //开电源,文本模式,开显示,不闪烁,不反白
}
//----------------------------
//隔点
//----------------------------
void dotScreen(uchar m)
{
uchar i,j;
writecom(0x00);writecom(0xc5); //开电源,图形模式,开显示,不闪烁,不反白
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x00);
for(j=0;j<64;j++)
{
for(i=0;i<30;i++)
writedat(m);
for(i=0;i<30;i++)
writedat(~m);
}
Delay(500);
writecom(0x00);writecom(0xcd); //开电源,文本模式,开显示,不闪烁,不反白
}
//----------------------------
//边框
//----------------------------
void biank()
{
uchar i,j;
writecom(0x00);writecom(0xc5);//开电源,图形模式,开显示,不闪烁,不反白
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x00);
for(i=0;i<30;i++)
{
writedat(0xff);
}

writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x7f);
for(i=0;i<30;i++)
{
writedat(0xff);
}

writecom(0x12);writecom(0x11);  //先垂直移动再水平移动
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x01);
for(i=0;i<126;i++)
{
writedat(0x80);
}

writecom(0x60);writecom(0x3d);
writecom(0x70);writecom(0x01);
for(i=0;i<126;i++)
{
writedat(0x01);
}
writecom(0x12);writecom(0x91);
writecom(0x00);writecom(0xcd); //开电源,文本模式,开显示,不闪烁,不反白
}
/*******************************************************
 文本写入
*******************************************************/
void text()
{
//biank();
writecom(0xf1);writecom(0x1f);
writecom(0x60);writecom(0x04);
writecom(0x70);writecom(0x20);
ShowText("利来手机国际光电");

writecom(0xf1);writecom(0x0f);
writecom(0x60);writecom(0x0c);
writecom(0x70);writecom(0x30);
ShowText("科技有限公司");

writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x5f);
writecom(0x10);writecom(0x79);
writecom(0x60);writecom(0x06);
writecom(0x70);writecom(0x40);
ShowText("HG2401288");
Delay(600);
  /*
writecom(0x00);writecom(0xcc);  // 文本 反白显示
Delay(600);
writecom(0x03);writecom(0xc4); // 设定Common 的自动卷动
Delay(60000);


writecom(0x00);writecom(0xcd);

writecom(0xf1);writecom(0x0f);
writecom(0x60);writecom(0x08);
writecom(0x70);writecom(0x70);
ShowText("杭州佳显科技有限公司HANGZHOU.");
Delay(6000);
 */
}
void tx11 () interrupt 3 using 2
{
 if(~x)
 {
 Delay(60000);
}
}
/*******************************************************
  向下卷动
************************************************************/
void lcd_up()
{
uchar i;
for(i=0;i<240;i++)
{
writecom(0x03);writecom(0xc4); // 设定Common 的自动卷动
Delay(400);}
}
/*******************************************************
  向左卷动
************************************************************/
void lcd_left()
{
uchar i,j;
for(j=0;j<30;j++)
{
 writecom(0x03);writecom(0xc3); // 设定seg 的自动卷动
 Delay(600);}
}
/*****************只能向左和想下卷动*****************************/

//----------------------------
//主程序
//----------------------------
main()
{
  uchar i;
  IE=0X88;
  IP=0X08;
  IT0=0;
  Init();
  while(1)
  {
  CleanScreen(0x00);i=0;
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0x0f);
 writeText(0,0,"利来手机国际光电提供内置中文字库产品:直接提取中文和西文,控制器RA8822是一个双图层(Two Pages)中英文文字与绘图模式的点矩阵液晶显示(LCD)控制器,内建512K Byte 的字型码,可以显示中文字形,英日欧文字等字母,产品型号为:");
   
  writecom(0xf1);writecom(0x4f);
  writeText1(0,112,"HG2401288-F-LWH");
   Delay(1200);
 do
 {  
  CleanScreen(0x00);
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0x4f);
 writeText1(2,0,"水平放大演示");
 
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0x4f);
 writeText1(2,50,"竖直放大演示");
 
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0x0f);
 writeText1(0,25,"2401288");
 
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0x4f);
 writeText1(2,70,"2 4 0 1 2 8 8");  
  Delay(1200);
  
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0x4f);
 writeText1(0,25,"2401288"); 
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0x5f);
 writeText1(2,70,"2 4 0 1 2 8 8");
  Delay(1200);
  
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0x8f);
 writeText1(0,25,"2401288");
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0x6f);
 writeText1(2,70,"2 4 0 1 2 8 8");
  Delay(1200);
  
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0xcf);
 writeText1(0,25,"2401288");
 writecom(0xf0);writecom(0xa0);
 writecom(0xf1);writecom(0x7f);
 writeText1(2,70,"2 4 0 1 2 8 8"); 
  Delay(1200);i++;}while(i<5);  
}}


am8亚美 am8亚美 am8亚美 凯发k8官网 am8亚美