Skip to content

Commit

Permalink
added firmware/git rev script
Browse files Browse the repository at this point in the history
  • Loading branch information
ilovehotcakes committed Jun 4, 2024
1 parent d0e7373 commit 07a5a1c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ build_flags =
extra_scripts =
pre:./src/frontend/assembly.py
pre:./src/scripts/modify_fastaccelstepper.py
pre:./src/scripts/git_revision.py

; board_build.partitions = default_8MB.csv
22 changes: 22 additions & 0 deletions src/scripts/git_revision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import subprocess

revision = (
subprocess.check_output(["git", "rev-parse", "HEAD"])
.strip()
.decode("utf-8")[:7]
)

def modify_system_task_h():
result = ""
with open("./src/system_task.h", 'r') as file:
for line in file:
if "String firmware_ =" in line:
result += f" String firmware_ = \"{revision}\";\n"
else:
result += line

with open("./src/system_task.h", 'w') as output:
output.write(result)


modify_system_task_h()
1 change: 1 addition & 0 deletions src/system_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void SystemTask::loadSettings() {
serial_ = getSerialNumber();
settings_["serial_"] = serial_;
}
firmware_ = getOrDefault("firmware_", firmware_);
system_wake_time_ = getOrDefault("system_wake_time_", system_wake_time_);
system_sleep_time_ = getOrDefault("system_sleep_time_", system_sleep_time_);

Expand Down
4 changes: 2 additions & 2 deletions src/system_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class SystemTask: public Task {
String serial_ = "";
// String manufacturer_ = "";
// String model_ = "";
// String firmware_ = "0.1.1";
int system_wake_time_ = SYSTEM_WAKE_DURATION; // ms
String firmware_ = "d0e7373";
int system_wake_time_ = SYSTEM_WAKE_DURATION; // ms
int system_sleep_time_ = SYSTEM_SLEEP_DURTION * 1000; // us

bool button_pressed_ = false;
Expand Down

0 comments on commit 07a5a1c

Please sign in to comment.