Skip to content

Commit a563a25

Browse files
ReanimationXPmarcelstoer
authored andcommitted
Add 128x32 support documentation and example (#217)
Also cleaned up SimpleDemo comments.
1 parent 4b84794 commit a563a25

File tree

2 files changed

+45
-36
lines changed

2 files changed

+45
-36
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
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 the SSD1306 based 128x64 pixel OLED display running on the Arduino/ESP8266 platform.
8-
Can be used with either the I2C or SPI version of the display
7+
This is a driver for SSD1306 128x64 and 128x32 OLED displays running on the Arduino/ESP8266 platform.
8+
Can be used with either the I2C or SPI version of the display.
99

10-
You can either download this library as a zip file and unpack it to your Arduino/libraries folder or (once it has been added) choose it from the Arduino library manager.
10+
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".
1111

1212
It is also available as a platformio library. Just execute the following command:
1313
```
@@ -68,14 +68,18 @@ The library supports different protocols to access the OLED display. Currently t
6868
#include <Wire.h>
6969
#include "SSD1306Wire.h"
7070

71-
SSD1306Wire display(ADDRESS, SDA, SDC);
71+
// for 128x64 displays:
72+
SSD1306Wire display(0x3c, SDA, SCL); // ADDRESS, SDA, SCL
73+
// for 128x32 displays:
74+
// SSD1306Wire display(0x3c, SDA, SCL, GEOMETRY_128_32); // ADDRESS, SDA, SCL, GEOMETRY_128_32 (or 128_64)
7275
```
73-
or for a SH1106:
76+
77+
for a SH1106:
7478
```C++
7579
#include <Wire.h>
7680
#include "SH1106Wire.h"
7781
78-
SH1106Wire display(ADDRESS, SDA, SDC);
82+
SH1106Wire display(0x3c, SDA, SCL); // ADDRESS, SDA, SCL
7983
```
8084

8185
### I2C with brzo_i2c
@@ -84,14 +88,14 @@ SH1106Wire display(ADDRESS, SDA, SDC);
8488
#include <brzo_i2c.h>
8589
#include "SSD1306Brzo.h"
8690

87-
SSD1306Brzo display(ADDRESS, SDA, SDC);
91+
SSD1306Brzo display(0x3c, SDA, SCL); // ADDRESS, SDA, SCL
8892
```
8993
or for the SH1106:
9094
```C++
9195
#include <brzo_i2c.h>
9296
#include "SH1106Brzo.h"
9397
94-
SH1106Brzo display(ADDRESS, SDA, SDC);
98+
SH1106Brzo display(0x3c, SDA, SCL); // ADDRESS, SDA, SCL
9599
```
96100

97101
### SPI
@@ -100,14 +104,14 @@ SH1106Brzo display(ADDRESS, SDA, SDC);
100104
#include <SPI.h>
101105
#include "SSD1306Spi.h"
102106

103-
SSD1306Spi display(RES, DC, CS);
107+
SSD1306Spi display(D0, D2, D8); // RES, DC, CS
104108
```
105109
or for the SH1106:
106110
```C++
107111
#include <SPI.h>
108112
#include "SH1106Spi.h"
109113
110-
SH1106Spi display(RES, DC, CS);
114+
SH1106Spi display(D0, D2); // RES, DC
111115
```
112116

113117
## API

examples/SSD1306SimpleDemo/SSD1306SimpleDemo.ino

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,49 @@
2727
* https://thingpulse.com
2828
*
2929
*/
30-
30+
3131
// Include the correct display library
32-
// For a connection via I2C using Wire include
33-
#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
34-
#include "SSD1306Wire.h" // legacy include: `#include "SSD1306.h"`
35-
// or #include "SH1106Wire.h", legacy include: `#include "SH1106.h"`
36-
// For a connection via I2C using brzo_i2c (must be installed) include
37-
// #include <brzo_i2c.h> // Only needed for Arduino 1.6.5 and earlier
32+
33+
// For a connection via I2C using the Arduino Wire include:
34+
#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
35+
#include "SSD1306Wire.h" // legacy: #include "SSD1306.h"
36+
// OR #include "SH1106Wire.h" // legacy: #include "SH1106.h"
37+
38+
// For a connection via I2C using brzo_i2c (must be installed) include:
39+
// #include <brzo_i2c.h> // Only needed for Arduino 1.6.5 and earlier
3840
// #include "SSD1306Brzo.h"
39-
// #include "SH1106Brzo.h"
40-
// For a connection via SPI include
41-
// #include <SPI.h> // Only needed for Arduino 1.6.5 and earlier
41+
// OR #include "SH1106Brzo.h"
42+
43+
// For a connection via SPI include:
44+
// #include <SPI.h> // Only needed for Arduino 1.6.5 and earlier
4245
// #include "SSD1306Spi.h"
43-
// #include "SH1106SPi.h"
46+
// OR #include "SH1106SPi.h"
47+
4448

45-
// Include custom images
49+
// Optionally include custom images
4650
#include "images.h"
4751

48-
// Initialize the OLED display using SPI
52+
53+
// Initialize the OLED display using Arduino Wire:
54+
SSD1306Wire display(0x3c, SDA, SCL); // ADDRESS, SDA, SCL - SDA and SCL usually populate automatically based on your board's pins_arduino.h
55+
// SSD1306Wire display(0x3c, D3, D5); // ADDRESS, SDA, SCL - If not, they can be specified manually.
56+
// SSD1306Wire display(0x3c, SDA, SCL, GEOMETRY_128_32); // ADDRESS, SDA, SCL, OLEDDISPLAY_GEOMETRY - Extra param required for 128x32 displays.
57+
// SH1106 display(0x3c, SDA, SCL); // ADDRESS, SDA, SCL
58+
59+
// Initialize the OLED display using brzo_i2c:
60+
// SSD1306Brzo display(0x3c, D3, D5); // ADDRESS, SDA, SCL
61+
// or
62+
// SH1106Brzo display(0x3c, D3, D5); // ADDRESS, SDA, SCL
63+
64+
// Initialize the OLED display using SPI:
4965
// D5 -> CLK
5066
// D7 -> MOSI (DOUT)
5167
// D0 -> RES
5268
// D2 -> DC
5369
// D8 -> CS
54-
// SSD1306Spi display(D0, D2, D8);
70+
// SSD1306Spi display(D0, D2, D8); // RES, DC, CS
5571
// or
56-
// SH1106Spi display(D0, D2);
57-
58-
// Initialize the OLED display using brzo_i2c
59-
// D3 -> SDA
60-
// D5 -> SCL
61-
// SSD1306Brzo display(0x3c, D3, D5);
62-
// or
63-
// SH1106Brzo display(0x3c, D3, D5);
64-
65-
// Initialize the OLED display using Wire library
66-
SSD1306Wire display(0x3c, D3, D5);
67-
// SH1106 display(0x3c, D3, D5);
72+
// SH1106Spi display(D0, D2); // RES, DC
6873

6974

7075
#define DEMO_DURATION 3000

0 commit comments

Comments
 (0)