diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2023-12-19 14:57:39 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2023-12-19 14:57:39 -0500 |
commit | 547bfbf81847c758a3fb07e76963544bdbc6438d (patch) | |
tree | f096cb949414194b0fcc0aa51294f98a712aedf3 /klippy/extras/pwm_tool.py | |
parent | 3417940fd82adf621f429f42289d3693ee832582 (diff) | |
download | kutter-547bfbf81847c758a3fb07e76963544bdbc6438d.tar.gz kutter-547bfbf81847c758a3fb07e76963544bdbc6438d.tar.xz kutter-547bfbf81847c758a3fb07e76963544bdbc6438d.zip |
pwm_tool: Fix error reporting
References to pins.error are not valid as the pins module is not
imported. Reported by @Piezoid.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/pwm_tool.py')
-rw-r--r-- | klippy/extras/pwm_tool.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/klippy/extras/pwm_tool.py b/klippy/extras/pwm_tool.py index 0b3dd0c0..5fc09eab 100644 --- a/klippy/extras/pwm_tool.py +++ b/klippy/extras/pwm_tool.py @@ -50,19 +50,20 @@ class MCU_queued_pwm: self._start_value = max(0., min(1., start_value)) self._shutdown_value = max(0., min(1., shutdown_value)) def _build_config(self): + config_error = self._mcu.get_printer().config_error if self._max_duration and self._start_value != self._shutdown_value: - raise pins.error("Pin with max duration must have start" - " value equal to shutdown value") + raise config_error("Pin with max duration must have start" + " value equal to shutdown value") cmd_queue = self._mcu.alloc_command_queue() curtime = self._mcu.get_printer().get_reactor().monotonic() printtime = self._mcu.estimated_print_time(curtime) self._last_clock = self._mcu.print_time_to_clock(printtime + 0.200) cycle_ticks = self._mcu.seconds_to_clock(self._cycle_time) if cycle_ticks >= 1<<31: - raise pins.error("PWM pin cycle time too large") + raise config_error("PWM pin cycle time too large") self._duration_ticks = self._mcu.seconds_to_clock(self._max_duration) if self._duration_ticks >= 1<<31: - raise pins.error("PWM pin max duration too large") + raise config_error("PWM pin max duration too large") if self._duration_ticks: self._mcu.register_flush_callback(self._flush_notification) if self._hardware_pwm: @@ -85,7 +86,7 @@ class MCU_queued_pwm: return # Software PWM if self._shutdown_value not in [0., 1.]: - raise pins.error("shutdown value must be 0.0 or 1.0 on soft pwm") + raise config_error("shutdown value must be 0.0 or 1.0 on soft pwm") self._mcu.add_config_cmd( "config_digital_out oid=%d pin=%s value=%d" " default_value=%d max_duration=%d" |