Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
[platformio]
default_envs = uno

[env]
extra_scripts = pre:tools/inject_version.py

[env:uno]
platform = atmelavr
board = uno
Expand Down
6 changes: 6 additions & 0 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

#include <stdint.h>

// ── Firmware version ──────────────────────────────────────────────────────────
// Injected at build time by tools/inject_version.py from the git tag.
#ifndef APP_VERSION
#define APP_VERSION "dev"
#endif

// ── Cooperative task intervals (ms) ──────────────────────────────────────────
// KWP is timing-critical; 0 = run every loop iteration.
static constexpr uint16_t INTERVAL_KWP_MS = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/obd/OBDDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ void OBDDisplay::begin()
void OBDDisplay::startupAnimation_()
{
display_.clear();
display_.print(0, 6, F("O B D"));
display_.print(2, 8, F("DISPLAY"));
display_.print(0, 6, F("OBDisplay"));
display_.print(2, 8, F(APP_VERSION));

uint32_t start = millis();
while (millis() - start < 777)
Expand Down
12 changes: 12 additions & 0 deletions tools/inject_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import subprocess
Import("env")

try:
version = subprocess.check_output(
["git", "describe", "--tags", "--abbrev=0"],
stderr=subprocess.DEVNULL,
).decode().strip() or "dev"
except Exception:
version = "dev"

env.Append(CPPDEFINES=[("APP_VERSION", '\\"' + version + '\\"')])
Loading