|
#include "lcd_show.h"
#define uint unsigned int
#define uchar unsigned char
#define CSA P2_1
#define CSB P2_0
#define E P2_3
#define RW P2_5
#define DI P2_6
sbit busy_bit=ACC^7; //lcd state byte bit 7
/*下面是对液晶屏gxm12864d操作的函数, 128x64点阵,汉字显示,CSA,CSB用来进行左右显示区的选择。*/
/* 发命令i到主窗口*/
void lcd_mwc(uchar i)
{
CSA=1;
CSB=0;
RW=1;
DI=0;
do {ACC=LCD;}
while (busy_bit) ;//wait for lcd not busy
RW=0;
LCD=i;
}
/* 写数据i到主窗口*/
void lcd_mwd(uchar i)
{
CSA=1;
CSB=0;
RW=1;
DI=0;
do {ACC=LCD;} while (busy_bit);//wait for lcd not busy
RW=0;
DI=1;
LCD=i;
}
/* 清屏 */
void lcd_clear(void)
{
uchar i;
uchar page;
for (page=0xb8;page<0xc0;page++)
{
lcd_mwc(page); /*设置显示页面*/
lcd_mwc(0x40); /*设置列地址*/
for (i=0;i<64;i++)
{
lcd_mwd(0);
}
}
}
//初始化lcd
void lcd_init(void)
{
lcd_mwc(0xc0);
lcd_mwc(0x3f);
}
//dispm_hz_up() display up half of a hanzi in left area
void dispm_hz_up(uchar code * hz)
{
uchar i;
for (i=0;i<16;i++) lcd_mwd(*(hz+i));
}
//dispm_hz_down() display down half of a hanzi in left area
void dispm_hz_down(uchar code * hz)
{
uchar i;
for (i=16;i<32;i++) lcd_mwd(*(hz+i));
}
void main(void)
{
E=1;
lcd_clear();
lcd_init();
lcd_mwc(0xb8);
lcd_mwc(0x40);
dispm_hz_up(&QING);
dispm_hz_up(&CHA);
dispm_hz_up(&KA);
lcd_mwc(0xb9);
lcd_mwc(0x40);
dispm_hz_down(&QING);
dispm_hz_down(&CHA);
dispm_hz_down(&KA);//display
}
|
|