diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-02-20 20:02:10 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-02-27 10:39:47 -0500 |
commit | e24709b11234d036bf8c8016c24cfe91faab6bc9 (patch) | |
tree | f49808c516ca61d8d18f3c527449bc1eb3fc8cd1 | |
parent | 2d781b834090b957f1a3850a7df68d07470bc8a5 (diff) | |
download | kutter-e24709b11234d036bf8c8016c24cfe91faab6bc9.tar.gz kutter-e24709b11234d036bf8c8016c24cfe91faab6bc9.tar.xz kutter-e24709b11234d036bf8c8016c24cfe91faab6bc9.zip |
tmc2660: Use common warning/error flag names and descriptions
Where the tmc2660 flags match other drivers, use lowercase so that the
same monitoring code can be used for all the tmc drivers. Also, use
the same field formatters where applicable.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | klippy/extras/tmc2660.py | 73 |
1 files changed, 30 insertions, 43 deletions
diff --git a/klippy/extras/tmc2660.py b/klippy/extras/tmc2660.py index 44280c86..a3f783f3 100644 --- a/klippy/extras/tmc2660.py +++ b/klippy/extras/tmc2660.py @@ -1,11 +1,11 @@ # TMC2660 configuration # # Copyright (C) 2018-2019 Florian Heilmann <Florian.Heilmann@gmx.net> -# Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net> +# Copyright (C) 2019-2021 Kevin O'Connor <kevin@koconnor.net> # # This file may be distributed under the terms of the GNU GPLv3 license. import math, logging -from . import bus, tmc +from . import bus, tmc, tmc2130 Registers = { "DRVCONF": 0xE, "SGCSCONF": 0xC, "SMARTEN": 0xA, @@ -59,66 +59,53 @@ Fields["DRVCONF"] = { Fields["READRSP@RDSEL0"] = { "SG": 0x01, - "OT": 0x01 << 1, - "OTPW": 0x01 << 2, - "S2GA": 0x01 << 3, - "S2GB": 0x01 << 4, - "OLA": 0x01 << 5, - "OLB": 0x01 << 6, - "STST": 0x01 << 7, + "ot": 0x01 << 1, + "otpw": 0x01 << 2, + "s2ga": 0x01 << 3, + "s2gb": 0x01 << 4, + "ola": 0x01 << 5, + "olb": 0x01 << 6, + "stst": 0x01 << 7, "MSTEP": 0x3ff << 10 } Fields["READRSP@RDSEL1"] = { "SG": 0x01, - "OT": 0x01 << 1, - "OTPW": 0x01 << 2, - "S2GA": 0x01 << 3, - "S2GB": 0x01 << 4, - "OLA": 0x01 << 5, - "OLB": 0x01 << 6, - "STST": 0x01 << 7, + "ot": 0x01 << 1, + "otpw": 0x01 << 2, + "s2ga": 0x01 << 3, + "s2gb": 0x01 << 4, + "ola": 0x01 << 5, + "olb": 0x01 << 6, + "stst": 0x01 << 7, "SG@RDSEL1": 0x3ff << 10 } Fields["READRSP@RDSEL2"] = { "SG": 0x01, - "OT": 0x01 << 1, - "OTPW": 0x01 << 2, - "S2GA": 0x01 << 3, - "S2GB": 0x01 << 4, - "OLA": 0x01 << 5, - "OLB": 0x01 << 6, - "STST": 0x01 << 7, + "ot": 0x01 << 1, + "otpw": 0x01 << 2, + "s2ga": 0x01 << 3, + "s2gb": 0x01 << 4, + "ola": 0x01 << 5, + "olb": 0x01 << 6, + "stst": 0x01 << 7, "SG@RDSEL2": 0x1f << 15, "SE": 0x1f << 10 } SignedFields = ["SGT"] -FieldFormatters = { - "MRES": (lambda v: "%d(%dusteps)" % (v, 0x100 >> v)), - "DEDGE": (lambda v: - "1(Both Edges Active)" if v else "0(Only Rising Edge active)"), - "intpol": (lambda v: "1(On)" if v else "0(Off)"), - "toff": (lambda v: ("%d" % v) if v else "0(Driver Disabled!)"), +FieldFormatters = dict(tmc2130.FieldFormatters) +FieldFormatters.update({ + "DEDGE": (lambda v: "1(Both Edges Active!)" if v else ""), "CHM": (lambda v: "1(constant toff)" if v else "0(spreadCycle)"), "SFILT": (lambda v: "1(Filtered mode)" if v else "0(Standard mode)"), "VSENSE": (lambda v: "%d(%dmV)" % (v, 165 if v else 305)), - "SDOFF": (lambda v: "1(Step/Dir disabled" if v else "0(Step/dir enabled)"), - "DISS2G": (lambda v: "%d(Short to GND protection %s)" % (v, - "disabled" if v else "enabled")), - "MSTEP": (lambda v: "%d(%d, OA1 %s OA2)" % (v, v & 0xff, - "<=" if v & 0x100 else "=>")), - "SG": (lambda v: "%d(%s)" % (v, "Stall!" if v else "No Stall!")), - "OT": (lambda v: "1(Overtemp shutdown!)" if v else ""), - "OTPW": (lambda v: "1(Overtemp warning!)" if v else ""), - "S2GA": (lambda v: "1(Short to GND Coil A!)" if v else ""), - "S2GB": (lambda v: "1(Short to GND Coil B!)" if v else ""), - "OLA": (lambda v: "1(Open Load Coil A at slow speed!)" if v else ""), - "OLB": (lambda v: "1(Open Load Coil B at slow speed!)" if v else ""), - "STST": (lambda v: "1(Standstill detected!)" if v else ""), -} + "SDOFF": (lambda v: "1(Step/Dir disabled!)" if v else ""), + "DISS2G": (lambda v: "%d(Short to GND disabled!)" if v else ""), + "SG": (lambda v: "1(Stall!)" if v else ""), +}) ###################################################################### |