Skip to content

Commit f8dc2e0

Browse files
committed
Updated with code to support either I2C or SPI
1 parent 23baef2 commit f8dc2e0

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

examples/SSD1306Demo/SSD1306Demo.ino

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,33 @@ SOFTWARE.
2323
See more at http://blog.squix.ch
2424
*/
2525
#include <Wire.h>
26+
#include <SPI.h>
2627
#include "SSD1306.h"
2728
#include "SSD1306Ui.h"
2829
#include "images.h"
2930

30-
// Initialize the oled display for address 0x3c
31-
// sda-pin=14 and sdc-pin=12
32-
SSD1306 display(0x3c, D3, D4);
31+
// Pin definitions for I2C
32+
#define OLED_SDA D2 // pin 14
33+
#define OLED_SDC D4 // pin 12
34+
#define OLED_ADDR 0x3C
35+
36+
/* Hardware Wemos D1 mini SPI pins
37+
D5 GPIO14 CLK - D0 pin OLED display
38+
D6 GPIO12 MISO (DIN) - not connected
39+
D7 GPIO13 MOSI (DOUT) - D1 pin OLED display
40+
D8 GPIO15 CS / SS - CS pin OLED display
41+
D0 GPIO16 RST - RST pin OLED display
42+
D2 GPIO4 DC - DC pin OLED
43+
*/
44+
45+
// Pin definitions for SPI
46+
#define OLED_RESET D0 // RESET
47+
#define OLED_DC D2 // Data/Command
48+
#define OLED_CS D8 // Chip select
49+
50+
// Uncomment one of the following based on OLED type
51+
SSD1306 display(true, OLED_RESET, OLED_DC, OLED_CS); // FOR SPI
52+
// SSD1306 display(OLED_ADDR, OLED_SDA, OLED_SDC); // For I2C
3353
SSD1306Ui ui ( &display );
3454

3555
// this array keeps function pointers to all frames

0 commit comments

Comments
 (0)