In what IDE do you write libraries for Arduino?

I fancy writing some libraries for Arduino etc. but I do not know which IDEs are used to write and debug and compile the C++ code? Any advice?

How does one debug the C++ program that runs inside Arduino's Java IDE?

Same way as you debug normal arduino stuff, with prints an LEDs. I just use a text editor and I have the test program in the arduino IDE. Any error messages appere in the arduino IDE.

Hi
When developing libraries it may be a good idea to understand what a Arduino library stands for.

In Arduino there is no difference between your sketch code and library code. All code is treated as standard code and linked as if it is one big program.
The only exception to the rule is the Arduino library code (the one you always need and use via arduino.h) which is actually build like a library.
The reason for this is that linking in a C library has the advantage of code optimizations (you don't need it you don't get it => smaller sketch).
However if you link in a library you need it; so code optimization is not (really) needed.
Best regards
Jantje

that is surprise, I always thought that code inside Arduino's IDE is Java, not C++.

There is this library for computer vision, made for ArduPilot:

http://code.google.com/p/ardupilot-mega/source/browse/#git%2Flibraries%2FAP_OpticalFlow

For this Arduino Vision thingy:

http://code.google.com/p/ardupilot-mega/source/browse/#git%2Flibraries%2FAP_OpticalFlow

Unfortunately they made it compatible for ArduPilot, I do not now if it would work with Arduino. Does anybody fancy adjusting this library for Arduino and letting pure old Ard. get some eyesight.

The IDE is written in Java, but that has nothing to do with libraries written to run on an Arduino. The IDE is just another application, it could just as well have been written in VB.

Does anybody fancy adjusting this library for Arduino

Not me :slight_smile:


Rob

I mostly write libraries in notepad++ while having a sample sketch to test the functionality in the IDE.

a tab for every .h and .cpp file makes switching a piece of cake.

in the FILE-> preferences menu you can also set /use an external editor for sketches, so the IDE is brought back to a compile and upload button.

For serial monitor I use putty.exe most of the time , recently played with br@y++ and that looks OK too.

I normally use emacs for my IDE and screen for my serial monitor. If you're not using a build system of some type, you can then tell the arduino IDE, via preferences, that you're using an external editor. You can edit your file in your editor/IDE of choice and then hit the verify button, whereby it will reload and compile the file in the arduino IDE.

If the "library" is project- (i.e. sketch-) specific, the Arduino IDE can be conveniently used with multiple tabs.

Yea EMACS! Me too.

tell the arduino IDE, via preferences, that you're using an external editor.

I find that this works really well, actually. It's one of those really simple-to-implement "compromises" that looks a lot better in practice than when described; essentially it turns the Arduino IDE into a one-click compile/upload engine, and lets all the editing happen elsewhere.

Well if we start mentioning product ...
I like my eclipse plugin. But I'm probably biased 8)
It is just that it provides me a single environment where I can easily do sketch and libraries compile and upload with nice features like bug marks, outline and jumps.

Best regards
Jantje

westfw:
Yea EMACS! Me too.

tell the arduino IDE, via preferences, that you're using an external editor.

I find that this works really well, actually. It's one of those really simple-to-implement "compromises" that looks a lot better in practice than when described; essentially it turns the Arduino IDE into a one-click compile/upload engine, and lets all the editing happen elsewhere.

Have you tried using daemon mode? A lot of emacians don't know about daemon mode. Use, "emacs --daemon" to start it up. Then use "emacsclient -n -c -a ". So for example, I use, "emacsclient -n -c -a nano". I then create an alias, in my case, "edit", for the emacsclient line. Then I can type, "edit ", and an emacs frame instantly pops up with . The cool things is, emacs is now running as a server so all buffers you have previously opened/created are now accessible within your new frame. And, should I type, "edit" and had not previously started emacs, it will go ahead and edit the file via the specified alternate editor; in my case, nano.

And if you're on linux, you can use the following to pull things together.

export EDITOR="$(which emacsclient) -n -c"
export VISUAL=$EDITOR
export EMACSCLIENT=$EDITOR
export ALTERNATE_EDITOR="$EDITOR -a nano"
alias edit=$ALTERNATE_EDITOR

@greg

Wow, really cool! Unfortunately I'm not into emacs (I'm of the vim church :slight_smile: ) I obtain a (somewhat) similar result on ssh-administered machines with tmux (or screen). That emacs daemon mode seems more powerful, though. I wonder if vi has one too (or anything close) ?

tuxduino:
@greg

Wow, really cool! Unfortunately I'm not into emacs (I'm of the vim church :slight_smile: ) I obtain a (somewhat) similar result on ssh-administered machines with tmux (or screen). That emacs daemon mode seems more powerful, though. I wonder if vi has one too (or anything close) ?

I've not heard of such a feature for vim. Doesn't mean it doesn't exist.

Of course, you can also try VIP, VIM, or VIPER mode for emacs. :wink: Emacs nicely emulates a lot of vi/vim features and key bindings, allowing all but the most hard core vim user to find a home within emacs. I still use vi from time to time, normally as root. If I think about it, I'll use nano as root but muscle memory is vi for that quick edit. And that's one of the nice things about daemon mode is that its so fast, its comparable to using vi for that fast edit.

I will say, once you get used to daemon mode, you won't want to go back to your other work flows.

Looks like vim has it too... :slight_smile:

Excellent. If you edit may files, I'm sure you'll quickly wonder how you ever worked without it.

I use Xcode to write libraries.

I need code-sense and some extra features the Arduino IDE doesn't provide.

I've developed a template for Xcode, embedXcode. Code is here and documentation there.

Contrary to Eclipse, NetBeans and Visual Studio, Xcode is rather secretive about its inner structure, so developing the template isn't that easy.

embedXcode works fine. :slight_smile:

I was literally just getting ready to post a link to this.

For most users who want a real IDE, something like codeblocks should be a massive step up from the Arduino IDE.

Avenue33

avenue33:
Contrary to Eclipse, NetBeans and Visual Studio, Xcode is rather secretive about its inner structure, so developing the template isn't that easy.

Maybe eclipse is more open but to call eclipse plugin development easy is a bridge to far 8)
Best regards
Jantje

Is anyone using the arduino-mode for Emacs?

I installed it in emacs 23 (and also a 24 snapshot), and initially it worked fine. I got highlighting of the code and best of all was able to compile and upload it to the arduino using EDE. I also got a serial window. It seems to be broken now, and all I get is the highlighting, but not the compile/upload/serial window functions.

I've tried uninstalling and reinstalling emacs, but it makes no difference.

Does anyone know what the problem might be, please?

Jim

emacs

I didn't know that anyone had gone and done an arduino-mode !

It looks like there is an "arduino-mode.el" that does basic C-style stuff, but compilation/upload is part of CEDET instead?
http://www.emacswiki.org/emacs/CollectionOfEmacsDevelopmentEnvironmentTools