工业控制液晶显示器
来源:互联网 发布:单片机和嵌入式关键词 编辑:程序博客网 时间:2024/04/29 08:18
玩了一段时间,算是比较熟悉了,在这共享一下代码啦~
//写一个数据子程序:
Write_Byte(uchar dc_data)
{
uchar xdata DC; //定义一个外部RAM变量
//uchar i;
CS0 = 0;
DC = dc_data; //数据dc_data写到外部RAM(即LCD控制板)。
CS0 = 1;
//加入适当的空操作延时
//当采用更高速的单片机时应加入更多的空操作延时
//这里加上8个空操作延时,在AT89C51,22MHz下是完全没问题的。
//for(i=0;i<1;i++){}
}
//读一个字节数据子程序:
uchar Read_Byte(void)
{
uchar xdata DC;
CS0 = 0;
return DC;
}
//////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////
/*
//测试从显示终端机读取时间。
test_timer()
{
uchar i;
Read_date();
while(Date[0] == 0){} //等待显示终端机送年月日数据到单片机
for(i=0;i<3;i++)
{
DIS_Value((6*16)+(i*24),32,Date[i+1],2);
}
Read_time();
while(Date[4] == 0){} //等待显示终端机送时分秒数据到单片机
for(i=0;i<3;i++)
{
DIS_Value((6*16)+(i*24),48,Date[i+5],2);
}
}
*/
//指令头,每一条指令都规定为"0x81, command1,command2,Fcolor,Bcolor"
command_head(unsigned char command1,unsigned char command2)
{
Write_Byte(0x81);
Write_Byte(command1);
Write_Byte(command2);
Write_Byte(Fcolor);
Write_Byte(Bcolor);
}
//清屏子程序
Lcd_Clr()
{
command_head(0x43,0x4c);
Write_Byte(0x84);
}
//保存原桌面内容
void COPY_DC()
{
command_head(0x43,0x44);
Write_Byte(0x84);
}
//恢复原来桌面
void EXIT_DC()
{
command_head(0x45,0x44);
Write_Byte(0x84);
}
Bell() //打开蜂鸣器。
{
Write_Byte(0x81);
Write_Byte(0x42);
Write_Byte(0x42);
Write_Byte(0x01); //设置蜂鸣器的时间
Write_Byte(0x84);
}
// 清矩形
void Clr_squ(unsigned short x0,unsigned short y0,unsigned short width,unsigned short heith)
{
command_head(0x43,0x58);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
Write_Byte(width/100);
Write_Byte(width%100);
Write_Byte(heith/100);
Write_Byte(heith%100);
Write_Byte(0x84);
}
// 反色矩形
void inv_squ(unsigned short x0,unsigned short y0,unsigned short width,unsigned short heith)
{
command_head(0x43,0x4e);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
Write_Byte(width/100);
Write_Byte(width%100);
Write_Byte(heith/100);
Write_Byte(heith%100);
Write_Byte(0x84);
}
/*
//读取年月日
Read_date()
{
Date[0] = 0;
command_head(0x52,0x44);
Write_Byte(0x84);
}
//读取时分秒
Read_time()
{
Date[4] = 0;
command_head(0x52,0x54);
Write_Byte(0x84);
}
*/
//画圆子程序。
DIS_Ellipse(unsigned short x0,unsigned short y0,unsigned short xr,unsigned short yr)
{
command_head(0x44,0x45);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
Write_Byte(xr/100);
Write_Byte(xr%100);
Write_Byte(yr/100);
Write_Byte(yr%100);
Write_Byte(x0/100);
Write_Byte(0x84);
}
/*
//画直线子程序。
DIS_Line(unsigned short x0,unsigned short y0,unsigned short x1,unsigned short y1,unsigned short with)
{
command_head(0x44,0x4c);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
Write_Byte(x1/100);
Write_Byte(x1%100);
Write_Byte(y1/100);
Write_Byte(y1%100);
Write_Byte(with/100);
Write_Byte(with%100);
Write_Byte(0x84);
}
*/
//在指定的开始位置(x0,y0)显示字符串子程序。
//当x0大于800且已打开光标功能时在以光标为开始位置显示字符串子程序。
/*DIS_String(unsigned short x0,unsigned short y0,char *fmt)
{
command_head(0x44,0x57);
//Write_Byte(0xE0);//字体以红色显示
//Write_Byte(0x1C);//背景为透明
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
while(*fmt)
{
Write_Byte(*fmt);
fmt++;
}
Write_Byte(0x84);
}
*/
//在指定的开始位置(x0,y0)显示字符串子程序。
//当x0大于800且已打开光标功能时在以光标为开始位置显示字符串子程序。
DIS_StringN(unsigned short x0,unsigned short y0,char *fmtn,uchar n)
{
uchar i;
command_head(0x44,0x57);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
for(i=0;i {
Write_Byte(*fmtn);
fmtn++;
}
Write_Byte(0x84);
}
//在指定的开始位置(x0,y0)显示字符串子程序。
//当x0大于800且已打开光标功能时在以光标为开始位置显示字符串子程序。
DIS_String64(unsigned short x0,unsigned short y0,char *fmt)
{
command_head(0x54,0x04);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
while(*fmt)
{
Write_Byte(*fmt);
fmt++;
}
Write_Byte(0x84);
}
/*
//显示时间子程序
void Dis_time(unsigned short x0,unsigned short y0,unsigned char i)
{
command_head(0x44,0x54);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
Write_Byte(i);
Write_Byte(0x84);
}
*/
/*
//设置时间子程序;
//年,月,日,时 ,分,秒,星期。
void Set_time(uchar year,uchar month,uchar day,uchar hour,uchar minute,uchar second,uchar date)
{
command_head(0x53,0x54);
Write_Byte(year);
Write_Byte(month);
Write_Byte(day);
Write_Byte(hour);
Write_Byte(minute);
Write_Byte(second);
Write_Byte(date);
Write_Byte(0x84);
}
*/
/*
//显示变量子程序
DIS_Value(unsigned short x0,unsigned short y0,unsigned short Va,unsigned char i)
{
command_head(0x44,0x56);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
Write_Byte(Va/100);
Write_Byte(Va%100);
Write_Byte(i);
Write_Byte(0x84);
}
*/
//显示位图子程序
DIS_BMP(unsigned short x0,unsigned short y0,uchar N1)
{
command_head(0x44,0x53);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
Write_Byte(N1);
Write_Byte(0x84);
}
/*
//自动显示位图子程序
AUTO_BMP(unsigned short x0,unsigned short y0,uchar N1,uchar N2,uchar T)
{
command_head(0x5a,0x44);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
Write_Byte(N1);
Write_Byte(N2);
Write_Byte(T);
Write_Byte(0x84);
}
*/
////////////////////////////////////////////////////////////////////////
//显示一个字符
DIS_Byte(unsigned short x0,unsigned short y0,char fmt)
{
command_head(0x44,0x57);
Write_Byte(x0/100);
Write_Byte(x0%100);
Write_Byte(y0/100);
Write_Byte(y0%100);
Write_Byte(fmt);
Write_Byte(0x84);
}
- 工业控制液晶显示器
- 工业顺序控制模拟
- 工业控制项目外包
- 工业PID控制原理
- 工业控制自动化技术
- 工业控制计算机
- 工业控制元器件介绍
- 工业控制PID
- 欧系工业控制和日系工业控制区别
- 工业控制与电脑编程
- 工业控制网络的发展
- 工业机器人的控制算法
- 工业控制——目录
- 工业过程控制领域中通信
- 工业控制自动化体系统架构
- 工业控制图像采集的好帮手!
- MFC OnCtlColor 工业控制中的陷阱
- RTX在工业控制中的优势
- javascript的Form验证
- Intel笔记本CPU大全
- 免责声明
- unix下标准库文件库编程
- Hello
- 工业控制液晶显示器
- 架构师能力调查
- C语言嵌入式系统编程修炼之道——软件架构篇
- 在LINUX下,struts 2 文件上传路径问题
- 看门狗的介绍
- 多国语言
- 512哀悼汶川让自己网站变灰色 过滤器
- 存储过程调用C#编写的DLL文件
- USB设备类