Arduino Forum

Development => Other Software Development => Topic started by: majenko on Nov 22, 2013, 08:30 pm

Title: Library generator
Post by: majenko on Nov 22, 2013, 08:30 pm
Bored with writing the same code time and again when you start a new library?  Me too.

That's why I wrote myself a little Automatic Library Generator: http://www.uecide.org/blanklib.php (http://www.uecide.org/blanklib.php)

Just enter the name for your new library, select a license (if any) and enter your name or organisation (only so it can fill in the license text - I never record anything like that), and press "Generate".  You'll get a Zip file with your new blank library in it, with all the files named right, the license information in it, a template class, all ready to go.  Just fill in the code :)
Title: Re: Library generator
Post by: Jimmy60 on Nov 22, 2013, 09:26 pm
Awesome. Works as promised. Thanks.
Title: Re: Library generator
Post by: graynomad on Nov 22, 2013, 11:49 pm
Quote
Just fill in the code

Can't you do that part as well, I'm also bored with that :)

______
Rob
Title: Re: Library generator
Post by: RbSCR on Nov 23, 2013, 12:11 pm
Thanks,  8) 8) 8)
Title: Re: Library generator
Post by: nicoverduin on Nov 23, 2013, 12:36 pm
Care to share the PHP code? I would like to extend it a little bit :) (like doxygen code etc) :)
Title: Re: Library generator
Post by: enginetech on Nov 23, 2013, 01:04 pm
Nice I would love to make my own too.
I am working on stepper motor
Title: Re: Library generator
Post by: majenko on Nov 23, 2013, 01:04 pm
I could do, but it's a little messy ;)

I know... I'll clean it up and github it - that way anyone could contribute.
Title: Re: Library generator
Post by: nicoverduin on Nov 23, 2013, 01:22 pm
Great!! thanks
Nico
Title: Re: Library generator
Post by: majenko on Nov 23, 2013, 01:27 pm
Ok, it's a bit cleaner.  There's enhancements I'd like to make too, like breaking out the actual template data from the code (it's embedded at the moment - quick'n'dirty ;) ).

https://github.com/majenkotech/ArduinoLibraryGenerator (https://github.com/majenkotech/ArduinoLibraryGenerator)

Feel free to fork, clone, edit, commit, push, and generate pull requests to your heart's content.
Title: Re: Library generator
Post by: majenko on Nov 23, 2013, 02:11 pm
Oh, and I have just split the template data out from the script into template files.  Much more elegant I feel - easier to edit and extend the template.
Title: Re: Library generator
Post by: Jantje on Nov 23, 2013, 02:20 pm
Quote
Java isn't bad in itself, but it has enabled morons to write programs.

So did visual basic and does php.  8)
karma +1 for daring to share this opinion.
Best regards
Jantje
Title: Re: Library generator
Post by: majenko on Nov 23, 2013, 02:30 pm

Quote
Java isn't bad in itself, but it has enabled morons to write programs.

So did visual basic and does php.  8)
karma +1 for daring to share this opinion.
Best regards
Jantje

It's not an opinion... : ]:D

PHP is great for quick'n'dirty scripting work, as you can see by my code ;) It's also, like Java, incredibly powerful in the right hands.  I wouldn't choose PHP to write a desktop application, and I wouldn't choose Java to write a web application.  Come to that I wouldn't choose Java to write anything really, but it's often what you're stuck with when you're working with someone else's code...

And let's not even mention Visual Basic...
Title: Re: Library generator
Post by: nicoverduin on Nov 23, 2013, 04:03 pm
Works like a charm. What I want to do is:
- add a bunch of doxygen parms I am working with
- add a couple of SVN parameters
- add the ability to work both under Arduino and Eclipse without source modifcation
- and any other nice to have stuff :)
But that does need some changes in the files and I am not sure the author likes it that way :smiley-mr-green: But of course I am always willing to share. Ia
Title: Re: Library generator
Post by: Jantje on Nov 23, 2013, 04:17 pm

...
- add the ability to work both under Arduino and Eclipse without source modifcation

What is needed for this?
Best regards
Jantje
Title: Re: Library generator
Post by: nicoverduin on Nov 23, 2013, 04:24 pm
Hi Jantje
For Eclipse we include the .h file with the references to setup and loop and any functions we use. Which btw is neat programming as far as I am concerned :)
In the Arduino we can skip all this.
And a couple of my customers just want the sketch and that's it. So now I solve it this way:
Code: [Select]


#ifdef __IN_ECLIPSE__
#include "test.h"
#endif


Then it always works
Title: Re: Library generator
Post by: majenko on Nov 23, 2013, 05:14 pm

Works like a charm. What I want to do is:
- add a bunch of doxygen parms I am working with
- add a couple of SVN parameters
- add the ability to work both under Arduino and Eclipse without source modifcation
- and any other nice to have stuff :)
But that does need some changes in the files and I am not sure the author likes it that way :smiley-mr-green: But of course I am always willing to share. Ia

It's under the BSD license - you can copy / modify / redistribute at will as long as you keep it under the same license ;)

If you do come up with some nice generic mods that would be useful for others, then it would be great if you could share them back to the original repo.
Title: Re: Library generator
Post by: nicoverduin on Nov 23, 2013, 05:27 pm
When I am finishied playing around, I put it back in GITHUB and let you decide if you want to commit.
Regards
Nico
Title: Re: Library generator
Post by: majenko on Nov 23, 2013, 05:43 pm
The way it's normally done is you fork the repo (press the "fork" button in the top right) then you have a copy of it on GitHub.  Then you clone your repo to your local computer, and do all your work in there.  Then you can check it in and push to your own repo as much as you like.

When you're happy with it you create a pull request (green button) which then generates a patch which I can apply to my repo automatically.
Title: Re: Library generator
Post by: Jantje on Nov 23, 2013, 05:48 pm

Hi Jantje
For Eclipse we include the .h file with the references to setup and loop and any functions we use. Which btw is neat programming as far as I am concerned :)
In the Arduino we can skip all this.
And a couple of my customers just want the sketch and that's it. So now I solve it this way:
Code: [Select]


#ifdef __IN_ECLIPSE__
#include "test.h"
#endif


Then it always works

I'm a bit confused here. IMHO Arduino does not do "pre processing" of the library files. So for libraries you are down to C/C++ including the need of function definitions before function usage.
For sketches the only file arduino includes behind your back is arduino.h. All the libraries need a include in the ino file. If not Arduino can not calculate the build and include path.
So IMHO
Code: [Select]

#ifdef __IN_ECLIPSE__
#include "test.h"
#endif

can always be replaced with
Code: [Select]

#include "test.h"

when test.h has the double include protection like

Code: [Select]

#ifndef _[HEADERNAME]_H_
#define _[HEADERNAME]_H_
//Your code goes here
#endif

If I'm wrong please tell me.

Note that I created the __IN_ECLIPSE__ define and I never used it. I'm not even sure V2 of the plugin still defines it.
So if there is a need I would like to know so I can make sure it stays in (or gets back into) the plugin.
Best regards
Jantje
Title: Re: Library generator
Post by: nicoverduin on Nov 23, 2013, 05:53 pm
Hi Jantje
I have customers who simply just don't want the extra include file when they compile the code. They just want the single .ino.
So if I simply put the include in, Arduino will start complaining.  Doing it this way the preprocessor knows it works within either Eclipse or not.
So please leave it in :)
Title: Re: Library generator
Post by: Jantje on Nov 23, 2013, 07:36 pm
You do have a point there.
You also have some demanding customers ;-)
I'll leave it in or put it back in.

Best regards
Jantje
Title: Re: Library generator
Post by: nicoverduin on Nov 23, 2013, 08:07 pm
nope :), totally ignorant to Arduino etc. II write software for all kinds of hardware solutions while I have never even seen the hardware itself :) I just build to design specs, mail the sketch, they load it and program the hardware. Cést tout....
And they pay the bills :)
Title: Re: Library generator
Post by: Jantje on Nov 23, 2013, 10:07 pm

nope :), totally ignorant to Arduino etc. II write software for all kinds of hardware solutions while I have never even seen the hardware itself :) I just build to design specs, mail the sketch, they load it and program the hardware. Cést tout....
And they pay the bills :)

Send them over to me if you have to much work  ;)
Back to the library generator.
Based on the discussion I see no reason for special eclipse code unless you also want to generate example frameworks.
Best regards
Jantje