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

📄 s6b33b0a.c

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


// Initialize routine for S6B33B0 
#define OSCILLATION_MODE_SET 0x02 
#define DRIVER_OUTPUT_MODE_SET 0x10 
#define DC_DC_SET 0x20 
#define CURRENT_BIAS_SET 0x22 
#define PCK_GENER_MODE_SET 0x24 // = DCDC Clock division set 
#define DCDC_AMP_ON_OFF_SET 0x26 
#define TEMP_COMPENSATION_SET 0x28 
#define CONTRAST_CONTROL1 0x2A 
#define CONTRAST_CONTROL2 0x2B 
#define STANDBY_MODE_OFF 0x2C 
#define STANDBY_MODE_ON 0x2D 
#define DDRAM_BURST_MODE_OFF 0x2E 
#define DDRAM_BURST_MODE_ON 0x2F 
#define ADDRESSING_MODE_SET 0x30 
#define ROW_VECTOR_MODE_SET 0x32 
#define N_LINE_INVERSION_SET 0x34 // = N-Block Inversion 
#define ENTRY_MODE_SET 0x40 
#define X_ADDRESS_AREA_SET 0x42 
#define Y_ADDRESS_AREA_SET 0x43 
#define RAM_SKIP_AREA_SET 0x45 
#define DISPLAY_OFF 0x50 
#define DISPLAY_ON 0x51 
#define SPEC_DISPLAY_PATTERN_SET 0x53 
#define PARTIAL_DISPLAY_MODE_SET 0x55 
#define PARTIAL_DISPLAY_START_LINE_SET 0x56 
#define PARTIAL_DISPLAY_END_LINE_SET 0x57 
#define AREA_SCROLL_MODE_SET 0x59 
#define SCROLL_START_LINE_SET 0x5A 
#define SET_DISPLAY_DATA_LENGTH 0xFC 
#define HS_LCD_INDEX_REG         0
#define HS_LCD_DATA              1

void Initalize(Byte M_Contrast)	
{

// Standby mode off 
 outpw(STANDBY_MODE_OFF); 
// Select internal or external OSC clock and OSC On/Off control 

outpw(OSCILLATION_MODE_SET); 
 outpw(0x01); // Use internal OSC and OSC On 
// Select the first booster抯 boosting step for V1 generation 

outpw(DC_DC_SET); 
outpw(0x05); // X1.5 step for normal mode(with partial mode 0) and partial mode 1 
// Control the 1st booster, V1 AMP, 2nd booster and 3rd booster 

outpw(DCDC_AMP_ON_OFF_SET); 
outpw(0x01); // 1st booster On 
DelayX1ms1(30); // Waiting 30mS for 1st booster output stabilization 

outpw(DCDC_AMP_ON_OFF_SET); 
outpw(0x09); // 1st Booster and V1 AMP On 
DelayX1ms1(30); // Waiting 30mS for V1 AMP output stabilization 

outpw(DCDC_AMP_ON_OFF_SET); 
outpw(0x0B); // 1st booster, V1 AMP and 2nd booster On 
DelayX1ms1(30); // Waiting 30mS for 2nd booster output stabilization 

outpw(DCDC_AMP_ON_OFF_SET); 
outpw(0x0F); // 1st booster, V1 AMP, 2nd booster and 3rd booster On 
DelayX1ms1(30); // Waiting 30mS for 3rd booster output stabilization 

// Set the temperature compensation ratio 
outpw(TEMP_COMPENSATION_SET); 
outpw(0x00); // 0.00 % 
 
// Burst mode off for data RAM write 
outpw(DDRAM_BURST_MODE_OFF); 
// when burst mode on, data RAM write data length change to 32bit regardless MPU interface setting. 

// RAM address skip area setting 
outpw(RAM_SKIP_AREA_SET); 
outpw(0x00); // Set to No skip 

// Specified display pattern select 
outpw(SPEC_DISPLAY_PATTERN_SET); 
outpw(0x00); // Normal display. 
// outpw(HS_LCD_INDEX_REG, 0x01); // Reverse display. 
// outpw(HS_LCD_INDEX_REG, 0x02); // All display off 
// outpw(HS_LCD_INDEX_REG, 0x03); // All display on 
// Select number of display line, Segment direction and Red/Blue output swap 

outpw(DRIVER_OUTPUT_MODE_SET); 
outpw(0x22); // 1/160 duty and Red/Blue output swap 
// DCDC Clock division set 

outpw(PCK_GENER_MODE_SET); 
outpw(0x33); // fosc/8 division for normal(with partial mode 0) and partial mode 1 
//outpw(0x22); 

// Addressing mode set 
outpw(ADDRESSING_MODE_SET); 
outpw(0x1B); 
// 65K color mode, Dummy sub group off, sub group frame inversion on, sub group inversion off and sub group phase 
// change every 2 pixel unit. 

// Row vector mode set 
outpw(ROW_VECTOR_MODE_SET); 
outpw(0x0E); // Increment type = Y, Vector type = Diagonal 

// Entry mode set 
outpw(ENTRY_MODE_SET); 
outpw(0x01); // Non-Reverse, Y-direction prefer, Read modify off 
// Y-address area set(for segment direction) 
 
   Lcd_Window(0,127,0,159);
   Set_NLine(13);
   Set_Contrast(M_Contrast);

// Driving current and bias set 
outpw(CURRENT_BIAS_SET); 
outpw(0x11); // Normal current driving mode and 1/5 bias for all display mode 
//outpw(0x22); 
// Partial display mode set 
outpw(PARTIAL_DISPLAY_MODE_SET); 
outpw(0x00); // Partial display mode off 

// Display start line set for all partial display mode 
outpw(PARTIAL_DISPLAY_START_LINE_SET); 
outpw(0x00); 

// Display end line set for all partial display mode 
outpw(PARTIAL_DISPLAY_END_LINE_SET); 
outpw(0x9F); 

// Area scroll set 
//outpw(AREA_SCROLL_MODE_SET); 
//outpw(0x00); // Area scroll mode off(Entire display) 
//outpw(0x00); // Scroll area start line 
//outpw(0x9F); // Scroll area end line 
//outpw(0x00); // Lower fixed number 

// Scroll start line set when use area scroll set 
// outpw(HS_LCD_INDEX_REG, SCROLL_S TART_LINE_SET); 
// outpw(0x00); 

// Write initial display data 
// outpw(HS_LCD_CTRL_REG, lcd_init_image[128*i+j]); 

// Display On 
outpw(DISPLAY_ON); 

}

void Main_Off(void)	
{

outpw(DISPLAY_OFF); 

outpw(STANDBY_MODE_ON); 

DelayX1ms1(200); 

}


void outpw(unsigned char Value_Lo)
{
   char  xdata *ptr ;
    
    CS2   = 1;
    CS1   = 0;
	RS    = 0;
    ptr = Value_Lo;
   *ptr=Value_Lo;
 
}



void Lcd_Window(unsigned char X1,unsigned char X2,unsigned char Y1,unsigned char Y2)
{
   
 
outpw(0x43); 
outpw(X1); // from 0 
outpw(X2); // to 127 for 128 segment 
// X-address area set(for common direction) 
outpw(0x42); 
outpw(Y1); // from 0 
outpw(Y2); // to 159 for 160 common 

}




void Set_NLine(unsigned char N_LINE)
{

  // N-line inversion set 
outpw(N_LINE_INVERSION_SET); 
outpw(N_LINE); // FIM=off, FIP=off, N-BLK=13  


}




void Set_Contrast(unsigned char Contrast)
{
// Contrast control for partial display mode 1 
//outpw(CONTRAST_CONTROL2); 
//outpw(0x20); // Can be change for suitable contrast 
// Contrast control for normal display and partial display mode 0 

outpw(CONTRAST_CONTROL1); 
//outpw(0xBF); // Can be change for suitable contrast 
outpw(Contrast); 

}


unsigned char xdata address _at_ 0x0000;



void Picture(int Page)
{
 
   Word i,j;	

  unsigned char xdata *index=&address;  	 
  char Value_Hi;   
  char Value_Lo; 
  // unsigned long  X_Addr;
 //  unsigned char  H_Addr;
  
 

  Lcd_Window(0,127,0,159);
  
  switch(Page)
  {
   case(0) :
    P1_0 = 0; 
    P1_1 = 0;      
    P1_2 = 0;
   index=0;
   break;
   
   case(1) :
    P1_0 = 0; 
    P1_1 = 0;      
    P1_2 = 0;
   index=0xa000;
   break ;
   
   case(2) :
    P1_0 = 1; 
    P1_1 = 0;      
    P1_2 = 0;
   index=0x4000;
   break;
  
   case(3) :
    P1_0 = 1; 
    P1_1 = 0;      
    P1_2 = 0;
   index=0xe000;
   break;

   case(4) :
    P1_0 = 0; 
    P1_1 = 1;      
    P1_2 = 0;
   index=0x8000;
   break;

   case(5) :
    P1_0 = 1; 
    P1_1 = 1;      
    P1_2 = 0;
   index=0x2000;
   break;

   case(6) :
    P1_0 = 1; 
    P1_1 = 1;      
    P1_2 = 0;
   index=0xc000;
   break;
  
   case(7) :
    P1_0 = 0; 
    P1_1 = 0;      
    P1_2 = 1;
   index=0x6000;
   break;
   
   case(8) :
    P1_0 = 1; 
    P1_1 = 0;      
    P1_2 = 1;
   index=0;
   break;
   
   case(9) : 
    P1_0 = 1; 
    P1_1 = 0;      
    P1_2 = 1;

   index=0xa000;
   break ;
   
   case(10) :
   
    P1_0 = 0; 
    P1_1 = 1;      
    P1_2 = 1;
   index=0x4000;
   break;
  
   case(11) :
    P1_0 = 0; 
    P1_1 = 1;      
    P1_2 = 1;
   index=0xe000;
   break;
   
   }

   for(i=0; i<160; i++)
    {
       for(j=0; j<128; j++)
        {    
	  
	   CS1   = LO;
	   RS    = HI;

      Value_Hi=*index; 
      index++;
      Value_Lo=*index; 
      index++;

      if ( index==0 )  	
     {
          P1=P1+1; 
     }
	  
       DPH=Value_Hi;
       DPL=Value_Lo;
       P2=Value_Hi;
       P0=Value_Lo;
       WR    = HI;
       WR    = LO;
       WR    = HI;
	  
	   	}
     }
 
 
}



void Grid(unsigned char X1,unsigned char X2,unsigned char Y1,unsigned char Y2, unsigned char C1, unsigned char C2)
{     
       
        Word i,j;
      
        Lcd_Window(X1,X2,Y1,Y2);
     
        for(i=Y1; i<=Y2;i++)
         { 
         for(j=X1; j<=X2; j++)
         { 
 	 
        
         CS1   = LO;
         RS    = HI;
         P2 = C1;
         P0 = C2;
         WR    = HI;
         WR    = LO;
	 	 WR    = HI;
         }
       }
}

void Dot(void)
{     
  
        Word i,j;
        Byte color;
       
		color=0xff;
       
	    Lcd_Window(0,127,0,159);
     
        for(i=0; i<160 ; i++)
         { 
          for(j=0; j<128; j++)
           { 
           CS1   = LO;
	       RS    = HI;
           P2 = color;
           P0 = color;
           WR    = HI;
           WR    = LO;
	       WR    = HI;
		   color=255-(color);
		   }
           color=255-(color);
         }
}

void Gray(void)
{  
    Byte j;
    Byte color;  
	  
              
        for(j=1; j<=16; j++)
         { 
	     color=2*j-1;          
         Grid(8*(j-1),8*j-1,20*(0),(20*(1)-1),(color<<3)&0xf1,0x00);		
         Grid(8*(j-1),8*j-1,20*(2),(20*(3)-1),(color>>2)&0x07,(color<<6)&0xe0);   
         Grid(8*(j-1),8*j-1,20*(4),(20*(5)-1),0x00,0x1f&(color));   
         Grid(8*(j-1),8*j-1,20*(6),(20*(7)-1),(color<<3)|(color>>2),(color<<6)|(color));
         }
          for(j=1; j<=16; j++)
         { 
	     color=33-(2*j);          
         Grid(8*(j-1),8*j-1,20*(1),(20*(2)-1),(color<<3)&0xf1,0x00);		
         Grid(8*(j-1),8*j-1,20*(3),(20*(4)-1),(color>>2)&0x07,(color<<6)&0xe0);   
         Grid(8*(j-1),8*j-1,20*(5),(20*(6)-1),0x00,0x1f&(color));   
         Grid(8*(j-1),8*j-1,20*(7),(20*(8)-1),(color<<3)|(color>>2),(color<<6)|(color));
         }
  

}


Byte code DISPLAY_TABLE[10][8] =
{
     0x00,0x3c,0x46,0x4a,0x52,0x62,0x3c,0x00,	//"0"
     0x00,0x18,0x38,0x08,0x08,0x08,0x7e,0x00,	//"1"
     0x00,0x3c,0x42,0x06,0x08,0x32,0x7e,0x00,	//"2"
     0x00,0x3e,0x44,0x18,0x04,0x42,0x3c,0x00,	//"3"
     0x00,0x04,0x0c,0x14,0x24,0x7e,0x04,0x00,	//"4"
     0x00,0x7e,0x40,0x7c,0x02,0x42,0x3c,0x00,	//"5"
     0x00,0x3c,0x40,0x7c,0x42,0x42,0x3c,0x00,   //"6"
     0x00,0x3e,0x42,0x04,0x08,0x18,0x18,0x00,   //"7"
     0x00,0x3c,0x42,0x3c,0x42,0x42,0x3c,0x00,   //"8"
     0x00,0x3c,0x42,0x42,0x3e,0x02,0x3c,0x00,   //"9"
};

/*****************************/
//sequent display 0~9
void Dot8x8(unsigned char XX,unsigned char YY, unsigned char NN)
{     
         
           unsigned char i,j,Num;
           Lcd_Window(XX,XX+7,YY,YY+7);


           for(j=0; j<8; j++)		
          {
       	     for(i=0; i<8; i++)
             {
              Num=DISPLAY_TABLE[NN][j]; 
			  CS1   = LO;
	          RS    = HI;
              if((Num>>(7-i) )&0x01)
              {
               P2 = 0x00;
               P0 = 0x00;
               }
              else
              {
               P2 = 0xff;
               P0 = 0xff;
              }
           
              WR    = HI;
              WR    = LO;
	 	      WR    = HI;
             } // i
	    } // j         	    	
    

	
}



void Dot16x16(Byte XX, Byte YY, Byte NN, Word C1,Word C2)
{     
         
           unsigned char i,j,k,Num;
           Lcd_Window(XX,XX+15,YY,YY+15);

           for(k=0; k<8; k++)		
          {
       	    for(j=0; j<2; j++)		
            {
		      for(i=0; i<8; i++)
              {
              Num=DISPLAY_TABLE[NN][k]; 
			  CS1   = LO;
	          RS    = HI;
              if((Num>>(7-i) )&0x01)
              {
               P2 = ( (Byte) ( (C1) >>8    ) );
               P0 = ( (Byte) ( (C1) & 0xff ) );
               }
              else
              {
               P2 =	( (Byte) ( (C2) >>8    ) );
               P0 = ( (Byte) ( (C2) & 0xff ) );
              }
           
              WR    = HI;
              WR    = LO;
	 	      WR    = HI;
              WR    = LO;
	 	      WR    = HI;

             } // i

	       } // j         	    	
    
       }  //k
	
}


void LcdMain_Select(Byte N1)
{
 Byte i;
 i=N1-(N1/21)*21;
 switch(i)
  {

   case(0) :
   Grid(0,127,0,159,0xff,0xff);  // white
   break;

   case(1) :
   Grid(0,127,0,159,0xf8,0x00);  // red
   break;
   case(2) :
   Grid(0,127,0,159,0x07,0xe0);  // green
   break;
   case(3) :
   Grid(0,127,0,159,0x00,0x1f);  // blue
   break;
 
   case(4) :
   Grid(0,127,0,159,0xff,0xff);  // frame
   Grid(1,126,1,158,0x00,0x00);  //
   break;

   case(5) :
   Dot();
   break;

   case(6) :

   Grid(0,63,0,159,0x00,0x00);   
   Grid(64,127,0,159,0xff,0xff);   

   Grid(20,45,22,45,0xc6,0x18);  // 
   Grid(20,45,68,91,0x84,0x10);  // 
   Grid(20,45,114,136,0x42,0x08);  //
   
   Grid(82,107,22,45,0x42,0x08);  //
   Grid(82,107,68,91,0x84,0x10);  // 
   Grid(82,107,114,136,0xc6,0x18);  // 



//   Grid(42,85,53,106,0x00,0x00);  // white_black
   break;

   case(7) :
  
   Grid(0,127,0,159,0x00,0x00);  // black

   Grid(10,117,4,21,0xff,0xff);  // white
   Grid(10,117,27,43,0xf8,0x00);  // red
   Grid(10,117,49,65,0xff,0xe0);  // red+greem
   Grid(10,117,71,87,0x07,0xe0);  // green
   Grid(10,117,93,109,0x07,0xff);  // greem+blue
   Grid(10,117,115,131,0x00,0x1f);  // blue
   Grid(10,117,137,154,0xf8,0x1f);  // red+blue
  
 //  Grid(0,127,0,19,0xff,0xff);  // white
  // Grid(0,127,20,39,0xf8,0x00);  // red
 //  Grid(0,127,40,59,0xff,0xe0);  // red+greem
  // Grid(0,127,60,89,0x07,0xe0);  // green
 //  Grid(0,127,80,99,0x07,0xff);  // greem+blue
  // Grid(0,127,100,119,0x00,0x1f);  // blue
  // Grid(0,127,120,139,0xf8,0x1f);  // red+blue
  // Grid(0,127,140,159,0x00,0x00);  // black
   break;
  
   case(8) :
   Gray();
   break;

   default:
   if (i<=21)
   {
   Picture(i-9);
   }

  } 
 
}



⌨️ 快捷键说明

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