微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > AMPIRE12864液晶C语言代码

AMPIRE12864液晶C语言代码

时间:11-17 来源:互联网 点击:

80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F},/*"m",18*/

{0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00},/*"/",19*/

{0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00},/*"2",20*/

{0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00},/*"8",21*/

{0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00},/*"2",22*/

{0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00},/*"2",23*/

{0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00},/*"8",24*/

{0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00},/*"0",25*/

{0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00},/*"0",26*/

{0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00},/*"7",27*/

{0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00},/*"2",28*/

{0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00},/*"/",29*/

{0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00},/*"b",30*/

{0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},/*"l",31*/

{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00},/*"o",32*/

{0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00}/*"g",33*/

};
void delay(uint ms)
{
uint i,j;
for(i=0;ifor(j=0;j<1141;j++);
}

void Write_cmd(uchar cmd)
{
RS_L();
RW_L();
E_H();
PORTB=cmd;
delay(2);
E_L();;

}
void Write_data(uchar data)
{
RS_H();
RW_L();
E_H();
PORTB=data;
delay(2);
E_L();

}

void WriteStr(uchar *s)
{
while(*s)
{ Write_data(*s++);
delay(5);

}
}
init_12864()
{
DDRB=0XFF;
DDRD|=BIT(4)|BIT(5)|BIT(6);//RS RW E
DDRA|=BIT(6)|BIT(7);//CS1 CS2
delay(5);
Write_cmd(0x30); //8位数据接口,1行显示。5*7点阵,选择基本指令集
delay(5);
Write_cmd(0x0f); //开显示(光标显示。闪烁)
delay(5);

Write_cmd(0x01); //清除显示,并且设定地址指针为00H
delay(5);
Write_cmd(0x06); //指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位
delay(5);
}

void SetLine(uchar line) //line -> 0 : 7
{
line = line & 0x07;
line = line | 0xb8; //1011 1xxx
Write_cmd(line);
}

void SetColum(uchar colum) //colum -> 0 :63
{
colum = colum & 0x3f;
colum = colum | 0x40; //01xx xxxx
Write_cmd(colum);
}

void SelectScreen(uchar screen)//0全屏,1左平,2右屏
{
switch(screen)
{
case 0:
CS1_L();CS2_L();
break;
case 1:
CS1_L();CS2_H();
break;
case 2:
CS1_H();CS2_L();
break;
}
}

//PAGE -> 0 : 7
//colum -> 0 :63
void display_HZ( uchar page,uchar col,uchar *temp) //显示汉字子程序
{
uchar j;
SelectScreen(1); //从左半屏开始 若列数超过128 改右
if(col>=64)
{
SelectScreen(2);
col-=0x40;
}
SetLine(page); //按要求写入页地址
SetColum(col); //按要求从相应列开始写数据
for(j=0;j<16;j++) //写入一个汉字的上半部分,共16字节
{
Write_data(temp[j]);
delay(1);
}
SetLine(page+1); //从下一页开始显示汉字的下半部分要求从相应的列开始写数据
SetColum(col);
for(j=16;j<32;j++)
{
Write_data(temp[j]);
delay(1);
}
}
void display_ZM( uchar page,uchar col,uchar *temp) //显示字母子程序
{
uchar j;
SelectScreen(1); //从左半屏开始 若列数超过128 改右

if(col>=64)
{
SelectScreen(2);
col-=64;
}

SetLine(page); //按要求写入页地址
SetColum(col); //按要求从相应列开始写数据
for(j=0;j<8;j++) //写入一个汉字的上半部分,共16字节
{
Write_data(temp[j]);
delay(1);
}
SetLine(page+1); //从下一页开始显示汉字的下半部分要求从相应的列开始写数据
SetColum(col);
for(j=8;j<16;j++)
{
Write_data(temp[j]);
delay(1);
}
}
void main()
{
uchar i,j;
init_12864();
for(i=0;i<8;i++)
display_HZ(0,16*i,HZ[i]);

for(i=0;i<34;i++)
{
if(i>=32)
{
display_ZM(6,8*i-256,ZM[i]);
continue;
}
if(i>=16)
{
display_ZM(4,8*i-128,ZM[i]);
continue;
}
display_ZM(2,8*i,ZM[i]);

}

字模软件

avr单片机

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top