0
\$\begingroup\$

I have an I2C 128x64 OLED display here. I've tried using Arduino and everything works flawlessly. Now I'm trying this but just writing in straight-up C code. Majority of the display is garbled up.

I've seen a post somewhere with a near similar situation but that is for 128x32 and the garbled up portion is horizontally aligned. The post wasn't helpful anyway so I'm posting here. enter image description here I'm using the library from this repository. https://github.com/Sylaina/oled-display

I believe it is an issue with my initialization sequence. I've extracted it out from lcd.c here.

const uint8_t init_sequence [] PROGMEM = {    // Initialization Sequence
    LCD_DISP_OFF,    // Display OFF (sleep mode)
    0x20, 0b00,        // Set Memory Addressing Mode
    // 00=Horizontal Addressing Mode; 01=Vertical Addressing Mode;
    // 10=Page Addressing Mode (RESET); 11=Invalid
    0xB0,            // Set Page Start Address for Page Addressing Mode, 0-7
    0xC8,            // Set COM Output Scan Direction
    0x00,            // --set low column address
    0x10,            // --set high column address
    0x40,            // --set start line address
    0x81, 0x3F,        // Set contrast control register
    0xA1,            // Set Segment Re-map. A0=address mapped; A1=address 127 mapped.
    0xA6,            // Set display mode. A6=Normal; A7=Inverse
    0xA8, 0x3F,        // Set multiplex ratio(1 to 64)
    0xA4,            // Output RAM to Display
    // 0xA4=Output follows RAM content; 0xA5,Output ignores RAM content
    0xD3, 0x00,        // Set display offset. 00 = no offset
    0xD5,            // --set display clock divide ratio/oscillator frequency
    0xF0,            // --set divide ratio
    0xD9, 0x22,        // Set pre-charge period
    0xDA, 0x12,        // Set com pins hardware configuration
    0xDB,            // --set vcomh
    0x20,            // 0x20,0.77xVcc
    0x8D, 0x14,        // Set DC-DC enable              
};
\$\endgroup\$
  • 1
    \$\begingroup\$ Isn't the Arduino using the C code, also? \$\endgroup\$ – Marko Buršič Aug 25 at 8:39
  • \$\begingroup\$ arduino is c++ fwiw (avr-gcc to be precise), but honestly, whatever library worked in arduino should be easy enough to port to plain old C. Arduino and all its libraries are open source after all. \$\endgroup\$ – vicatcu Aug 25 at 13:50
  • \$\begingroup\$ if you must use github.com/Sylaina/oled-display why not post an issue to that repository? \$\endgroup\$ – vicatcu Aug 25 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.