Skip to content

add 64x32 oled support #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

> We just released version 4.0.0. Please have a look at our [upgrade guide](UPGRADE-4.0.md)

This is a driver for SSD1306 128x64 and 128x32 OLED displays running on the Arduino/ESP8266 & ESP32 and mbed-os platforms.
This is a driver for SSD1306 128x64, 128x32, 64x48 and 64x32 OLED displays running on the Arduino/ESP8266 & ESP32 and mbed-os platforms.
Can be used with either the I2C or SPI version of the display.

You can either download this library as a zip file and unpack it to your Arduino/libraries folder or find it in the Arduino library manager under "ESP8266 and ESP32 Oled Driver for SSD1306 display". For mbed-os a copy of the files are available as an mbed-os library.
Expand Down
13 changes: 10 additions & 3 deletions src/OLEDDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,10 @@ void OLEDDisplay::setGeometry(OLEDDISPLAY_GEOMETRY g, uint16_t width, uint16_t h
this->displayWidth = 64;
this->displayHeight = 48;
break;
case GEOMETRY_64_32:
this->displayWidth = 64;
this->displayHeight = 32;
break;
case GEOMETRY_RAWMODE:
this->displayWidth = width > 0 ? width : 128;
this->displayHeight = height > 0 ? height : 64;
Expand All @@ -877,7 +881,10 @@ void OLEDDisplay::sendInitCommands(void) {
sendCommand(this->height() - 1);
sendCommand(SETDISPLAYOFFSET);
sendCommand(0x00);
sendCommand(SETSTARTLINE);
if(geometry == GEOMETRY_64_32)
sendCommand(0x00);
else
sendCommand(SETSTARTLINE);
sendCommand(CHARGEPUMP);
sendCommand(0x14);
sendCommand(MEMORYMODE);
Expand All @@ -886,15 +893,15 @@ void OLEDDisplay::sendInitCommands(void) {
sendCommand(COMSCANINC);
sendCommand(SETCOMPINS);

if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48) {
if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48 || geometry == GEOMETRY_64_32) {
sendCommand(0x12);
} else if (geometry == GEOMETRY_128_32) {
sendCommand(0x02);
}

sendCommand(SETCONTRAST);

if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48) {
if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48 || geometry == GEOMETRY_64_32) {
sendCommand(0xCF);
} else if (geometry == GEOMETRY_128_32) {
sendCommand(0x8F);
Expand Down
1 change: 1 addition & 0 deletions src/OLEDDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ enum OLEDDISPLAY_GEOMETRY {
GEOMETRY_128_64 = 0,
GEOMETRY_128_32 = 1,
GEOMETRY_64_48 = 2,
GEOMETRY_64_32 = 3,
GEOMETRY_RAWMODE = 4
};

Expand Down
2 changes: 1 addition & 1 deletion src/SSD1306Spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class SSD1306Spi : public OLEDDisplay {
sendCommand(PAGEADDR);
sendCommand(0x0);

if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48) {
if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48 || geometry == GEOMETRY_64_32 ) {
sendCommand(0x7);
} else if (geometry == GEOMETRY_128_32) {
sendCommand(0x3);
Expand Down