adafruit / Adafruit_FeatherOLED

Helper class to work with 128x32 OLED displays on Adafruit Feathers
MIT License
25 stars 15 forks source link

can't compile on PlatformIO for Adafruit Feather S2, #define VBATPIN A13 error #31

Open EtoTen opened 1 year ago

EtoTen commented 1 year ago

VSCode, PlatformIO (latest)

platformio.ini:

[env:featheresp32-s2]
platform = espressif32
board = featheresp32-s2
framework = arduino
lib_deps = 
    plerup/EspSoftwareSerial@^7.0.0
    arcao/Syslog@^2.0.0
    makerspaceleiden/TLog@^1.0.3
    arduino-libraries/ArduinoHttpClient@^0.4.0
    jchristensen/movingAvg@^2.3.1
    arduino-libraries/NTPClient@^3.2.1
    adafruit/Adafruit GFX Library@^1.11.5
    adafruit/Adafruit NeoPixel@^1.10.7
    rlogiacco/CircularBuffer@^1.3.3
    yiannisbourkelis/Uptime Library@^1.0.0
    https://github.com/adafruit/Adafruit_FeatherOLED
    https://github.com/knolleary/pubsubclient
    https://github.com/adafruit/Adafruit_LC709203F

Board definition: https://github.com/platformio/platform-espressif32/blob/master/boards/featheresp32-s2.json "name": "Adafruit ESP32-S2 Feather Development Board"

Compile error:


In file included from .pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED.cpp:43:
.pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED.cpp: In member function 'float Adafruit_FeatherOLED::getBatteryVoltage()':
.pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED.h:48:17: error: 'A13' was not declared in this scope
 #define VBATPIN A13
                 ^~~
.pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED.cpp:180:21: note: in expansion of macro 'VBATPIN'
   return analogRead(VBATPIN) * VBAT_MULTIPLIER;
                     ^~~~~~~
.pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED.h:48:17: note: suggested alternative: 'T13'
 #define VBATPIN A13
                 ^~~
.pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED.cpp:180:21: note: in expansion of macro 'VBATPIN'
   return analogRead(VBATPIN) * VBAT_MULTIPLIER;
                     ^~~~~~~
*** [.pio\build\featheresp32-s2\lib256\Adafruit Feather OLED\Adafruit_FeatherOLED.cpp.o] Error 1
In file included from .pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED_SH110X.h:11,
                 from .pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED_SH110X.cpp:42:
.pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED_SH110X.cpp: In member function 'float Adafruit_FeatherOLED_SH110X::getBatteryVoltage()':
.pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED.h:48:17: error: 'A13' was not declared in this scope
 #define VBATPIN A13
                 ^~~
.pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED_SH110X.cpp:183:21: note: in expansion of macro 'VBATPIN'
   return analogRead(VBATPIN) * VBAT_MULTIPLIER;
                     ^~~~~~~
.pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED.h:48:17: note: suggested alternative: 'T13'
 #define VBATPIN A13
                 ^~~
.pio/libdeps/featheresp32-s2/Adafruit Feather OLED/Adafruit_FeatherOLED_SH110X.cpp:183:21: note: in expansion of macro 'VBATPIN'
   return analogRead(VBATPIN) * VBAT_MULTIPLIER;
                     ^~~~~~~
*** [.pio\build\featheresp32-s2\lib256\Adafruit Feather OLED\Adafruit_FeatherOLED_SH110X.cpp.o] Error 1

I am assuming that the define "ARDUINO_ADAFRUIT_FEATHER_ESP32S2" does not get defined in my environment for some reason and thus the check "#elif defined(ESP32) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) " Adafruit_FeatherOLED.h:46 still passes and tries to set an invalid pin for the S2

EtoTen commented 1 year ago

Update Adding: ARDUINO_ADAFRUIT_FEATHER_ESP32S2 manually to the build flags, let it build ok.

I guess that definition is not getting set automatically in PlatformIO for the "featheresp32-s2" maybe it is in Arduino IDE? Where is that define supposed to come from?

build_flags=
   -D ARDUINO_SERIAL_PORT=1
   -D ARDUINO_USB_CDC_ON_BOOT
   -D ARDUINO_ADAFRUIT_FEATHER_ESP32S2