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() {
}