Skip to content

Commit

Permalink
feat/tmc - warning for sense_resistor
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerlz committed Jul 4, 2024
1 parent 82364d4 commit c1b3a90
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions klippy/extras/tmc2130.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
import math
from . import bus, tmc
from configfile import PrinterConfig

TMC_FREQUENCY = 13200000.0

Expand Down Expand Up @@ -200,6 +201,19 @@
class TMC2130CurrentHelper(tmc.BaseTMCCurrentHelper):
def __init__(self, config, mcu_tmc):
super().__init__(config, mcu_tmc, MAX_CURRENT)
pconfig: PrinterConfig = self.printer.lookup_object("configfile")

self.sense_resistor = config.get("sense_resistor", None)
if self.sense_resistor is None:
pconfig.warn(
"config",
f"""[{self.name}] sense_resistor not specified; using default = 0.110.
If this value is wrong, it might burn your house down.
This parameter will be mandatory in future versions.
Specify the parameter to omit this message""",
self.name,
"sense_resistor",
)

self.sense_resistor = config.getfloat(
"sense_resistor", 0.110, above=0.0
Expand Down
14 changes: 14 additions & 0 deletions klippy/extras/tmc5160.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import math
from . import tmc
from . import tmc2130
from configfile import PrinterConfig

TMC_FREQUENCY = 12000000.0

Expand Down Expand Up @@ -254,6 +255,19 @@
class TMC5160CurrentHelper(tmc.BaseTMCCurrentHelper):
def __init__(self, config, mcu_tmc):
super().__init__(config, mcu_tmc, MAX_CURRENT)
pconfig: PrinterConfig = self.printer.lookup_object("configfile")

self.sense_resistor = config.get("sense_resistor", None)
if self.sense_resistor is None:
pconfig.warn(
"config",
f"""[{self.name}] sense_resistor not specified; using default = 0.075.
If this value is wrong, it might burn your house down.
This parameter will be mandatory in future versions.
Specify the parameter to omit this message""",
self.name,
"sense_resistor",
)

self.sense_resistor = config.getfloat(
"sense_resistor", 0.075, above=0.0
Expand Down

0 comments on commit c1b3a90

Please sign in to comment.