For anyone who wants this feature, here is a way to achieve at least a basic way of doing it.
1. Create a file in your project called version.h
2. Put the following in version.h
#define VERSION 1
3. Create a version.bat file in your project and mark it as Exclude from project
4. Add the following to version.bat:
@echo off
setlocal EnableDelayedExpansion
set file=%1
for /F "tokens=1-3 delims=N " %%a in (%file%) do (
for %%A in (%%a %%b %%c) do set "i=%%A"
)
set /a i=i+1
echo #define VERSION %i% > %file%
5. Add the following to your Board.txt
# Increment version before build
recipe.hooks.sketch.prebuild.1.pattern=cmd.exe /c "{build.project_path}\version.bat {build.project_path}\version.h"
6. Add #Include "version.h" in your sketch
The version number will increment by 1 every time you do a build, irrespective if it succeeds or fails.
To use the version just use the defined VERSION in your code for example:
Serial.printf("Startup Version:%d\n", VERSION);
Acuario