SSD1306 ASCII - Rotate 180

(I'm using a 0.96" (or 1.3") I2C OLED.)

I absolutely love this library. It is small and does everything I want. However, during the PCB design process and enclosure layout, I realized that the pins (that come presoldered) will possibly touch the PCB if the OLED is "right-side up."

However, if I rotate the OLED so that it's "upside down," then the pins won't touch and I'll have no clearance issues.

I'm pretty sure that the library doesn't natively support this; I'm also hoping I don't need the 1k buffer to be able to do so.

Is it possible? Am I barking up a bad tree?

Thanks in advance, Kyle

Look at command(0xA1) and command(0xDA) in the data sheet. You should be able to add these to your setup()

Untested.

David.

David,

Thanks for the direction! I wouldn’t have thought to look there.

After Googling a bit more, I found a guy who said to do this in the Adafruit library (notice the comment slashes):

//ssd1306_command(SSD1306_SEGREMAP | 0x1);
ssd1306_command(SSD1306_SEGREMAP);

//ssd1306_command(SSD1306_COMSCANDEC);
ssd1306_command(SSD1306_COMSCANINC);

I’m going to try adding a new DevType/MEM_TYPE in the ASCII library that uses these init commands; then I’ll report back and see how it went.

U8g2 includes a text only/ASCII library called u8x8. It has similar advantages compared with other ASCII libs for graphics OLEDs: Small size and fast. U8x8 support 180 degree rotation.

Oliver

olikraus: U8g2 includes a text only/ASCII library called u8x8. It has similar advantages compared with other ASCII libs for graphics OLEDs: Small size and fast. U8x8 support 180 degree rotation.

Oliver

Hey Oliver,

Thanks for the input. I'm already knee-deep in the other library, and it's been serving me VERY well so far. If I ever have to switch because of something, I'll head over to U8x8.

OK, so here's what I found that worked in case anyone else stumbles across this. I created a new DevType with the following setup:

static const uint8_t MEM_TYPE SH1106_128x64Invinit[] = {
    SSD1306_DISPLAYOFF,
    SSD1306_SETSTARTPAGE | 0X0,            // set page address
    SSD1306_SETCONTRAST, 0x80,             // 128
    SSD1306_SEGREMAP,                // set segment remap
    SSD1306_NORMALDISPLAY,                 // normal / reverse
    SSD1306_SETMULTIPLEX, 0x3F,            // ratio 64
    SH1106_SET_PUMP_MODE, SH1106_PUMP_ON,  // set charge pump enable
    SH1106_SET_PUMP_VOLTAGE | 0X2,         // 8.0 volts
    SSD1306_COMSCANINC,                    // Com scan direction
    SSD1306_SETDISPLAYOFFSET, 0X00,        // set display offset
    SSD1306_SETDISPLAYCLOCKDIV, 0X80,      // set osc division
    SSD1306_SETPRECHARGE, 0X1F,            // set pre-charge period
    SSD1306_SETCOMPINS, 0X12,              // set COM pins
    SSD1306_SETVCOMDETECT,  0x40,          // set vcomh
    SSD1306_DISPLAYON
};
/** Initialize a 128x64 oled SH1106 display. */
static const DevType MEM_TYPE SH1106_128x64Inv = {
    SH1106_128x64Invinit,
    sizeof(SH1106_128x64Invinit),
    128,
    64,
    2    // SH1106 is a 132x64 controller.  Use middle 128 columns.
};

I modified the SSD1306_COMSCANINC vs SSD1306_COMSCANDEC and SSD1306_SEGREMAP vs. SSD1306_SEGREMAP | 0X1. That's it!

Thanks again!