/********************************************************************
创建人:牟铭
时间:2013.1.17
功能:LCD12864液晶函数
******************************************************************/
#include"LCD12864.h"
//#define DPOT P2
/*
//unchar code tab1[]={
//" xnian.com "
//"欢迎使用这个程序"
//" 纪小年 "
//" 这人是谁啊? "
//};
//#pragma data:code
//以下是字模工具取出的图片数组
//========================== 菜单图片(宽度x高度=32*24)=============================
const unchar xdata menu_pic[6][96]={
// 调整
{0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x00,0x00,0x02,
0x40,0x00,0x00,0x82,0x47,0xFF,0xE1,0xC2,0x47,0xFF,0xF3,0xE2,0x47,0x38,0x68,0x02,
0x46,0xDF,0x68,0x82,0x46,0xDF,0x69,0xC2,0x46,0xDE,0xE8,0x82,0x46,0xDD,0xE8,0x02,
0x46,0xDD,0xE8,0x02,0x47,0x3D,0xE8,0x02,0x47,0xFF,0xE8,0x02,0x47,0xFF,0xE9,0xC2,
0x42,0x00,0x18,0x02,0x41,0xFF,0xF3,0xE2,0x40,0x00,0x01,0xC2,0x40,0x00,0x00,0x82,
0x40,0x00,0x00,0x02,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00
},
// 工具
{0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x00,0x03,0x82,
0x41,0xF0,0x07,0xC2,0x43,0xFF,0xCF,0xE2,0x47,0x3F,0xFE,0x02,0x47,0x3F,0xFE,0x02,
0x43,0xFF,0xCF,0xE2,0x41,0xF0,0x0F,0xC2,0x40,0x00,0x03,0x82,0x40,0x00,0x00,0x02,
0x40,0x00,0x03,0xC2,0x40,0x00,0x03,0xC2,0x41,0x80,0x01,0x82,0x43,0xFF,0xF3,0xC2,
0x47,0xFF,0xFF,0xE2,0x47,0xFF,0xFF,0xE2,0x43,0xFF,0xF3,0xC2,0x41,0x80,0x01,0x82,
0x40,0x00,0x01,0x82,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00
},
// 设置
{0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x43,0x18,0x00,0x02,
0x44,0xA4,0x0E,0x02,0x44,0xA4,0x1F,0x02,0x43,0x24,0x3F,0x02,0x40,0x00,0x7F,0x02,
0x40,0xF0,0xFC,0x02,0x43,0xF9,0xF0,0x02,0x43,0x03,0xE0,0x02,0x46,0x77,0x80,0x02,
0x46,0x7F,0x00,0x02,0x46,0x7E,0x00,0x02,0x46,0x7C,0x00,0x02,0x47,0x3D,0x00,0x02,
0x43,0x1D,0x81,0x22,0x43,0x81,0xB2,0x42,0x41,0xC3,0x4F,0xE2,0x40,0xFE,0x4A,0x42,
0x40,0x3C,0x32,0x42,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00
},
// 保密
{0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0xFC,0x03,0x02,
0x41,0xFE,0x1F,0x02,0x43,0x87,0x03,0x82,0x43,0x03,0x03,0x02,0x43,0x03,0x03,0x02,
0x43,0x03,0x0F,0x02,0x43,0x03,0x03,0x02,0x43,0x03,0x03,0x02,0x47,0xFF,0x83,0x02,
0x47,0xFF,0x83,0x02,0x47,0xCF,0x83,0x02,0x47,0x87,0x83,0x02,0x47,0xCF,0x83,0x02,
0x47,0xCF,0x87,0x82,0x47,0xCF,0x8F,0xC2,0x47,0xCF,0x9C,0xE2,0x47,0xFF,0x8F,0xC2,
0x43,0xFF,0x07,0x82,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00
},
// 版本
{0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x00,0x00,0x02,
0x40,0x0F,0x00,0x62,0x40,0x1D,0x80,0xF2,0x40,0x38,0x41,0xF2,0x40,0x70,0x23,0xE2,
0x40,0xE2,0x17,0xC2,0x41,0xE4,0x4F,0x82,0x41,0xF0,0x9F,0x02,0x41,0x59,0x16,0x02,
0x42,0x4C,0x1D,0x02,0x42,0x46,0x20,0x82,0x42,0x47,0x00,0x42,0x44,0x43,0x80,0xC2,
0x44,0x44,0xC1,0xC2,0x44,0xC8,0x63,0x82,0x45,0x50,0x37,0x02,0x46,0x60,0x1E,0x02,
0x40,0x40,0x0C,0x02,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00
},
// 退出
{0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x40,0xFF,0xE2,
0x40,0x60,0x80,0x62,0x43,0xF0,0x80,0xA2,0x43,0xF0,0x81,0x22,0x40,0x60,0x82,0x22,
0x40,0x40,0x84,0x22,0x40,0x00,0x88,0x22,0x40,0x00,0x88,0x22,0x47,0xFF,0xF8,0x22,
0x47,0xFF,0xF8,0x22,0x46,0x2A,0x2A,0x22,0x46,0xE3,0x78,0x22,0x46,0x77,0x78,0x22,
0x46,0xE3,0x78,0x62,0x46,0x2A,0x38,0x82,0x47,0xFF,0xF9,0x02,0x47,0xFF,0xFA,0x02,
0x40,0x00,0x0C,0x02,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00
}
};
//#pragma data:data
unchar xdata menu_cn[6][8]={"调 整","工 具","设 置","保 密","版 本","退 出"};
*/
unchar xdata Result[5];
/*****************************************************************************/
//如果定义的串行模式,就有发送字节函数
/******************************************************************************************
* 函数名称 :Send_byte
* 功能描述 :用串口作为数据传输方式时,用作发送字节函数
* 参数 :
******************************************************************************************/
void Send_byte(unchar bbyte)
{
unchar i;
for(i=0;i<8;i++)
{
SID=bbyte&0x80; //取出最高位
SCLK=1;
SCLK=0;
bbyte<<=1; //左移
}
}
/******************************************************************************************
* 函数名称 :Write_char
* 功能描述 :写指令或数据
* 参数 :start:0为写指令,1为写数据
******************************************************************************************/
void Write_char(bit start, unchar ddata)
{
unchar start_data,Hdata,Ldata;
if(start==0)
start_data=0xf8; //写指令,根据st7920的datasheet,发送一数据前,有5个1的同步位,接着是rw和rs,
//rw和rs的几种组合代表的是写指令还是写数据,或者是读数据
else
start_data=0xfa; //写数据
Hdata=ddata&0xf0; //取高四位
Ldata=(ddata<<4)&0xf0; //取低四位
Send_byte(start_data); //发送起始信号
//Delay5ms(); //延时是必须的
Send_byte(Hdata); //发送高四位
//Delay1ms(); //延时是必须的
Send_byte(Ldata); //发送低四位
//Delay1ms(); //延时是必须的
}
/******************************************************************************************
* 函数名称 :Lcd_reset
* 功能描述 :写指令或数据
* 参数 :start:0为写指令,1为写数据
******************************************************************************************/
void Lcd_reset(void)
{
RES=0; //复位
//delay(1); //延时
RES=1; //复位置高
//delay(10);
}
/******************************************************************************************
* 函数名称 :Lcd_init
* 功能描述 :写指令或数据
* 参数 :start:0为写指令,1为写数据
******************************************************************************************/
void Lcd_init(void)
{
PSB = 0;
CS = 1;
//Lcd_reset();
Write_char(0,0x30); //8 位介面,基本指令集
Write_char(0,0x01); //清屏,地址指针指向00H
//Delay (100);
Write_char(0,0x06); //光标的移动方向
Write_char(0,0x0c); //显示打开,光标关,反白关
}
/******************************************************************************************
* 函数名称 :Disp_all
* 功能描述 :
******************************************************************************************/
void Disp_all(unchar code *chn)
{
unchar i,j;
Write_char(0,0x30);
Write_char(0,0x80);
for(j=0;j<4;j++)
{
for(i=0;i<16;i++)
Write_char(1,chn[j*16+i]);
}
}
/******************************************************************************************
* 函数名称 :Lcd_clr
* 功能描述 :清屏函数
******************************************************************************************/
void Lcd_clr(void)//清屏函数
{
Write_char(0,0x30);
Write_char(0,0x01); //清屏,将DDRAM的地址计数器归零
//Delay (100);
}
/******************************************************************************************
* 函数名称 :Set_xy
* 功能描述 :设置指针地址x,y为指定的地址
* 说明 :x,y为指定的地址,x范围为0~3,y范围为0~7,
* 如下图所示:
0~7 x
o------------------------------------->
0~3 |
评论1