Adafruit_L3GD20 Library Errors

Hi Everyone,

It’s my first time working with the Spark Core (I’ve worked with Arduino before though). I’m trying to connect the Adafruit gyroscope L3GD20 to the Core, and I added the Adarfruit-L3GD20 library to my app. However, when I attempt to verify my code with the library, I get this error:

    In file included from Adafruit_L3GD20/Adafruit_L3GD20.cpp:18:0:
Adafruit_L3GD20/Adafruit_L3GD20.h:17:0: error: unterminated #ifndef
#ifndef __L3GD20_H__
^
Adafruit_L3GD20/Adafruit_L3GD20.cpp:24:1: error: 'Adafruit_L3GD20' does not name a type
Adafruit_L3GD20::Adafruit_L3GD20(int8_t cs, int8_t miso, int8_t mosi, int8_t clk) {
^
Adafruit_L3GD20/Adafruit_L3GD20.cpp:31:1: error: 'Adafruit_L3GD20' does not name a type
Adafruit_L3GD20::Adafruit_L3GD20(void) {
^
Adafruit_L3GD20/Adafruit_L3GD20.cpp:36:6: error: 'Adafruit_L3GD20' has not been declared
bool Adafruit_L3GD20::begin(l3gd20Range_t rng, byte addr)
^
Adafruit_L3GD20/Adafruit_L3GD20.cpp:36:29: error: 'l3gd20Range_t' was not declared in this scope
bool Adafruit_L3GD20::begin(l3gd20Range_t rng, byte addr)
^
Adafruit_L3GD20/Adafruit_L3GD20.cpp:36:48: error: 'byte' was not declared in this scope
bool Adafruit_L3GD20::begin(l3gd20Range_t rng, byte addr)
^
Adafruit_L3GD20/Adafruit_L3GD20.cpp:36:57: error: expression list treated as compound expression in initializer [-fpermissive]
bool Adafruit_L3GD20::begin(l3gd20Range_t rng, byte addr)
^
Adafruit_L3GD20/Adafruit_L3GD20.cpp:37:1: error: expected ',' or ';' before '{' token
{
^
make: *** [Adafruit_L3GD20/Adafruit_L3GD20.o] Error 1

I guess the problem lies in Adafruit_L3GD20.h in this code

...
#if (ARDUINO >= 100)
 #include "Arduino.h"
//#else
// #include "WProgram.h"
//#endif
...

The commented out #endif breaks the balancing of #if .. #endif blocks.
To correct this you could either also comment the first two lines, or un-comment the #endif.

Maybe @kennethlimcp could take care of this, since he seems to have corrected it already but hasn’t uploaded the lib to the Web IDE, yet :wink:

1 Like

Sorry about that!

I did the fix and testing a compilation in Web IDE.

Let me know if it’s still not working!

3 Likes

Using the new library, I get a new error :frowning:

  In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_L3GD20/Adafruit_L3GD20.h:20,
from Adafruit_L3GD20/Adafruit_L3GD20.cpp:18:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
Adafruit_Sensor/Adafruit_Sensor.cpp:1:45: fatal error: Adafruit_Sensor/Adafruit_Sensor.h: No such file or directory
#include "Adafruit_Sensor/Adafruit_Sensor.h"
^
compilation terminated.
make: *** [Adafruit_Sensor/Adafruit_Sensor.o] Error 1

Weird. Did you include the library? Can you try using the example app?

Can you try without #include "Adafruit_Sensor/Adafruit_Sensor.h"?

I’m not 100% sure, that this “lib” is meant to be included in a project directly.
When trying to do so, in Web IDE it comes up with two remove-lib buttons next to the lib name.

I think it’s more like an abstract class to build sensor libraries on top, but @mdma might know better :wink:

Where can I find the example app?

I tried deleting my app and starting over again, but still received the same error. I’m not sure why the error is appearing still.

There’s something funny going on. Let me take a look

Not sure what went wrong with the Web IDE but i simply did a version bump and things are working now.

To use the example app, search for the library and:

1 Like