I’m trying to port the Adafruit ADS1x15 libary to Spark. I’ve got the 16 bit ADS1115, but the libraries are written for a few versions. The problem is that I’ve got no clue what i’m doing. I’ve searched and searched the forums here to no avail. I can program in a few other languages, but these compiled languages really throw me for a loop. I am failing first to understand how to even use libraries that don’t exist. I started trying to use an example Arduino SOS library to learn and use in place of the Tinker app, but I even failed there.
My ultimate goal is to be able to use my ADC, but I genuinely wan’t to know how to port libraries on my own, I just don’t know where to start and have the experience to do so.
To test code, don’t I just click the + button and add the .cpp and .h file code then “verify”?
Do I replace #include <Wire.h> with #include "application.h" or #include <application.h> or something else?
I had found the Library List + Porting How To and I’m sure my answers will be there in the future, but for now, I’m looking for some very rudimentary help to even get going. Can anyone answer my 2 questions?
In that guide however, what would be helpful would be a complete walk through, like taking a simple application and creating a library from it. It would be almost identical to the Arduino library tutorial I referenced that converts a the tinker app to a version that uses a custom user created library.
First: If you use the Web IDE, then YES. Copy/Paste your code into the respective files and add an #include statement in your .ino file.
Second: That is exactly what you will have found already in the GitHub link above
#if defined (SPARK)
#include "application.h"
#else
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
// This line is only required for Arduino, since on Spark it's already
// done via application.h
#include "Wire.h" // this line is added for your particular case
#endif
And no need to #include "application.h" inside you .ino file, since this will be done by the preprocessor.
And inside Adafruit_ADS1015.cpp I'd comment out this part, since this is already done via the Adafruit_ADS1015.h
/* ***** no need for double action ******
// #if ARDUINO >= 100
// #include "Arduino.h"
// #else
// #include "WProgram.h"
// #endif
//
// #include <Wire.h>
*************************************** */