mirror of https://github.com/Desuuuu/klipper.git
mcu: Drop support for TICKS() expansion in mcu config commands
It's no longer necessary to use the TICKS() hack as the config commands are now all generated after the mcu speed is known. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
80dc1dfcc1
commit
68ba3d5106
|
@ -45,9 +45,9 @@ class MCU_stepper:
|
|||
min_stop_interval = max(0., self._min_stop_interval - max_error)
|
||||
self._mcu.add_config_cmd(
|
||||
"config_stepper oid=%d step_pin=%s dir_pin=%s"
|
||||
" min_stop_interval=TICKS(%.9f) invert_step=%d" % (
|
||||
" min_stop_interval=%d invert_step=%d" % (
|
||||
self._oid, self._step_pin, self._dir_pin,
|
||||
min_stop_interval, self._invert_step))
|
||||
min_stop_interval * self._mcu_freq, self._invert_step))
|
||||
step_cmd = self._mcu.lookup_command(
|
||||
"queue_step oid=%c interval=%u count=%hu add=%hi")
|
||||
dir_cmd = self._mcu.lookup_command(
|
||||
|
@ -261,8 +261,9 @@ class MCU_digital_out:
|
|||
self._oid = self._mcu.create_oid()
|
||||
self._mcu.add_config_cmd(
|
||||
"config_digital_out oid=%d pin=%s default_value=%d"
|
||||
" max_duration=TICKS(%f)" % (
|
||||
self._oid, self._pin, self._invert, self._max_duration))
|
||||
" max_duration=%d" % (
|
||||
self._oid, self._pin, self._invert,
|
||||
self._max_duration * self._mcu_freq))
|
||||
self._set_cmd = self._mcu.lookup_command(
|
||||
"schedule_digital_out oid=%c clock=%u value=%c")
|
||||
def set_digital(self, mcu_time, value):
|
||||
|
@ -326,9 +327,9 @@ class MCU_pwm:
|
|||
self._oid = self._mcu.create_oid()
|
||||
self._mcu.add_config_cmd(
|
||||
"config_pwm_out oid=%d pin=%s cycle_ticks=%d default_value=%d"
|
||||
" max_duration=TICKS(%f)" % (
|
||||
" max_duration=%d" % (
|
||||
self._oid, self._pin, self._cycle_time, self._invert,
|
||||
self._max_duration))
|
||||
self._max_duration * self._mcu_freq))
|
||||
self._set_cmd = self._mcu.lookup_command(
|
||||
"schedule_pwm_out oid=%c clock=%u value=%hu")
|
||||
else:
|
||||
|
@ -342,10 +343,10 @@ class MCU_pwm:
|
|||
return
|
||||
self._oid = self._mcu.create_oid()
|
||||
self._mcu.add_config_cmd(
|
||||
"config_soft_pwm_out oid=%d pin=%s cycle_ticks=TICKS(%f)"
|
||||
" default_value=%d max_duration=TICKS(%f)" % (
|
||||
self._oid, self._pin, self._cycle_time, self._invert,
|
||||
self._max_duration))
|
||||
"config_soft_pwm_out oid=%d pin=%s cycle_ticks=%d"
|
||||
" default_value=%d max_duration=%d" % (
|
||||
self._oid, self._pin, self._cycle_time * self._mcu_freq,
|
||||
self._invert, self._max_duration * self._mcu_freq))
|
||||
self._set_cmd = self._mcu.lookup_command(
|
||||
"schedule_soft_pwm_out oid=%c clock=%u value=%hu")
|
||||
def set_pwm(self, mcu_time, value):
|
||||
|
|
|
@ -159,15 +159,12 @@ def get_pin_map(mcu, mapping_name=None):
|
|||
update_map_beaglebone(pins, mcu)
|
||||
return pins
|
||||
|
||||
# Translate pin names and tick times in a firmware command
|
||||
# Translate pin names in a firmware command
|
||||
re_pin = re.compile(r'(?P<prefix>[ _]pin=)(?P<name>[^ ]*)')
|
||||
re_ticks = re.compile(r'TICKS\((?P<ticks>[^)]*)\)')
|
||||
def update_command(cmd, mcu_freq, pmap):
|
||||
def pin_fixup(m):
|
||||
return m.group('prefix') + str(pmap[m.group('name')])
|
||||
def ticks_fixup(m):
|
||||
return str(int(mcu_freq * float(m.group('ticks'))))
|
||||
return re_ticks.sub(ticks_fixup, re_pin.sub(pin_fixup, cmd))
|
||||
return re_pin.sub(pin_fixup, cmd)
|
||||
|
||||
|
||||
######################################################################
|
||||
|
|
Loading…
Reference in New Issue