void OLED_Init()
{
unsigned char i;
RES=0;
for(i=0;i<200;i++)
{
uDelay(200);
}
RES=1;
Set_Display_On_Off(0xAE); // Display Off (0xAE/0xAF)
Set_Display_Clock(0xA0); // Set Clock as 80 Frames/Sec
Set_Multiplex_Ratio(0x3F); // 1/64 Duty (0x0F~0x3F)
Set_Display_Offset(0x00); // Shift Mapping RAM Counter (0x00~0x3F)
Set_Start_Line(0x00); // Set Mapping RAM Display Start Line (0x00~0x3F)
Set_Master_Config(0x8E); // Disable Embedded DC/DC Converter (0x8E/0x8F)
Set_Area_Color(0x05); // Set Monochrome & Low Power Save Mode
Set_Addressing_Mode(0x02); // Set Page Addressing Mode (0x00/0x01/0x02)
Set_Segment_Remap(0xA1); // Set SEG/Column Mapping (0xA0/0xA1)
Set_Common_Remap(0xC8); // Set COM/Row Scan Direction (0xC0/0xC8)
Set_Common_Config(0x12); // Set Alternative Configuration (0x02/0x12)
Set_LUT(0x3F,0x3F,0x3F,0x3F); // Define All Banks Pulse Width as 64 Clocks
Set_Contrast_Control(Brightness); // Set SEG Output Current
Set_Area_Brightness(Brightness); // Set Brightness for Area Color Banks
Set_Precharge_Period(0x82); // Set Pre-Charge as 8 Clocks & Discharge as 2 Clocks
Set_VCOMH(0x3C); // Set VCOM Deselect Level
Set_Entire_Display(0xA4); // Disable Entire Display On (0xA4/0xA5)
Set_Inverse_Display(0xA6); // Disable Inverse Display On (0xA6/0xA7)
Fill_RAM(0x00); // Clear Screen
Set_Display_On_Off(0xAF); // Display On (0xAE/0xAF)
}