Skip to content

Commit 78bdcfb

Browse files
authored
Add support for 64x32 OLED (#314)
1 parent b17fccd commit 78bdcfb

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
> We just released version 4.0.0. Please have a look at our [upgrade guide](UPGRADE-4.0.md)
66
7-
This is a driver for SSD1306 128x64 and 128x32 OLED displays running on the Arduino/ESP8266 & ESP32 and mbed-os platforms.
7+
This is a driver for SSD1306 128x64, 128x32, 64x48 and 64x32 OLED displays running on the Arduino/ESP8266 & ESP32 and mbed-os platforms.
88
Can be used with either the I2C or SPI version of the display.
99

1010
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.

src/OLEDDisplay.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,10 @@ void OLEDDisplay::setGeometry(OLEDDISPLAY_GEOMETRY g, uint16_t width, uint16_t h
859859
this->displayWidth = 64;
860860
this->displayHeight = 48;
861861
break;
862+
case GEOMETRY_64_32:
863+
this->displayWidth = 64;
864+
this->displayHeight = 32;
865+
break;
862866
case GEOMETRY_RAWMODE:
863867
this->displayWidth = width > 0 ? width : 128;
864868
this->displayHeight = height > 0 ? height : 64;
@@ -877,7 +881,10 @@ void OLEDDisplay::sendInitCommands(void) {
877881
sendCommand(this->height() - 1);
878882
sendCommand(SETDISPLAYOFFSET);
879883
sendCommand(0x00);
880-
sendCommand(SETSTARTLINE);
884+
if(geometry == GEOMETRY_64_32)
885+
sendCommand(0x00);
886+
else
887+
sendCommand(SETSTARTLINE);
881888
sendCommand(CHARGEPUMP);
882889
sendCommand(0x14);
883890
sendCommand(MEMORYMODE);
@@ -886,15 +893,15 @@ void OLEDDisplay::sendInitCommands(void) {
886893
sendCommand(COMSCANINC);
887894
sendCommand(SETCOMPINS);
888895

889-
if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48) {
896+
if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48 || geometry == GEOMETRY_64_32) {
890897
sendCommand(0x12);
891898
} else if (geometry == GEOMETRY_128_32) {
892899
sendCommand(0x02);
893900
}
894901

895902
sendCommand(SETCONTRAST);
896903

897-
if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48) {
904+
if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48 || geometry == GEOMETRY_64_32) {
898905
sendCommand(0xCF);
899906
} else if (geometry == GEOMETRY_128_32) {
900907
sendCommand(0x8F);

src/OLEDDisplay.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ enum OLEDDISPLAY_GEOMETRY {
139139
GEOMETRY_128_64 = 0,
140140
GEOMETRY_128_32 = 1,
141141
GEOMETRY_64_48 = 2,
142+
GEOMETRY_64_32 = 3,
142143
GEOMETRY_RAWMODE = 4
143144
};
144145

src/SSD1306Spi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class SSD1306Spi : public OLEDDisplay {
130130
sendCommand(PAGEADDR);
131131
sendCommand(0x0);
132132

133-
if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48) {
133+
if (geometry == GEOMETRY_128_64 || geometry == GEOMETRY_64_48 || geometry == GEOMETRY_64_32 ) {
134134
sendCommand(0x7);
135135
} else if (geometry == GEOMETRY_128_32) {
136136
sendCommand(0x3);

0 commit comments

Comments
 (0)