您当前位置:一步电子网 > 博谈 > 技术文章 > HG1286418测试程序
收藏 分享

HG1286418测试程序

HG1286418测试程序:

#include <>
#include <>
#include <>
#define uchar unsigned char
#define uint unsigned int
#define buslcd P1

sbit A0=P3^0; ///////RS
sbit RW=P3^1;
sbit E=P3^2;
sbit CS1=P3^4;
sbit CS2=P3^5;
sbit RST=P3^6;

uchar code tab1[][8]={
0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00, /*'H'=28h*/
0x00,0x3E,0x41,0x41,0x49,0x7A,0x00,0x00, /*'G'=27h*/
0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00, /*'1'=11h*/
0x00,0x42,0x61,0x51,0x49,0x46,0x00,0x00, /*'2'=12h*/
0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, /*'8'=18h*/
0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00, /*'6'=16h*/
0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00, /*'4'=14h*/
0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00, /*'1'=11h*/
0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, /*'8'=18h*/
0x00,0x7F,0x49,0x49,0x49,0x49,0x00,0x00, /*'E'=25h*/
0x00,0x41,0x7F,0x41,0x41,0x3E,0x00,0x00, /*'D'=24h*/
0x00,0x00,0x41,0x7F,0x41,0x00,0x00,0x00, /*'I'=29h*/
0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00, /*'T'=34h*/
0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00, /*'O'=2Fh*/
0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00, /*'R'=32h*/
0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00, /*':'=1Ah*/
0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00, /*'M'=2Dh*/
0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00, /*'R'=32h*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*' '=32h*/
0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00, /*'Q'=31h*/
0x00,0x00,0x41,0x7F,0x41,0x00,0x00,0x00, /*'I'=29h*/
0x00,0x7F,0x06,0x08,0x30,0x7F,0x00,0x00, /*'N'=2Eh*/
0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00, /*'Q'=31h*/
0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00, /*'Q'=31h*/
0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00, /*':'=1Ah*/
0x00,0x21,0x41,0x45,0x4B,0x31,0x00,0x00, /*'3'=13h*/
0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, /*'8'=18h*/
0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00, /*'1'=11h*/
0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00, /*'1'=11h*/
0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00, /*'9'=19h*/
0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, /*'8'=18h*/
0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00, /*'4'=14h*/
0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00, /*'6'=16h*/
0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00, /*'4'=14h*/
};
uchar code tab2[][32]={
/* 点阵:16x16
提取点阵方向:纵向
字节掉转:是
字节方式:C语言 */
0x10,0x10,0xD0,0xFF,0x90,0x10,0x08,0xC8, // 杭
0x49,0x4E,0x48,0xE8,0x4C,0x08,0x00,0x00,
0x04,0x03,0x00,0xFF,0x80,0x41,0x20,0x1F,
0x00,0x00,0x00,0x3F,0x40,0x40,0x70,0x00,

0x80,0x70,0x00,0xFF,0x00,0x10,0x60,0x00, // 州
0xFE,0x00,0x10,0x60,0x00,0xFF,0x00,0x00,
0x00,0x40,0x30,0x0F,0x00,0x00,0x00,0x00,
0x3F,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,

0x10,0x22,0x64,0x0C,0xC0,0x44,0x54,0x54, // 清
0x54,0x7F,0x54,0x54,0xD6,0x44,0x40,0x00,
0x04,0x04,0xFE,0x01,0x00,0x00,0xFF,0x15,
0x15,0x15,0x55,0x95,0x7F,0x01,0x00,0x00,

0x40,0x42,0xCC,0x00,0x20,0x20,0x20,0xA0, // 达
0x7F,0x20,0x20,0x20,0x30,0x20,0x00,0x00,
0x40,0x20,0x1F,0x20,0x50,0x48,0x46,0x41,
0x40,0x41,0x42,0x4C,0x58,0x60,0x20,0x00,

0x40,0x40,0x42,0x44,0x58,0xC0,0x40,0x7F, // 光
0x40,0xC0,0x50,0x48,0x46,0x64,0x40,0x00,
0x00,0x80,0x40,0x20,0x18,0x07,0x00,0x00,
0x00,0x3F,0x40,0x40,0x40,0x40,0x70,0x00,

0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48, // 电
0x48,0x48,0x48,0xFC,0x08,0x00,0x00,0x00,
0x00,0x07,0x02,0x02,0x02,0x02,0x3F,0x42,
0x42,0x42,0x42,0x47,0x40,0x70,0x00,0x00,

0x10,0x22,0x64,0x0C,0x80,0x04,0xC4,0x34, // 液
0x05,0xC6,0xBC,0x24,0x24,0xE6,0x04,0x00,
0x04,0x04,0xFE,0x01,0x02,0x01,0xFF,0x42,
0x21,0x16,0x08,0x15,0x23,0x60,0x20,0x00,

0x00,0x00,0x00,0x00,0xFF,0x49,0x49,0x49, // 晶
0x49,0x49,0xFF,0x00,0x00,0x80,0x00,0x00,
0x00,0xFF,0x49,0x49,0x49,0x49,0xFF,0x00,
0xFF,0x49,0x49,0x49,0x49,0xFF,0x01,0x00,

0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0x92, // 显
0x92,0x92,0x92,0xFF,0x02,0x00,0x00,0x00,
0x40,0x42,0x44,0x4D,0x40,0x7F,0x40,0x40,
0x40,0x7F,0x40,0x49,0x44,0x66,0x40,0x00,

0x40,0x40,0x42,0x42,0x42,0x42,0x42,0xC2, // 示
0x42,0x42,0x42,0x43,0x42,0x60,0x40,0x00,
0x00,0x10,0x08,0x04,0x06,0x40,0x80,0x7F,
0x00,0x00,0x02,0x04,0x0C,0x18,0x00,0x00,

0x10,0x10,0xD0,0xFF,0x94,0x14,0xE4,0xBF, // 模
0xA4,0xA4,0xA4,0xBF,0xF4,0x26,0x04,0x00,
0x04,0x03,0x00,0xFF,0x08,0x89,0x8B,0x4A,
0x2A,0x1E,0x2A,0x2A,0x4B,0xC8,0x48,0x00,

0x20,0x20,0x20,0xFF,0x20,0x20,0x10,0x10, // 块
0xFF,0x10,0x10,0x10,0xF8,0x10,0x00,0x00,
0x08,0x18,0x08,0x0F,0x84,0x46,0x22,0x1A,
0x07,0x0A,0x12,0x22,0x43,0xC2,0x42,0x00,
};

/*** 延时子程序***/
void Delay(uint t)
{uint i,j;
for(i=0;i<t;i++)
for(j=0;j<305;j++)
_nop_();_nop_();_nop_();_nop_();
}
/*** 忙判断子程序***/
void Busy()
{
A0=0;
RW=1;
buslcd=0xff;
E=1;
_nop_();
while(buslcd&0x80);
E=0;
_nop_();
}
/*** 写入左半屏指令 子程序***/
void Writecom1(uchar wcom)
{
CS1=0;CS2=1;
Busy();
buslcd=wcom;
A0=0;
RW=0;
E=1;
_nop_();
E=0;
_nop_();}
/*** 写入左半屏数据 子程序***/
void Writedata1(uchar wdata)
{
CS1=0;CS2=1;
Busy();
buslcd=wdata;
A0=1;
RW=0;
E=1;
_nop_();
E=0;
_nop_();}
/*** 写入右半屏指令 子程序***/
void Writecom2(uchar wcom)
{
CS1=1;CS2=0;
Busy();
buslcd=wcom;
A0=0;
RW=0;
E=1;
_nop_();
E=0;
_nop_();}
/*** 写入右半屏数据 子程序***/
void Writedata2(uchar wdata)
{
CS1=1;CS2=0;
Busy();
buslcd=wdata;
A0=1;
RW=0;
E=1;
_nop_();
E=0;
_nop_();}
/***读出左半屏数据 子程序***/
uchar Readdata1()
{
uchar rdata;
CS1=0;CS2=1;
Busy();
buslcd=rdata;
A0=1;
RW=1;
E=1;
_nop_();_nop_();_nop_();
E=0;
_nop_();
return rdata;
}
/***读出右半屏数据 子程序***/
uchar Readdata2()
{
uchar rdata;
CS1=1;CS2=0;
Busy();
buslcd=rdata;
A0=1;
RW=1;
E=1;
_nop_();_nop_();_nop_();
E=0;
_nop_();
return rdata;
}
/****清屏子程序***/
void Clear(void)
{uchar i,j;
for(i=0;i<8;i++)
{Writecom1(0xb8+i);Writecom1(0x40);
Writecom2(0xb8+i);;Writecom2(0x40);
for(j=0;j<64;j++)
{Writedata1(0);Writedata2(0);}}
}
/** 液晶初始化子程序**/
void INT()
{
Delay(3);
Writecom1(0x3f);
Writecom2(0x3f);
Writecom1(0xc0);
Writecom2(0xc0);
Writecom1(0xb8);
Writecom2(0xb8);
Writecom1(0x40);
Writecom2(0x40);
Clear();
}
/*** 8*8字体 x,y 为液晶对应地址 coder为字母的字摸***/
void display8(uchar x,uchar y,uchar coder)
{
uchar i;
for(i=0;i<8;i++)
{
if(x<64)
{
Writecom1(0xb8+y);
Writecom1(0x40+x);
Writedata1(tab1[coder][i]);
}
else
{
Writecom2(0xb8+y);
Writecom2(x);
Writedata2(tab1[coder][i]);
}
x++;
}
}

/***********写入 一串 8*8字母*************/
void hz88(uchar x,uchar y,uchar m,uchar mend)
{
uchar i;
for(i=m;i<mend;i++)
{
display8(x,y,i);
x=x+8;}
}
/*** 汉字写入 x,y 为液晶对应地址 coder为汉字的字摸***/
void hz11(uchar x,uchar y,uchar coder)
{
uchar i,n,m;
uchar j=1;
n=x;m=y;
for(i=0;i<16;i++)
{
if(x<64)
{
Writecom1(0xb8+y);
Writecom1(0x40+x);
Writedata1(tab2[coder][i]);
}
else
{
Writecom2(0xb8+y);
Writecom2(x);
Writedata2(tab2[coder][i]);
} x++;}

x=n;y=m+1;
for(i=0;i<16;i++)
{
if(x<64)
{
Writecom1(0xb8+y);
Writecom1(0x40+x);
Writedata1(tab2[coder][i+(j<<4)]);
}
else
{
Writecom2(0xb8+y);
Writecom2(x);
Writedata2(tab2[coder][i+(j<<4)]);
}x++;}
}
/*************写入 一串16*16汉字***********/
void hz1616(uchar x,uchar y,uchar m,uchar mend)
{
uchar i;
for(i=m;i<mend;i++)
{
hz11(x,y,i);
x=x+16;}
}
/*** 主程序***/
void main()
{
uchar i;
RST=0;
Delay(1);
RST=1;
_nop_(); _nop_();
INT();
hz1616(16,0,0,6);
hz1616(16,2,6,12);
hz88(32,5,0,9);
hz88(0,6,9,22);
hz88(0,7,22,34);
while(1);
}

小编推荐

我有话要说

网友评论仅供网友表达个人看法,并不表明一步电子网同意其观点或证实其描述

对不起没有相关信息
免责声明:
1、凡本网注明来源:一步电子网www.8039fde.tw的所有文字、图片和音视频稿件,版权均为一步电子网www.8039fde.tw独家所有,任何媒体、网站或个人在转载使用时必须注明来源一步电子网www.8039fde.tw违反者本网将依法追究责任
2、本文系本网编辑转载,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。
3、如涉及作品内容、版权和其它问题,请作者来电或来函联系。
经营模式:生产型
所在地区:浙江 - 杭州
企业类别:私营有限责任公司
网站推荐
万博代理怎么加入k 平阴县| 邵武市| 那坡县| 杨浦区| 南江县| 黎城县| 玉山县| 双流县| 类乌齐县| 舟山市| 安阳市| 修武县| 罗山县| 铁力市| 化德县| 怀安县| 盐山县| 泸溪县| 玉山县| 阿勒泰市| 靖远县| 西林县| 鄂伦春自治旗| 宜兴市| 成武县| 门头沟区| 西林县| 敦煌市| 呼玛县| 登封市| 兴宁市| 辰溪县| 留坝县| 奎屯市| 太谷县| 岳西县| 柘城县| 唐海县| 丰都县| 安远县| 临汾市|