Adafruit SSD1306 Library Compile Problem

Hello,

I purchased a 128x32 OLED display from Adafruit and I can’t compile the SSD1306 128x32 i2c example code. I have the correct COMM and Board selected. It seems like the issue is with the .cpp file in the library. I’ve reinstalled the library multiple times and this error continues to appear.

Attached is the .h and .cpp files.

Thank you for the help.

Here is the error message:

C:\Users\collin.cutler\Documents\Arduino\libraries\Adafruit_SSD1306-master\Adafruit_SSD1306.cpp: In member function 'bool Adafruit_SSD1306::begin(uint8_t, uint8_t, bool, bool)':
C:\Users\collin.cutler\Documents\Arduino\libraries\Adafruit_SSD1306-master\Adafruit_SSD1306.cpp:494:44: error: 'digitalPinToPort' was not declared in this scope
     dcPort = (PortReg *)portOutputRegister(digitalPinToPort(dcPin));
                                            ^~~~~~~~~~~~~~~~
C:\Users\collin.cutler\Documents\Arduino\libraries\Adafruit_SSD1306-master\Adafruit_SSD1306.cpp:494:44: note: suggested alternative: 'digitalPinToInterrupt'
     dcPort = (PortReg *)portOutputRegister(digitalPinToPort(dcPin));
                                            ^~~~~~~~~~~~~~~~
                                            digitalPinToInterrupt
C:\Users\collin.cutler\Documents\Arduino\libraries\Adafruit_SSD1306-master\Adafruit_SSD1306.cpp:494:25: error: 'portOutputRegister' was not declared in this scope
     dcPort = (PortReg *)portOutputRegister(digitalPinToPort(dcPin));
                         ^~~~~~~~~~~~~~~~~~
C:\Users\collin.cutler\Documents\Arduino\libraries\Adafruit_SSD1306-master\Adafruit_SSD1306.cpp:495:17: error: 'digitalPinToBitMask' was not declared in this scope
     dcPinMask = digitalPinToBitMask(dcPin);
                 ^~~~~~~~~~~~~~~~~~~
C:\Users\collin.cutler\Documents\Arduino\libraries\Adafruit_SSD1306-master\Adafruit_SSD1306.cpp:495:17: note: suggested alternative: 'digitalPinToInterrupt'
     dcPinMask = digitalPinToBitMask(dcPin);
                 ^~~~~~~~~~~~~~~~~~~
                 digitalPinToInterrupt
Using library Wire at version 1.0 in folder: C:\Users\collin.cutler\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.2.0\libraries\Wire 
Using library Adafruit_GFX_Library at version 1.10.1 in folder: C:\Users\collin.cutler\Documents\Arduino\libraries\Adafruit_GFX_Library 
Using library Adafruit_SSD1306-master at version 2.4.0 in folder: C:\Users\collin.cutler\Documents\Arduino\libraries\Adafruit_SSD1306-master 
Using library SPI at version 1.0 in folder: C:\Users\collin.cutler\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.2.0\libraries\SPI 
Using library Adafruit_BusIO at version 1.5.0 in folder: C:\Users\collin.cutler\Documents\Arduino\libraries\Adafruit_BusIO 
exit status 1
Error compiling for board SparkFun RedBoard Artemis.

Adafruit_SSD1306.cpp (41.5 KB)

Adafruit_SSD1306.h (7.85 KB)

TLDR version
Sadly, this isn’t a bug. Sparkfun hasn’t written their Arduino core to support the Adafruit library.

Long version
I noticed the compiler errors show you are attempting to run this sketch on a Sparkfun Redboard Artemis. I am running into the same errors using the same Adafruit libraries and the same board. I found that when I compile the same sketch using the Arduino Uno board, it compiles successfully.

A Google search for this error lead me to another forum. The discussion there identified that the missing definitions are found in the Arduino.h file for Arduino’s AVR boards. This file is found in …/arduino-<ver#>/hardware/arduino/avr/cores/arduino. At least, for Linux that is its location.

Sparkfun has written its own Arduino core for their Apollo3 boards. Their Arduino.h file located in .arduino15/packages/Sparkfun/hardware/apollo3/<ver#>/cores/arduino/ard_sup. When I looked at that Arduino.h file, wouldn’t you know it. The needed definitions are missing.

This topic came up in Sparkfun’s forum as well, and they came to the same conclusion. The Arduino core for the Apollo3 boards doesn’t support the content the Adafruit libraries are seeking.