Skip to content

Commit

Permalink
Added vesion tracking for git. Is this overkill for an example??
Browse files Browse the repository at this point in the history
  • Loading branch information
maniacbug committed Jun 12, 2011
1 parent 9ea4cb4 commit 2a2f893
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/sensornet/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version.h
output/
ojam/
.*.swp
18 changes: 17 additions & 1 deletion examples/sensornet/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ;
AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ;
AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ;

DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) ;
DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
CTUNING = -ffunction-sections -fdata-sections ;
CXXTUNING = -fno-exceptions ;
CFLAGS = -Os -Werror -Wall -Wextra -mmcu=$(MCU) $(CTUNING) ;
Expand Down Expand Up @@ -77,6 +77,21 @@ AVRDUDE_FLAGS = -V -F -D -C $(AVRDUDECONFIG_PATH)/avrdude.conf -p $(MCU) -c $(AV
# Echo [ GLOB $(ARDUINO_LIB)/$(>:B) $(SKETCH_LIB)/$(>:B) : *.cpp ] ;
#}

rule GitVersion
{
Always $(<) ;
Depends all : $(<) ;
}

actions GitVersion
{
echo "const char program_version[] = \"\\" > $(<)
git log @{1}..@{0} --pretty=format:%h >> $(<)
echo "\";" >> $(<)
}

GitVersion version.h ;

rule AvrCc
{
Depends $(<) : $(>) ;
Expand Down Expand Up @@ -189,6 +204,7 @@ rule AvrUpload
Depends $(2) : $(3) ;
NotFile $(1) ;
Always $(1) ;
Always $(2) ;
AvrUploadAction $(2) : $(3) ;
}

Expand Down
9 changes: 8 additions & 1 deletion examples/sensornet/sensornet.pde
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
#undef PSTR
#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];}))

#ifdef VERSION_H
#include "version.h"
#else
const char program_version[] = "Unknown";
#endif

// This exact same code will work with an unlimited number of nodes connected in a giant mesh.
// Increase the sleep delay with many more nodes!
RF24NodeLine topology[] =
Expand Down Expand Up @@ -79,7 +85,8 @@ void setup(void)

Serial.begin(57600);
printf_begin();
printf("\n\rRF24Network/examples/sensornet/\n\r");
printf_P(PSTR("\n\rRF24Network/examples/sensornet/\n\r"));
printf_P(PSTR("VERSION: %s\n\r"),program_version);

//
// Pull node address out of eeprom
Expand Down

0 comments on commit 2a2f893

Please sign in to comment.