发个LCD12232液晶驱动程序

2020-02-02 09:14发布

显示效果如下:



程序:
#include <AT89X51.h>
#include <absacc.h>
/*----接口说明--------*/
/*rst--P1^0;  e1 =P1^1; e2 =P1^2 ;rw =P1^3;a0 =P1^4;*/
/*-----送数据口:P0--------*/

#define dat  1        //写数据标志
#define comm  0       //写指令标志
#define f_page  0xb8  //页地址设置(0~3)
#define f_row   0xc0  //显示起始地址
#define f_line  0x00  //列地址设置(0~61)

sbit rst=P1^0;
sbit e1 =P1^1;
sbit e2 =P1^2;
sbit rw =P1^3;
sbit a0 =P1^4;

sbit bf =P0^7;   //lcd忙检测位


void wr_lcd (unsigned char choe1,unsigned char choe2,unsigned char data_comm,unsigned char content);
/*choe1为1,控制左半屏,choe2为1,控制右半屏*/
void chk_busy (unsigned char choe1,unsigned char choe2); /*忙检测*/
void delay (unsigned int us);
void delay1 (unsigned int ms);
void init_lcd (void);           /*液晶初始化*/
void disphz (unsigned char code *chn);
void dispzf (unsigned char code *chn);
void disptu (unsigned char code *img);  
void wrlattice (unsigned char data1,unsigned char data2); /*写点阵*/
void Write_One_Chinese(unsigned char x,unsigned char y,unsigned char code *chinese);
/*一串到指定位置写汉字*/
void Write_Chinese_Characters(unsigned char row,unsigned char line,
                                                                unsigned char code *characters,unsigned char chinese_num);

/******************************************************字模**************************************/
//字模:"三木多功能实验板"
unsigned char code sanmu[]={
        0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x88,0x0C,0x00,0x00,0x00,0x20,
        0x20,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x20,0x20,0x00,0x00,0x00,/*"三",0*/
        0x00,0x00,0x20,0x20,0x20,0xE0,0xFE,0x62,0xA0,0x20,0x20,0x10,0x00,0x00,0x00,0x10,
        0x08,0x04,0x02,0x01,0xFF,0x00,0x01,0x02,0x0C,0x18,0x00,0x00,0x00,0x00,/*"木",1*/
        0x00,0x00,0x20,0x20,0x10,0x98,0xA4,0xC8,0x48,0x28,0x18,0x08,0x00,0x00,0x00,0x80,
        0x82,0x89,0x85,0x44,0x5B,0x21,0x12,0x12,0x0E,0x06,0x02,0x00,0x00,0x00,/*"多",2*/
        0x00,0x00,0x10,0xF0,0x10,0x10,0x28,0x20,0xF8,0x26,0x20,0x20,0xE0,0x00,0x00,0x10,
        0x08,0x0F,0x88,0x44,0x20,0x18,0x07,0x40,0x40,0x7E,0x01,0x00,0x00,0x00,/*"功",3*/
        0x00,0x70,0xA8,0xA4,0xA0,0xE8,0x30,0x00,0x7C,0x90,0x88,0x88,0x60,0x00,0x00,0x00,
        0x7F,0x0A,0x4A,0x7F,0x00,0x00,0x7E,0x48,0x44,0x42,0x70,0x00,0x00,0x00,/*"能",4*/
        0x00,0x20,0x38,0x10,0x30,0xD0,0x0A,0xD4,0x30,0x10,0x10,0x10,0x18,0x00,0x00,0x84,
        0x84,0x85,0x47,0x24,0x14,0x0F,0x14,0x24,0x24,0x44,0x04,0x00,0x00,0x00,/*"实",5*/
        0x00,0xC0,0x38,0x08,0xFC,0x80,0x40,0xB0,0x8E,0x88,0xB0,0x40,0x40,0x00,0x00,0x09,
        0x0A,0x41,0x7E,0x43,0x46,0x58,0x46,0x68,0x58,0x46,0x40,0x00,0x00,0x00,/*"验",6*/
        0x00,0x00,0xE0,0xFE,0x90,0x20,0xF8,0xC8,0x48,0x44,0xC4,0x62,0x00,0x00,0x00,0x06,
        0x01,0x7F,0x41,0xB8,0x47,0x21,0x16,0x0C,0x33,0x60,0x40,0x00,0x00,0x00,/*"板",7*/
};

//字模"小灵通号"
unsigned char code moble[]={
        0x00,0x00,0x00,0x80,0x60,0x00,0x00,0xFE,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x04,
        0x02,0x01,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x03,0x06,0x00,0x00,0x00,/*"小",0*/
        0x00,0x00,0x40,0x54,0x54,0x54,0xD4,0x54,0x54,0x54,0x7E,0x00,0x00,0x00,0x00,0x80,
        0x44,0x43,0x30,0x0C,0x03,0x0C,0x14,0x22,0x21,0x40,0x40,0x00,0x00,0x00,/*"灵",1*/
        0x00,0x00,0x84,0x48,0x00,0xF0,0xA4,0xAC,0xFC,0xAC,0xA4,0xF4,0x00,0x00,0x00,0x20,
        0x1F,0x10,0x20,0x5F,0x42,0x42,0x5F,0x52,0x52,0x5F,0x00,0x00,0x00,0x00,/*"通",2*/
        0x00,0x80,0x80,0xFE,0xA4,0xA4,0xA4,0xA4,0xA4,0xA4,0xBC,0x80,0x80,0x00,0x00,0x00,
        0x00,0x00,0x06,0x05,0x04,0x44,0x44,0x64,0x1E,0x00,0x00,0x00,0x00,0x00,/*"号",3*/
};


unsigned char code moble_num[]={
        0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*"0",0*/
        0x00,0x38,0x08,0x08,0xE8,0x18,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,/*"7",1*/
        0x00,0x38,0x08,0x08,0xE8,0x18,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,/*"7",2*/
        0x00,0x30,0x08,0x88,0x88,0x70,0x00,0x00,0x18,0x20,0x20,0x31,0x1E,0x00,/*"3",3*/
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,/*"-",4*/
        0x00,0x70,0x08,0x08,0x08,0xF0,0x00,0x00,0x30,0x2C,0x22,0x21,0x30,0x00,/*"2",5*/
        0xF0,0x08,0x08,0x08,0x18,0xE0,0x00,0x31,0x22,0x22,0x32,0x19,0x07,0x00,/*"9",6*/
        0xF0,0x08,0x08,0x08,0x18,0xE0,0x00,0x31,0x22,0x22,0x32,0x19,0x07,0x00,/*"9",7*/
        0xE0,0x10,0x88,0x88,0x88,0x18,0x00,0x0F,0x11,0x20,0x20,0x31,0x1F,0x00,/*"6",8*/
        0x70,0x98,0x88,0x08,0x98,0x70,0x00,0x1E,0x21,0x21,0x21,0x31,0x1E,0x00,/*"8",9*/
        0x70,0x98,0x88,0x08,0x98,0x70,0x00,0x1E,0x21,0x21,0x21,0x31,0x1E,0x00,/*"8",10*/
        0x00,0x30,0x08,0x88,0x88,0x70,0x00,0x00,0x18,0x20,0x20,0x31,0x1E,0x00,/*"3",11*/
};


//字模:"固定电话"
unsigned char code tel[]={
        0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x24,0x24,0xA4,0x24,0xFE,0x00,0x00,0x00,0x00,
        0x7F,0x40,0x4F,0x49,0x48,0x49,0x49,0x5F,0x40,0x7F,0x00,0x00,0x00,0x00,/*"固",0*/
        0x00,0x20,0x38,0x90,0x90,0x90,0x8A,0x94,0x90,0x90,0xB0,0x50,0x00,0x00,0x00,0x40,
        0x30,0x0F,0x10,0x20,0x3B,0x44,0x44,0x44,0x46,0x44,0x00,0x00,0x00,0x00,/*"定",1*/
        0x00,0x00,0xF0,0x90,0x90,0x90,0xFE,0x90,0x90,0x90,0xF0,0x10,0x00,0x00,0x00,0x00,
        0x0F,0x08,0x08,0x08,0x7F,0x48,0x48,0x48,0x4F,0x50,0x60,0x00,0x00,0x00,/*"电",2*/
        0x00,0x00,0x84,0xCC,0x00,0x40,0x40,0x48,0xFC,0x44,0x44,0x42,0x20,0x00,0x00,0x00,
        0x00,0x7F,0x10,0x10,0x7E,0x44,0x43,0x44,0x44,0x7E,0x00,0x00,0x00,0x00,/*"话",3*/
};

//电话号码:"0773-2996883"
unsigned char code tel_num[]={
        0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*"0",0*/
        0x00,0x38,0x08,0x08,0xE8,0x18,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,/*"7",1*/
        0x00,0x38,0x08,0x08,0xE8,0x18,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,/*"7",2*/
        0x00,0x30,0x08,0x88,0x88,0x70,0x00,0x00,0x18,0x20,0x20,0x31,0x1E,0x00,/*"3",3*/
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,/*"-",4*/
        0x00,0xF8,0x08,0x88,0x88,0x08,0x00,0x00,0x19,0x21,0x20,0x31,0x1F,0x00,/*"5",5*/
        0xE0,0x10,0x88,0x88,0x88,0x18,0x00,0x0F,0x11,0x20,0x20,0x31,0x1F,0x00,/*"6",6*/
        0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*"0",7*/
        0xF0,0x08,0x08,0x08,0x18,0xE0,0x00,0x31,0x22,0x22,0x32,0x19,0x07,0x00,/*"9",8*/
        0x00,0x80,0x40,0x20,0xF8,0x00,0x00,0x06,0x05,0x04,0x24,0x3F,0x24,0x04,/*"4",9*/
        0x00,0xF8,0x08,0x88,0x88,0x08,0x00,0x00,0x19,0x21,0x20,0x31,0x1F,0x00,/*"5",10*/
        0x70,0x98,0x88,0x08,0x98,0x70,0x00,0x1E,0x21,0x21,0x21,0x31,0x1E,0x00,/*"8",11*/
};

//字模"0123456789"
unsigned char code num[]={
        0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*"0"*/
        0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,/*"1"*/
        0x00,0x70,0x08,0x08,0x08,0xF0,0x00,0x00,0x30,0x2C,0x22,0x21,0x30,0x00,/*"2"*/
        0x00,0x30,0x08,0x88,0x88,0x70,0x00,0x00,0x18,0x20,0x20,0x31,0x1E,0x00,/*"3"*/
        0x00,0x80,0x40,0x20,0xF8,0x00,0x00,0x06,0x05,0x04,0x24,0x3F,0x24,0x04,/*"4"*/
        0x00,0xF8,0x08,0x88,0x88,0x08,0x00,0x00,0x19,0x21,0x20,0x31,0x1F,0x00,/*"5"*/
        0xE0,0x10,0x88,0x88,0x88,0x18,0x00,0x0F,0x11,0x20,0x20,0x31,0x1F,0x00,/*"6"*/
        0x00,0x38,0x08,0x08,0xE8,0x18,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,/*"7"*/
        0x70,0x98,0x88,0x08,0x98,0x70,0x00,0x1E,0x21,0x21,0x21,0x31,0x1E,0x00,/*"8"*/
        0xF0,0x08,0x08,0x08,0x18,0xE0,0x00,0x31,0x22,0x22,0x32,0x19,0x07,0x00,/*"9"*/       
};


//字模"--QQ:289994918--"
unsigned char code QQ[]={       

        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,/*"-",0*/
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,/*"-",1*/
        0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x78,0x4F,0x00,/*"Q",2*/
        0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x78,0x4F,0x00,/*"Q",3*/
        0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,/*":",4*/
        0x00,0x70,0x08,0x08,0x08,0xF0,0x00,0x00,0x30,0x2C,0x22,0x21,0x30,0x00,/*"2",5*/
        0x70,0x98,0x88,0x08,0x98,0x70,0x00,0x1E,0x21,0x21,0x21,0x31,0x1E,0x00,/*"8",6*/
        0xF0,0x08,0x08,0x08,0x18,0xE0,0x00,0x31,0x22,0x22,0x32,0x19,0x07,0x00,/*"9",7*/
        0xF0,0x08,0x08,0x08,0x18,0xE0,0x00,0x31,0x22,0x22,0x32,0x19,0x07,0x00,/*"9",8*/
        0xF0,0x08,0x08,0x08,0x18,0xE0,0x00,0x31,0x22,0x22,0x32,0x19,0x07,0x00,/*"9",9*/
        0x00,0x80,0x40,0x20,0xF8,0x00,0x00,0x06,0x05,0x04,0x24,0x3F,0x24,0x04,/*"4",10*/
        0xF0,0x08,0x08,0x08,0x18,0xE0,0x00,0x31,0x22,0x22,0x32,0x19,0x07,0x00,/*"9",11*/
        0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,/*"1",12*/
        0x70,0x98,0x88,0x08,0x98,0x70,0x00,0x1E,0x21,0x21,0x21,0x31,0x1E,0x00,/*"8",13*/
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,/*"-",14*/
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,/*"-",15*/
};



unsigned char code tup[]={
/*--  一幅图像: --*/
/*--  宽度x高度=122x32  --*/
0x00,0x00,0x00,0x70,0xF8,0xF8,0xFC,0xFC,0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,0xF0,0xE0,
0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x48,0xD4,0xB4,0x62,0xC2,0x82,0x03,0x02,0x02,
0x02,0x84,0xC4,0xE0,0xA0,0xE0,0x60,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xB0,0xF8,0xF0,0xF0,0xF8,0xFC,0x60,0x60,0x30,
0x18,0x00,0x00,0x00,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF0,0xD8,0x58,0x58,0x58,0x58,
0x58,0xD8,0xD8,0x98,0xB0,0x30,0x70,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
0x07,0x07,0x02,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xFC,0xFC,0xFC,
0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xF8,0xF0,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x01,0x00,0x04,
0x0D,0x1B,0x36,0x6D,0xDB,0xF6,0xED,0xFB,0xFE,0xFE,0xFF,0x7F,0x1F,0x07,0x01,0x00,
0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xFC,0xFE,0xFE,
0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xE0,0xC0,0xC0,0xF8,0xFE,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x3E,0xF8,0x01,0x37,
0x0C,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x60,0xFF,0xC7,0x03,0x03,0x03,0x03,0xE1,
0xFF,0x3F,0x0F,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x0F,0x3F,0x7F,0xFF,0xEF,
0xBF,0x7F,0xFF,0xC7,0x07,0x1F,0xFE,0xF8,0xB0,0x60,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x08,0x10,0x20,0x40,0x40,0x80,0x83,
0xFF,0xFF,0xFF,0xFF,0x83,0x40,0x40,0x20,0x10,0x08,0x04,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x07,0x0F,0x1F,0x3F,0x3F,0x7F,0xFF,
0xFF,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xDF,0x3F,0x3F,0x0F,0x61,0x3F,0x1F,0x2F,0x3F,
0x1F,0x0F,0x00,0x0F,0x07,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x1E,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x60,0x70,0x3C,0x1F,0x07,0x03,0x01,0x01,0x00,0x00,
0x01,0x07,0x07,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x44,0xEC,0x00,
0x7C,0x44,0x7C,0x00,0x7C,0x40,0x40,0x00,0x7C,0x44,0x38,0x00,0x7C,0x14,0x1C,0x00,
0x7C,0x40,0x40,0x00,0x78,0x24,0x78,0x00,0x7C,0x18,0x18,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x10,0x04,0x07,0x00,0x01,0x00,0x00,0x00,0x01,
0x05,0x03,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};


/*------------------------------------------*/
void wr_lcd (unsigned char choe1,unsigned char choe2,unsigned char data_comm,unsigned char content)
{
  chk_busy (choe1,choe2);
  if(data_comm)
   {
    a0=1;   //data
    rw=0;   //write
   }
  else
   {
    a0=0;   //command
    rw=0;   //write
   }
  if(choe1==1)
  {
    P0=content;   //output data or comm
    e1=1;
    ;
    e1=0;
  }
  if(choe2==1)
  {
    P0=content;   //output data or comm
    e2=1;
    ;
    e2=0;
  }
}

/**********忙检测***************************************/
void chk_busy (unsigned char choe1,unsigned char choe2)
{
  if(choe1==1)
  {
    a0=0;
    rw=1;
    e1=1;
    while(bf==1)
      delay(2);
    e1=0;
  }
  if(choe2==1)
  {
    a0=0;
    rw=1;
    e2=1;
    while(bf==1)
      delay(2);
    e2=0;
  }
}


void delay (unsigned int us)   //delay time
{
  while(us--);
}
void delay1 (unsigned int ms)
{
  unsigned int i,j;
  for(i=0;i<ms;i++)
  for(j=0;j<1000;j++)
  ;
}


/************写一串汉字****************************/
/*显示"三木多功能实验板"*/
/*一行八个汉字一起写*/
/*row为0~3的数,其实是把液晶上下两行分成4行即4*8=32
line为0~7的数,液晶一行可以写入像素为长×宽=15*16的八个汉字/
*characters为要写入汉字串的首地址*/
void Write_Chinese_Characters(unsigned char row,unsigned char line,
                                                                unsigned char code *characters,unsigned char chinese_num)
{

unsigned char i;
  for(i=0;i<chinese_num ;i++)
   {
    Write_One_Chinese(row, line+i, characters+30*i);
   }

}


/************写一个汉字到任意位置上****************************/
/*---------汉字像素为长×宽=15*16--------*/
//x=0表示写入第一行,x=2表示写入第二行,*characters表示要写的字模数据
//y=(0~7)表示开始写入的列位置,每一行可以写入八个汉字,就是把液晶一行分成8个汉字位置
void Write_One_Chinese(unsigned char x,unsigned char y,unsigned char code *chinese)
{                                 

unsigned char i,j;
   
   for(j=0;j<2;j++)
    {
      /////////////////////////////
           wr_lcd (1,0,comm,0xc0);//  列地址指针归零
           ////////////////////////////
     if((y/4)==0)   
          {
           wr_lcd (1,0,comm,f_page+j+x);
       wr_lcd (1,0,comm,f_row+x*8);
           wr_lcd (1,0,comm,y*15+j);
       for(i=0;i<15;i++)
            {
        wr_lcd (1,0,dat,chinese[j*15+i]);
                }
       
           }
         else
          {
           wr_lcd (0,1,comm,f_page+j+x);
       wr_lcd (0,1,comm,f_row+x*8);
           wr_lcd (0,1,comm,(y-4)*15+j);
       for(i=0;i<15;i++)
          {
        wr_lcd (0,1,dat,chinese[j*15+i]);}
          }
          //////////////////////////////
        //   wr_lcd (0,1,comm,0xc0);//列地址指针归零
          //////////////////////////////
    }
}

/**********************显示一个字符********************/

void Write_One_Char(unsigned char x,unsigned char y,unsigned char code *one_char)
{
   unsigned char i,j;
   for(j=0;j<2;j++)
    {

     if((y/8)==0)   
          {
           wr_lcd (1,0,comm,f_page+j+x);
       wr_lcd (1,0,comm,f_row+x*8);
           wr_lcd (1,0,comm,y*7+5);
       for(i=0;i<7;i++)
            {
        wr_lcd (1,0,dat,one_char[j*7+i]);
                }
           /////////////////////////////
           wr_lcd (1,0,comm,0xc0);//  列地址指针归零
           ////////////////////////////
           }
         else
          {
           wr_lcd (0,1,comm,f_page+j+x);
       wr_lcd (0,1,comm,f_row+x*8);
           wr_lcd (0,1,comm,(y-8)*7);
       for(i=0;i<7;i++)
          {
        wr_lcd (0,1,dat,one_char[j*7+i]);}
          }
          //////////////////////////////
           wr_lcd (0,1,comm,0xc0);//列地址指针归零
          //////////////////////////////
    }
}


/**************写一串字符**********************/
/****************************************************************************/
/*x=(0~4)--字符行首址;y=(0~15)--字符列首址;char_num=(1~16)--要写入字符的个数*/
/****************************************************************************/
void Write_Chars(unsigned char x,unsigned char y,unsigned char code *chars,unsigned char char_num)
{
unsigned char i;
for(i=0;i<char_num;i++)
   {
    Write_One_Char( x, y+i, chars+14*i);
   }
}


/*----------------画图形-----------------*/
void disptu (unsigned char code *img)
{
  unsigned char i,j;
  for(j=0;j<4;j++)
  {
    wr_lcd (1,1,comm,f_page+j);
    wr_lcd (1,1,comm,f_row);
    wr_lcd (1,1,comm,f_line);
    for(i=0;i<122;i++)
    {
      if(i<61)
      {wr_lcd (1,0,comm,f_line+i);
       wr_lcd (1,0,dat,img[j*122+i]);}
      else
      {wr_lcd (0,1,comm,f_line+i-61);
       wr_lcd (0,1,dat,img[j*122+i]);}
    }
  }
}
/*--------------写点阵------------------*/
void wrlattice (unsigned char data1,unsigned char data2)
{
  unsigned char i,j;
  for(j=0;j<4;j++)
  {
    wr_lcd (1,1,comm,f_page+j);
    wr_lcd (1,1,comm,f_row);
    wr_lcd (1,1,comm,f_line);
    for(i=0;i<61;i=i+2)
    {
      wr_lcd (1,1,dat,data1);
      wr_lcd (1,1,dat,data2);
    }
  }
}

/*------------------初始化-----------------*/
void init_lcd (void)
{
  rst=1;
  wr_lcd (1,1,comm,0xe2);  //软件复位
  wr_lcd (1,1,comm,0xa4);  //动态驱动
// wr_lcd (1,1,comm,0xae);//显示关闭
  wr_lcd (1,1,comm,0xa9); //刷新时钟设置1/32
  wr_lcd (1,1,comm,0xa0); //clockwise
  wr_lcd (1,1,comm,0xee);  //写模式
  wr_lcd (1,1,comm,0xaf);//显示打开

}



/*------------------主程序--------------------*/
void main ()
{
    init_lcd ();
    while(1)
    {
        Write_Chinese_Characters(0,0,sanmu,8); //第一行显示"三木多功能实验板"
    Write_Chars(2,0,QQ,16);  //第二行显示"--QQ:289994918--"
    delay1 (500);
        wrlattice (0x00,0x00);   //清屏
    Write_Chinese_Characters(0,2,moble,4); //第一行中间位置显示"小灵通号"
    Write_Chars(2,2,moble_num,12);  //第二行显示"0773-2996883"
        delay1 (500);
        wrlattice (0x00,0x00);   //清屏
        Write_Chinese_Characters(0,2,tel,4); //第一行中间位置显示"固定电话"
    Write_Chars(2,2,tel_num,12);  //第二行显示"0773-5609458"
        delay1 (500);
        wrlattice (0x00,0x00);   //清屏
        disptu (tup);       //显示一幅图片                    
        delay1 (500);
        wrlattice (0x00,0x00);   //清屏
     }
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
41条回答
ermeg
1楼-- · 2020-02-02 13:14
 精彩回答 2  元偷偷看……
gumplin
2楼-- · 2020-02-02 13:42
怎么会事,我用这程序我的板子中TS12232D显示不了,不知道什么问题啊.我是这样接的:数据口-----P0;
E1 ----P2_2
E2---- P2_3
res----- P3_4
RW------ P2_4
A0 ----P2_5


望高手指点下!!!!!
pulan
3楼-- · 2020-02-02 17:51
p0口加上拉电阻看看
gumplin
4楼-- · 2020-02-02 22:30
加了4.7K的上拉电阻,没有什么效果
abcdezh
5楼-- · 2020-02-03 01:35
有一快12232,试试
谢谢
gumplin
6楼-- · 2020-02-03 04:43
 精彩回答 2  元偷偷看……

一周热门 更多>