sys/arduino: Using Arduino libraries#12180
Conversation
d8b8c64 to
b186c23
Compare
|
@cladmi @haukepetersen What do think about this approach. Maybe, there could be a solution in future for pulling Ardunio libraries into the build directory of an application instead of having a package for each of the thousands Arduino libraries. But for the moment, the proposed approach helps to use the pool of Arduino drivers. BTW, I have used this approach in PR #10363 together with PR #10592 to use a pretty complex Ardunio driver for the VL53L1X ToF ranging sensor which worked like a magic with any changes in the Arduino code. |
|
wow, this seems so useful! |
|
I do not like the I would prefer to introduce another module to differentiate between "arduino" that gives the headers and pulls the required features and modules, and a module to says use "arduino_sketches". I can do a change for this, I just do not know what would be preferred between:
That really depends on the usage. http://doc.riot-os.org/group__sys__arduino.html |
|
@cladmi It works in exactly that way with the If you prefere, we can use |
|
@cladmi It would be good if one module is realized on top of the other module to have only one place where we define include pathes, compiler flags, a.s.o., for the Arduino stuff. |
|
Ohh my bad, I thought there were 3 things, when there are 2. With your naming, somehow the Somehow I think it just makes sense to say "use @haukepetersen as you added this, what do you think about it? |
|
I am stupid, we could only build the 'arduino_sketches' module if there are '.sketches' files. |
|
What could be the reason that the test program hangs after 727 loop iterations? |
|
@keestux I have no idea. Maybe it is problem of the TalkingLED library and the handling of the delay. What platform did you use to test? I have tested it with an ESP32 board, and haven't seen this problem. |
|
Ah, found the reason for the hang. |
|
@gschorcht Did you run the test program for longer than 4295 seconds? I assume it would hang on ESP32 as well. |
|
Shall we go ahead with this one? It looks OK to me. |
aabadie
left a comment
There was a problem hiding this comment.
@keestux pointed out this PR in #12386 so I had a quick look (without testing).
I like the proposed approach of this PR, it makes the reuse of Arduino libraries in existing RIOT applications code very simple and compatible.
For simplicity, the arduino_lib module could be pull-in automatically by the package.
I also found some typos and the test application README still has to be written. See my comments below.
Otherwise, it looks good.
|
@aabadie Thanks for reviewing, I will provide some changes later today.
@keestux I didn't continue working on this PR for the moment since @cladmi suggested in #12180 (comment) and #12180 (comment) a slightly different approach but asked @haukepetersen for his opinion first. I will have a look later today. |
ecc2a98 to
45530e4
Compare
|
Didn't look at the code, but I used it to test #10592 and it worked like a charm |
|
Even though @cladmi proposed to think about a change of the make system so that the sketch is only compiled if it exist, this PR is compatible with current master and does the job it should do. Maybe, we should make it productive. |
|
Finally, I was able to change This has the advantage that we can use the existing dummy module @aabadie All your change requests were addressed. |
Done. The "TalkingLED" Arduino Lib builds on the Arduino Uno and the LED blinks as described in |
Thanks. |
boolean and byte are data types defined in Arduino.h and very often used in Arduino code.
5cab1a2 to
e999961
Compare
aabadie
left a comment
There was a problem hiding this comment.
Looks very nice now. The integration with the build system is very light.
I have no more comment and tested this PR on arduino-zero: it works like a charm.
Please squash!
To make it possible to use an Arduino library, a new pseudomodule arduino_lib is introduced. This pseudomodule enables implicitly module arduino but avoids that a sketch is required or generated and compiled. Thus, it is possible to compile and use a package or directory with some source files from an Arduino library in RIOT applications.
97657da to
3c465dc
Compare
3c465dc to
c5672e5
Compare
This test application defines a packages which imports a very simple Arduino library that is used by test application to demonstrate how an Arduino library can be imported as package and used by an application.
c5672e5 to
eb47f1c
Compare
|
Murdock is now happy. |
|
Thank you for your support with all these PRs. |
Contribution description
This PR allows the use of an Arduino library in RIOT applications without the need for an Arduino sketch. For this purpose it introduces the pseudomodule
arduino_lib. This pseudomodule enables implicitly modulearduinobut avoids that a sketch is required or generated and compiled. Thus, it becomes possible just to compile and use a package or a directory with some source files from an Arduino library in RIOT applications without having an Arduino sketch. The application has to enable thearduino_libmodule instead of thearduinomodule.The test app
tests/arduino_libdemonstrates how to import and use Arduino libraries as packages using a very simple Arduino library. For this purpose, the PR contains the packagetalking_ledsfor on-board LED flashing sequences.In addition, this PR introduces the Arduino standard header file
Arduino.hand the data typesbooleanandbyteto improvethe compatibility ofsys/arduinowith Arduino libraries and applications.Testing procedure
Compile and flash
tests/sys_arduino_lib:The integrated LED should flash in a loop twice short and twice long.
Issues/PRs references