Skip to content

Commit

Permalink
updated git_revision.py to using pio macro intead of overwritting sys…
Browse files Browse the repository at this point in the history
…tem_task.h
  • Loading branch information
ilovehotcakes committed Jun 4, 2024
1 parent 07a5a1c commit 0a3372c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
23 changes: 12 additions & 11 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,23 @@ build_flags =
-D BUTTON_PIN=0 ; User button

; Define ESP32 connections to stepper motor driver (Trinamic TMC2209) and other settings
-D STEP_PIN=GPIO_NUM_16 ; Step pin
-D DIR_PIN=GPIO_NUM_18 ; Direction pin
-D DIAG_PIN=GPIO_NUM_23 ; For StallGuard, High if detect error
-D STBY_PIN=GPIO_NUM_19 ; Pull high to disable TMC2209
-D TXD1=GPIO_NUM_22 ; For Serial1
-D RXD1=GPIO_NUM_21 ; For Serial1
-D R_SENSE=0.12f ; Sense resistor, double check the board's sense resistor value
-D DRIVER_ADDR=0b00 ; 0b00 is slave, since there're no other TMC stepper motor drivers
-D STEP_PIN=GPIO_NUM_16 ; Step pin
-D DIR_PIN=GPIO_NUM_18 ; Direction pin
-D DIAG_PIN=GPIO_NUM_23 ; For StallGuard, High if detect error
-D STBY_PIN=GPIO_NUM_19 ; Pull high to disable TMC2209
-D TXD1=GPIO_NUM_22 ; For Serial1
-D RXD1=GPIO_NUM_21 ; For Serial1
-D R_SENSE=0.12f ; Sense resistor, double check the board's sense resistor value
-D DRIVER_ADDR=0b00 ; 0b00 is slave, since there're no other TMC stepper motor drivers

; Define ESP32 connection to rotary encoder (AS5600)
-D SCL_PIN=GPIO_NUM_27 ; SPI clock pin
-D SDA_PIN=GPIO_NUM_14 ; SPI data pin
-D SCL_PIN=GPIO_NUM_27 ; SPI clock pin
-D SDA_PIN=GPIO_NUM_14 ; SPI data pin

!python ./src/scripts/git_revision.py

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
16 changes: 1 addition & 15 deletions src/scripts/git_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,4 @@
.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()
print("'-D GIT_REV=\"%s\"'" % revision)
2 changes: 1 addition & 1 deletion src/system_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SystemTask: public Task {
String serial_ = "";
// String manufacturer_ = "";
// String model_ = "";
String firmware_ = "d0e7373";
String firmware_ = GIT_REV;
int system_wake_time_ = SYSTEM_WAKE_DURATION; // ms
int system_sleep_time_ = SYSTEM_SLEEP_DURTION * 1000; // us

Expand Down

0 comments on commit 0a3372c

Please sign in to comment.