Beispiel #1
0
void OLED_Init(void)        
{
  //OLED Pins
  gpio_init (PORTA,12,GPO,1); 
  gpio_init (PORTA,13,GPO,1);
  gpio_init (PORTA,15,GPO,1); 
  gpio_init (PORTA,16,GPO,1);
  
  D0=1;
  //CS=1;	//预制SLK和SS为高电平   	
  
  RST=0;
  DLY_ms(50);
  RST=1;
	
	//从上电到下面开始初始化要有足够的时间,即等待RC复位完毕
  Set_Display_On_Off(0x00);		  // Display Off (0x00/0x01)
  Set_Display_Clock(0x80);		  // Set Clock as 100 Frames/Sec
  Set_Multiplex_Ratio(0x3F);		// 1/64 Duty (0x0F~0x3F)
  Set_Display_Offset(0x00);		  // Shift Mapping RAM Counter (0x00~0x3F)
  SetStartLine(0x00);			      // Set Mapping RAM Display Start Line (0x00~0x3F)
  Set_Charge_Pump(0x04);		    // Enable Embedded DC/DC Converter (0x00/0x04)
  SetAddressingMode(0x02);		  // Set Page Addressing Mode (0x00/0x01/0x02)
  Set_Segment_Remap(0x01);		  // Set SEG/Column Mapping     0x00左右反置 0x01正常
  Set_Common_Remap(0x08);			  // Set COM/Row Scan Direction 0x00上下反置 0x08正常
  Set_Common_Config(0x10);		  // Set Sequential Configuration (0x00/0x10)
  SetContrastControl(Brightness);	// Set SEG Output Current
  Set_Precharge_Period(0xF1);		// Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
  Set_VCOMH(0x40);			        // Set VCOM Deselect Level
  Set_Entire_Display(0x00);		  // Disable Entire Display On (0x00/0x01)
  Set_Inverse_Display(0x00);		// Disable Inverse Display On (0x00/0x01)  
  Set_Display_On_Off(0x01);		  // Display On (0x00/0x01)
  OLED_Fill(0x00);  //初始清屏
	OLED_Set_Pos(0,0); 
} 
Beispiel #2
0
/*********************LCD初始化************************************/
void OLED_Init(void)     
{
	OLED_DLY_ms(1);
	OLED_WrCmd(0xae);//--turn off oled panel
	OLED_WrCmd(0x00);//---set low column address
	OLED_WrCmd(0x10);//---set high column address
	OLED_WrCmd(0x40);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
	OLED_WrCmd(0x81);//--set contrast control register
	OLED_WrCmd(0xcf); // Set SEG Output Current Brightness
	OLED_WrCmd(0xa1);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常
	OLED_WrCmd(0xc8);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常
	OLED_WrCmd(0xa6);//--set normal display
	OLED_WrCmd(0xa8);//--set multiplex ratio(1 to 64)
	OLED_WrCmd(0x3f);//--1/64 duty
	OLED_WrCmd(0xd3);//-set display offset	Shift Mapping RAM Counter (0x00~0x3F)
	OLED_WrCmd(0x00);//-not offset
	OLED_WrCmd(0xd5);//--set display clock divide ratio/oscillator frequency
	OLED_WrCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
	OLED_WrCmd(0xd9);//--set pre-charge period
	OLED_WrCmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
	OLED_WrCmd(0xda);//--set com pins hardware configuration
	OLED_WrCmd(0x12);
	OLED_WrCmd(0xdb);//--set vcomh
	OLED_WrCmd(0x40);//Set VCOM Deselect Level
	OLED_WrCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
	OLED_WrCmd(0x02);//
	OLED_WrCmd(0x8d);//--set Charge Pump enable/disable
	OLED_WrCmd(0x14);//--set(0x10) disable
	OLED_WrCmd(0xa4);// Disable Entire Display On (0xa4/0xa5)
	OLED_WrCmd(0xa6);// Disable Inverse Display On (0xa6/a7) 
	OLED_WrCmd(0xaf);//--turn on oled panel
	OLED_Fill(0x00);  //初始清屏
	OLED_Set_Pos(0,0); 	
} 
Beispiel #3
0
void Oled_Displayinit()
{
	OLED_Fill(0);
	OLED_ShowStr(16,0,"Select mode",2);
	OLED_ShowStr(0,2,"  Fixed line  ",2);
	OLED_ShowStr(0,7,"OK             NEST",1);
}
/*****************************************************************************
 函 数 名  : OLED_Init
 功能描述  : OOLED初始化
 输入参数  : void
 输出参数  : NONE
 返 回 值  : NONE
*****************************************************************************/
void OLED_Init(void)
{
    uchar8 i;

    OLED |=OLED_SCL;
    OLED &=~OLED_RST;

    for(i = 0; i < 100; i++)
    {
        _nop();            //从上电到下面开始初始化要有足够的时间,即等待RC复位完毕
    }

    OLED |=OLED_RST;

    SetDisplayOnOff(0x00);     // Display Off (0x00/0x01)
    SetDisplayClock(0x80);     // Set Clock as 100 Frames/Sec
    SetMultiplexRatio(0x3F);   // 1/64 Duty (0x0F~0x3F)
    SetDisplayOffset(0x00);    // Shift Mapping RAM Counter (0x00~0x3F)
    SetStartLine(0x00);        // Set Mapping RAM Display Start Line (0x00~0x3F)
    SetChargePump(0x04);       // Enable Embedded DC/DC Converter (0x00/0x04)
    SetAddressingMode(0x02);   // Set Page Addressing Mode (0x00/0x01/0x02)
    SetSegmentRemap(0x01);     // Set SEG/Column Mapping     0x00左右反置 0x01正常
    SetCommonRemap(0x08);      // Set COM/Row Scan Direction 0x00上下反置 0x08正常
    SetCommonConfig(0x10);     // Set Sequential Configuration (0x00/0x10)
    SetContrastControl(0xCF);  // Set SEG Output Current
    SetPrechargePeriod(0xF1);  // Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
    SetVCOMH(0x40);            // Set VCOM Deselect Level
    SetEntireDisplay(0x00);    // Disable Entire Display On (0x00/0x01)
    SetInverseDisplay(0x00);   // Disable Inverse Display On (0x00/0x01)
    SetDisplayOnOff(0x01);     // Display On (0x00/0x01)
    OLED_Fill(0x00);            // 初始清屏
    OLED_SetPos(0,0);

    return;
}
Beispiel #5
0
void  Get_ZeroGauss_OffsetXY( int16_t* pMField_X_Raw_Offset, int16_t* pMField_Y_Raw_Offset )
{

#define  NUM_CALIB_CIRCLES 1   
  // Calibration performed by taking 8 measurements 45deg apart, 
  // repeated NUM_CALIB_CIRCLES times

uint8_t i;
uint8_t		MField_X_LowByte, MField_X_HighByte;
uint8_t		MField_Y_LowByte, MField_Y_HighByte;
int16_t		MField_X_Raw, MField_Y_Raw;
int32_t		MField_X_Acc = 0, MField_Y_Acc = 0;
uint16_t 	ColorSequence[8] = {RED, WHITE, GREEN, BLUE, CYAN, ORANGE, LIGHT_BLUE, YELLOW } ;  


  // Display Instructions :
  OLED_PrintString("CALIBRATION\n\n");
  OLED_PrintString("Lay La BlueFrog flat\n");
  OLED_PrintString("Then rotate it 45 deg.\n  at each change of color:");
  Delay_ms(5000);

  // Go --- 8 equally spaced magnetic field measurements, repeatable n times per #define
  for (i=0; i < 8*NUM_CALIB_CIRCLES; i++)   
  {
          OLED_Fill( X_FULL_SCREEN/2 -20, Y_FULL_SCREEN/2-20, 40, 40, ColorSequence[i] );
          Delay_ms(2500);

	  Stm32_Led_ON();

          // SINGLE SHOT conversion : CTRL_REG3 @0x22 :   
          I2C2_WriteSingleReg(LIS3MDL_CHIPID, 0x22, 0x01);  // 0b00000001

          while ( (I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x27)& 0x08) != 0x08);  
                    // read status reg until it flags new XYZ data available

	  // Accumulate Results
	  MField_X_LowByte = I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x28);
	  MField_X_HighByte = I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x29);
	  MField_X_Raw =  
	         (int16_t)( (MField_X_HighByte <<8 ) | MField_X_LowByte );
	  MField_X_Acc += (int32_t)(MField_X_Raw);
	  MField_Y_LowByte = I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x2A);
	  MField_Y_HighByte = I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x2B);
	  MField_Y_Raw =  
	         (int16_t)( (MField_Y_HighByte <<8 ) | MField_Y_LowByte );
	  MField_Y_Acc += (int32_t)(MField_Y_Raw);

	  Stm32_Led_OFF();
   }
 
   *pMField_X_Raw_Offset =  (int16_t)(MField_X_Acc / i);
   *pMField_Y_Raw_Offset =  (int16_t)(MField_Y_Acc / i);

   GUI_DispStringAt("", 10, 90);
   OLED_PrintString("THANKS,\nCALIBRATION DONE !");
   Delay_ms(2000);
   OLED_Clear();

}
Beispiel #6
0
void State_Display(void)
{
    OLED_Fill(0x00); //清屏	
	  OLED_P8x16Str(30,3,"WelCome!");
//	OLED_P6x8Str(0,6,"THR:");
//	OLED_P6x8Str(63,5,"ROLL:");
//	OLED_P6x8Str(63,6,"PITCH:");
//  OLED_P6x8Str(0,7,"r");
//  OLED_P6x8Str(42,7,"p");	
//	OLED_P6x8Str(84,7,"y");	
}
Beispiel #7
0
int main()
{
    UART_InitTypeDef UART_InitStructure;

	SystemInit();
  /* Configure UART2 */
   	S_UART_Init(115200);
    
    conf.scl = I2C_PA_9;
    conf.sda = I2C_PA_10;

    I2C_Init(&conf);
    OLED_Init();
	
	
	OLED_Fill(0xFF);
	delay_ms(20);
	OLED_Fill(0x00);
	delay_ms(10);
    
	OLED_ShowStr(0,3,"Welcome to",1);
	OLED_ShowStr(0,4,"WIznet ^^",2);	

  } 
Beispiel #8
0
void  main1(void)
{
  
 OLED_Init();
  OLED_Fill(0x00);//黑屏
  car_init();
  
  OLED_P8x16Str(5,0,"test");
  
  
  
  //setup();
  //sd_read();
  
  while(1){
  sensor_accelerator_read();
  sensor_accelerator_calculate();
  char buffer [100] ;
  float  OutData[1];
   // OutData[0]=angle;
 // vcan_sendware((char *)OutData,sizeof(OutData));
  sprintf(buffer,"%d",(int)angle);
  //OLED_P8x16Str(5,0,"    ");

  //OLED_P8x16Str(6,0,buffer);
 //motor_left_pid(1);
 //motor_right_pid(0);
  angle_control(20);
  //sensor_electromagnet_read();
  
  //printf("%lld\n",electromagnet_L6);
  
  }

 
}
Beispiel #9
0
 /**
  * @brief  OLED_CLS,清屏
  * @param  无
	* @retval 无
  */
void OLED_CLS(void)//清屏
{
	OLED_Fill(0x00);
}
Beispiel #10
0
void OLED_Init(void)
{
	Virtual_I2C_init();
	Delay_ms(100); //这里的延时很重要
	
//	WriteCmd(0xAE); //display off
//	WriteCmd(0x20);	//Set Memory Addressing Mode	
//	WriteCmd(0x10);	//00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
//	WriteCmd(0xb0);	//Set Page Start Address for Page Addressing Mode,0-7
//	WriteCmd(0xc8);	//Set COM Output Scan Direction
//	WriteCmd(0x00); //---set low column address
//	WriteCmd(0x10); //---set high column address
//	WriteCmd(0x40); //--set start line address
//	WriteCmd(0x81); //--set contrast control register
//	WriteCmd(0x55); //亮度调节 0x00~0xff
//	WriteCmd(0xa1); //--set segment re-map 0 to 127
//	WriteCmd(0xa6); //--set normal display
//	WriteCmd(0xa8); //--set multiplex ratio(1 to 64)
//	WriteCmd(0x3F); //
//	WriteCmd(0xa4); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
//	WriteCmd(0xd3); //-set display offset
//	WriteCmd(0x00); //-not offset
//	WriteCmd(0xd5); //--set display clock divide ratio/oscillator frequency
//	WriteCmd(0xf0); //--set divide ratio
//	WriteCmd(0xd9); //--set pre-charge period
//	WriteCmd(0x22); //
//	WriteCmd(0xda); //--set com pins hardware configuration
//	WriteCmd(0x12);
//	WriteCmd(0xdb); //--set vcomh
//	WriteCmd(0x20); //0x20,0.77xVcc
//	WriteCmd(0x8d); //--set DC-DC enable
//	WriteCmd(0x14); //
//	WriteCmd(0xaf); //--turn on oled panel

	OLED_WrCmd(0xae);//--turn off oled panel
	OLED_WrCmd(0x00);//---set low column address
	OLED_WrCmd(0x10);//---set high column address
	OLED_WrCmd(0x40);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
	OLED_WrCmd(0x81);//--set contrast control register
	OLED_WrCmd(Brightness); // Set SEG Output Current Brightness
	OLED_WrCmd(0xa1);//--Set SEG/Column Mapping     0xa0???? 0xa1??
	OLED_WrCmd(0xc8);//Set COM/Row Scan Direction   0xc0???? 0xc8??
	OLED_WrCmd(0xa6);//--set normal display
	OLED_WrCmd(0xa8);//--set multiplex ratio(1 to 64)
	OLED_WrCmd(0x3f);//--1/64 duty
	OLED_WrCmd(0xd3);//-set display offset	Shift Mapping RAM Counter (0x00~0x3F)
	OLED_WrCmd(0x00);//-not offset
	OLED_WrCmd(0xd5);//--set display clock divide ratio/oscillator frequency
	OLED_WrCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
	OLED_WrCmd(0xd9);//--set pre-charge period
	OLED_WrCmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
	OLED_WrCmd(0xda);//--set com pins hardware configuration
	OLED_WrCmd(0x12);
	OLED_WrCmd(0xdb);//--set vcomh
	OLED_WrCmd(0x40);//Set VCOM Deselect Level
	OLED_WrCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
	OLED_WrCmd(0x02);//
	OLED_WrCmd(0x8d);//--set Charge Pump enable/disable
	OLED_WrCmd(0x14);//--set(0x10) disable
	OLED_WrCmd(0xa4);// Disable Entire Display On (0xa4/0xa5)
	OLED_WrCmd(0xa6);// Disable Inverse Display On (0xa6/a7) 
	OLED_WrCmd(0xaf);//--turn on oled panel
	OLED_Fill(0x00); //????
//	OLED_Set_Pos(0,0);
}
Beispiel #11
0
/*******************************************************************************
* Function Name  : main.
* Description    : Main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{

/* ================================================================ */
/* Board Initializations and Configurations except OLED             */
/* (clocks, I/Os, on-chip peripherals, on-board ICs)                */
/* ================================================================ */

    LBF_Board_Init();

    Red_Led_ON();

/* ================================================================ */
/* Optional initialization of Middleware libraries :                */
/* USBD drivers, FatFS File System, STemWin GUI                     */
/* ================================================================ */

    // UNCOMMENT IF YOU WELL BE USING ...:
  
    /* ... La BlueFrog as USB Mass Storage (Full Speed)             */
    /*     (based on ST-provided stack part of STM32 Cube offering  */
    // Delay_ms(1000);
    // LBF_LaunchUSB_MassStorage();
 
    /* ... the FAT File System (FatFS)                              */
    /*     (based on ChanN's FatFS included in STM32 Cube offering) */
    // LBF_FatFS_Init();

    /* ... the STemWin Graphical Library                            */
    /*     (based on Segger's emWin included in STM32 Cube offering)*/
    LBF_emWin_Init();


    Red_Led_OFF();



/* ================================================================ */
/*   Application Code Below                                         */
/* ================================================================ */

/* ==  User Declarations ========================================== */

uint16_t fconfig[11];  // configuration file to control some OLED parameters
GUI_MEMDEV_Handle hMemDevice;  //handle to a memory device


/* ==  Body              ========================================== */

   fconfig[0]=0xFFFF;  // to use default settings
   LBF_OLED_Init(fconfig);  
        //sets up OLED register and powers on OLED VDDH(13V) 


   OLED_Fill(0, 0, 160, 128, CYAN);

   Red_Led_ON();


  /*** Start Demo *******************************************************/

  /* Different options posible */ 
  /* Use Display Cache or Use Memory Device or use Banded Memory Device */
  /* With 32K SRAM only the latter allows to cover full screen */


  // =============================================================
  // == Using the dislay cache  ==================================

  // Usage of display cache can be enabled through parameters of function 
  // GUIDRV_FlexColor_SetFunc() called in LCDConf_FlexColor_LBF.c
  // found in library LBF_STemWin

  // !!! ISSUE !!!
  // XSIZE_PHYS x YSIZE_PHYS (defined in above files) need to be set to 160x128 
  // to hold full display. However at 16bpp that represents about 40BK
  // but available SRAM is only 32KB...
  // Work-Around: define a smaller display cache (XSIZE_PHYS, YSIZE_PHYS)
  // -- but will not allow to address full screen

  // Not much interest vs use of "Memory Device", below, anyway
/*
  GUI_SetFont(&GUI_Font20_1);
  GUI_SetTextMode(GUI_TM_TRANS);  // write with transparent background
  GUI_DispStringAt("Hello from La BlueFrog !", LCD_GetXSize()/8, LCD_GetYSize()/2);  
  Green_Led_ON();
*/


  // =============================================================
  // == Using a "Memory Device"  (refer to emWin documentation) 

  // Work with a centered 128x64 window    
  // (cannot cover full screen for same memory limitation as above)
  #define X_FULL_SCREEN  160
  #define Y_FULL_SCREEN  128
  #define MD_X_LEFT  (X_FULL_SCREEN -128)/2
  #define MD_X_RIGHT  160-MD_X_LEFT
  #define MD_Y_TOP   (Y_FULL_SCREEN -64)/2
  #define MD_Y_BOT    128-MD_Y_TOP


  // Create Memory Device (top left & bottom right coordinates) on Layer 0:
  GUI_SelectLayer(0);
  hMemDevice = GUI_MEMDEV_Create(MD_X_LEFT, MD_Y_TOP,  (MD_X_RIGHT-MD_X_LEFT+1), (MD_Y_BOT-MD_Y_TOP+1) );
      // Caution: 
      // Memory allocated by GUI_X_Config in GUIConf_LBF.c must be sufficient to fit MemDevice buffer
      // plus other needs of emWin
      // Else GUI_MEMDEV_Create will fail (returns 0) and operations will be done directly to screen

  // Activate it: 
  GUI_MEMDEV_Select(hMemDevice);

  // Draw Stuff   (refer to emWin documentation)
  GUI_DrawGradientRoundedH( MD_X_LEFT, MD_Y_TOP,  MD_X_RIGHT, MD_Y_BOT, 
                            10, // rounded corner radius
                            0xFF0000, 0xFFFF00); // red to yellow
  GUI_SetPenSize(6);
  GUI_DrawLine(MD_X_LEFT, MD_Y_TOP, MD_X_RIGHT, MD_Y_BOT);
  GUI_DrawLine(MD_X_LEFT, MD_Y_BOT, MD_X_RIGHT, MD_Y_TOP);

  GUI_SetFont(&GUI_Font13_1);
  GUI_SetColor(GUI_BLACK);
  GUI_SetTextMode(GUI_TM_TRANS);  // write with transparent background
  GUI_DispStringAt("Hello !\n", MD_X_LEFT+10, MD_Y_TOP+10 );  

  // Copy to display
  GUI_MEMDEV_CopyToLCD(hMemDevice);

  // Free memory
  GUI_MEMDEV_Delete(hMemDevice);


  // =============================================================
  // == Using a "Banded Memory Device"  (refer to emWin documentation) 
  // == (Banding, aka tiling, allows to cover full screen by processing
  // ==  a number of bands successively)

  //TODO
  // use function: GUI_MEMDEV_Draw (GUI_RECT * pRect, GUI_CALLBACK_VOID_P * pfDraw, 
  //                 void* pData, int NumLines, int Flags);



while(1);

 
}
Beispiel #12
0
void OLED_Clear(void)                 // 全部写上0
{
  OLED_Fill(0x00);
}
Beispiel #13
0
/*************************************************************************
*                           蓝宙电子工作室
*
*  函数名称:OLED_Init
*  功能说明:初始化函数
*  参数说明:无
*  函数返回:无
*  修改时间:2014-9-13
*  备    注:
*************************************************************************/
void OLED_Init(void)
{
  PORT_PCR_REG(PORTE_BASE_PTR, 1)=  0 ;
  PORT_PCR_REG(PORTE_BASE_PTR, 1)= PORT_PCR_MUX(1);
  GPIO_PDDR_REG(PTE_BASE_PTR) |= (1 << 1);
  GPIO_PDOR_REG(PTE_BASE_PTR) |=  (1<<(1));
  PORT_PCR_REG(PORTE_BASE_PTR, 2)=  0 ;
  PORT_PCR_REG(PORTE_BASE_PTR, 2)= PORT_PCR_MUX(1);
  GPIO_PDDR_REG(PTE_BASE_PTR) |= (1 << 2);
  GPIO_PDOR_REG(PTE_BASE_PTR) |=  (1<<(2));
  PORT_PCR_REG(PORTE_BASE_PTR, 3)=  0 ;
  PORT_PCR_REG(PORTE_BASE_PTR, 3)= PORT_PCR_MUX(1);
  GPIO_PDDR_REG(PTE_BASE_PTR) |= (1 << 3);
  GPIO_PDOR_REG(PTE_BASE_PTR) |=  (1<<(3));
  PORT_PCR_REG(PORTE_BASE_PTR, 4)=  0 ;
  PORT_PCR_REG(PORTE_BASE_PTR, 4)= PORT_PCR_MUX(1);
  GPIO_PDDR_REG(PTE_BASE_PTR) |= (1 << 4);
  GPIO_PDOR_REG(PTE_BASE_PTR) |=  (1<<(4));
  PORT_PCR_REG(PORTE_BASE_PTR, 5)=  0 ;
  PORT_PCR_REG(PORTE_BASE_PTR, 5)= PORT_PCR_MUX(1);
  GPIO_PDDR_REG(PTE_BASE_PTR) |= (1 << 5);
  GPIO_PDOR_REG(PTE_BASE_PTR) |=  (1<<(5));
 /* gpio_init (PTE1, GPO,HIGH);
  gpio_init (PTE2, GPO,HIGH);
  gpio_init (PTE3, GPO,HIGH);
  gpio_init (PTE4, GPO,HIGH);
  gpio_init (PTE5, GPO,LOW);*/
  
  OLED_SCL=1;
  OLED_CS = 0 ; ///使能信号端,拉低时正常使用
  OLED_RST=0;
  OLED_DLY_ms(100);
  OLED_RST=1;
  
  OLED_WrCmd(0xae);//--turn off oled panel
  OLED_WrCmd(0x00);//---set low column address
  OLED_WrCmd(0x10);//---set high column address
  OLED_WrCmd(0x40);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
  OLED_WrCmd(0x81);//--set contrast control register
  OLED_WrCmd(0xcf); // Set SEG Output Current Brightness
  OLED_WrCmd(0xa1);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常
  OLED_WrCmd(0xc8);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常
  OLED_WrCmd(0xa6);//--set normal display
  OLED_WrCmd(0xa8);//--set multiplex ratio(1 to 64)
  OLED_WrCmd(0x3f);//--1/64 duty
  OLED_WrCmd(0xd3);//-set display offset	Shift Mapping RAM Counter (0x00~0x3F)
  OLED_WrCmd(0x00);//-not offset
  OLED_WrCmd(0xd5);//--set display clock divide ratio/oscillator frequency
  OLED_WrCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
  OLED_WrCmd(0xd9);//--set pre-charge period
  OLED_WrCmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
  OLED_WrCmd(0xda);//--set com pins hardware configuration
  OLED_WrCmd(0x12);
  OLED_WrCmd(0xdb);//--set vcomh
  OLED_WrCmd(0x40);//Set VCOM Deselect Level
  OLED_WrCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
  OLED_WrCmd(0x02);//
  OLED_WrCmd(0x8d);//--set Charge Pump enable/disable
  OLED_WrCmd(0x14);//--set(0x10) disable
  OLED_WrCmd(0xa4);// Disable Entire Display On (0xa4/0xa5)
  OLED_WrCmd(0xa6);// Disable Inverse Display On (0xa6/a7)
  OLED_WrCmd(0xaf);//--turn on oled panel
  OLED_Fill(0x00);  //初始清屏
  //OLED_Set_Pos(0,0);
  //OLED_Fill(0x00);//黑屏 
  //OLED_DLY_ms(100); 
}