diff --git a/AfRApay.MateCard/include/vars.h b/AfRApay.MateCard/include/vars.h index b28d9b3..a83ed80 100644 --- a/AfRApay.MateCard/include/vars.h +++ b/AfRApay.MateCard/include/vars.h @@ -3,10 +3,13 @@ #pragma ide diagnostic ignored "OCUnusedMacroInspection" // this should be defined by our build script -#ifndef AFRAPAY_REVISION -#define AFRAPAY_REVISION "unknown" +#ifndef AFRAPAY_GIT_BRANCH +#define AFRAPAY_GIT_BRANCH "?" #endif +#ifndef AFRAPAY_GIT_COMMIT +#define AFRAPAY_GIT_COMMIT "unknown" +#endif //MFRC522 pinout (front) 3V3 RST GND IRQ MISO MOSI SCK SDA //MFRC522 pinout (rear) SDA SCK MOSI MISO IRQ GND RST 3V3 #define PIN_HSPI_RST 4 diff --git a/AfRApay.MateCard/platformio.ini b/AfRApay.MateCard/platformio.ini index 0a87771..99c6c64 100644 --- a/AfRApay.MateCard/platformio.ini +++ b/AfRApay.MateCard/platformio.ini @@ -26,4 +26,4 @@ lib_deps = check_tool = clangtidy check_flags = clangtidy: --config-file=.clang-tidy -build_flags = !echo '-DAFRAPAY_REVISION=\\"'$(git describe --long --always --dirty --exclude=* --abbrev=8)'\\"' +build_flags = !scripts/build_git_rev.sh diff --git a/AfRApay.MateCard/scripts/build_git_rev.sh b/AfRApay.MateCard/scripts/build_git_rev.sh new file mode 100755 index 0000000..9146814 --- /dev/null +++ b/AfRApay.MateCard/scripts/build_git_rev.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +branch=$(git rev-parse --abbrev-ref HEAD) +rev=$(git diff --quiet && git describe --long --always --dirty --exclude=* --abbrev=8 || echo "dirty") + +echo "-DAFRAPAY_GIT_BRANCH=\\\"$branch\\\" -DAFRAPAY_GIT_COMMIT=\\\"$rev\\\"" diff --git a/AfRApay.MateCard/src/oled.cpp b/AfRApay.MateCard/src/oled.cpp index ad7bd26..2ab0cae 100644 --- a/AfRApay.MateCard/src/oled.cpp +++ b/AfRApay.MateCard/src/oled.cpp @@ -129,7 +129,7 @@ void updateOLED(U8G2 u8g2, e_state state, const String& statusText, const String void updateOLED(const U8G2& u8g2, e_state state) { String time = DateTime.format(DateFormatter::TIME_ONLY); if (!digitalRead(PIN_INTERRUPT_CANCEL) || millis()%20000 < 10000) - updateOLED(u8g2, state, time, AFRAPAY_REVISION); + updateOLED(u8g2, state, time, AFRAPAY_GIT_COMMIT); else updateOLED(u8g2, state, time, WiFi.localIP().toString()); }