Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Arduino compatibility #1216

Merged
merged 7 commits into from Jan 11, 2017

Conversation

@monkbroc
Copy link
Member

commented Dec 22, 2016

  • Simulate latest Arduino version: The latest Arduino version is 1.8.0 and uses C++11. Some libraries check this constant to know if they can use C++11 syntax.

  • Ensure Arduino compatibility macros are defined even when Particle.h has already been included. This happens when compiling a .ino file on the compile server since the preprocessor includes Particle.h before the application has a chance of including Arduino.h. Also happens for all existing Particle Libraries since Arduino.h was replaced typically with application.h or Particle.h.

  • Define additional hardware serial defines.

  • Added optional command line parameter to disable arduino compatibility. Duplicated docs for this below.


Compilation without Arduino Compatibility Support

Arduino compatibility defines are included by default to support hundreds of libraries that have been ported from Arduino to Particle. If those defines should cause an issue with your build, you may remove them by adding

PARTICLE_NO_ARDUINO_COMPATIBILITY=y to the make command line. This requires a clean build.

There should be no difference in FLASH or RAM allocation with or without these defines.


Doneness:

  • Contributor has signed CLA
  • Problem and Solution clearly stated
  • Code peer reviewed
  • API tests compiled
  • Run unit/integration/application tests on device
  • Add documentation
  • Add to CHANGELOG.md after merging (add links to docs and issues)

Enhancements

  • [PR #1216] Improved Arduino Compatibility (now supported by default, added PARTICLE_NO_ARDUINO_COMPATIBILITY=y command line option for disabling)
Simulate latest Arduino version
The latest Arduino version is 1.8.0 and uses C++11. Some libraries check this constant to know if they can use C++11 syntax.

@technobly technobly added this to the 0.6.1 milestone Dec 22, 2016

@technobly technobly self-requested a review Dec 22, 2016

@monkbroc

This comment has been minimized.

Copy link
Member Author

commented Dec 22, 2016

Thanks you sir :)

@monkbroc monkbroc changed the title Simulate latest Arduino version Improve Arduino compatibility Dec 22, 2016

@avtolstoy avtolstoy self-requested a review Dec 22, 2016

@avtolstoy avtolstoy self-assigned this Dec 22, 2016

@technobly technobly removed their request for review Dec 22, 2016

@@ -4,6 +4,7 @@

#define PARTICLE_ARDUINO_COMPATIBILITY
#include "Particle.h"
#include "spark_wiring_arduino.h"

This comment has been minimized.

Copy link
@technobly

technobly Jan 5, 2017

Member

This change may break existing libraries, since when original Arduino libraries were ported to Particle, Arduino.h was typically replaced with application.h or Particle.h. I would suggest leaving #include "spark_wiring_arduino.h" in application.h and keeping the removal of #ifdef PARTICLE_ARDUINO_COMPATIBILITY in spark_wiring_arduino.h so that arduino is just supported by default.

This comment has been minimized.

Copy link
@technobly

technobly Jan 6, 2017

Member

Changing my mind on how we include arduino support by default, but we still need it. I'll follow up with a commit.

This comment has been minimized.

Copy link
@monkbroc

monkbroc Jan 10, 2017

Author Member

I want to make sure your removal of this change still keeps the intent that:

#include "application.h"
#include "Arduino.h"
// compatibility macros should be defined here

It wasn't the case due to Arduino.h loading Particle.h loading application.h which had already been loaded without compatibility macros and wasn't loaded a second time due to the guard clauses.

This comment has been minimized.

Copy link
@technobly

technobly Jan 10, 2017

Member

Yep, by default now application.h will define PARTICLE_ARDUINO_COMPATIBILITY = 1 unless PARTICLE_NO_ARDUINO_COMPATIBILITY is explicitly defined as =y on the make command line. Also Arduino.h just includes Particle.h which is an alias for application.h.

@technobly technobly merged commit 111612b into develop Jan 11, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@technobly technobly deleted the feature/arduino-1.8.0 branch Jan 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.