void OLED_Init(void)
{
// delay_ms(100); //这里的延时很重要
//
// WriteCmd(0xAE); //display off
//
// WriteCmd(0xd5); //Set Memory Addressing Mode
// WriteCmd(0x10); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
//
// WriteCmd(0xa8); //Set Page Start Address for Page Addressing Mode,0-7
// WriteCmd(0x1f); //Set COM Output Scan Direction
//
// WriteCmd(0xd3); //---set low column address
// WriteCmd(0x00); //---set high column address
//
// WriteCmd(0x40); //--set start line address
//
// WriteCmd(0xad); //--set contrast control register
// WriteCmd(0x8e); //亮度调节 0x00~0xff
//
// WriteCmd(0xd8); //--set segment re-map 0 to 127
// WriteCmd(0x05); //--set normal display
//
// WriteCmd(0xa1); //--set multiplex ratio(1 to 64)
//
// WriteCmd(0xc8); //
//
// WriteCmd(0xda); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
// WriteCmd(0x12); //-set display offset
//
// WriteCmd(0x91); //-not offset
// WriteCmd(0x3f); //--set display clock divide ratio/oscillator frequency
// WriteCmd(0x3f); //--set divide ratio
// WriteCmd(0x3f); //--set pre-charge period
// WriteCmd(0x3f); //
//
// WriteCmd(0x81);
// WriteCmd(0xef); //--set vcomh
//
// WriteCmd(0xd9); //0x20,0.77xVcc
// WriteCmd(0xd2); //--turn on oled panel
//
// WriteCmd(0xdb); //--turn on oled panel
// WriteCmd(0x08); //--turn on oled panel
//
// WriteCmd(0xa4); //--turn on oled panel
//
// WriteCmd(0xa6); //--turn on oled panel
//
// WriteCmd(0xaf); //--turn on oled panel
//delay_ms(10); //这里的延时很重要
WriteCmd(0xAE ); //关闭显示
WriteCmd(0xD5 ); //设置时钟分频因子,震荡频率
WriteCmd(80 ); //[3:0],分频因子;[7:4],震荡频率
WriteCmd(0xA8 ); //设置驱动路数
WriteCmd(0x1f );
WriteCmd(0X3F ); //默认0X3F(1/64)
WriteCmd(0xD3 ); //设置显示偏移
WriteCmd(0X00 ); //默认为0
WriteCmd(0x40 ); //设置显示开始行 [5:0],行数.
WriteCmd(0x8D ); //电荷泵设置
WriteCmd(0x14 ); //bit2,开启/关闭
WriteCmd(0x20 ); //设置内存地址模式
WriteCmd(0x02 ); //[1:0],00,列地址模式;01,行地址模式;10,页地址模式;默认10;
WriteCmd(0xA1 ); //段重定义设置,bit0:0,0->0;1,0->127;
WriteCmd(0xC0 ); //设置COM扫描方向;bit3:0,普通模式;1,重定义模式 COM[N-1]->COM0;N:驱动路数
WriteCmd(0xDA ); //设置COM硬件引脚配置 这部分在一开始出现问题 2016.07.10
WriteCmd(0x00 ); //[5:4]配置
WriteCmd(0x81 ); //对比度设置
WriteCmd(0x7f ); //1~255;默认0X7F (亮度设置,越大越亮)
// WriteCmd(0xc2);
WriteCmd(0xD9 ); //设置预充电周期
WriteCmd(0xf1 ); //[3:0],PHASE 1;[7:4],PHASE 2;
WriteCmd(0xDB ); //设置VCOMH 电压倍率
WriteCmd(0x00 ); //[6:4] 000,0.65*vcc;001,0.77*vcc;011,0.83*vcc;
WriteCmd(0xA4 ); //全局显示开启;bit0:1,开启;0,关闭;(白屏/黑屏)
WriteCmd(0xA6 ); //设置显示方式;bit0:1,反相显示;0,正常显示
WriteCmd(0xAF ); //开启显示
} |