Landing : Athabascau University
  • Blogs
  • Using Private Arduino Libraries with Eclipse

Using Private Arduino Libraries with Eclipse

Using Private Arduino Libraries with Eclipse

I wrote about swapping over from the Arduino IDE to Eclipse in Switching from the Arduino IDE to Eclipse, and even included an example program. Since then, I've run into a limitation for the mentioned plugin (Eclipse C++ IDE for Arduino 3.0): there is no simple way to link to or import a library not available in the Arduino Download Manager. There is some talk about modifying your local ...\.arduinocdt\library_index.json file to include your library, but there are issues with this as it is not meant for local modifications.

I added the QuickStats library by doing the following:

  1. Downloaded QuickStats from GitHub and put/extracted it where I put things like this (I used C:\Users\tyblu\Documents\repos\QuickStats). Actually, I use git (Sourcetree), so I cloned the QuickStats repository. (This way I can keep it up to date and track any changes.)
  2. Opened my Eclipse project tybluRobotArm and created a new class (right click project > New > Class) named QuickStats, which gives me QuickStats.h and QuickStats.cpp. Added #include "QuickStats.h" to my main program, tybluRobotArm.cpp, and built it just to make sure that it was working. (You can probably skip that part.) Closed Eclipse.
  3. Navigated to my Eclipse project source code directory and deleted QuickStats.h and QuickStats.cpp. (What!? Have no fear, the magic is coming.)
  4. Opened a Windows command prompt in administrator mode. (I do this by typing "cmd" into the windows search bar, right-clicking on Command Prompt and selecting Run as administrator.) Created two hardlinks in the project source code directory, where you just deleted the .h and .cpp files, to the downloaded QuickStats.h and .cpp files, with mklink.

    image
  5. Tested it out. It works! Here's my test program: [GitHub link to specific commit of tybluRobotArm.cpp].image

You can ignore all of this if your library is one of the core Arduino libraries or is available in the Arduino Downloads Manager.

Comments

  • Hi Tyler. Thanks for posting these tips. I suppose Github code might require Eclipse rather than the Arduino IDE.  Why is that?

    Your code does averages and modes.  Do you plan on using averages and modes to move your robotic arm?  Or is the code just testing ground to see if Eclipse works with your Arduino?

    Thank you.

    Susanne Cardwell October 14, 2017 - 3:30pm

  • GitHub code runs fine using the Arduino IDE, and it's really easy. This guy lays it out: https://www.baldengineer.com/installing-arduino-library-from-github.html

    I'm going to use the QuickStats library to filter some noisy sensor data. It is sometimes better to calculate the mode to filter out spikes than the average, especially if the noise isn't spread out nicely (skewed). The above code is just to test out the library though -- not close to what I'm doing.

    Tyler Lucas October 14, 2017 - 3:41pm

  • Hi Tyler,

    I set up a sample library in PlatformIO using example code from the Arduino Library tutorial.

    The readme.txt in the \lib directory explains the expected path structure.

    Here's a screenshot. Works great.

     image

    peterde October 16, 2017 - 2:48pm

  • Hi Peter. Are you going to switch the Morse code with voice commands?  How does the voice command get detected?  Thank you.

    Susanne Cardwell October 16, 2017 - 2:58pm

  • Looks great @peterde! The screenshot is the Atom version, right? I haven't given Atom much attention beyond downloading and playing with the windows. (It sure is pretty.) I wonder how it's serial terminal behaves in our embedded toolchain. Eclipse's serial terminal layout is quite good, making it easy for re-compiling/uploading without losing focus or having to do extra steps.

    @Susanne, the Peter's example is just the Arduino Library tutorial, not his project. (Though I do use similar functions named dot(int,int) and ellipsis() in my own project code...)

    Tyler Lucas October 16, 2017 - 6:22pm

  • Hey Tyler,

    This is actually a screenshot of the VSCode version. I tried PlatformIO on the Atom editor and it's nice but they recommended the VSCode version as it is more full featured. Having tried both I have to agree. Here's the download page for both. 

    Peter

    peterde October 16, 2017 - 7:50pm

  • I just tried linking in a larger library, SdFat, with multiple directories, using junctions (mklink /j <target> <source>). I've spent about 30 minutes fighting with Eclipse to build/link the thing, and it's still not working. Gonna give ParticleIO VSCode a shot for the next 30 minutes, to change the pace.

    Tyler Lucas October 23, 2017 - 5:13pm

  • Just installed the SDFat library via PlatformIO library manager. 

    peterde October 23, 2017 - 6:16pm

  • Yep, everything is moved over now and working, using PlatformIO's version of the SdFat and QuickStats libraries. Thanks Peter!

    Tyler Lucas October 23, 2017 - 7:27pm

These comments are moderated. Your comment will not be visible unless accepted by the content owner.

Only simple HTML formatting is allowed and any hyperlinks will be stripped away. If you need to include a URL then please simply type it so that users can copy and paste it if needed.

(Required)

(Required)