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

📄 lcd.c

📁 这个是我DSP板的LCD显示程序
💻 C
📖 第 1 页 / 共 2 页
字号:
            LCD_COM = 0x4F;
        	LCD_COM = 0x46;
			LCD_DAT = d.e.low;
			LCD_DAT = d.e.high;
			LCD_COM = 0x42;
   	    	for (j=0;j<high;j++)  LCD_DAT=0x78;
		}   
//清条形图
void	ClearBar(Uint16	 x,	Uint16	y, Uint16	high, Uint16  partition)
		{
			union{
					Uint16	total;
					struct{
							Uint16	high:8;
							Uint16	low:8;
						  }e;
				 }d;
			Uint16	j;
	        d.total=x+(y-high)*41;
   	        if (partition==2) d.total=d.total+0x2a00;
   	    	if (partition==3) d.total=d.total+0x5400;
            LCD_COM = 0x4F;
        	LCD_COM = 0x46;
			LCD_DAT = d.e.low;
			LCD_DAT = d.e.high;
			LCD_COM = 0x42;
   	    	for (j=0;j<high;j++)  LCD_DAT=0x00;
		}		 
//==============================================================================
//************************* PAGE  2 ********************************************
//==============================================================================
// 显示24x24点阵字
void 	display1(Uint16 dsp,Uint16 x, Uint16  y,Uint16 condition,Uint16 partition) 
     	{
       		union 
            	{
                  	Uint16 total;
                  	struct
                    {
                        Uint16	high:8;
                        Uint16	low:8;                        
                    }e;
            	}d;
      
      		Uint16  dspah;
      		Uint16	i,j,k;
      		const Uint16  *word;

            if(dsp<500) k=2,word=LIB16x24,dspah=dsp*48; 
            else k=3,word=LIB24x24,dspah=(dsp-500)*72;  

              for(i=0;i<k;i++)
          	    {
          	        d.total=x+y*41+i;
          	        if (partition==2) d.total=d.total+0x2a00;
          	    	if (partition==3) d.total=d.total+0x5400;

                        LCD_COM = 0x4F;
    	   	        	LCD_COM = 0x46;
						LCD_DAT = d.e.low;
						LCD_DAT = d.e.high;
						LCD_COM = 0x42;
          	    	
              	    	for (j=0;j<24;j++)
          	    	     {
    	      	 	     	dsp=word[dspah+j*k+i];
	       	    	     	if (condition==0) LCD_DAT = dsp;
          	    	     	else LCD_DAT = ~dsp;
          	    	     }	
          	    }
            }

//显示16x16点汉字
void 	display2(Uint16 dsp,Uint16 x, Uint16  y,Uint16 condition,Uint16 partition) /*显示16x24点阵,24X24点阵*/
     	{
       		union 
            	{
                  	Uint16 total;
                  	struct
                    {
                        Uint16	high:8;
                        Uint16	low:8;                        
                    }e;
            	}d;
      
      		Uint16  dspah;
      		Uint16	i,j,k;
      		const Uint16  *word;

            if(dsp<500) k=1,word=LIB8x16,dspah=dsp*16; 
            else k=2,word=LIB16x16,dspah=(dsp-500)*32;     

              for(i=0;i<k;i++)
          	    {
          	        d.total=x+y*41+i;
          	        if (partition==2) d.total=d.total+0x2a00;
          	    	if (partition==3) d.total=d.total+0x5400;

                        LCD_COM = 0x4F;
    	   	        	LCD_COM = 0x46;
						LCD_DAT = d.e.low;
						LCD_DAT = d.e.high;
						LCD_COM = 0x42;
          	    	
              	    	for (j=0;j<16;j++)
          	    	     {
    	      	 	     	dsp=word[dspah+j*k+i];
	       	    	     	if (condition==0) LCD_DAT = dsp;
          	    	     	else LCD_DAT = ~dsp;
          	    	     }	
          	    }
            }

void 	display64(Uint16 dsp,Uint16 x, Uint16  y,Uint16 condition,Uint16 partition) 
     	{
       		union 
            	{
                  	Uint16 total;
                  	struct
                    {
                        Uint16	high:8;
                        Uint16	low:8;                        
                    }e;
            	}d;
      
      		Uint16  dspah;
      		Uint16	i,j;
      		const Uint16  *word;

            word=LIB64,dspah=dsp*512; 

              for(i=0;i<8;i++)
          	    {
          	        d.total=x+y*41+i;
          	        if (partition==2) d.total=d.total+0x2a00;
          	    	if (partition==3) d.total=d.total+0x5400;

                        LCD_COM = 0x4F;
    	   	        	LCD_COM = 0x46;
						LCD_DAT = d.e.low;
						LCD_DAT = d.e.high;
						LCD_COM = 0x42;
          	    	
              	    	for (j=0;j<64;j++)
          	    	     {
    	      	 	     	dsp=word[dspah+j*8+i];
	       	    	     	if (condition==0) LCD_DAT = dsp;
          	    	     	else LCD_DAT = ~dsp;
          	    	     }	
          	    }
            }


void 	ShowWord(Uint16 menunum,Uint16 partition ) 
    	{
    		Uint16 a,b,m=0;
    		const Uint16 *mnum;  
    	
        	if(menunum<500) mnum=WordList1[menunum];
    		else  mnum=WordList2[menunum-500];
    	
    		while (mnum[m]!=last)
    	     {
       	    	  
                a=mnum[m],m++;	
                b=mnum[m],m++;                 
	    	while (mnum[m]!= end)     
    	               {
    	                  if(menunum<500) display1(mnum[m],a,b,0,partition),a++,a++;
                          else display2(mnum[m],a,b,0,partition),a++;
                          if (mnum[m]>=500) a++;
                          m++;
                          }
               m++;
               }    	        
 
    }	

void 	ShowIcon(Uint16 menunum,Uint16 partition ) 
    	{
    		Uint16 a,b,m=0;
    		const Uint16 *mnum;  
    	
        	mnum=IconList[menunum];
    	
    		while (mnum[m]!=last)
    	     {
       	    	  
                a=mnum[m],m++;	
                b=mnum[m],m++;                 
	    		while (mnum[m]!= end)     
    	               {
    	                  display64(mnum[m],a,b,0,partition),a++,a++,a++,a++;
                          m++;
                       }
               	m++;
              }    	        
 
    	}	

void 	ShowChar(Uint16 menunum,Uint16 Num,Uint16 partition ) 
    	{
    		Uint16 a,b,m=0;
    		Uint16 TempNum=0;
    		const Uint16 *mnum;  
    	
        	if(menunum<500) mnum=WordList1[menunum];
    		else  mnum=WordList2[menunum-500];
    		while (TempNum != Num)
    	    	{
	    			while (mnum[m]!= end)     
    	       			{
                   			m++;
               			}
            		TempNum++;       
            		m++;
            		if (mnum[m] == last) return;
            	}    	        
            	a=mnum[m],m++;	
            	b=mnum[m],m++;                 
	    		while (mnum[m]!= end)     
    	    		{
    	        		if(menunum<500) display1(mnum[m],a,b,0,partition),a++,a++;
                    	else display2(mnum[m],a,b,0,partition),a++;
                    	if (mnum[m]>=500) a++;
                   		 m++;
                	}
                m++;
		}	
				 		  	
//***********************************************************************
//======================================================================
//=====================  PAGE  3 =========================================
//=======================================================================
//***********************************************************************
void 	WhiteNum(Uint16 num,Uint16 white,Uint16 partition)
     	{
        	union 
            	{
                  	Uint16	 total;
                  	struct
                    	{
                        	Uint16	high:8;
                        	Uint16	low:8;                        	
                         }e;
            	 }d;
       
        	Uint16	 i,j;
        	const	Uint16  *mnum;  
    		mnum=WhiteList[num];
        
        	white=4*white;
        	for (i=0;i<mnum[white+2];i++)
               {
                  for(j=0;j<mnum[white+3];j++)
                        {
             	             d.total=(i+mnum[white])+(mnum[white+1]+j)*41;/*字符在显存中的地址int型*/
                             if (partition==2) d.total=d.total+0x2a00;
                             if (partition==3) d.total=d.total+0x5400;    
                             
                             LCD_COM = 0x46;
                             LCD_DAT = d.e.low;
      	                     LCD_DAT = d.e.high;
      	                     LCD_COM = 0x43;
      	                     num = LCD_COM;
      	                     num=~num;
      	                     LCD_COM = 0x46;       
      	                     LCD_DAT = d.e.low; 
      	                     LCD_DAT = d.e.high; 
                             LCD_COM = 0x42;
                             LCD_DAT = num;               

                        }
                }
      	}

		
//***********************************************************************
//======================================================================
//=====================  PAGE  4  =======================================
//=======================================================================
//***********************************************************************

void	Smenu(void)
		{
		  drawabscissa(50,10,300,3);
		 //	drawarea(1,1,320,240,2);
		 //	drawarea(2,2,319,239,2);
 		//	drawabscissa(29,1,320,2);
 		//	drawabscissa(28,1,320,2);
 		//	drawabscissa(219,1,320,2);
 		//	drawabscissa(220,1,320,2);
         //   drawordinate1(50,2,250,3,2);
 			ShowWord(0,2);
 		//	ShowIcon(0,2);
 		//	ShowWord(500,2);
		//drawarea(20,30,80,100,5);
		}

//===============================================================

⌨️ 快捷键说明

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