tmc2130: Do not error if run current below hold current (#2190)
Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
This commit is contained in:
parent
9055e9f9b5
commit
b0a158c271
|
@ -123,11 +123,13 @@ class TMCCurrentHelper:
|
|||
def _calc_current(self, run_current, hold_current):
|
||||
vsense = False
|
||||
irun = self._calc_current_bits(run_current, vsense)
|
||||
ihold = self._calc_current_bits(hold_current, vsense)
|
||||
ihold = self._calc_current_bits(min(hold_current, run_current),
|
||||
vsense)
|
||||
if irun < 16 and ihold < 16:
|
||||
vsense = True
|
||||
irun = self._calc_current_bits(run_current, vsense)
|
||||
ihold = self._calc_current_bits(hold_current, vsense)
|
||||
ihold = self._calc_current_bits(min(hold_current, run_current),
|
||||
vsense)
|
||||
return vsense, irun, ihold
|
||||
def _calc_current_from_field(self, field_name):
|
||||
bits = self.fields.get_field(field_name)
|
||||
|
@ -147,7 +149,7 @@ class TMCCurrentHelper:
|
|||
hold_current = self._calc_current_from_field("IHOLD")
|
||||
if 'CURRENT' in params:
|
||||
run_current = gcode.get_float(
|
||||
'CURRENT', params, minval=hold_current, maxval=MAX_CURRENT)
|
||||
'CURRENT', params, minval=0., maxval=MAX_CURRENT)
|
||||
else:
|
||||
run_current = self._calc_current_from_field("IRUN")
|
||||
if 'HOLDCURRENT' not in params and 'CURRENT' not in params:
|
||||
|
|
|
@ -250,7 +250,7 @@ class TMC5160CurrentHelper:
|
|||
return max(0, min(31, cs))
|
||||
def _calc_current(self, run_current, hold_current):
|
||||
irun = self._calc_current_bits(run_current)
|
||||
ihold = self._calc_current_bits(hold_current)
|
||||
ihold = self._calc_current_bits(min(hold_current, run_current))
|
||||
return irun, ihold
|
||||
def _calc_current_from_field(self, field_name):
|
||||
bits = self.fields.get_field(field_name)
|
||||
|
@ -267,7 +267,7 @@ class TMC5160CurrentHelper:
|
|||
hold_current = self._calc_current_from_field("IHOLD")
|
||||
if 'CURRENT' in params:
|
||||
run_current = gcode.get_float(
|
||||
'CURRENT', params, minval=hold_current, maxval=MAX_CURRENT)
|
||||
'CURRENT', params, minval=0., maxval=MAX_CURRENT)
|
||||
else:
|
||||
run_current = self._calc_current_from_field("IRUN")
|
||||
if 'HOLDCURRENT' not in params and 'CURRENT' not in params:
|
||||
|
|
Loading…
Reference in New Issue