//——————–st_12864.h————————
#ifndef _LCD12864_ST7920
#define _LCD12864_ST7920
#ifndef uint8
#define uint8 unsigned char
#endif
#ifndef uint16
#define uint16 unsigned int
#endif
extern void st_writeCmd(uint8 CMD);
extern void st_writeDat(uint8 DAT);
//extern void Delay(uint16 ms);
extern uint8 st_checkBusy(void);
extern void st_drawFull(uint8 x, uint8 y, const uint8 *Draw);
//extern void Picture_Set_XY(uint8 x, uint8 y);
extern void st_sendstr(uint8 x, uint8 y, uint8 *p);
extern void st_init(void);
extern void st_setDraw(void);
extern void st_flash(uint16 delay_t,uint8 times);
extern void st_moveChar(uint8 step,uint8 dirction,uint16 time);
extern void st_drawFree(uint8 x1,uint8 y1,uint8 x2,uint8 y2,const uint8 *dat);
extern void st_readRam(uint8 x,uint8 y);
extern void st_drawPixel(uint8 x,uint8 y,uint8 color);
extern void st_clr(void);
extern void st_drawRectangle(uint8, uint8, uint8, uint8, uint8, uint8);
extern void st_drawVerticalLine(uint8 x1, uint8 y1, uint8 y2, uint8 color);
extern void st_drawLevelLine(uint8 x1, uint8 y1, uint8 x2, uint8 color);
extern void st_setChar(void);
#endif
//———————————————
//——————–st_12864.c————————-
/
//12864接口
#define ST_DATA P1
#define DATA_PORT P1
//st7920指令
#define ST_CLEAR 0x01
#define ST_HOME 0x02
#define ST_ENTRY_MODE 0x06
#define ST_DISPLAY_OFF 0x08
#define ST_DISPLAY_ON 0x0c
#define ST_FUN_8 0x30
#define ST_FUN_8_BAS 0x30
#define ST_FUN_8_EXT 0x34
#define ST_FUN_8_G 0x36
#define ST_BUSY P1&0x80
sbit st_rs=P0^1;
sbit st_rw=P0^2;
sbit st_e=P0^3;
void st_writeCmd(uint8 CMD);
void st_writeDat(uint8 DAT);
void Delay(uint16 ms);
uint8 st_checkBusy(void);
void st_drawFull(uint8 x,uint8 y,const uint8*Draw);
//void Picture_Set_XY(uint8 x,uint8 y);
void st_sendstr(uint8 x,uint8 y,uint8*p);
void st_init(void);
void st_setDraw(void);
void st_flash(uint16 delay_t,uint8 times);
void st_moveChar(uint8 step,uint8 dirction,uint16 time);
void st_drawFree(uint8 x1,uint8 y1,uint8 x2,uint8 y2, const uint8 *dat);
void st_readRam(uint8 x,uint8 y);
void st_drawPixel(uint8 x,uint8 y,uint8 color);
void st_clr(void);
void st_drawRectangle(uint8,uint8,uint8,uint8,uint8,uint8);
void st_drawVerticalLine(uint8 x1,uint8 y1,uint8 y2,uint8 color);
void st_drawLevelLine(uint8 x1,uint8 y1,uint8 x2,uint8 color);
void st_setChar(void);
uint8 readdispdata[2];
void st_init(void)
{
delay_ms(50);
//delay_us(120);
st_writeCmd(ST_FUN_8_BAS);
//st_writeCmd(ST_FUN_8_G);
//delay_us(50);
//delay_us(120);
//清屏
//delay_ms(12);
//delay_us(120);
delay_us(1);
EA=1;
}
void st_flash(uint16 delay_t,uint8 times)
{
}
void st_moveChar(uint8 step,uint8 dirction,uint16 time)
{
}
//写操控指令函数
void st_writeCmd(uint8 CMD)
{
while(st_checkBusy());
delay_us(2);
}
//写数据函数
void st_writeDat(uint8 DAT)
{
delay_us(2);
delay_us(2);
}
uint8 st_checkBusy(void)
{
//delay_us(1);
DATA_PORT=0xff;
//st_e=1;
//delay_us(1);
}
void st_sendstr(uint8 x,uint8 y,uint8*p)
{
if(y==0)
EA=1;
}
void st_setDraw(void)
{
st_writeCmd(ST_CLEAR);
EA=1;
}
void st_setChar(void)
{
st_writeCmd(ST_FUN_8_BAS);
EA=1;
}
void st_drawFull(uint8 x,uint8 y,const uint8*Draw)
{
temp_x=x ;
}
//—————————————————-add by july
void st_drawFree(uint8 x1,uint8 y1,uint8 x2,uint8 y2,const uint8 *dat)
{
y1y2=y2-y1 ;
EA=1;
}
//————–读显现数据———–add by july
void st_readRam(uint8 x,uint8 y)
{
if(y>31)
EA=1;
}
//—————-写一个像素————————add by july
void st_drawPixel(uint8 x,uint8 y,uint8 color)
{
realx=x/16 ;
EA=1;
}
//————–lcd clear—————-add by july
void st_clr(void)
{
}
//———draw line——————–add by july
void st_drawLevelLine(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char color)
{
}
void st_drawVerticalLine(unsigned char x1,unsigned char y1,unsigned char y2,unsigned char color)
{
}
//—————–draw rectangle——————add by july
void st_drawRectangle(unsigned char lf,unsigned char tp,unsigned char rt,unsigned char bt,unsigned char w,unsigned char cl)
{
}
//———————————————
//——————–pic.h————————-
code const uint8 PIC1[][16]=
{
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,0X60,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X98,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X02,0X04,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X02,0XF4,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X04,0XB2,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X0C,0X00,0X00,0X00,0X00,0X00,0X18,0X04,0XE2,0X00,
0X00,0X00,0X00,0X00,0X00,0X01,0XE0,0X00,0X1F,0XFF,0X80,0X00,0X06,0X04,0XA2,0X00,
0X00,0X00,0X00,0X00,0X00,0X0E,0X00,0X03,0XFF,0XFF,0XF8,0X00,0X07,0X82,0X94,0X00,
0X00,0X00,0X00,0X00,0X00,0XF8,0X00,0X0F,0XFF,0XFF,0XFE,0X00,0X03,0XC2,0X04,0X00,
0X00,0X00,0X00,0X00,0X07,0XC0,0X00,0X7F,0XFF,0XFF,0XFF,0X00,0X03,0XE1,0X98,0X00,
0X00,0X00,0X00,0X00,0X3F,0X00,0X01,0XFF,0XFF,0XFF,0XFF,0X00,0X07,0XF0,0X60,0X00,
0X00,0X00,0X00,0X00,0XFC,0X00,0X03,0XFF,0XFF,0XFF,0XFE,0X00,0X0F,0XF8,0X00,0X00,
0X00,0X00,0X00,0X03,0XF0,0X00,0X0F,0XFF,0XFF,0XFF,0XF8,0X00,0X3F,0XF8,0X00,0X00,
0X00,0X00,0X00,0X0F,0XE0,0X00,0X1F,0XFF,0XFF,0XFF,0XFC,0X00,0XFF,0XF8,0X00,0X00,
0X00,0X00,0X00,0X3F,0XC0,0X00,0X1F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF8,0X00,0X00,
0X00,0X00,0X00,0XFF,0X80,0X00,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF8,0X00,0X00,
0X00,0X00,0X01,0XFF,0X00,0X00,0X3F,0XF8,0X00,0X00,0X03,0XFF,0XFF,0XF0,0X00,0X00,
0X00,0X00,0X03,0XFF,0X00,0X00,0X1E,0X00,0X00,0X00,0X00,0X3F,0XFF,0XF0,0X00,0X00,
0X00,0X00,0X0F,0XFF,0X00,0X00,0X0E,0X00,0X00,0X00,0X00,0X07,0XFF,0XE0,0X00,0X00,
0X00,0X00,0X1F,0XFF,0X00,0X00,0X03,0XF0,0XE0,0X00,0X00,0X03,0XFF,0XE0,0X00,0X00,
0X00,0X00,0X3F,0XFF,0X80,0X00,0X00,0X3F,0XFF,0X00,0X00,0X01,0XFF,0X80,0X00,0X00,
0X00,0X00,0X7F,0XFF,0XC0,0X00,0X00,0X00,0X01,0XC0,0X00,0X01,0XFF,0X00,0X00,0X00,
0X00,0X00,0X7F,0XFF,0XF0,0X00,0X00,0X00,0X00,0XF0,0X00,0X00,0XFE,0X00,0X00,0X00,
0X00,0X00,0XFF,0XFF,0XFE,0X00,0X00,0X00,0X0F,0XF8,0X00,0X01,0XFC,0X00,0X00,0X00,
0X00,0X00,0XFF,0XFF,0XFF,0XFB,0X00,0X0F,0XFF,0XF8,0X00,0X01,0XF0,0X00,0X00,0X00,
0X00,0X00,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF8,0X00,0X03,0XC0,0X00,0X00,0X00,
0X00,0X00,0XFF,0XFF,0X03,0XFF,0XFF,0XFF,0XFF,0XF0,0X00,0X07,0X80,0X00,0X00,0X00,
0X00,0X00,0XFF,0XFC,0X00,0X7F,0XFF,0XFF,0XFF,0XE0,0X00,0X1C,0X00,0X00,0X00,0X00,
0X00,0X00,0X7F,0XF8,0X00,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X30,0X00,0X00,0X00,0X00,
0X00,0X00,0X7F,0XE0,0X00,0XFF,0XFF,0XFF,0XFF,0X00,0X00,0XC0,0X00,0X00,0X00,0X00,
0X00,0X00,0X3F,0XC0,0X00,0XFF,0XFF,0XFF,0XFC,0X00,0X03,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X1F,0XC0,0X00,0X7F,0XFF,0XFF,0XF0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X0F,0XC0,0X00,0X1F,0XFF,0XFF,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X07,0XC0,0X00,0X00,0XFF,0XF0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0XE0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X30,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,0X1E,0X06,0X04,0X02,0X03,0XC1,0XC0,0X48,0X00,0X20,0X0C,0X07,0X83,0XC0,0X00,
0X00,0X1A,0X06,0X04,0X02,0X06,0XC3,0X40,0X48,0X00,0X20,0X0C,0X04,0X86,0XC0,0X00,
0X00,0X18,0X02,0X04,0X02,0X06,0X03,0X40,0X68,0X00,0X20,0X0C,0X04,0X86,0X00,0X00,
0X00,0X18,0X02,0X04,0X02,0X02,0X01,0X40,0X68,0X00,0X20,0X0C,0X04,0X82,0X00,0X00,
0X00,0X08,0X02,0X04,0X02,0X06,0X03,0X40,0X68,0X00,0X20,0X0C,0X04,0X83,0X00,0X00,
0X00,0X04,0X02,0X04,0X02,0X02,0X03,0X40,0X78,0X00,0X20,0X14,0X07,0X01,0X80,0X00,
0X00,0X02,0X02,0X04,0X02,0X02,0X01,0X40,0X58,0X00,0X20,0X14,0X04,0X80,0X80,0X00,
0X00,0X02,0X02,0X04,0X02,0X06,0X01,0X40,0X58,0X00,0X20,0X16,0X04,0X80,0XC0,0X00,
0X00,0X02,0X02,0X04,0X02,0X02,0X03,0X40,0X58,0X00,0X20,0X1E,0X04,0X80,0XC0,0X00,
0X00,0X1A,0X02,0X04,0X02,0X06,0XC3,0X40,0X58,0X00,0X20,0X12,0X04,0X86,0XC0,0X00,
0X00,0X1A,0X02,0X06,0X02,0X02,0XC1,0X40,0X58,0X00,0X30,0X12,0X05,0X82,0XC0,0X00,
0X00,0X0E,0X02,0X07,0X02,0X03,0X81,0XC0,0X48,0X00,0X38,0X32,0X07,0X83,0X80,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,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,
};
//———————————————