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

📄 dsp_display.h

📁 基于DSP芯片TMS320LF2407的高速公路室外显示屏驱动程序
💻 H
字号:
#ifndef DSP_DISP_H   
#define DSP_DISP_H

int chgYesNo=0; 
volatile unsigned char *pdata48=(volatile unsigned char*)  0x0e00;
volatile unsigned char *cy_str=(volatile unsigned char*)   0x0f70;
volatile unsigned char *pInfo=(volatile unsigned char*)  0x949; 

int  move_length=64;
  
void spec_disp(int a){
     int i,j=0,m; 
     int temp;
     unsigned int k;
     volatile unsigned int *pdata=(volatile unsigned int*)  0x8000;                     
                          
     g_flag=g_flag|0x20;
     selectchip(g_flag);
     
     for(j=0;j<3;j++){
       temp=a&(1<<j);    
       if(temp!=0){
          pdata=(volatile unsigned int*)  (0x8000+j*0x2000); 
          for(m=0;m<48;m++){
             pdata=pdata;
             for(i=0;i<0x80;i++){      
                  k=*pdata;
                  pdata++;
             }
         }  
        }
     }
                 
     g_flag=g_flag&0xDF;
     selectchip(g_flag);
 
 } 
/////////////////// ///////////////////////////
  void clr_dispRam(int kk){
   long i=0; 
   volatile unsigned int *pdata=(volatile unsigned int*)  0x8000;
   g_flag=g_flag|0x08;
   
   selectchip(g_flag);  
   for(i=0;i<0x8000;i++){ 
         *pdata=kk;
          pdata++; 
     }
  
   
   spec_disp(0x0f);              
  }
////////////////////////////// ////////////
//     函数功能:取出最右边的一列数
//////////////////////////////////////////
 void sort_char(volatile BYTE* data48,int  m,BYTE clr,int width){
      int i,n;
      int temp; 
      
      BYTE n_byte,g_temp,thisa;
      
      volatile unsigned int *pdata=(volatile unsigned int*)  0x8000;
      
      n_byte=m%8;
      m=m/8;
      g_temp=g_flag;
      g_flag=g_flag|0x08;
      selectchip(g_flag);
////////////////////////////////////////////
//  这种寻址红绿蓝数据空间的方式可借鉴
      for(n=0;n<3;n++){
         if((clr&(1<<n))!=0){
            pdata=(volatile unsigned int*)  0x8000+(2-n)*0x2000;
///////////////////////////////////////////
            for(i=0;i<48;i++){

               if(width%3==0){
                    if(((*(data48+i*width+m))&(1<<n_byte))!=0) {  //????????????????
                       temp=(i+1)*0x80-1;
                       thisa=(BYTE)(*(pdata+temp));
                       thisa=thisa|0x80;
                       *(pdata+temp)=thisa; 
                    }
                 }
               else{
               
                    if((i<40)&&(i>7)&& (((*(data48+(i-8)*width+m))&(1<<n_byte))!=0) ) {
                       temp=(i+1)*0x80-1;
                       thisa=(BYTE)(*(pdata+temp));
                       thisa=thisa|0x80;
                       *(pdata+temp)=thisa; 
                    } 
               
               }
  //////////////////////////////////////////////             
              }
           }
      }
 
     g_flag=g_temp;
     selectchip(g_flag);
 }         
 
void move_left(int aa)
{
    
    int i,j=0,m,n; 
    int temp;
    BYTE g_temp;
    int a,b; 
    BYTE btemp; 
    int fl;
    unsigned int k;
    volatile unsigned char *pdata =(volatile unsigned char*)  0x8000;
    volatile unsigned char *pdata1=(volatile unsigned char*)  0x8000;                     
    volatile unsigned int *pdata2=(volatile unsigned int*)   0x8000; 
                      
    g_temp=g_flag;
    g_flag=g_flag|0x08;
    selectchip(g_flag);
     
 
     
     move_length=128-screen_length*4; ////////////////Calculate the moved byte
     
     for(j=0;j<3;j++){
       temp=aa&(1<<j);
       if(temp!=0){
          pdata=(volatile unsigned char*)  (0x8000+j*0x2000);
          pdata1=pdata;
          for(m=0;m<48;m++){
             a=0;
             pdata=pdata1+(m+1)*0x80-1;
             for(i=0x7f;i>=move_length;i--){                   
                 btemp=*pdata;
                 b=btemp&0x01;               
                 btemp=btemp>>1; 
                 btemp=btemp|(a<<7);
                 *pdata=btemp;
                 a=b;                 
                 pdata--;
                 
             }
         }  
        }
     }
    g_flag=g_temp;
    selectchip(g_flag);
}     


void left_disp(int a,int l_time){
     
     int mm=0;
     int aa;
     int end_flag;
 
     int num=0;
     int hh=0;
     int i=0;
     
     int width=48;   //// initialize width 
     BYTE icolor;
     int X,Y;
     int ifont; 
     
          
     BYTE temp;     
     chgYesNo=0;
     temp=g_flag;
                   
     end_flag=10+screen_length*32;             
     selectchip(0x08);  
     clr_dispRam(0x0000);
     selectchip(0x18);  
     clr_dispRam(0x0000);
     
     mm=0;
     
     while(end_flag>10){ 
         if(aa==0x08)
             aa=0x18;
         else  
             aa=0x08;         
         while(chgYesNo>0);  
         
         selectchip(aa);         
         chgYesNo=l_time*2;         
 
         if(mm==0){
              if(num<a){
                  X=calc_X(pInfo+5*num);
                  Y=calc_Y(pInfo+5*num);
                  ifont=calc_font(pInfo+5*num);
                  width=8*calc_wide(pInfo+5*num);
                  icolor=(BYTE)calc_color(pInfo+5*num);
                  getPic(pdata48,X,Y,0,ifont);
                  end_flag=10+screen_length*32+width; ///???
               }
             
              else{
                  for(i=0;i<288;i++)
                  *(pdata48+i)=0;
               }        
                  num++; 
           }
         move_left(0x03);
         if(mm<width){
            sort_char(pdata48,mm,icolor,width/8);
            end_flag--; 
         }
                        
         mm++;
         if(mm>=width)      
             mm=0;      
         spec_disp(0x03);      
     }  
  
        g_flag=temp;
        selectchip(g_flag);  
     
}    
///////////////////////////////////////////////////////
/*排屏*/ 
void sort_screen(int m,int n,volatile unsigned char *p,int i_wide,BYTE i_color){
	volatile unsigned char *p_Pre;
	int i,j,k;
	BYTE dd;
	for(j=0;j<48;j++){
	    for(i=0;i<i_wide;i++){
	       if((i_wide%3)==0){
	       	   for(k=0;k<3;k++){
	       	      dd=i_color&(1<<(2-k));    ///??????????????????
	       	       if(dd!=0){
	       	       	 if(k==0)
	       	       	    p_Pre=(volatile unsigned char*)0x8000;
	       	       	 if(k==1)
	       	       	    p_Pre=(volatile unsigned char*)0xa000; 
	       	       	 if(k==2)
	       	       	    p_Pre=(volatile unsigned char*)0xc000;
	       	         if((m*4+n+i)<128)
	                    *( p_Pre+j*128+m*4+n+i )=*(p+i_wide*j+i);
                   }
                }
           }
	       else{
	         if((j>=8)&&(j<40)){
	         	
	           for(k=0;k<3;k++){
	       	      dd=i_color&(1<<(2-k));    //???????????????????
	       	       if(dd!=0){
	       	       	 if(k==0)
	       	       	    p_Pre=(volatile unsigned char*)0x8000;
	       	       	 if(k==1)
	       	       	    p_Pre=(volatile unsigned char*)0xa000; 
	       	       	 if(k==2)
	       	       	    p_Pre=(volatile unsigned char*)0xc000;
	       	         if((m*4+n+i)<128)
	                  *( p_Pre+j*128+m*4+n+i)=*(p+i_wide*(j-8)+i);
                   }// /* dd*/
                   
                }// /*for k*/     
               
               }///*if j>=8*/
           }////*else*/
	    }///*for  i<i_wide*/
	}

}
 
 
/*排屏*/
/////////////////////////////
/* 翻屏显示   */ 



void disp_all(int length){ 
   int i,j,len;
   int weX,weY;
   int m=0,n=0,tq_len;
   BYTE temp;
   
   m=32-screen_length;   
   clr_dispRam(0);
   temp=g_flag;
   g_flag=g_flag&0xF0;
   g_flag=g_flag|0x08;
   selectchip(g_flag);  
   len=length/5; 
   i_delay=((*p_flashbuf)&0x0f)*10+((*(p_flashbuf+1))&0x0f);
   i_delay=i_delay*3;
   i_delay=i_delay/2;
   if(i_delay<2)
     i_delay=7;  
   for(i=0;i<len;i++){
	
		if((i==0)&&(calc_color(pInfo+5*i)==1)&&(calc_X(pInfo+5*i)==4)){
			
			for(j=0;j<3;j++){
		        getPic(pdata48,calc_X(pInfo+5*i),(calc_Y(pInfo+5*i)+j),6,0);
	            sort_screen(m,n,pdata48,6,(4>>j));
            }
            m=m+(n+6)/4;
	        n=(n+6)%4;
            
		}
		
		else if((i==0)&&(calc_color(pInfo+5*i)==0)&&(calc_X(pInfo+5*i)==4)){
			     tq_len=flash_read(1,cy_str,0);
			     if(tq_len!=4){
				    for(j=0;j<3;j++){
				       getPic(pdata48,calc_X(pInfo+5*i),(calc_Y(pInfo+5*i)+j),6,0);
	                   sort_screen(m,n,pdata48,6,(4>>j)); 
                      } 
                    m=m+(n+6)/4;
	                n=(n+6)%4;
			        }
			     else{
				     weX=(cy_str[0]&0x0F)*10+(cy_str[1]&0x0F);
				     weY=(cy_str[2]&0x0F)*10+(cy_str[3]&0x0F);
				
				     /////////////////////
				     for(j=0;j<3;j++){
		                getPic(pdata48,weX,(weY+j),6,0);
	                    sort_screen(m,n,pdata48,6,(4>>j));
                     }
				   
				     ///////////////////
				     m=m+(n+6)/4;
	                 n=(n+6)%4;
				    
		            }
		}
	         
		else{
		   getPic(pdata48,calc_X(pInfo+5*i),calc_Y(pInfo+5*i),calc_wide(pInfo+5*i),calc_font(pInfo+5*i));
	       //if(  ((m+(n+calc_wide(pInfo+5*i))/4) <32) || (((m+(n+calc_wide(pInfo+5*i))/4)==32)&& ( (calc_wide(pInfo+5*i)%4)==0)  ) )
	       sort_screen(m,n,pdata48,calc_wide(pInfo+5*i),calc_color(pInfo+5*i));
		   /// 
		   m=m+(n+calc_wide(pInfo+5*i))/4;
	       n=(n+calc_wide(pInfo+5*i))%4;
        } 
        
        
        if(m>32)
           i=len; 
         
	    
       }

   spec_disp(0x07);  
   g_flag=temp;
   selectchip(g_flag);
     
}
/* 翻屏显示   */
/////////////////////////// 
////////////////////////////////////////////////////////
void total_disp(int a){
    int i,num,l_time;
    num=flash_read(a,p_flashbuf,0);
    i=((*(p_flashbuf+2))&0x0f)*10+((*(p_flashbuf+3))&0x0f);
    num=(num-9);
    l_time=((*p_flashbuf)&0x0f)*10+((*(p_flashbuf+1))&0x0f);
    if(i==1){
           left_disp(num/5,l_time);
           i_delay=0;
        }  
    else       
        disp_all(num);
       
}
////////////////////////////////////////////////////////
#ifdef _FAC_TEST
void make_lean(int a){    
     int i;
     int k;
     k=a/48;     
     
     for(i=0;i<288;i++){
             
        if(k==0)
          *(pdata48+i)=1<<(((i/6)+(i%6)*8+(a%48))%48) ;
        else 
          *(pdata48+i)=1<<(47-(((i/6)+(i%6)*8+(a%48))%48)) ;
     
     }     
}

void test_lean(){
     int m,n;
     int k;
     int kk;
     int aa=0x08;
     
     
     m=0;
     n=0;
     kk=0;
     k=0;
     selectchip(0x08);  
     clr_dispRam(0x0000);
     selectchip(0x18);  
     clr_dispRam(0x0000);
     selectchip(0x08);
     do{
        
        make_lean(k);  
        m=0;
        n=0;
        while(m<32){   
          if(kk<3)     
            sort_screen(m,n,pdata48,6,(4>>kk));
          else
            sort_screen(m,n,pdata48,6,7);
          m=m+((n+6)/4);
          n=(n+6)%4;       
        }
        
        spec_disp(0x07);
        if(aa==0x08)
           aa=0x18;
        else
           aa=0x08;
        selectchip(aa);  
        
        my_second=1;
        div_second=600;
        while(my_second>0);
        
        k++;
        //k=0;
        if(k>47){
            k=0;
            kk++;
            selectchip(0x08);  
            clr_dispRam(0x0000);
            selectchip(0x18);  
            clr_dispRam(0x0000); 
            
        }
       
      }while(kk<4);
       
}



void test_cartoon(){
     BYTE temp;
     int i,j,m,n;
     int aa=0x08; 
     volatile unsigned char *pdata =(volatile unsigned char*)  0x8000;
      
     for(i=4;i<8;i++){
       
       for(j=0;j<8;j++){
            for(m=0;m<4;m++){
               flash_read_Ext(i,pdata48,4*j+m);
               g_flag=g_flag&0xF0;
               g_flag=g_flag|0x08; 
               selectchip(g_flag);
               for(n=0;n<512;n++)
                 *(pdata+m*0x1000+(n/16)*128+112+(n%16))=*(pdata48+n);
               } 
            spec_disp(0x07);
            if(aa==0x08)
               aa=0x18;
            else
               aa=0x08; 
            while(chgYesNo>0);
            selectchip(aa);         
            chgYesNo=20;  
             
                
          }
       }
}


#endif
#endif

⌨️ 快捷键说明

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