Problem with 128*64 OLED

So I tried the Adafruit SSD1306 128*64 I2C example and worked flawlessly.

For that image, LCDAssistant and other programs return this array:

static const unsigned char PROGMEM test[] = { 
0x00, 0x18, 0x1C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0x00,
0x00, 0x06, 0x06, 0x07, 0x07, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00
};

But I just get gibberish on my screen. It doesn't work. BUT, if I introduce a bitmap pixel by pixel like:

static const unsigned char PROGMEM test[] = { 
B00000000,B11111110,
B00011000,B11111110,
B00111000,B00000110,
B01111000,B00000110,
B01111000,B00000110,
B00011000,B00000110,
B00011000,B00000110,
B00011000,B00000110,
B00011000,B00000110,
B01111110,B00000110,
B01111110,B00000110,
};

So, what am I doing wrong?

My code is:

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

static const unsigned char PROGMEM test[] = { 
/*B00000000,B11111110,
B00011000,B11111110,
B00111000,B00000110,
B01111000,B00000110,
B01111000,B00000110,
B00011000,B00000110,
B00011000,B00000110,
B00011000,B00000110,
B00011000,B00000110,
B01111110,B00000110,
B01111110,B00000110,*/

0x00, 0x18, 0x1C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0x00,
0x00, 0x06, 0x06, 0x07, 0x07, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00
};

#if (SSD1306_LCDHEIGHT != 64)
//#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

void setup()   {                
  Serial.begin(9600);

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done

  // Clear the buffer.
  display.clearDisplay();

  // miniature bitmap display
  display.drawBitmap(128-15, 0,  test, 16, 16, 1);
  display.display();
}


void loop() {
  
}

Go on. You have been a member for over a year. You have even made several posts.

Some graphics displays are organised as pixels horizontally e.g. one byte writes 8 pixels sideways.
16 bytes to draw columns 0-127 in row 0.

Other displays go vertically e.g. KS0108, SSD1306, ...

One byte writes 8 pixels vertically e.g. 128 bytes draws 128x8 strip of pixels. Columns 0-127, rows 0-7.
The next 128 bytes draw another strip in rows 8-15, ...

As a general rule, you do not need to worry how the low level bytes are written. Just read the library documentation. Obey the format specified for the bitmap. Some libraries might accept multiple formats. Then do the appropriate mangling for the hardware.

David.

Ah nevermind, I was just being retarded and the LCD Assistant was set on vertical isntead of horizontal.

Now my current problem is that while I want to draw this:

I get this instead:

Which is strange, because I theoretically bought a 128*64 display, and it looks like one. Actually, it seems like it's skipping half of lines.

Solution:

Go to your libraries folder > Adafruit_SSD1306 > Open Adafruit_SSD1306.h
Now go to lines 72 to 76. Comment all three and uncomment the one for the device you have. In my case it's a 128*64 display, therefore my code need to be like this:

    -----------------------------------------------------------------------*/
   #define SSD1306_128_64
//   #define SSD1306_128_32
//   #define SSD1306_96_16
/*=========================================================================*/

Problem solved!