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

📄 s6b07x.c

📁 SAMSUNG S6B33B0程序
💻 C
字号:
#include  "define.h"
#include  "cpu8052.h"
#include  "global.h"
#include  "delay.h"
#include  "S6b07x.h"


//    Instruction S6b07x

#define Display_ON                 0xAF
#define Display_OFF                0xAE
#define Initial_Display_Line       0x40

#define Set_page_address           0xB0
#define Set_column_address_MSB     0x10
#define Set_column_address_LSB     0x00

#define ADC_select                 0xA0 
#define LCD_bias_select            0xA3
#define SHL_select                 0xC8

#define Power_control_0            0x28
#define Power_control_1            0x2C
#define Power_control_2            0x2E
#define Power_control_3            0x2F

#define Regulator_resistor_select  0x25
#define Set_reference_voltage      0x81 



void Sub_Initalize(Byte Contrast)	
{

  LcdSub_Send_Command_Func(ADC_select);
  LcdSub_Send_Command_Func(SHL_select);
  LcdSub_Send_Command_Func(LCD_bias_select);

  LcdSub_Send_Command_Func(Power_control_1);
  DelayX1ms1(10);
  LcdSub_Send_Command_Func(Power_control_2);
  DelayX1ms1(2);
  LcdSub_Send_Command_Func(Power_control_3);
  DelayX1ms1(2);

  LcdSub_Send_Command_Func(Regulator_resistor_select);
 
  LcdSub_Clear();
  LcdSub_Contrast(Contrast);

  LcdSub_Send_Command_Func(Initial_Display_Line);
  LcdSub_Send_Command_Func(Display_ON);

}


void Sub_Off(void)	
{

  LcdSub_Send_Command_Func(Display_OFF);

  LcdSub_Send_Command_Func(0x2d);
  DelayX1ms1(100);
  LcdSub_Send_Command_Func(0x2c);
  DelayX1ms1(5);
  LcdSub_Send_Command_Func(0x28);
  DelayX1ms1(5);
 
}

void  LcdSub_Send_Command_Func(unsigned char Lcd_Command)
{
   // char  xdata *ptr ;
    
         CS1   = 1;
         CS2   = 0;

         RS    = 0;
         P0 = Lcd_Command;
         WR    = HI;
         WR    = LO;
	 	 WR    = HI;
 
}



void LcdSub_Send_Data_Func(unsigned char Lcd_Data)
{
    
   // char  xdata *ptr ;
    
	CS1   = 1;
    CS2   = 0;

	RS    = 1;
    P0    =  Lcd_Data ;
    WR    = HI;
    WR    = LO;
	WR    = HI;
  
 
}


void LcdSub_Contrast(unsigned char Contrast)
{
 LcdSub_Send_Command_Func(Set_reference_voltage);
 LcdSub_Send_Command_Func(Contrast);
 LcdSub_ShowNum(Contrast);
}



void LcdSub_Address(unsigned char Page,unsigned char Address)
{
 
  LcdSub_Send_Command_Func(Set_page_address|(Page & 0x0f) );
  LcdSub_Send_Command_Func(Set_column_address_MSB | ( Address>>4 ));
  LcdSub_Send_Command_Func(Set_column_address_LSB | ( Address&0x0F));

}

void LcdSub_Black(void)
{
     Byte i,j;
   
	 for(i=0; i<8; i++)
       {     
        LcdSub_Address(i,0x00);
        for(j=0; j<96; j++)
        { 
        LcdSub_Send_Data_Func(0xff);
        }

       }
}

void LcdSub_Clear(void)
{
     Byte i,j;
   
	 for(i=0; i<8; i++)
       {     
        LcdSub_Address(i,0x00);
        for(j=0; j<96; j++)
        { 
        LcdSub_Send_Data_Func(0x00);
        }
       }
}

void LcdSub_Dot(void)
{
     Byte i,j;
   
	 for(i=0; i<8; i++)
       {     
        LcdSub_Address(i,0x00);
        for(j=0; j<48; j++)
        { 
        LcdSub_Send_Data_Func(0xaa);
        LcdSub_Send_Data_Func(0x55);
        }
       }
}


void LcdSub_Frame(void)
{
        Byte i,j;
    
        LcdSub_Address(0,0x00);
        LcdSub_Send_Data_Func(0xff);
        for(j=0; j<94; j++)
         { 
         LcdSub_Send_Data_Func(0x01);
         }
        LcdSub_Send_Data_Func(0xff);
       // 

        for(i=1; i<7; i++)
        { 
        LcdSub_Address(i,0x00);
        LcdSub_Send_Data_Func(0xff);
        for(j=0; j<94; j++)
         { 
         LcdSub_Send_Data_Func(0x00);
         }
         LcdSub_Send_Data_Func(0xff);
        }
       //
        LcdSub_Address(7,0x00);
        LcdSub_Send_Data_Func(0xff);
        for(j=0; j<94; j++)
         { 
         LcdSub_Send_Data_Func(0x80);
         }
        LcdSub_Send_Data_Func(0xff);

}


void LcdSub_Dot4x4(void)
{
     Byte i,j;
   
	 for(i=0; i<8; i++)
       {     
        LcdSub_Address(i,0x00);
        for(j=0; j<12; j++)
        { 
        LcdSub_Send_Data_Func(0xf0);
        LcdSub_Send_Data_Func(0xf0);
        LcdSub_Send_Data_Func(0xf0);
        LcdSub_Send_Data_Func(0xf0);
        LcdSub_Send_Data_Func(0x0f);
        LcdSub_Send_Data_Func(0x0f); 
        LcdSub_Send_Data_Func(0x0f); 
        LcdSub_Send_Data_Func(0x0f); 
        }
       }    // 

       LcdSub_Address(4,0x00);
       for (i=1; i<=12; i++)
        { 
         LcdSub_Num(i-(i/10)*10);
        }  

       for (i=1; i<=8; i++)
        { 
         LcdSub_Address(i-1,32);
         LcdSub_Num(i);
        }  


}


Byte code DISPLAY_Num[10][8] =
{
     0x00,0x3c,0x42,0x42,0x42,0x42,0x3c,0x00,	//"0"
     0x00,0x40,0x40,0x44,0x7e,0x40,0x40,0x00,	//"1"
     0x00,0x44,0x62,0x52,0x4a,0x4a,0x44,0x00,	//"2"
     0x00,0x24,0x42,0x42,0x4a,0x4a,0x34,0x00,	//"3"
     0x00,0x20,0x30,0x28,0x24,0x7e,0x20,0x00,	//"4"
     0x00,0x2e,0x4a,0x4a,0x4a,0x4a,0x32,0x00,	//"5"
     0x00,0x3c,0x4a,0x4a,0x4a,0x4a,0x30,0x00,   //"6"
     0x00,0x06,0x02,0x72,0x7a,0x0a,0x06,0x00,   //"7"
     0x00,0x34,0x4a,0x4a,0x4a,0x4a,0x34,0x00,   //"8"
     0x00,0x0c,0x52,0x52,0x52,0x52,0x3c,0x00,   //"9"
    
};


void LcdSub_Num(Byte NN)
{
     Byte j;

     for(j=0; j<8; j++)
     { 
     LcdSub_Send_Data_Func(DISPLAY_Num[NN][j]);
     }
      
}

void LcdSub_ShowNum(Byte NN)
{
  
     Byte j;

     LcdSub_Address(3,32);

     for(j=0; j<8; j++)
     { 
     LcdSub_Send_Data_Func((DISPLAY_Num[(NN/100)][j])^0xff);
     }
      for(j=0; j<8; j++)
     { 
     LcdSub_Send_Data_Func((DISPLAY_Num[((NN-(NN/100)*100)/10)][j])^0xff);
     }
      for(j=0; j<8; j++)
     { 
     LcdSub_Send_Data_Func((DISPLAY_Num[(NN-(NN/10)*10)][j])^0xff);
     }
   
}






void LcdSub_NBar(void)
{
     Byte i,j,k;

       for(i=0; i<8; i++)
       {     
        LcdSub_Address(i,0x00);
        for(j=0; j<12; j++)
        {
        LcdSub_Send_Data_Func(0x00);
        LcdSub_Send_Data_Func(0xff);
        LcdSub_Send_Data_Func(0xff);
        LcdSub_Send_Data_Func(0xff);
        LcdSub_Send_Data_Func(0xff);
        LcdSub_Send_Data_Func(0xff); 
        LcdSub_Send_Data_Func(0xff); 
        LcdSub_Send_Data_Func(0x00); 
        }
       } // 

     k=8;
	 for(i=0; i<12; i++)
       {  
         for(j=1; j<k; j++)
         { 
          LcdSub_Address(j-1,i*8);
          LcdSub_Num(j);
          } 

          k--; 
         if (k==1)
          {
           k=8;
          }
       }    // 
}

void LcdSub_Select(Byte N2)
{
 Byte i;
 i=N2-(N2/5)*5;
  switch(i)
  {
   case(0) :
   LcdSub_Black( );
   break;
   case(1) :
   LcdSub_Dot( );
   break;
   case(2) :
   LcdSub_Frame( );
   break;
   case(3) :
   LcdSub_Dot4x4( );
   break;
   case(4) :
   LcdSub_NBar( );
   break;
   }

}

⌨️ 快捷键说明

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