Ejemplo n.º 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); 
} 
Ejemplo n.º 2
0
void LED_Init(void)        
{
	unsigned char i;
        LEDPIN_Init();
//	LED_PORT=0X0F;
	//LED_SCLH;;;		
	//LED_RSTL;;;
        digitalWrite(SCL_PIN,HIGH);;;
        digitalWrite(RST_PIN,LOW);;;
//	for(i=0;i<100;i++)asm("nop");     	
        LED_DLY_ms(50);
	//LED_RSTH;;;
        digitalWrite(RST_PIN,HIGH);
	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  
	Set_Common_Remap(0x08);	  // Set COM/Row Scan Direction 
	Set_Common_Config(0x10);	  // Set Sequential Configuration (0x00/0x10)
	SetContrastControl(0xCF); // 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)
	LED_Fill(0x00);                               //clear all
	LED_Set_Pos(0,0); 	
} 
Ejemplo n.º 3
0
void LED_Init(void) {

	LEDPIN_Init();

	/*while(1)
			{
				//MB_Sleep(1000);
				LED_WrCmd(0xaa);
				//MB_Sleep(1000);
				XGpio_DiscreteWrite(&led2, reset_CHANNEL, 0x1);
				XGpio_DiscreteWrite(&led1, reset_CHANNEL, 0x0);
			}*/
	XGpio_DiscreteWrite(&reset, reset_CHANNEL, 0x0);
	//usleep(800);
	MB_Sleep(80);
	XGpio_DiscreteWrite(&reset, reset_CHANNEL, 0x1);
	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(0xCF); // 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)
	LED_Fill(0x00);                               //初始清屏
	LED_Set_Pos(0, 0);
}
void OLED_Configuration(void)        
{
    GPIO_InitTypeDef gpio;
	
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE);

	gpio.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;
	gpio.GPIO_Mode = GPIO_Mode_OUT;
	gpio.GPIO_OType = GPIO_OType_PP;
	gpio.GPIO_Speed = GPIO_Speed_100MHz;
	GPIO_Init(GPIOC, &gpio);    

	LCD_SCL_1;
	LCD_RST_0;
	delay_ms(200);
	LCD_RST_1;

    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     
    Set_Common_Remap(0x08);			// Set COM/Row Scan Direction 
    Set_Common_Config(0x10);		// Set Sequential Configuration (0x00/0x10)
    SetContrastControl(0xCF);	    // 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_Clear();
	  LCD_Set_Pos(0,0);
}
Ejemplo n.º 5
0
void oled_reinit(uint8_t clock,uint8_t multiplex,uint8_t functionselect,uint8_t vsl,uint8_t phaselen,uint8_t prechargevolt,uint8_t prechargeperiod,uint8_t vcomh) {
    Set_Display_Off();

    // cuts power to the display
    gpio_write_bit(PIN_MAP[LCD_PWR_GPIO].gpio_device,
                   PIN_MAP[LCD_PWR_GPIO].gpio_bit,
                   0);

    delay_us(250000); // give it 250ms to discharge, hard wait; prevent issues with switch bounce


    /* Set the data/command pin to be a GPIO */
    gpio_set_mode(PIN_MAP[LCD_DC_GPIO].gpio_device,
                  PIN_MAP[LCD_DC_GPIO].gpio_bit,
                  GPIO_OUTPUT_PP);
    gpio_write_bit(PIN_MAP[LCD_DC_GPIO].gpio_device,
                   PIN_MAP[LCD_DC_GPIO].gpio_bit,
                   0);

    /* Set chip-select to be a GPIO */
    gpio_set_mode(PIN_MAP[LCD_CS_GPIO].gpio_device,
                  PIN_MAP[LCD_CS_GPIO].gpio_bit,
                  GPIO_OUTPUT_PP);
    gpio_write_bit(PIN_MAP[LCD_CS_GPIO].gpio_device,
                   PIN_MAP[LCD_CS_GPIO].gpio_bit,
                   0);

    /* Turn the display on */
    gpio_set_mode(PIN_MAP[LCD_PWR_GPIO].gpio_device,
                  PIN_MAP[LCD_PWR_GPIO].gpio_bit,
                  GPIO_OUTPUT_PP);
    gpio_write_bit(PIN_MAP[LCD_PWR_GPIO].gpio_device,
                   PIN_MAP[LCD_PWR_GPIO].gpio_bit,
                   1);

    delay_us(2000); /* Documentation says at least 1ms */

    /* Reset the display */
    gpio_set_mode(PIN_MAP[LCD_RES_GPIO].gpio_device,
                  PIN_MAP[LCD_RES_GPIO].gpio_bit,
                  GPIO_OUTPUT_PP);
    gpio_write_bit(PIN_MAP[LCD_RES_GPIO].gpio_device,
                   PIN_MAP[LCD_RES_GPIO].gpio_bit,
                   0);
    delay_us(20); /* Documentation says at least 2us */
    gpio_write_bit(PIN_MAP[LCD_RES_GPIO].gpio_device,
		   PIN_MAP[LCD_RES_GPIO].gpio_bit,
		   1);



    //==============================

    Set_Command_Lock(0x12);         // Unlock Driver IC (0x12/0x16/0xB0/0xB1)
    Set_Command_Lock(0xB1);         // Unlock All Commands (0x12/0x16/0xB0/0xB1)
    Set_Display_Off();
    Set_Display_Clock(clock);        // Set Clock as 90 Frames/Sec
    Set_Multiplex_Ratio(multiplex);      // 1/128 Duty (0x0F~0x7F)// 7F
    Set_Display_Offset(0x00);       // Shift Mapping RAM Counter (0x00~0x7F)
    Set_Start_Line(0x00);           // Set Mapping RAM Display Start Line (0x00~0x7F)
    Set_Remap_Format(0x74);         // Set Horizontal Address Increment
                                    //     Column Address 0 Mapped to SEG0
                                    //     Color Sequence D[15:0]=[RRRRR:GGGGGG:BBBBB]
                                    //     Scan from COM127 to COM0
                                    //     Enable COM Split Odd Even
                                    //     65,536 Colors Mode (0x74)
                                    //     * 262,144 Colors Mode (0xB4)
    Set_GPIO(0x00);                 // Disable GPIO Pins Input

    Set_Function_Selection(functionselect);   // Disable Internal VDD Regulator
                                    // Select 8-bit Parallel Interface
    Set_VSL(vsl);                  // Enable External VSL
    Set_Gray_Scale_Table();         // Set Pulse Width for Gray Scale Table
    Set_Phase_Length(0x32);         // Set Phase 1 as 5 Clocks & Phase 2 as 3 Clocks
    Set_Display_Enhancement(0xA4);  // Enhance Display Performance
    Set_Precharge_Voltage(prechargevolt);    // Set Pre-Charge Voltage Level as 0.50*VCC, 1c in 4D
    Set_Precharge_Period(prechargeperiod);     // Set Second Pre-Charge Period as 1 Clock,
    Set_VCOMH(vcomh);                // Set Common Pins Deselect Voltage Level as 0.82*VCC. 1F in 4D
    Set_Display_Mode(0x02);         // Normal Display Mode (0x00/0x01/0x02/0x03)

    CLS(0);                          // Clear Screen

    delay_us(1000);

    Set_Display_On();

}
Ejemplo n.º 6
0
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//  Initialization
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void oled_init(void) {
    /* Set the data/command pin to be a GPIO */
    gpio_set_mode(PIN_MAP[LCD_DC_GPIO].gpio_device,
                  PIN_MAP[LCD_DC_GPIO].gpio_bit,
                  GPIO_OUTPUT_PP);
    gpio_write_bit(PIN_MAP[LCD_DC_GPIO].gpio_device,
                   PIN_MAP[LCD_DC_GPIO].gpio_bit,
                   0);

    /* Set chip-select to be a GPIO */
    gpio_set_mode(PIN_MAP[LCD_CS_GPIO].gpio_device,
                  PIN_MAP[LCD_CS_GPIO].gpio_bit,
                  GPIO_OUTPUT_PP);
    gpio_write_bit(PIN_MAP[LCD_CS_GPIO].gpio_device,
                   PIN_MAP[LCD_CS_GPIO].gpio_bit,
                   0);

    /* Turn the display on */
    gpio_set_mode(PIN_MAP[LCD_PWR_GPIO].gpio_device,
                  PIN_MAP[LCD_PWR_GPIO].gpio_bit,
                  GPIO_OUTPUT_PP);
    gpio_write_bit(PIN_MAP[LCD_PWR_GPIO].gpio_device,
                   PIN_MAP[LCD_PWR_GPIO].gpio_bit,
                   1);

    delay_us(2000); /* Documentation says at least 1ms */

    /* Reset the display */
    gpio_set_mode(PIN_MAP[LCD_RES_GPIO].gpio_device,
                  PIN_MAP[LCD_RES_GPIO].gpio_bit,
                  GPIO_OUTPUT_PP);
    gpio_write_bit(PIN_MAP[LCD_RES_GPIO].gpio_device,
                   PIN_MAP[LCD_RES_GPIO].gpio_bit,
                   0);
    delay_us(20); /* Documentation says at least 2us */
    gpio_write_bit(PIN_MAP[LCD_RES_GPIO].gpio_device,
		   PIN_MAP[LCD_RES_GPIO].gpio_bit,
		   1);

    //==============================

    Set_Command_Lock(0x12);         // Unlock Driver IC (0x12/0x16/0xB0/0xB1)
    Set_Command_Lock(0xB1);         // Unlock All Commands (0x12/0x16/0xB0/0xB1)
    Set_Display_Off();
    Set_Display_Clock(0xF1);        // Set Clock as 90 Frames/Sec
    Set_Multiplex_Ratio(0x7F);      // 1/128 Duty (0x0F~0x7F)// 7F
    Set_Display_Offset(0x00);       // Shift Mapping RAM Counter (0x00~0x7F)

    Set_Start_Line(0x00);           // Set Mapping RAM Display Start Line (0x00~0x7F)
    Set_Remap_Format(0x74);         // Set Horizontal Address Increment
                                    //     Column Address 0 Mapped to SEG0
                                    //     Color Sequence D[15:0]=[RRRRR:GGGGGG:BBBBB]
                                    //     Scan from COM127 to COM0
                                    //     Enable COM Split Odd Even
                                    //     65,536 Colors Mode (0x74)
                                    //     * 262,144 Colors Mode (0xB4)
    Set_GPIO(0x00);                 // Disable GPIO Pins Input

    Set_Function_Selection(0x01);   // Disable Internal VDD Regulator
                                    // Select 8-bit Parallel Interface
    Set_VSL(0x01);                  // Enable External VSL
    //Set_Contrast_Color(0x80,0x80,0x80); // Set Contrast of Color A (Red)
    Set_Contrast_Color(0xC8,0x80,0xC8); // Set Contrast of Color A (Red)
                                    // Set Contrast of Color B (Green)
                                    // Set Contrast of Color C (Blue)
    Set_Master_Current(Brightness);     // Set Scale Factor of Segment Output Current Control
    Set_Gray_Scale_Table();         // Set Pulse Width for Gray Scale Table
    Set_Phase_Length(0x32);         // Set Phase 1 as 5 Clocks & Phase 2 as 3 Clocks
    Set_Display_Enhancement(0xA4);  // Enhance Display Performance
    Set_Precharge_Voltage(0x17);    // Set Pre-Charge Voltage Level as 0.50*VCC
    Set_Precharge_Period(0x08);     // Set Second Pre-Charge Period as 1 Clock
    Set_Master_Current(Brightness);     // Set Scale Factor of Segment Output Current Control
    Set_Gray_Scale_Table();         // Set Pulse Width for Gray Scale Table
    Set_Phase_Length(0x32);         // Set Phase 1 as 5 Clocks & Phase 2 as 3 Clocks
    Set_Display_Enhancement(0xA4);  // Enhance Display Performance
    Set_Precharge_Voltage(0x17);    // Set Pre-Charge Voltage Level as 0.50*VCC
    Set_Precharge_Period(0x08);     // Set Second Pre-Charge Period as 1 Clock
    Set_VCOMH(0x05);                // Set Common Pins Deselect Voltage Level as 0.82*VCC
    Set_Display_Mode(0x02);         // Normal Display Mode (0x00/0x01/0x02/0x03)

    CLS(0);                          // Clear Screen

    delay_us(1000);

    Set_Display_On();

}