Including/define version numbers in sketch.

Hi all,

In all your opinions what is the best way to include/define a sketch version number like v0.1.0 into the sketch so that it could be used. For example serial print the version number when the sketch starts up.

Many thanks ppl.

A common technique is to use DATE and TIME to indicate a revision.

How does that work please.

Would this be a good way?

Software version - v0.1.0
*/

const char SoftwearVersion[7] = "v0.1.0";

///////////////////////////////
//Software serial port setup.//
//Rx pin 2, Tx pin 3.        //
///////////////////////////////
#include <SoftwareSerial.h>
SoftwareSerial SoftwareSerial(2, 3);

Would this be a good way?

const char SoftwearVersion[7] = "v0.1.0";

Softwear? Is that like socks and t-shirts?

There is no reason to define the size of the array. The compiler can count.

Forget to answer the question. Yes, that is a good way.

Pavilion1984: Would this be a good way?

Certainly.

An example of how to use DATE and TIME ... http://arduino.cc/playground/Main/ShowInfo

Pavilion1984: How does that work please.

DATE and TIME are created by the compiler and are strings based on the date and time that GCC compiled the object file. So, in your setup function you could utilize the string pasting that the compiler does for adjacent string literals and do:

void setup (void)
{
    Serial.begin (9600);
    Serial.println ("Built on " __DATE__ " at " __TIME__");
}

Thanks PaulS, just noticed :blush:. Thanks Coding Badly and MichaelMeissner.

I suggest to not use strings that way. This approach allocates unnecessary amounts of RAM. Instead I would do this with the F macro like so:

 Serial.println (F("Built on " __DATE__ " at " __TIME__"));

What does the F macro do?

http://www.arduino.cc/playground/Learning/Memory

[quote author=Udo Klein link=topic=116707.msg878467#msg878467 date=1343764093] I suggest to not use strings that way. This approach allocates unnecessary amounts of RAM. Instead I would do this with the F macro like so: [/quote]

IIRC, F did not exist in the ancient version (0.22) of the IDE environment I'm currently stuck on, so at present I don't use it.

If you are curious, newer versions of Fedora LInux have moved to Gnome3 which doesn't work too well with my older Dell D620 laptop's video chip. Unfortunately, Fedora needs a special version of avrdude, and my initial attempts at getting the Arduino 1.0.1 release to use the Fedora avrdude haven't been successful.

MichaelMeissner:
IIRC, F did not exist in the ancient version (0.22) of the IDE environment I’m currently stuck on, so at present I don’t use it.

Would you like to add it?

Many thanks to you all, learnt alot ;).

[quote author=Coding Badly link=topic=116707.msg878556#msg878556 date=1343768876]

MichaelMeissner: IIRC, F did not exist in the ancient version (0.22) of the IDE environment I'm currently stuck on, so at present I don't use it.

Would you like to add it?

[/quote] Well, I really would like to move past Fedora 14 to Fedora 17, and to at least 1.0 of the IDE. I was trying to upgrade last night, and it hung in bringing up the video.

At the present, I'm not running out of space, so I haven't worried about it.

Of course as an amusing factoid, in the GCC 4.5 time frame, I implemented some framework in the GCC compiler for supporting different address spaces, that I believe newer versions of the compiler use on the AVR port. Of course, I did this to support the processor I was working on at the time (Cell), but it is useful in a few other embedded ports like the AVR. However, I really don't want to go digging into the AVR stuff for a hobby project. I'm already quite busy with my current day job. :)