From 68ba3d51065f56947e4c2d7d76f46b7b8913f61a Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 25 Aug 2017 23:21:55 -0400 Subject: [PATCH] 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 --- klippy/mcu.py | 21 +++++++++++---------- klippy/pins.py | 7 ++----- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/klippy/mcu.py b/klippy/mcu.py index 1132ab42..b653379a 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -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): diff --git a/klippy/pins.py b/klippy/pins.py index cdfdede0..a9a2ec26 100644 --- a/klippy/pins.py +++ b/klippy/pins.py @@ -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[ _]pin=)(?P[^ ]*)') -re_ticks = re.compile(r'TICKS\((?P[^)]*)\)') 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) ######################################################################