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>
This commit is contained in:
Kevin O'Connor 2023-12-19 14:57:39 -05:00
parent 3417940fd8
commit 547bfbf818
1 changed files with 6 additions and 5 deletions

View File

@ -50,8 +50,9 @@ class MCU_queued_pwm:
self._start_value = max(0., min(1., start_value)) self._start_value = max(0., min(1., start_value))
self._shutdown_value = max(0., min(1., shutdown_value)) self._shutdown_value = max(0., min(1., shutdown_value))
def _build_config(self): def _build_config(self):
config_error = self._mcu.get_printer().config_error
if self._max_duration and self._start_value != self._shutdown_value: if self._max_duration and self._start_value != self._shutdown_value:
raise pins.error("Pin with max duration must have start" raise config_error("Pin with max duration must have start"
" value equal to shutdown value") " value equal to shutdown value")
cmd_queue = self._mcu.alloc_command_queue() cmd_queue = self._mcu.alloc_command_queue()
curtime = self._mcu.get_printer().get_reactor().monotonic() curtime = self._mcu.get_printer().get_reactor().monotonic()
@ -59,10 +60,10 @@ class MCU_queued_pwm:
self._last_clock = self._mcu.print_time_to_clock(printtime + 0.200) self._last_clock = self._mcu.print_time_to_clock(printtime + 0.200)
cycle_ticks = self._mcu.seconds_to_clock(self._cycle_time) cycle_ticks = self._mcu.seconds_to_clock(self._cycle_time)
if cycle_ticks >= 1<<31: 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) self._duration_ticks = self._mcu.seconds_to_clock(self._max_duration)
if self._duration_ticks >= 1<<31: 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: if self._duration_ticks:
self._mcu.register_flush_callback(self._flush_notification) self._mcu.register_flush_callback(self._flush_notification)
if self._hardware_pwm: if self._hardware_pwm:
@ -85,7 +86,7 @@ class MCU_queued_pwm:
return return
# Software PWM # Software PWM
if self._shutdown_value not in [0., 1.]: 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( self._mcu.add_config_cmd(
"config_digital_out oid=%d pin=%s value=%d" "config_digital_out oid=%d pin=%s value=%d"
" default_value=%d max_duration=%d" " default_value=%d max_duration=%d"