Skip to content

Commit c324fad

Browse files
mcauserdok-net
authored andcommitted
Add support for 64x48 OLED
I2C connections for ESP8266: SCL = GPIO5 SDA = GPIO4 RST = GPIO0
1 parent 56a1c94 commit c324fad

File tree

4 files changed

+472
-9
lines changed

4 files changed

+472
-9
lines changed

Adafruit_SSD1306.cpp

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,15 @@ bool Adafruit_SSD1306::begin(uint8_t vcs, uint8_t addr, bool reset,
467467
return false;
468468

469469
clearDisplay();
470-
if (HEIGHT > 32) {
470+
if (WIDTH > 64 && HEIGHT > 32) {
471471
drawBitmap((WIDTH - splash1_width) / 2, (HEIGHT - splash1_height) / 2,
472472
splash1_data, splash1_width, splash1_height, 1);
473-
} else {
473+
} else if(WIDTH > 64) {
474474
drawBitmap((WIDTH - splash2_width) / 2, (HEIGHT - splash2_height) / 2,
475475
splash2_data, splash2_width, splash2_height, 1);
476+
} else {
477+
drawBitmap((WIDTH - splash3_width) / 2, (HEIGHT - splash3_height) / 2,
478+
splash3_data, splash3_width, splash3_height, 1);
476479
}
477480

478481
vccstate = vcs;
@@ -563,6 +566,13 @@ bool Adafruit_SSD1306::begin(uint8_t vcs, uint8_t addr, bool reset,
563566
} else if ((WIDTH == 96) && (HEIGHT == 16)) {
564567
comPins = 0x2; // ada x12
565568
contrast = (vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0xAF;
569+
} else if ((WIDTH == 64) && (HEIGHT == 48)) {
570+
static const uint8_t PROGMEM init4d[] = {
571+
SSD1306_SETCOMPINS, // 0xDA
572+
0x12,
573+
SSD1306_SETCONTRAST }; // 0x81
574+
ssd1306_commandList(init4d, sizeof(init4d));
575+
ssd1306_command1((vccstate == SSD1306_EXTERNALVCC) ? 0x9F : 0xCF);
566576
} else {
567577
// Other screen varieties -- TBD
568578
}
@@ -925,13 +935,27 @@ uint8_t *Adafruit_SSD1306::getBuffer(void) { return buffer; }
925935
*/
926936
void Adafruit_SSD1306::display(void) {
927937
TRANSACTION_START
928-
static const uint8_t PROGMEM dlist1[] = {
938+
if ((WIDTH != 64) || (HEIGHT != 48)) {
939+
static const uint8_t PROGMEM dlist1a[] = {
929940
SSD1306_PAGEADDR,
930-
0, // Page start address
931-
0xFF, // Page end (not really, but works here)
932-
SSD1306_COLUMNADDR, 0}; // Column start address
933-
ssd1306_commandList(dlist1, sizeof(dlist1));
934-
ssd1306_command1(WIDTH - 1); // Column end address
941+
0, // Page start address
942+
0xFF, // Page end (not really, but works here)
943+
SSD1306_COLUMNADDR,
944+
0 }; // Column start address
945+
ssd1306_commandList(dlist1a, sizeof(dlist1a));
946+
ssd1306_command1(WIDTH - 1); // Column end address
947+
} else {
948+
static const uint8_t PROGMEM dlist1b[] = {
949+
SSD1306_PAGEADDR,
950+
0 }; // Page start address
951+
ssd1306_commandList(dlist1b, sizeof(dlist1b));
952+
ssd1306_command1((HEIGHT / 8) - 1); // Page end address
953+
static const uint8_t PROGMEM dlist2b[] = {
954+
SSD1306_COLUMNADDR,
955+
32 }; // Column start address
956+
ssd1306_commandList(dlist2b, sizeof(dlist2b));
957+
ssd1306_command1(32 + WIDTH - 1); // Column end address
958+
}
935959

936960
#if defined(ESP8266)
937961
// ESP8266 needs a periodic yield() call to avoid watchdog reset.

Adafruit_SSD1306.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
#ifndef _Adafruit_SSD1306_H_
2525
#define _Adafruit_SSD1306_H_
2626

27-
// ONE of the following three lines must be #defined:
27+
// ONE of the following four lines must be #defined:
2828
//#define SSD1306_128_64 ///< DEPRECTAED: old way to specify 128x64 screen
2929
#define SSD1306_128_32 ///< DEPRECATED: old way to specify 128x32 screen
3030
//#define SSD1306_96_16 ///< DEPRECATED: old way to specify 96x16 screen
31+
//#define SSD1306_64_48 ///< DEPRECATED: old way to specify 64x48 screen
3132
// This establishes the screen dimensions in old Adafruit_SSD1306 sketches
3233
// (NEW CODE SHOULD IGNORE THIS, USE THE CONSTRUCTORS THAT ACCEPT WIDTH
3334
// AND HEIGHT ARGUMENTS).
@@ -118,6 +119,10 @@ typedef uint32_t PortMask;
118119
#define SSD1306_LCDWIDTH 96 ///< DEPRECATED: width w/SSD1306_96_16 defined
119120
#define SSD1306_LCDHEIGHT 16 ///< DEPRECATED: height w/SSD1306_96_16 defined
120121
#endif
122+
#if defined SSD1306_64_48
123+
#define SSD1306_LCDWIDTH 64 ///< DEPRECATED: width w/SSD1306_64_48 defined
124+
#define SSD1306_LCDHEIGHT 48 ///< DEPRECATED: height w/SSD1306_64_48 defined
125+
#endif
121126

122127
/*!
123128
@brief Class that stores state and functions for interacting with

0 commit comments

Comments
 (0)