Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By Mario Mikočević
#19777 Heya,

after some datasheet reading found the culprit for display misbehaving,
in the init code was missing addressing mode and scrolling parts,
here is my init_OLED() as per datasheet ->
(both versions of Draw_* work now)

Code: Select allstatic void init_OLED(void) {

  SendCommand( 0xAE );  // Set Display Off

  SendCommand(0xD5);    // Set Display Clock Divide Ratio\Oscilator Frequency
  SendCommand(0x80);    // the suggested ratio 0x80

  SendCommand(0xA8);    // Set Multiplex Ratio
  SendCommand(0x3F);

  SendCommand(0xD3);    // Set Display Offset
  SendCommand(0x00);    // no offset

  SendCommand(0x40);    // Set Display Start Line

  SendCommand(0x8D);    // Set Charge Pump
  SendCommand(0x14);    // Vcc internal

  SendCommand(0xA1);    // Set Segment Re-Map

  SendCommand(0xC8);    // Set COM Output Scan Direction

  SendCommand(0xDA);    // Set COM Pins Hardware Configuration
  SendCommand(0x12);

  SendCommand(0x81);    // Set Contrast Control
  SendCommand(0xCF);    // internal

  SendCommand(0xD9);    // Set Pre-Charge Period
  SendCommand(0xF1);    // internal

  SendCommand(0xDB);    // Set VCOMH Deselect Level
  SendCommand(0x40);

  SendCommand(0xA4);    // Set Entire Display On/Off

  SendCommand(0xA6);    // Set Normal/Inverse Display

  SendCommand( 0x2E );  // Deactivate Scroll

  SendCommand( 0x20 );  // Set Memory Addressing Mode
  SendCommand( 0x00 );  // Horizontal Addressing Mode

  SendCommand( 0xAF );  // Set Display On

}


--
Mozz
User avatar
By danbicks
#20350 Hi ya Mozz,

Well done you. I did not have any issue's with original Init code, well done fixing yours. I agree have to be careful with board layouts as displays do vary with pin-out configurations. I have just arrived from China some new ESP8266-12E versions, I will be using these for the final version with MQTT control.

Keep up the good work.

Dans