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

📄 main.c

📁 LGDP4525 51驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
	for(k=0;k<ROW/6+1;k++)
	{	
		for(i=0;i<COL-COL/32*32;i++){DBL=0x00;WR0=0;WR0=1;DBL=0x1f;WR0=0;WR0=1;}
		for(i=31;i>0;i--)
		{
			for(j=0;j<COL/31;j++)
			{
				DBL=0;
				WR0=0;
				WR0=1;

				DBL=i;
				WR0=0;
				WR0=1;
			}
		}
		for(i=0;i<COL/31;i++){DBL=0x00;WR0=0;WR0=1;DBL=0x00;WR0=0;WR0=1;}
	}

	CS0=1;
}

void DispPic(unsigned char code *picture)
{
    unsigned int  i,j;
   
	//BlockWrite(0,COL-1,0,ROW-1);

	CS0=0;
	RS =1;
	RD0=1;

	for(i=0;i<ROW/2;i++)
	{
		for(j=0;j<COL;j++)
	    {
		    DBL=*(picture++); 
			WR0=0;
			WR0=1;
			 
			DBL=*(picture++);  
			WR0=0;
			WR0=1;
	  	}
	}

	CS0=1;
}

void DispSnow(void)
{
	unsigned int i,j;

	BlockWrite(0,COL-1,0,ROW-1);

	CS0=0;
   	RS=1;
	RD0=1;

	DBL = 0;
	DBH = 0;

	for(i=0;i<ROW;i++)
	{
		for(j=0;j<COL/2;j++) 
		{
			WR0 = 0; WR0 = 1;
			DBL = ~DBL;
			DBH = ~DBH;
			WR0 = 0; WR0 = 1;
 			DBL = ~DBL;
			DBH = ~DBH;
		} 
        
		DBL = ~DBL;
		DBH = ~DBH;
	}
    
	CS0 = 1;
}

void DispSingleColorLine(unsigned char code *graphic)
{
    unsigned char i;

	CS0=0;
	RS =1;
	RD0=1;
    for(i=0;i<COL;i++)
    {
	 	
		DBH=*(graphic++);  
		DBL=*(graphic++);  
		WR0=0;
		WR0=1;
	    
	}
	CS0=1;
}					
void FillColorLine(unsigned char code *graphic)
{
    unsigned int i;

	BlockWrite(0,COL-1,0,ROW-1);
	   
    for(i=0;i<ROW;i++)
    {
		DispSingleColorLine(graphic);
    }
}


void FillGrayRGB(unsigned char code *graphic_r1,unsigned char code *graphic_r2,unsigned char code *graphic_g1,unsigned char code *graphic_g2,unsigned char code *graphic_b1,unsigned char code *graphic_b2)
{
    unsigned int i,k;  
	 
    k = ROW /6;
    
	BlockWrite(0,COL-1,0,ROW-1);

    for(i=0;i<k;i++)
	{
		DispSingleColorLine(graphic_r1);
	}
	
	for(i=0;i<k;i++)
	{
		DispSingleColorLine(graphic_r2);
	}
	
	for(i=0;i<k;i++)
	{
		DispSingleColorLine(graphic_g1);
	}

	for(i=0;i<k;i++)
	{
		DispSingleColorLine(graphic_g2);

	}
	
	for(i=0;i<k;i++)
	{
		DispSingleColorLine(graphic_b1);
	}
	
	for(i=0;i<k;i++)
	{
		DispSingleColorLine(graphic_b2);
	}

	//
	for(i=0;i<ROW%6;i++)
	{
		DispSingleColorLine(graphic_b2);
	}
}

void FillGraphic8(unsigned char code *graphic,unsigned int Frgb,Brgb)
{
    unsigned int i,j,k,n;
    unsigned char temp;

	BlockWrite(0,COL-1,0,ROW-1);
	
    for(n=0;n<ROW/8;n++)
    {
        for(i=0;i<8;i++)
        {
			for(j=0;j<COL/8;j++)
			{
				temp = graphic[i];
				for(k=0;k<8;k++)
				{
					if((temp<<k)&(0x80))
					{
						WriteData(Frgb);
					}
					else
					{
						WriteData(Brgb);
					}
				}
			}

			//
			for(k=0;k<COL%8;k++)
			{
				WriteData(0xffff);
			}

		}
	}
     
    // 
	for(i=0;i<ROW%8;i++)
	{
		for(j=0;j<COL;j++)
		{
			WriteData(Brgb);
		}
	}
}

void FillGraphic16(unsigned char code *graphic,unsigned int Frgb,Brgb)
{
    unsigned int i,j,k,n;
    unsigned char temp;
        
	BlockWrite(0,COL-1,0,ROW-1);

    for(n=0;n<ROW/16;n++)
    {
        for(i=0;i<16;i++)
        {

			for(j=0;j<COL/16;j++)
			{
				temp = graphic[i*2];
				for(k=0;k<8;k++)
				{
					if((temp<<k)&(0x80))
					{
						WriteData(Frgb); 

					}
					else
					{
						WriteData(Brgb);
					}

				}
	
				temp = graphic[i*2+1];

				for(k=0;k<8;k++)
				{
					if((temp<<k)&(0x80))
					{
						WriteData(Frgb);
					}
					else
					{
						WriteData(Brgb);
					}

				}

				//
				for(k=0;k<COL%16;k++)
				{
					WriteData(0xffff);
				}

			}
		}
	}
     
     //
	for(i=0;i<ROW%16;i++)
	{
		for(j=0;j<COL;j++)
		{
			WriteData(Brgb);
		}
	}
}

unsigned int ReadIDReg(void)
{
	
    unsigned int temp1,temp2;

	WriteComm(0x00);
	WriteComm(0x00);


	CS0 = 0;
	RS  = 1;
	WR0 = 1;

	RD0 = 0;
	Delay(500);

	DBH  = 0xFF; //置P1口读状态
	DBL  = 0xFF; //置P0口读状态

	temp1= DBL;
	RD0 = 1; 

	RD0 = 0;
	Delay(500);

	DBH  = 0xFF; //置P1口读状态
	DBL  = 0xFF; //置P0口读状态

	temp2= DBL;
	RD0 = 1; 
		
	temp1=(temp1<<8)|temp2;
	Delay(50);

	CS0 = 1;

	return temp1;

}

void DispID(void)
{
    unsigned char n1,n2,n3,n4;
	unsigned int id;

	id = ReadIDReg(); 

	n1 = (id>>12)%16;
	n2 = (id>>8)%16;
	n3 = (id>>4)%16;
	n4 = id%16;
	 

	WriteWord(8,wordImg,0,0,0x0000);	 //ID:
	WriteWord(3,wordImg,8,0,0x0000);
	WriteWord(2,symbolImg,16,0,0x0000);  

	WriteWord(n1,numbelImg,24,0,0x0000); //xxxx
	WriteWord(n2,numbelImg,32,0,0x0000);
	WriteWord(n3,numbelImg,40,0,0x0000);
	WriteWord(n4,numbelImg,48,0,0x0000); 
	
	if(id!=0x4525)
	{
		WriteWord(8,wordImg,0,0,~0xFFC0);//ID:
		WriteWord(3,wordImg,8,0,~0xFFC0);
		WriteWord(2,symbolImg,16,0,~0xFFC0); 
		 
		WriteWord(0,symbolImg,24,0,~0xFFC0);//????
		WriteWord(0,symbolImg,32,0,~0xFFC0);
		WriteWord(0,symbolImg,40,0,~0xFFC0);
		WriteWord(0,symbolImg,48,0,~0xFFC0);
	}

}

void  WriteWord(unsigned int index,unsigned char code *array,unsigned int Xstart,unsigned int Ystart,unsigned int rgb)	 
{													  
   unsigned char i,j,temp;
   unsigned char  *p;

   BlockWrite(Xstart,Xstart+7,Ystart,Ystart+15);
   
   index = index*16;
   p = array;
   p = p+index;

   for(i=0;i<16;i++)
    {
       temp=*p++;
       for(j=0;j<8;j++)
        {
           if((temp<<j)&0x80)
             {
                WriteChar(rgb);
             }      
           else 
             {
                WriteChar(~rgb);
             }
         }
     }
}

void DispPos(unsigned int bout1,unsigned int bout2)//显示TP X,Y坐标
{
	unsigned char bouta,boutb,boutc,boutd;
	
	bouta=bout1/1000;
	bout1=bout1%1000;
	
	boutb=bout1/100;
	bout1=bout1%100;
	
	boutc=bout1/10;
	boutd=bout1%10;

	
	WriteWord(23,wordImg,0x0024,0x0000,0x0000);		//X:
	WriteWord(2,symbolImg,0x002C,0x0000,0x0000);

	WriteWord(bouta,numbelImg,0x0034,0x0000,0x0000);//显示数据,XSTART,YSTART,RGB
	WriteWord(boutb,numbelImg,0x003C,0x0000,0x0000);
	WriteWord(boutc,numbelImg,0x0044,0x0000,0x0000);
	WriteWord(boutd,numbelImg,0x004C,0x0000,0x0000);
	
	bouta=bout2/1000;
	bout2=bout2%1000;
	
	boutb=bout2/100;
	bout2=bout2%100;
	
	boutc=bout2/10;
	boutd=bout2%10;
	
	
	WriteWord(24,wordImg,0x0024,0x0012,0x0000);		//Y:
	WriteWord(2,symbolImg,0x002C,0x0012,0x0000);

	WriteWord(bouta,numbelImg,0x0034,0x0012,0x0000);//显示数据,XSTART,YSTART,RGB
	WriteWord(boutb,numbelImg,0x003C,0x0012,0x0000);
	WriteWord(boutc,numbelImg,0x0044,0x0012,0x0000);
	WriteWord(boutd,numbelImg,0x004C,0x0012,0x0000);

}

void FillIconWindow(long int Xstart,long int Ystart,unsigned int rgb)
{
	unsigned char i,j;

	BlockWrite(Xstart,Xstart+29,Ystart,Ystart+29);

	for(i=0;i<30;i++)			   
		for(j=0;j<30;j++)
		{
			WriteChar(rgb);
		}
}

void WriteIconWindow(long int Xstart,long int Ystart,unsigned char code *p)
{
	unsigned char i,j;	  

	BlockWrite(Xstart,Xstart+29,Ystart,Ystart+29);
	
	CS0=0;
	RS=1;
	RD0=1;
	
	for(i=0;i<30;i++)
	{
		for(j=0;j<30;j++)
		{
			DBL=*p++; 
			WR0=0;
			WR0=1;
			 
			DBL=*p++;
			WR0=0;
			WR0=1;
		}
	}
	
	RS=1;
	CS0=1;
} 

unsigned char ConvPosX(unsigned int x)
{

⌨️ 快捷键说明

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