单片机源程序如下:
- #include"reg52.h"
- #include"math.h"
- #include"intrins.h"
- #include"function.h"
- #define DB P0
- sbit RS = P1^4;
- sbit RW = P1^5;
- sbit E = P1^6;
- uchar code logo[] = {
- /*-- 调入了一幅图像:I:\液晶屏BMP图\菜单.bmp --*/
- /*-- 宽度x高度=128x64 --*/
- 0x00,0x00,0x00,0x20,0x20,0x08,0x20,0x20,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x20,0x17,0xFC,0x13,0xF0,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x78,0x20,0x50,0x08,0x12,0x20,0x24,0x90,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x10,0x00,0x4B,0xFC,0x40,0x08,0x02,0x20,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x70,0x00,0x48,0x20,0x47,0xC8,0x02,0x1C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x10,0x00,0x48,0x20,0x44,0x48,0xF4,0x00,0x7F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x10,0x00,0x79,0x20,0x44,0x48,0x1B,0xF0,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x10,0x00,0x48,0xA0,0x47,0xC8,0x11,0x10,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x10,0x00,0x48,0xA0,0x44,0x48,0x11,0x10,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x10,0x00,0x48,0x20,0x44,0x48,0x14,0xA0,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x10,0x00,0x78,0x20,0x47,0xC8,0x18,0x40,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x10,0x60,0x48,0x20,0x40,0x08,0x10,0xA0,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x7C,0x60,0x40,0xA0,0x40,0x28,0x03,0x1C,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x40,0x40,0x10,0x0C,0x08,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x10,0x00,0x10,0x20,0x20,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x1F,0xF8,0x3F,0xF8,0x13,0xF0,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x10,0x10,0x00,0x00,0x12,0x20,0x24,0x90,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x3C,0x00,0x1F,0xF0,0x00,0x00,0x02,0x20,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x42,0x00,0x10,0x10,0x00,0x08,0x02,0x1C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x42,0x00,0x1F,0xF0,0x7F,0xFC,0xF4,0x00,0x7F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x02,0x00,0x10,0x10,0x01,0x00,0x1B,0xF0,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x04,0x80,0x09,0x40,0x11,0x10,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x44,0x88,0x09,0x20,0x11,0x10,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x10,0x00,0x24,0x90,0x11,0x10,0x14,0xA0,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x20,0x00,0x14,0xA0,0x21,0x08,0x18,0x40,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x42,0x60,0x14,0xC0,0x41,0x08,0x10,0xA0,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x7E,0x60,0x04,0x88,0x05,0x00,0x03,0x1C,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xFF,0xFC,0x02,0x00,0x0C,0x08,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x08,0x40,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x1C,0x40,0x02,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xF0,0x40,0x7F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x3C,0x00,0x11,0x50,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x42,0x00,0xFD,0x48,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x42,0x00,0x11,0x44,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x32,0x44,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x18,0x00,0x3A,0x40,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x52,0x48,0x09,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x02,0x00,0x50,0x10,0x18,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x42,0x00,0x90,0x20,0x28,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x42,0x60,0x10,0x40,0xC9,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x3C,0x60,0x11,0x80,0x0A,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x16,0x00,0x0C,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x20,0x08,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x17,0xFC,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x48,0x08,0x3C,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x42,0x08,0x41,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x5F,0xE8,0x41,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x18,0x00,0x42,0x08,0xF9,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x28,0x00,0x4F,0xC8,0xA1,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x48,0x00,0x4A,0x48,0x21,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x48,0x00,0x4A,0x48,0xFD,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x7E,0x00,0x4A,0x48,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x4A,0xC8,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x08,0x60,0x42,0x08,0x28,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x1E,0x60,0x42,0x28,0x30,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x40,0x10,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };
- /************************************************************************************
- 查忙函数
- ************************************************************************************/
- void busy(void)//RS=0;RW=1;wait=0闲;wait!=0忙
- {
- uchar wait;
- RS = 0;
- RW = 1;
- E = 1;
- for(;;)
- {
- wait = DB;
- wait &= 0x80;
- if(wait == 0)break;
- }
- E = 0;
- }
- /************************************************************************************
- 写指令函数
- ************************************************************************************/
- void w_code(uchar c)//RS=0;RW=0;E下降沿
- {
- busy();
- RS = 0;
- RW = 0;
- DB = c;
- E = 1;
- E = 0;
- DB = 0xff;
- }
- /************************************************************************************
- 写数据函数
- ************************************************************************************/
- void w_data(uchar d)//RS=1;RW=0;E下降沿
- {
- busy();
- RS = 1;
- RW = 0;
- DB = d;
- E = 1;
- E = 0;
- DB = 0xff;
- }
- /************************************************************************************
- 读数据函数
- ************************************************************************************/
- uchar r_data(void)//RS=1;RW=1;E下降沿
- {
- uchar rd_lcd;
- busy();
- RS = 1;
- RW = 1;
- E = 1;
- rd_lcd = DB;
- E = 0;
- return rd_lcd;
- }
- /************************************************************************************
- 写DGRAM:x_lcd横坐标,y_lcd纵坐标
- ************************************************************************************/
- void address(uchar x_lcd,uchar y_lcd)//
- {
- w_code(y_lcd);//垂直坐标
- w_code(x_lcd);//水平坐标
- }
- /************************************************************************************
- 初始化液晶屏
- 0:字库 1:绘图
- ************************************************************************************/
- void lcd_rst(bit a)
- {
- if(a)
- {
- w_code(0x01);// 清屏
- w_code(0x32);// 功能设置---8BIT控制界面,绘图显示ON
- w_code(0x36);// 功能设置---8BIT控制界面,扩充指令集
- }
- else
- {
- w_code(0x30);// 功能设置---8BIT控制界面,基本指令集
- w_code(0x0c);//显示打开,光标关,反白显示关
- w_code(0x01);// 清除屏幕显示,将DDRAM的地址计数器归零
- }
- }
- /************************************************************************************
- ---------------------------写整屏点阵数据
- ---------------------------x :图像数据的起始地址
- ************************************************************************************/
- void write_lcd_full(uint x )
- {
- uchar i,j,a;
- j = 0x80; //Y地址寄存器
- for(a = 0;a < 32;a++)
- {
- w_code(j);
- j++;
- w_code(0x80);//X地址寄存器
- for(i = 0;i < 16;i ++)
- {
- w_data(logo[x]);
- x++;
- }
- }
- j = 0x80; //Y地址寄存器
- for(a = 0;a < 32;a++)
- {
- w_code(j);
- j++;
- w_code(0x88);//X地址寄存器
- for(i = 0;i < 16;i ++)
- {
- w_data(logo[x]);
- x++;
- }
- }
- }
复制代码
所有资料51hei提供下载:
0-30V 4A数控稳压电源图.pdf
(68.11 KB, 下载次数: 18)
|