Skip to content

Commit

Permalink
small refactor for tmc2660
Browse files Browse the repository at this point in the history
  • Loading branch information
bwnance committed Nov 6, 2023
1 parent 5c1d8bb commit d731f23
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions klippy/extras/homing.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def _set_current_homing(self, homing_axes):

for rail in affected_rails:
ch = rail.get_tmc_current_helper()
if ch is not None and ch._home_current != ch.run_current:
if ch is not None and ch.needs_home_current_change():
ch.set_current_for_homing(print_time)
self.toolhead.dwell(ch.current_change_dwell_time)

Expand All @@ -254,7 +254,7 @@ def _set_current_post_homing(self, homing_axes):

for rail in affected_rails:
ch = rail.get_tmc_current_helper()
if ch is not None and ch._home_current != ch.run_current:
if ch is not None and ch.needs_home_current_change():
ch.set_current_for_normal(print_time)
self.toolhead.dwell(ch.current_change_dwell_time)

Expand Down
3 changes: 3 additions & 0 deletions klippy/extras/tmc2130.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ def __init__(self, config, mcu_tmc):
self.fields.set_field("ihold", ihold)
self.fields.set_field("irun", irun)

def needs_home_current_change(self):
return self._home_current != self.run_current

def set_home_current(self, new_home_current):
self._home_current = min(MAX_CURRENT, new_home_current)

Expand Down
3 changes: 3 additions & 0 deletions klippy/extras/tmc2240.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ def __init__(self, config, mcu_tmc):
self.fields.set_field("ihold", ihold)
self.fields.set_field("irun", irun)

def needs_home_current_change(self):
return self._home_current != self.run_current

def set_home_current(self, new_home_current):
self._home_current = min(self.max_cur, new_home_current)

Expand Down
3 changes: 3 additions & 0 deletions klippy/extras/tmc2660.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ def __init__(self, config, mcu_tmc):
"idle_timeout:ready", self._handle_ready
)

def needs_home_current_change(self):
return self._home_current != self.current

def set_home_current(self, new_home_current):
self._home_current = min(MAX_CURRENT, new_home_current)

Expand Down
3 changes: 3 additions & 0 deletions klippy/extras/tmc5160.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ def __init__(self, config, mcu_tmc):
self.fields.set_field("ihold", ihold)
self.fields.set_field("irun", irun)

def needs_home_current_change(self):
return self._home_current != self.run_current

def set_home_current(self, new_home_current):
self._home_current = min(MAX_CURRENT, new_home_current)

Expand Down

0 comments on commit d731f23

Please sign in to comment.