/***********************************************************************
工 程:ST7920驱动的12864液晶的3线串行驱动形式
创立日期:2007年9月16日
引脚界说:RS(CS)=====>PB5
RW(SID)====>PB6
EN(SCLK)===>PB7
PSB为硬件操控,接高电平为8位或4位的并行形式,接低电平为串行形式
本例程运用3线串行形式
************************************************************************/
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define nop() NOP()
#define xtal 8
#define CS PB5
#define SID PB6
#define SCLK PB7
#define Set_CS() DDRB |= (1<
void Delay(uint ms); //延时子程序
void W_1byte(uchar RW, uchar RS, uchar W_data);
void Write_8bits(uint W_bits);
void LCD_Init(void);
void Char_Set_XY(uchar x, uchar y, uchar *p);
void Set_Draw(void);
//设定哪一行,从那一个方位开端到那一个方位完毕运用反白
//x=液晶屏上汉字的方位(1~8);end_x=汉字完毕的地址(1~8);y=1~4行
//clear=1:铲除反白;clear=0:设置反白;
void Set_White(uchar x,uchar y,uchar end_x,uchar clear);
void Draw_Pic(uchar x, uchar y, const uchar *Draw);
/*
/********************************************************************
********************************************************************/
const uchar PIC1[64][16]={
/*– 调入了一幅图画:C:Documents and SettingsAdministrator桌面atmel.bmp –*/
/*– 宽度x高度=128×64 –*/
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,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0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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
};
//==================================================================
const uchar PIC2[64][16]={
/*– 调入了一幅图画:C:Documents and SettingsAdministrator桌面AVR.BMP –*/
/*– 宽度x高度=128×64 –*/
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,0x3C,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xBD,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x27,
0x00,0x00,0x1F,0xFF,0x83,0xFF,0xE0,0x00,0x00,0xFF,0xF8,0x3F,0xFF,0xFF,0x01,0x3C,
0x00,0x00,0x3F,0xFF,0x81,0xFF,0xF0,0x00,0x01,0xFF,0xF0,0x7F,0xFF,0xFF,0xC1,0x3E,
0x00,0x00,0x3F,0xFF,0xC1,0xFF,0xF0,0x00,0x01,0xFF,0xF0,0x7F,0xFF,0xFF,0xE0,0xA7,
0x00,0x00,0x3F,0xFF,0xC1,0xFF,0xF0,0x00,0x03,0xFF,0xE0,0x7F,0xFF,0xFF,0xF0,0xE7,
0x00,0x00,0x7F,0xFF,0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,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,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
};
/********************************************************************/