22
2013
03

12232液晶显示屏驱动(C语言)

全新原包装紫晶库存12232点阵液晶模块  无背光 (显示区域是一体的中间没有缝 不分上下屏)

三个起售!!!

控制器:SED1520     外形尺寸:84*44  (1脚焊盘中心距边缘13.5mm)  18pin

引脚定义(方焊盘为1脚):1.GND  2.VCC  3.VO  4.A0  5.E1  6.E2  7.R/W  8-15.DB0-DB7  16.RST  17.LEDA  18.LEDK

工作电压5伏,3脚接地,字迹稍淡,3脚最好外接-0.3伏的负电压。或在3脚接地的情况下稍微提高工作电压。

 

台湾产全新带背光12232液晶显示屏驱动程序(C语言)

 

/*============================================================
MCU:at89c2051
接线图:
--------------------------------------------------|
|DB0-----P1.0 | DB4-----P1.4 | RW-------P3.5 | RST接VCC        |
|DB1-----P1.1 | DB5-----P1.5 | A0-------P3.7 | V0接1K电阻到GND |
|DB2-----P1.2 | DB6-----P1.6 | E1-------P3.3 | 
|DB3-----P1.3 | DB7-----P1.7 | E2-------P3.4 |
---------------------------------------------------
液晶接口:
1--VDD
2--VSS
3--V0
4--RST
5--E1
6--E2
7--RW
8--A0
9--DB0
  -
  -
  -
  -
16--DB7
17--A
18--K
=============================================================*/
#i nclude <reg51.h>

#define uchar unsigned char
#define uint unsigned int

sbit E1=P3^3; //块1 左边
sbit E2=P3^4; //块2 右边
sbit RW=P3^5;
sbit A0=P3^7; //A0为1时是数据,0时为指令数据
#define LCD_DATA P1 //数据
/*
extern unsigned char code Bmpt1[];
extern unsigned char code Bmpt2[];
extern unsigned char code Bmpt3[];
extern unsigned char code Bmpt4[];
extern unsigned char code Bmpt5[];
extern unsigned char code Bmpt6[];
extern unsigned char code Bmpt7[];
extern unsigned char code Bmptc[];
extern unsigned char code Bmp08[];
extern unsigned char code Bmp07[];
extern unsigned char code Bmp06[];
extern unsigned char code Bmp05[];
extern unsigned char code Bmp04[];
extern unsigned char code Bmp03[];
extern unsigned char code Bmp02[];
extern unsigned char code Bmp01[];
extern unsigned char code Bmp012[];
*/
extern  unsigned char code bmp001[];
extern unsigned char code Bmp002[];


//延时
void delay(unsigned int i)
{
 unsigned char k=200;
 while(i>0)
 {
  i--;
 }
 while(k>1)k--;
}

//左页
//发送数据
void OUTMD(unsigned char i)
{
 A0=1; //写数据
 //delay(5);
 E1=1;
 //delay(10);
 LCD_DATA=i;
 //delay(5);
 E1=0;

}
//左页
//发送命令
void OUTMI(unsigned char i)
{
 A0=0; //写指令
 //delay(5);
 E1=1;
 //delay(10);
 LCD_DATA=i;
 //delay(5);
 E1=0;

}
//右页
//发送数据
void OUTSD(unsigned char i)
{
 A0=1; //写数据
 //delay(5);
 E2=1;
 //delay(10);
 LCD_DATA=i;
 //delay(5);
 E2=0;

}
//右页
//发送命令
void OUTSI(unsigned char i)
{
 A0=0; //写指令
 //delay(5);
 E2=1;
 //delay(10);
 LCD_DATA=i;
 //delay(5);
 E2=0;

}

 

//初始化
void lcdini(void)
{
 RW=0;
 OUTMI(0XE2);
 OUTSI(0XE2);//复位
 OUTMI(0XAE);
 OUTSI(0XAE);//POWER SAVE
 OUTMI(0XA4);
 OUTSI(0XA4);//动态驱动
 OUTMI(0XA9);
 OUTSI(0XA9);//1/32占空比
 OUTMI(0XA0);
 OUTSI(0XA0);//时钟线输出
 OUTMI(0XEE);
 OUTSI(0XEE);//写模式

 OUTMI(0X00);
 OUTMI(0XC0);
 OUTSI(0X00);
 OUTSI(0XC0);

 OUTMI(0XAF);
 OUTSI(0XAF);

}
/*
函数说明:同时设置主从显示页为0-3页。(内函数,私有,用户不直接调用)
------------------------------------------------------------------------
*/
void SetPage(uchar page0,uchar page1)
{
OUTMI(0xB8|page1);OUTSI(0xB8|page0);
}

/*
--------------------------------------------------------------------------------
函数说明:同时设置主从列地址为0-121。(内函数,私有,用户不直接调用)
--------------------------------------------------------------------------------
*/
void SetAddress(uchar address0,uchar address1)
{
OUTMI(address1);OUTSI(address0);
}

/*
--------------------------------------------------------------------------------

调用方式:void PutChar0(uchar ch)
函数说明:在右页当前地址画一个字节8个点。(内函数,私有,用户不直接调用)
--------------------------------------------------------------------------------
-*/
void PutCharR(uchar ch)
{
OUTSD(ch);
}

/*
--------------------------------------------------------------------------------

调用方式:void PutChar1(uchar ch)
函数说明:在左页当前地址画一个字节8个点。(内函数,私有,用户不直接调用)
--------------------------------------------------------------------------------
-*/
void PutCharL(uchar ch)
{
OUTMD(ch);
}

/*
--------------------------------------------------------------------------------

调用方式:void DrawBmp(bit layer,uchar width,uchar *bmp)
函数说明:画一个图,layer表示上下层,width是图形的宽,高都是16,bmp是
图形指针
          使用zimo3软件,纵向取模,字节倒序/240字节
--------------------------------------------------------------------------------
-*/
void DrawBmp(bit layer,uchar width,uchar *bmp)
{
uchar x,address,i=0;     //address表示显存的物理地址
uchar page=0; //page表示上下两页
bit window=0;  //window表示左右两页
//putcharR //右边
//putcharL //左边

for (x=width;x>0;x--)
{
if (i>60) {window=1;address=i%61;}
else address=i;

if(layer==0) //显示一行八个字
 {
 SetPage(0,0);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp[i]);
 else PutCharL(bmp[i]);
 SetPage(1,1);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp[i+width]);
 else PutCharL(bmp[i+width]);
 }
else
 { //显示第二行八个汉字
 SetPage(2,2);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp[i]);
 else PutCharL(bmp[i]);
 SetPage(3,3);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp[i+width]);
 else PutCharL(bmp[i+width]);
 }
    i++;

}
}


/*
--------------------------------------------------------------------------------

调用方式:void clrscr(void)
函数说明:清屏
--------------------------------------------------------------------------------
-*/
void clrscr(void)
{
uchar i;
uchar page;
for (page=0;page<4;page++)
{
SetPage(page,page);
SetAddress(0,0);
for (i=0;i<61;i++){PutCharR(0);PutCharL(0);}
}
}
/*
//-----------------------------------------------------------
//图片显示,h=32dot
//采用字模2生成或字模3生成的都可以.
//-----------------------------------------------------------
void DrawBmp1(uint x_add, uchar width,uchar *bmp)
{
uchar x,address,i=0;     //address表示显存的物理地址
uchar page=0; //page表示上下两页
bit window=0;  //window表示左右两页
//putcharR //右边
//putcharL //左边
for (x=width;x>1;x--)
{
if (x_add>60) {window=1;address=x_add%61;}
else address=x_add;


 SetPage(0,0);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp[i]);
 else PutCharL(bmp[i]);
 SetPage(1,1);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp[i+width]);
 else PutCharL(bmp[i+width]);


 SetPage(2,2);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp[i+width+width]);
 else PutCharL(bmp[i+width+width]);
 SetPage(3,3);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp[i+width+width+width]);
 else PutCharL(bmp[i+width+width+width]);
    i++;
    x_add++;

}
}
*/
//---------------------------------------------------------------
//---------------------------------------------------------------
//采用zimo2  显示汉字,以汉字的显示方式
//void Draw_word(uchar d_where,uint x_add,bit layer,uchar width)
//d_where表示在码表中第几个汉字,x_add横坐标位置,layer显示的层, width显示的宽度。
//void Draw_word(0-。。。。。,显存的物理地址0-121,0=第一行,非0=第二行,字的宽度)
//---------------------------------------------------------------

void Draw_word(uint d_where,uint x_add,bit layer,uchar width)
{
uchar x,i=0,address;     //address表示显存的物理地址
uchar page=0; //page表示上下两页
bit window=0;  //window表示左右两页
//putcharR //右边
//putcharL //左边
d_where=d_where*32;

for (x=width;x>0;x--)
{
if (x_add>60) {window=1;address=x_add%61;}
else address=x_add;

if(layer==0) //显示一行八个字
 {

 SetPage(0,0);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp001[d_where]);//右边
 else PutCharL(bmp001[d_where]);//左边
 SetPage(1,1);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp001[d_where+width]);
 else PutCharL(bmp001[d_where+width]);

 }
else
 { //显示第二行八个汉字
 SetPage(2,2);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp001[d_where]);//右边
 else PutCharL(bmp001[d_where]);//左边
 SetPage(3,3);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp001[d_where+width]);
 else PutCharL(bmp001[d_where+width]);

 }
    x_add++;
   d_where++;
}
}
/*
//------------------------------------------------------------------
//字模2显示一个汉字
//纵向取模,字节倒序
void disp_one(bit top_low,bit widows,uchar address,uchar width,uchar*bmp)
{
if(top_low==0)
 {
 SetPage(0,0);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp001[next][i]);
 else PutCharL(bmp001[next][i]);
 SetPage(1,1);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp001[next][i+width]);
 else PutCharL(bmp001[next][i+width]);
 }
else
 {
 SetPage(0,0);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp001[next][i]);
 else PutCharL(bmp001[next][i]);
 SetPage(1,1);
 SetAddress(address,address);
 if(window==1)PutCharR(bmp001[next][i+width]);
 else PutCharL(bmp001[next][i+width]);
 }
}
*/

 


//液晶显示规则
// M(左)  S(右)
// page  page
// 0 | 0
// 1 | 1
// 2 | 2
// 3 | 3

void delay1s(unsigned char i)
{
 while(i>1)
 {
  i--;

  delay(65530);
 }
}
/*
//显示动态的等待图标
void wait1(unsigned char i)
{
 for(;i>1;i--)
 {delay1s(2);
 clrscr(); //
 DrawBmp1(0,60,Bmptc); //
 DrawBmp1(76,19,Bmpt1); //
 delay1s(2);
 clrscr(); //
 DrawBmp1(0,60,Bmptc); //
 DrawBmp1(76,19,Bmpt2); //
 delay1s(2);
 clrscr(); //
 DrawBmp1(0,60,Bmptc); //
 DrawBmp1(76,19,Bmpt3); //
 delay1s(2);
 clrscr(); //
 DrawBmp1(0,60,Bmptc); //
 DrawBmp1(76,19,Bmpt4); //
 delay1s(2);
 clrscr(); //
 DrawBmp1(0,60,Bmptc); //
 DrawBmp1(76,19,Bmpt5); //
 delay1s(2);
 clrscr(); //
 DrawBmp1(0,60,Bmptc); //
 DrawBmp1(76,19,Bmpt6); //
 delay1s(2);
 clrscr(); //
 DrawBmp1(0,60,Bmptc); //
 DrawBmp1(76,19,Bmpt7); //
 }

}

*/
//演示程序
void main()
{

 lcdini(); //reset
 clrscr(); //clr

 while(1)
 {
  Draw_word(0,13,0,16); //
  Draw_word(1,29,0,16); //
  Draw_word(2,45,0,16); //
  Draw_word(3,61,0,16); //
  Draw_word(4,77,0,16); //
  Draw_word(3,93,0,16); //
  
  DrawBmp(1, 122,Bmp002);
  
  delay1s(20000);
  clrscr(); //clr  
  
 //DrawBmp(0, 32,Bmp002);
  }
}

unsigned char code bmp001[]=
{
/*--  0文字:  图  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0xFE,0x42,0x42,0x22,0x1E,0xAA,0x4A,0xAA,0x9A,0x0A,0x02,0x02,0xFE,0x00,0x00,
0x00,0xFF,0x42,0x42,0x41,0x41,0x48,0x72,0x54,0x40,0x41,0x43,0x41,0xFF,0x00,0x00,

/*--  1文字:  像  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x40,0x20,0xF8,0x17,0x02,0xF8,0x4C,0x4B,0xCA,0x7A,0x4E,0x4A,0xC8,0x78,0x00,0x00,
0x00,0x00,0xFF,0x00,0x2A,0x2A,0x16,0x15,0x49,0x86,0x7A,0x05,0x09,0x31,0x10,0x00,

/*--  2文字:  显  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0x00,0x3E,0x2A,0xEA,0x2A,0x2A,0x2A,0xEA,0x2A,0x3E,0x00,0x00,0x00,0x00,
0x20,0x21,0x22,0x2C,0x20,0x3F,0x20,0x20,0x20,0x3F,0x28,0x24,0x23,0x20,0x20,0x00,

/*--  3文字:  示  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x20,0x20,0x22,0x22,0x22,0x22,0xE2,0x22,0x22,0x22,0x22,0x22,0x20,0x20,0x00,
0x10,0x08,0x04,0x03,0x00,0x40,0x80,0x7F,0x00,0x00,0x01,0x02,0x0C,0x18,0x00,0x00,

/*--  4文字:  演  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x21,0x86,0x60,0x00,0x0C,0xD4,0x54,0x55,0xF6,0x54,0x54,0xD4,0x0C,0x04,0x00,
0x04,0xFC,0x03,0x00,0x00,0x00,0x8F,0x69,0x09,0x0F,0x09,0x29,0xCF,0x00,0x00,0x00,

//字模软件V2.1,纵向取模,字节倒序 。
};

   unsigned char code bmp002[]=
{
/*--  调入了一幅图像:这是您新建的图像  --*/
/*--  宽度x高度=122x16  --*/
0xFF,0x83,0x45,0x29,0xF1,0x99,0x55,0x33,0x33,0x55,0x99,0xF1,0x29,0x45,0x83,0xFF,
0x00,0x00,0x00,0x80,0x60,0x18,0x06,0x01,0x06,0x18,0x60,0x80,0x00,0x00,0x00,0x01,
0x02,0x0C,0x3C,0xF8,0x78,0xB0,0x50,0xB0,0x50,0xB0,0x78,0xF8,0x3C,0x0C,0x02,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x30,0x0C,0x03,0x00,0x80,0x48,0x24,0x48,
0x80,0x00,0x03,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0x0C,0x0C,0x8F,0xCF,0xEC,0x6C,0xEF,0xCF,0x8C,0x0C,0x0F,0xEF,0xEC,
0x0C,0x0F,0x0F,0xEC,0xEC,0x0F,0x0F,0xEC,0xEC,0x6F,0x6F,0x6C,0x6C,0x6F,0x0F,0x0C,
0xEC,0xEF,0x6F,0x6C,0x6C,0xEF,0xCF,0x0C,0x0C,0xFF,0xFF,0xC1,0xA2,0x94,0x8F,0x99,
0xAA,0xCC,0xCC,0xAA,0x99,0x8F,0x94,0xA2,0xC1,0xFF,0x00,0x00,0x00,0x01,0x06,0x18,
0x60,0x80,0x60,0x18,0x06,0x01,0x00,0x00,0x00,0x80,0x40,0x30,0x3C,0x1F,0x1E,0x0D,
0x0A,0x0D,0x0A,0x0D,0x1E,0x1F,0x3C,0x30,0x40,0x80,0x00,0x00,0x00,0xC0,0x30,0x0C,
0x03,0x00,0x00,0x00,0x80,0x48,0x24,0x12,0x09,0x12,0x24,0x48,0x80,0x00,0x00,0x00,
0x03,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x1F,
0x3F,0x70,0x60,0x70,0x3F,0x1F,0x00,0x00,0x0F,0x1F,0x38,0x70,0x38,0x1F,0x0F,0x00,
0x00,0x7F,0x7F,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x7F,0x7F,0x0E,0x1E,0x3E,0x77,
0x63,0x00,0x00,0xFF,

//字模软件V2.1,纵向取模,字节倒序 。
};

 

 

 12232的资料(其它厂家的资料,与该屏完全兼容):

程序中使用的字模软件为:字模V2.1

 

 硬件电路图:

 

点亮后的图片:

 

« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。