Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Arduino Compatibility for All #1278
To provide maximum compatibility for Arduino libraries, and still support hundreds of libraries that were ported from Arduino to Particle, we include Arduino defines by default for 0.6.1 firmware now.
In the past <= 0.6.0, users would get Arduino defines without the need to add
Now Arduino.h just includes Particle.h (which in turn includes the legacy application.h). Also legacy libraries would include application.h directly in many cases. If application.h is included, PARTICLE_ARDUINO_COMPATIBILITY will be defined. And by default it will be included and set to 1. If that is the case, all of the defines in
There is no way to get ahead of the application.h include if it is included in a library and that is added to your app in the Web IDE. It appears to compile the library first.
If we could get the app to compile first, and compile the library once the include for the library is found, we could juggle something like this perhaps:
But that's going to be a mess I think because there's bound to be a bunch of things to redefine.
Suggested Way Forward (for 0.6.1)
I think the proper thing to do here to maintain compatibility with the library and older AND newer firmware, is to wrap the arduino-based defines embedded in the library with
These defines would have been needed in the past for older firmware when we didn't have a lot of arduino defines by default. Now that we include everything and the kitchen sink, you don't need to include these any more.
If you have your arduino defines grouped in one place, a test for ARDUINO might be a good way to include them all. That way you don't have to put #ifndef on each of them, even though it's still a good idea.
So that might look like this:
Future Thoughts (for 0.6.2)
A way around some of the issues we are having now might have been to not include the new big list of arduino defines by default, but instead just include the small list of defines from 0.6.0 by default and require users to include