From e6307ca9fe8d6e63037fa22ec9a2200f7921537c Mon Sep 17 00:00:00 2001
From: Alex Voinea <voinea.dragos.alexandru@gmail.com>
Date: Sat, 4 Mar 2023 10:11:22 +0100
Subject: [PATCH] tmc: Fix s2vs field formatters

Rename the field formatter text for tmc2208/tmc2209 and implement it also for tmc5160.

Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
---
 docs/TMC_Drivers.md      | 2 +-
 klippy/extras/tmc2208.py | 4 ++--
 klippy/extras/tmc5160.py | 4 ++++
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/docs/TMC_Drivers.md b/docs/TMC_Drivers.md
index b036b57e0..d2a7eaa33 100644
--- a/docs/TMC_Drivers.md
+++ b/docs/TMC_Drivers.md
@@ -544,7 +544,7 @@ hot. Typical solutions are to decrease the stepper motor current,
 increase cooling on the stepper motor driver, and/or increase cooling
 on the stepper motor.
 
-#### TMC reports error: `... ShortToGND` OR `LowSideShort`
+#### TMC reports error: `... ShortToGND` OR `ShortToSupply`
 
 This indicates the driver has disabled itself because it detected very
 high current passing through the driver. This may indicate a loose or
diff --git a/klippy/extras/tmc2208.py b/klippy/extras/tmc2208.py
index 1b5968a91..1378c6260 100644
--- a/klippy/extras/tmc2208.py
+++ b/klippy/extras/tmc2208.py
@@ -173,8 +173,8 @@ SignedFields = ["cur_a", "cur_b", "pwm_scale_auto"]
 FieldFormatters = dict(tmc2130.FieldFormatters)
 FieldFormatters.update({
     "sel_a":            (lambda v: "%d(%s)" % (v, ["TMC222x", "TMC220x"][v])),
-    "s2vsa":            (lambda v: "1(LowSideShort_A!)" if v else ""),
-    "s2vsb":            (lambda v: "1(LowSideShort_B!)" if v else ""),
+    "s2vsa":            (lambda v: "1(ShortToSupply_A!)" if v else ""),
+    "s2vsb":            (lambda v: "1(ShortToSupply_B!)" if v else ""),
 })
 
 
diff --git a/klippy/extras/tmc5160.py b/klippy/extras/tmc5160.py
index 5d570958a..f63d17ee2 100644
--- a/klippy/extras/tmc5160.py
+++ b/klippy/extras/tmc5160.py
@@ -239,6 +239,10 @@ Fields["TSTEP"] = {
 SignedFields = ["cur_a", "cur_b", "sgt", "xactual", "vactual", "pwm_scale_auto"]
 
 FieldFormatters = dict(tmc2130.FieldFormatters)
+FieldFormatters.update({
+    "s2vsa":            (lambda v: "1(ShortToSupply_A!)" if v else ""),
+    "s2vsb":            (lambda v: "1(ShortToSupply_B!)" if v else ""),
+})
 
 
 ######################################################################