Pages: [1]   Go Down
Author Topic: writing custom libraries.  (Read 1406 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wish that it was easier to write custom libraries in the Arduino IDE for Mac OSX (I'm running Arduino 1.0.1)

I just spent a whole bunch of time importing Morse.cpp and Morse.h into new tabs of a sketch called Morse.ino and the whole system got confused.

seems like the only way so far is to have the .cpp and .h files in the official library folder and they can only be edited as a text file.

:-(

please someone tell me there is a better way.... I'm desperately wanting to start writing my own libraries and access registers and such.

best regards.

K7
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 615
Posts: 49388
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I just spent a whole bunch of time importing Morse.cpp and Morse.h into new tabs of a sketch called Morse.ino and the whole system got confused.
We can't help you until you do a better job of explaining "the whole system got confused".

Generally, .cpp and .h files can be added to tabs in the IDE, and edited there. When the project is saved, the .cpp and .h files will also be saved.

When the development is complete, then is the time to move (NOT copy) the files to a directory in the libraries folder. Change the sketch to use different symbols around the name in the #include statements, and the code should compile and link with no problems.
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1920
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Paul
The method of working you are proposing is acceptable when you create a new library.
But when you have multiple libraries you need multiple projects (for each library 1) and multiple moves (for each release of a library).
Then when you have a project that uses the libraries and that needs a change in a library you have to remove the library link (delete#include"header") move the files to the project. When done you reenter the link and move the files.
I'm not saying it cannot be done but it is cumbersome.
Easier is to have a better development environment that allows you to change the library and the project at the same time.
There are alternatives around and my eclipse plugin is one of them.

That being said I see no reason to make a library to access registers. There is nothing you can do in a library that can not do in a project.
Making a library is just harder because you have to comply with a C/C++ rules; where the Arduino IDE takes care of that when using ino files.

My advice: Ask yourself following questions:
 Do you have more than one project needing the same source code?
Apart from you;  Will there be someone using the library?
Are you willing to support other people when they use your library?
Are you willing to take hard comments on your code?
Have you shared code before?
If you have 3 times yes you may be wiling to tackle libraries. Otherwise it is probably better not to write a library.

Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I develop larger projects like libraries using an external text editor to which I am already very accustomed, editing the library files directly in the libraries/bitlash/src directory (for example).  Then I switch to the Arduino IDE, where I have opened an example sketch which includes the library (for an example see bitlashdemo), to recompile and upload.  

You might call it the Alt+Tab/Alt+U IDE.  Anyway, it works for me.  I will need a new Alt key soon, though.

-br
http://bitlash.net

PS: Should have mentioned that to protect against my own confusion I also have a terminal window open so I can commit changes to git every so often and push them somewhere safe several times per day.
« Last Edit: October 25, 2012, 12:32:56 pm by billroy » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

my apologies, I'm a newbie to C and Arduino.

My only other experience was about 2 years worth of PICmicro programming in their Assembly and I just did everything directly to the registers and within the main code. I never did anything fancy like making my own libraries before..... I suppose I'm taking on a lot, but I'm learning quickly....

I'll try accessing the registers within the main project and ignore making libraries until I absolutely have to... I suppose.

Essentially when I imported the Morse code project, I tried having the .h and .cpp files in my tabs but I kept on experiencing compiling errors until I had those files in the official Libraries folder and those tabs closed/deleted.
Logged

Pages: [1]   Go Up
Jump to: