⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 picture-show.c

📁 用于128*64图形液晶显示
💻 C
字号:
//TX-1B实验板12864液晶测试程序
//测试驱动液晶的程序. 在指定的位置显示汉字
#include <reg51.h>
#define uchar unsigned char
#define uint  unsigned int
unsigned char code lcd_lattice16_16[];
unsigned char code lcd_letter_8_16[];
void display_8_16(uchar,uchar,uchar);
void displaycoslight(uchar);
void display_coslight_2();
unsigned char code lcd_lattice_coslight[15][320];
sbit CS1=P3^0;
sbit CS2=P3^1;
sbit RS=P3^5;
sbit E=P3^4;
//sbit LCD_LIGHT=P2^7;
bit dot_not;
delay(long uu)
{long mm;
for(mm=0;mm<uu;mm++)
;
}
void wrst_le(uchar date)    //写左部分状态字
{
  CS1=1;
  CS2=0;
  RS=0;
  E=1;
  P0=date;
  E=0;
}
void wrst_ri(uchar date)    //写右部分状态字
{
  CS1=0;
  CS2=1;
  RS=0;
  E=1;
  P0=date;
  E=0;
}
void wrda_le(uchar date)    //写左部分数据
{
  CS1=1;
  CS2=0;
  RS=1;
  E=1;
  P0=date;
  E=0;
}
void wrda_ri(uchar date)    //写右部分数据
{
  CS1=0;
  CS2=1;
  RS=1;
  E=1;
  P0=date;
  E=0;
}
void lcdinit()
{
 wrst_le(0x3f);
 wrst_ri(0x3f);   /*display on*/
}
void displaycls(uchar background)     //0清白屏,1清成黑屏
{
 uchar i;
 uchar j;
 lcdinit();
 wrst_le(0xc0);
 wrst_ri(0xc0);//设置显示起始行
 for(i=0;i<8;i++)
  {
     wrst_le(0xb8|i);//设置页地址
     wrst_le(0x40|0);//设置列地址
     for(j=0;j<64;j++)
     {
        if (background==0)
        {
             wrda_le(0xff);//清成白屏
        }
        else
        {
              wrda_le(0);//清成黑屏
        }
     }
  }
  for(i=0;i<8;i++)
  {
      wrst_ri(0xb8|i);//设置页地址
      wrst_ri(0x40|0);//设置列地址
      for(j=0;j<64;j++)
      {
          if (background==0)
          {
               wrda_ri(0xff);//清成白屏
           }
           else
           {
                wrda_ri(0);//清成黑屏
           }
      }
   }
}
void displayword(uchar lcdrow,uchar lcdline,uchar wordnumber)
{

 uchar i;
 uint j;
 if(lcdline<64)
 {
        lcdinit();
        wrst_le(0xc0);
        wrst_le(0xb8|lcdrow);             //设置页地址
        wrst_le(0x40|lcdline);            //设置列地址
        j=(wordnumber-1)*32;
        for(i=0;i<32;i++)
        {
                 if(dot_not==1){ wrda_le(~lcd_lattice16_16[i+j]); }
                else{ wrda_le(lcd_lattice16_16[i+j]);}
                if(i==15)
                {
                        lcdinit();
                        wrst_le(0xb8|(lcdrow+1));            //设置页地址
                        wrst_le(0x40|lcdline);               //设置列地址
                 }
         }
		
 }
 else
 {
        lcdinit();
        wrst_ri(0xc0);                                    //设置显示起始行
        wrst_ri(0xb8|lcdrow);                             //设置页地址
        wrst_ri(0x40|(lcdline-64));                       //设置列地址
        j=(wordnumber-1)*32;
        for(i=0;i<32;i++)
        {
                if(dot_not==1){wrda_ri(~lcd_lattice16_16[i+j]);}
                else       {wrda_ri(lcd_lattice16_16[i+j]);		 }
                if(i==15)
                 {
                     //   lcdinit();
                        wrst_ri(0xb8|(lcdrow+1));         //设置页地址
                        wrst_ri(0x40|(lcdline-64));       //设置列地址
                  }
        }
 }
}

void displaycoslight(uchar high,uchar ch_wide,uchar string[],uchar line)
{
 uchar i;
 uchar j;
 uchar k;
 lcdinit();
 wrst_le(0xc0);
 wrst_ri(0xc0);/*设置显示起始行*/
wrst_le(0xb8|0);
wrst_ri(0xb8|0);
if(high<=64)
{
if(high%8!=0)
k=(high/8)+1;
else
k=high/8;}
else if(high>64)
k=8;
 for(i=0;i<k;i++)
  {	 wrst_ri(0xb8|i);/*设置页地址*/
   	 wrst_le(0xb8|i);/*设置页地址*/
	 wrst_le(0x40|line);/*设置列地址*/
	 wrst_ri(0x40|line);/*设置列地址*/


for(j=0;j<ch_wide;j++)
     {if((j+line)<64)
      {
	  wrda_le(string[ch_wide*i+j]);}
	  else if((j+line)>64)
	  {
	  wrda_ri(string[ch_wide*i+j]);}}
   }
   	
}

void display_8_16(uchar lcdrow,uchar lcdline,uchar datanumber)
{
 uchar i;
 uint j;
if(lcdline<64)
 {
  wrst_le(0xc0);
  wrst_le(0xb8|lcdrow);//设置页地址
  wrst_le(0x40|lcdline);//设置列地址
  j=datanumber-1;
  j=(32*j);
  for(i=0;i<32;i++)
  {
    if(dot_not) {wrda_le(~lcd_letter_8_16[i+j]);}
    else {wrda_le(lcd_letter_8_16[i+j]);}
   if(i==15)
    {wrst_le(0xb8|(lcdrow+1));//设置页地址
     wrst_le(0x40|lcdline);//设置列地址
     }
  }


  wrst_le(0xc0);
  wrst_le(0xb8|lcdrow+2);//设置页地址
  wrst_le(0x40|lcdline);//设置列地址
  j=datanumber;
  j=(32*j);
  for(i=0;i<32;i++)
  {
    if(dot_not) {wrda_le(~lcd_letter_8_16[i+j]);}
    else {wrda_le(lcd_letter_8_16[i+j]);}
   if(i==15)
    {wrst_le(0xb8|(lcdrow+3));//设置页地址
     wrst_le(0x40|lcdline);//设置列地址
     }
  }	 }

 else if(lcdline<122)
 {
  wrst_ri(0xc0);//设置显示起始行
  wrst_ri(0xb8|lcdrow);//设置页地址
  if(lcdline<121)
   {
     wrda_ri(0x40|(lcdline-64));//设置列地址
   }
  j=datanumber*16;
  for(i=0;i<16;i++)
  {
     if(dot_not)
    {
    wrda_ri(~lcd_letter_8_16[i+j]);
    }
    else {wrda_ri(lcd_letter_8_16[i+j]);}
    if(i==7)
    {wrst_ri(0xb8|(lcdrow+1));//设置页地址
     wrst_ri(0x40|(lcdline-64));//设置列地址
     }
  }
 }
}


/************************************************************************/



///////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
unsigned char code lcd_letter_8_16[]=
{
		  /*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,0x80,0x80,0x80,0xC0,0xE0,0xC0,0x80,0x00,0x00,
0x00,0x00,0xF0,0xF0,0xE0,0xE0,0xC0,0xC0,0x00,0x00,0x00,0x00,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,0x10,0x10,0x10,0x18,0x18,0x18,0x08,0x0C,0x0C,0x0C,
0x0C,0x0E,0xFE,0xFE,0xFE,0xFF,0x07,0x07,0x07,0x07,0x03,0x03,0x03,0x03,0x02,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x0F,0x1E,
0xFE,0xFC,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0xFF,0xFF,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0xFF,0xFF,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x81,0x83,0x83,0xC1,0xE0,0xF0,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0xE0,0xF8,0xF0,0xE0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,
0xE0,0xE0,0xFF,0xFF,0xFF,0xFF,0x30,0x18,0x18,0x18,0x0C,0x0C,0x04,0x06,0x02,0x02,
0x01,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFC,0x00,0x00,0x80,0xC0,0xE0,0xF8,0xFE,0x7F,
0x1F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x06,0x0F,0x1F,0x1F,0x0F,0x0F,0x07,0x07,0x03,0x03,0x01,0x01,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0xC0,0xE7,0xFF,0xFF,0xFF,0xFE,0xFF,0xCF,0x07,0x01,0x00,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,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
0x80,0x80,0xFF,0xFF,0xFF,0xFF,0x00,0x80,0x80,0xC0,0x60,0x60,0x30,0x38,0x18,0x1C,
0x0E,0x0E,0x07,0x07,0x03,0x01,0x00,0x00,0x01,0x03,0x07,0x0F,0x3F,0x3E,0x7C,0xF8,
0xF0,0xF0,0xE0,0xC0,0xC0,0x80,0x80,0x00,0x00,0xF8,0xFF,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x07,
0x1F,0x1F,0x0F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x03,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F,0x1F,0x1F,0x18,0x10,0x00,0x00,/*我*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,
0xF0,0xF0,0xE0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,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,0x80,0xF0,0xFE,0xFF,
0x3F,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x01,0x03,0x0F,
0x7F,0xFE,0xFC,0xF8,0x00,0x00,0x00,0x00,0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x18,0xFC,0xFE,0xFC,0x38,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xFC,0x7F,0xFF,0xFB,0xF0,
0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x02,0x00,0x00,0x00,
0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0x3C,0x1F,0x07,0x03,0x00,0x00,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xC0,0xC0,0x80,0x80,
0x80,0x80,0x80,0x80,0xC0,0xF8,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x0F,0x0F,0x07,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0x07,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x03,0x07,0x1F,0x0F,0x0F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00/*们*/



};


unsigned char code lcd_lattice16_16[]={


0x00,0x00,0x88,0x88,0x88,0x88,0xFC,0xFC,0x84,0x84,0x84,0xFE,0xFE,0x80,0x84,0x9C,
0x98,0xD0,0x40,0x00,0x00,0x10,0x30,0x30,0x10,0x18,0xFF,0xFF,0x0C,0x04,0x84,0xCF,
0x7F,0xF0,0xFC,0x8F,0x07,0x02,0xC0,0xC0,0x00,0x00,0x00,0x02,0x02,0x06,0x07,0x03,
0x03,0x01,0x01,0x00,0x00,0x00,0x01,0x03,0x03,0x06,0x07,0x07/*我*/


};


void main()
{
   uchar u;
   P2=0x0c;
	for(u=0;u<64;u++)
    { displaycls (1);
	
	  displaycoslight(64,64,lcd_letter_8_16,u);
	  delay(1000);
					 if(u==64)
					 u=0;
	 
	 }
   
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -