mirror of https://github.com/Desuuuu/klipper.git
heater: Use printer.command_error() instead of internal heater.error()
Use the more standard command_error to report invalid temperature requests. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
254789f4c5
commit
665323eb29
|
@ -28,9 +28,9 @@ class PIDCalibrate:
|
||||||
old_control = heater.set_control(calibrate)
|
old_control = heater.set_control(calibrate)
|
||||||
try:
|
try:
|
||||||
heater.set_temp(print_time, target)
|
heater.set_temp(print_time, target)
|
||||||
except heater.error as e:
|
except self.printer.command_error as e:
|
||||||
heater.set_control(old_control)
|
heater.set_control(old_control)
|
||||||
raise self.gcode.error(str(e))
|
raise
|
||||||
self.gcode.bg_temp(heater)
|
self.gcode.bg_temp(heater)
|
||||||
heater.set_control(old_control)
|
heater.set_control(old_control)
|
||||||
if write_file:
|
if write_file:
|
||||||
|
|
|
@ -418,10 +418,7 @@ class GCodeParser:
|
||||||
self.respond_error("Heater not configured")
|
self.respond_error("Heater not configured")
|
||||||
return
|
return
|
||||||
print_time = self.toolhead.get_last_move_time()
|
print_time = self.toolhead.get_last_move_time()
|
||||||
try:
|
|
||||||
heater.set_temp(print_time, temp)
|
heater.set_temp(print_time, temp)
|
||||||
except heater.error as e:
|
|
||||||
raise self.error(str(e))
|
|
||||||
if wait and temp:
|
if wait and temp:
|
||||||
self.bg_temp(heater)
|
self.bg_temp(heater)
|
||||||
# G-Code special command handlers
|
# G-Code special command handlers
|
||||||
|
|
|
@ -15,11 +15,7 @@ MAX_HEAT_TIME = 5.0
|
||||||
AMBIENT_TEMP = 25.
|
AMBIENT_TEMP = 25.
|
||||||
PID_PARAM_BASE = 255.
|
PID_PARAM_BASE = 255.
|
||||||
|
|
||||||
class error(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class Heater:
|
class Heater:
|
||||||
error = error
|
|
||||||
def __init__(self, config, sensor):
|
def __init__(self, config, sensor):
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.gcode = self.printer.lookup_object("gcode")
|
self.gcode = self.printer.lookup_object("gcode")
|
||||||
|
@ -103,7 +99,8 @@ class Heater:
|
||||||
return self.smooth_time
|
return self.smooth_time
|
||||||
def set_temp(self, print_time, degrees):
|
def set_temp(self, print_time, degrees):
|
||||||
if degrees and (degrees < self.min_temp or degrees > self.max_temp):
|
if degrees and (degrees < self.min_temp or degrees > self.max_temp):
|
||||||
raise error("Requested temperature (%.1f) out of range (%.1f:%.1f)"
|
raise self.printer.command_error(
|
||||||
|
"Requested temperature (%.1f) out of range (%.1f:%.1f)"
|
||||||
% (degrees, self.min_temp, self.max_temp))
|
% (degrees, self.min_temp, self.max_temp))
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self.target_temp = degrees
|
self.target_temp = degrees
|
||||||
|
|
Loading…
Reference in New Issue