0.66 inch OLED Module 64×48 I2C SSD1317
I have this tiny 0.66in OLED display bought from AliExpress, The store page says it is using SSD1317 driver but I could not find anything for SSD1317 except for its datasheet also the datasheet used a 128×64 display, not the one I am using which is 64×48.
I have used it with U8G3 library with the constructor U8G2_SSD1306_64X48_ER_F_SW_I2C
with no issue https://www.youtube.com/watch?v=nvjk07Py2w4
Which made me think it should also work with Adafruit’s SSD1306 library. One immediate issue is there is no option to choose 64×48 resolution and only 3 options which also seem to be already depricated. The new way was to initialize the display with the params width and height in the construction function.
U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx;
#define SCREEN_WIDTH 64 // OLED display width, in pixels
#define SCREEN_HEIGHT 48 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS \
0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
This actually works but the display is completely useless as there is a huge offset, with the right half of the screen just filled with random dots and every other row is ignored as seen in the image below.
I went into Adafruit library files and found out that although the choice of screen size is deprecated, there is still a block of code where the following are based on the definition of screen sizes.
if ((WIDTH == 128) && (HEIGHT == 32)) {
comPins = 0x02;
contrast = 0x8F;
} else if ((WIDTH == 128) && (HEIGHT == 64)) {
comPins = 0x12;
contrast = (vccstate == SSD1306_EXTERNALVCC) ? 0x9F : 0xCF;
} else if ((WIDTH == 96) && (HEIGHT == 16)) {
comPins = 0x2; // ada x12
contrast = (vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0xAF;
} else {
// Other screen varieties -- TBD
}
I updated the last else block and added the following:
comPins = 0x12;
contrast = 0xCF;
Then the skipping of rows was fixed so there was no offset in the vertical direction.
The horizontal offset is still there. The x position of the icon is 32px but it seems to just appear at the left edge which makes me think if I could offset this by 32px, the right half of random stuff will be gone and the full screen can be used.
Can anyone suggest, where could I look to make this change?