Pages: [1]   Go Down
Author Topic: Writing Libraries  (Read 640 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are there any good tutorials on writing proper libraries? I am moderately new to C and very new to C++. I have found that I really like the OO stuff in C++ and just trying to figure out where to start with regards especially to writing libraries (classes, class hiearchy, etc...)

I know there is C++ stuff out there, but anything specific for arduino for dummies?
Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you try the tutorial on the official Arduino website?

http://arduino.cc/en/Hacking/LibraryTutorial
Logged

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes. No problems with any of the subjects that covers. I guess I am hoping to find something a bit more advanced. All books, etc... always seem to be aimed at beginners and always seem to stop right where I already am at.
Logged

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

A library is nothing more than a header file that defines a class and a source file that implements the class. There is nothing particularly advanced about that. I'm having a hard time envisioning what your problems might be.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A library is nothing more than a header file that defines a class and a source file that implements the class.

The part in bold assumes the library contains a class - it doesn't have to.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's not so much a 'problem' as just being a complete newbie to C++, but not C. I get the standard class structure. No problem there. I can write libraries, I can build a simple class structure. Just looking for more advanced tutorials to learn more about using more features of C++ with Arduino. I have been reading books about C++, so I am learning. But so far nothing specific and with examples for the arduino. You were mentioning some more advanced technics to me in another thread about class hierachy, etc... and all those concepts were foreign to me. I'd like to learn how to use them.

Oh well, perhaps something like that doesn't exist. Just thought I would ask if anyone knew of any.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 502
Posts: 19085
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds to me like you are trying to find a problem to fit the solution.

I will write a library simply to save repeating the same code in multiple projects. Not necessarily even using a class. If a class is warranted, I'd use it. Or a namespace. Or a struct.

The Arduino compiler is basically straight C++, so there is no real need to look for Arduino-type solutions.

Take HardwareSerial, for example. Since the chips can have multiple serial ports, they made the port interface a class, and each individual port an instance of the class.
Logged


Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just find a book on C++.

I like Thinking In C++ by Bruce Eckel
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 47
Posts: 2927
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thinking in C++ and Programming in C++, Nice, Free books.... Code too.
Not for beginners, though.

Bob
« Last Edit: February 15, 2013, 07:08:18 am by Docedison » Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Offline Offline
Full Member
***
Karma: 1
Posts: 135
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just wrote one, it was surprisingly easy and it compiles on the fly -- change .cpp source, you run your sketch, it is compiled!!!

I wonder why I was not into Arduino world before . . . :-)
Logged

Search for "mjkzz" on eBay :-)

Pages: [1]   Go Up
Jump to: