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

📄 main.c

📁 SAMSUNG S6B33B0程序
💻 C
字号:

/*****************************/
/* include files             */
/*****************************/
#include  "define.h"
#include  "cpu8052.h"
#include  "global.h"
#include  "delay.h"
#include  "S6B33B0A.h"
#include  "poweron.h"
#include  "S6b07x.h"

#include  <intrins.h>

void SubRoutine11(void);
void SubRoutine22(void);
void SubRoutine33(void);

unsigned char idata M_Contrast;
unsigned char idata S_Contrast;
unsigned char idata N_Line;
/*****************************/
	
//One interrupt
void  Power_Off(void) interrupt 2 
{

    EX1 = 0;		//disable int0
  
    while(DISPOFF==0 )
    {
    Main_Off();	
    Sub_Off();
	DelayX10ms(1);
    RES=0;         
	DelayX10ms(10);
    P0=0;
    P2=0;
    POWER=1;      //power off

    }
    
	EX1 = 1;		//enable next interrupt
    IE1 = 0;		//set TCON.3 flag

}

/*****************************/
//More interrupt
void  Adj(void) interrupt 0 
{
    EX0 = 0;

     while(STOP==0 )
    {
  
    if ( UP==0 & ALT==1 )  	//interrupt 1
    {
       M_Contrast++;
       M_Contrast=M_Contrast&0xff;
	   Set_Contrast(M_Contrast);
       LcdSub_ShowNum(M_Contrast);
       DelayX10ms(50);
    }
    if ( DOWN==0 & ALT==1 )	//interrupt 2
    {
       M_Contrast--;
       M_Contrast=M_Contrast&0xff;
       Set_Contrast(M_Contrast);
       LcdSub_ShowNum(M_Contrast);
       DelayX10ms(50);
    }    
    
    if ( UP==0 & ALT==0 )  	//interrupt 1
    {
 	     
	   //  N_Line++;
	   //  Set_NLine(N_Line);
	   //  LcdSub_ShowNum(N_Line);
         S_Contrast++;
         S_Contrast=S_Contrast&0x3f;
         LcdSub_Contrast(S_Contrast);
           DelayX10ms(50);
    }
    if ( DOWN==0 & ALT==0 )	//interrupt 2
    {
        
    //      N_Line--;
	//      Set_NLine(N_Line);
    //      LcdSub_ShowNum(N_Line);
	 
         S_Contrast--;
         S_Contrast=S_Contrast&0x3f;
         LcdSub_Contrast(S_Contrast);
           DelayX10ms(50);
    }    


    }   
    EX0 = 1;
    IE0 = 0;		//set TCON.1 flag
}

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




//program start from main( ) while power on
void Main(void)
{
    
    PowerOnInitial();

    POWER=0;         //power on
	DelayX10ms(10);

    RES=0;
	DelayX10ms(1);
    RES=1;
	DelayX10ms(10);

 // M_Contrast=150;
    M_Contrast=214;
 //  M_Contrast=100;
      
	N_Line=13;

    S_Contrast=32;
    CS2   = 1;
    Initalize(M_Contrast);   
    CS1   = 1;
    Sub_Initalize(S_Contrast);
  

    while( 1 )
    {
   
   
       SubRoutine11( );
            
       SubRoutine22( );
     
       SubRoutine33( );
     
         
    }
}


void SubRoutine11(void)
{
   
    int i;
    i=0; 
   
    CS2   = 1;
    LcdMain_Select(i);
    CS1   = 1;
    LcdSub_Select(i);

    while( (DOWN==1)|(UP==1))
    {
      
	if (ALT==1) 
   
 	{	
       
       if ( DOWN==0)	
       {
        i--; 
        CS2   = 1;
        LcdMain_Select(i);
        CS1   = 1;
        LcdSub_Select(i);
        DelayX10ms(10);
       }
     
	   if ( UP==0 )  
       {
        i++;
        CS2   = 1;
        LcdMain_Select(i);
        CS1   = 1;
        LcdSub_Select(i);
        DelayX10ms(10);
       }

      
     }  
           
     else 
     {
     CS2   = 1;
     LcdMain_Select(i);
     CS1   = 1;
     LcdSub_Select(i);
     DelayX10ms(150);
	 i++;
     }
 
       if ( i>21)
       {
 	   i=0;
       }

       if (i<0) 
       {
    	i=21;
       }


    }  // end while
}


void SubRoutine22(void)
{ 
       int i,j;
      CS2   = HI;  
	  Grid(0,127,0,159,0xff,0xff);

   	  for(j=0; j<10; j++)
	   {
        for(i=0; i<6; i++)
        {
        Dot16x16((i*16+16),(j*16),j,0x0000,0xffff);
        }
       }

	 j=5;
     while(ALT==1)
	  {

      for(i=0; i<6; i++)
      {
       Dot16x16((i*16+16),(j*16),j,0xffff,0x0000);
      }
    
	  DelayX10ms(10);

      if ( UP==0 )  
      {
       
	   for(i=0; i<6; i++)
       {
       Dot16x16((i*16+16),(j*16),j,0x0000,0xffff);
  	   }
       DelayX10ms(30);
       j++ ;  
    
	   if ( j>=10)
       {
 	   j=0;
       }
       
      

	  }

     if ( DOWN==0)	
     {
        
	    for(i=0; i<6; i++)
        {
        Dot16x16((i*16+16),(j*16),j,0x0000,0xffff);
        }
	    DelayX10ms(30);
	    j--; 
       
	    if (j<0) 
    	{
    	j=9;
        }

      

      } //

      } // end while

      DelayX10ms(30);

}




void SubRoutine33(void)
{
    
     int x,y;
     x=0;
     y=0; 
	 CS2   = HI;
 //  Grid(0,127,0,159,0xff,0xff);
     Grid(0,127,0,159,0x57,0xEA);
     DelayX10ms(10);
	 while (ALT==1 )
	{	
    
    if ( UP==0 )  	
    {
       // Grid(10,120,y,y+20,0xff,0xff);
	   Grid(10,120,y,y+20,0x57,0xEA);
       y=y+20;
       if ( y > 140 )
	   {
       y=0;
	   }
	  
       DelayX10ms(10);
    }
    if ( DOWN==0)	
    {
     
    // Grid(10,120,y,y+20,0xff,0xff);
      Grid(10,120,y,y+20,0x57,0xEA);
	  y=y-20;
      
       if ( y < 0 )
	   {
        y=0;
        y=139;
	   }
       DelayX10ms(10);  
	   
     }    
      Grid(10,120,y,y+20,0x21,0x04);
   //   DelayX10ms(60);
   }  

    


}




⌨️ 快捷键说明

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