ThingPulse / esp8266-oled-ssd1306

Driver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
https://thingpulse.com
Other
2k stars 638 forks source link

compilation error 'D2' was not declared in this scope #156

Closed b3gi closed 4 years ago

b3gi commented 6 years ago

Hey. I ran into a problem. The program does not allow me to compile my project. An error: 'D2' was not declared in this scope.

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

include

define USE_DISPLAY / <-- uncomment that if you wanna use the display /

include

//include the library you need

include "SSD1306.h"

//#include "SH1106.h"

//button pins

define upBtn D6

define downBtn D7

define selectBtn D5

define buttonDelay 180 //delay in ms

//render settings

define fontSize 8

define rowsPerSite 8

//create display(Adr, SDA-pin, SCL-pin) SSD1306 display(0x3c, D2, D1); //SH1106 display(0x3c, D2, D1);

Error: esp8266_deauther:61: error: 'D2' was not declared in this scope

esp8266_deauther:61: error: 'D1' was not declared in this scope

C:\Users\Григорий\Desktop\esp8266_deauther-master\esp8266_deauther\esp8266_deauther.ino: In function 'void setup()':

esp8266_deauther:49: error: 'D6' was not declared in this scope

C:\Users\Григорий\Desktop\esp8266_deauther-master\esp8266_deauther\esp8266_deauther.ino:377:11: note: in expansion of macro 'upBtn'

esp8266_deauther:50: error: 'D7' was not declared in this scope

C:\Users\Григорий\Desktop\esp8266_deauther-master\esp8266_deauther\esp8266_deauther.ino:378:11: note: in expansion of macro 'downBtn'

esp8266_deauther:51: error: 'D5' was not declared in this scope

C:\Users\Григорий\Desktop\esp8266_deauther-master\esp8266_deauther\esp8266_deauther.ino:379:11: note: in expansion of macro 'selectBtn'

C:\Users\Григорий\Desktop\esp8266_deauther-master\esp8266_deauther\esp8266_deauther.ino: In function 'void loop()':

esp8266_deauther:49: error: 'D6' was not declared in this scope

C:\Users\Григорий\Desktop\esp8266_deauther-master\esp8266_deauther\esp8266_deauther.ino:484:19: note: in expansion of macro 'upBtn'

esp8266_deauther:50: error: 'D7' was not declared in this scope

C:\Users\Григорий\Desktop\esp8266_deauther-master\esp8266_deauther\esp8266_deauther.ino:492:26: note: in expansion of macro 'downBtn'

esp8266_deauther:51: error: 'D5' was not declared in this scope

C:\Users\Григорий\Desktop\esp8266_deauther-master\esp8266_deauther\esp8266_deauther.ino:500:26: note: in expansion of macro 'selectBtn'

In programming, I'm not strong and generally I'm R-RUS, so if there are grammatical errors, forgive me) BYE BYE)

reivaxy commented 6 years ago

Hey,

Try moving #include before the other include instructions.

reivaxy commented 6 years ago

@b3gi any news ?

per1234 commented 6 years ago

The cause of this error is that the Dn pin names are only defined for a subset of ESP32 and ESP8266 boards:

ESP32

ESP8266

Compiling the examples with any other board selected will fail.

FrankenApps commented 6 years ago

There is an easy fix though: For ESP32 boards simply replace SSD1306 display(0x3c, D2, D1); with SSD1306 display(0x3c, 21, 22); and change the wiring accordingly...

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

georgedrive commented 4 years ago

WeMos D1 R2:

include

//OLED myOLED(D2, D1); OLED myOLED(4, 5);

work

see https://github.com/esp8266/Arduino/blob/master/variants/d1_mini/pins_arduino.h

moeinrahimi1 commented 1 week ago

just use pin numbers instead

D0 = GPIO16
D1 = GPIO5
D2 = GPIO4
D3 = GPIO0
D4 = GPIO2
D5 = GPIO14
D6 = GPIO12
D7 = GPIO13
D8 = GPIO15