heaters: Use new GCodeCommand wrappers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
c186766708
commit
5fe5e21508
|
@ -18,7 +18,6 @@ PID_PARAM_BASE = 255.
|
||||||
class Heater:
|
class Heater:
|
||||||
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.name = config.get_name().split()[-1]
|
self.name = config.get_name().split()[-1]
|
||||||
# Setup sensor
|
# Setup sensor
|
||||||
self.sensor = sensor
|
self.sensor = sensor
|
||||||
|
@ -61,10 +60,10 @@ class Heater:
|
||||||
# Load additional modules
|
# Load additional modules
|
||||||
self.printer.try_load_module(config, "verify_heater %s" % (self.name,))
|
self.printer.try_load_module(config, "verify_heater %s" % (self.name,))
|
||||||
self.printer.try_load_module(config, "pid_calibrate")
|
self.printer.try_load_module(config, "pid_calibrate")
|
||||||
self.gcode.register_mux_command(
|
gcode = self.printer.lookup_object("gcode")
|
||||||
"SET_HEATER_TEMPERATURE", "HEATER", self.name,
|
gcode.register_mux_command("SET_HEATER_TEMPERATURE", "HEATER",
|
||||||
self.cmd_SET_HEATER_TEMPERATURE,
|
self.name, self.cmd_SET_HEATER_TEMPERATURE,
|
||||||
desc=self.cmd_SET_HEATER_TEMPERATURE_help)
|
desc=self.cmd_SET_HEATER_TEMPERATURE_help)
|
||||||
def set_pwm(self, read_time, value):
|
def set_pwm(self, read_time, value):
|
||||||
if self.target_temp <= 0.:
|
if self.target_temp <= 0.:
|
||||||
value = 0.
|
value = 0.
|
||||||
|
@ -138,8 +137,8 @@ class Heater:
|
||||||
smoothed_temp = self.smoothed_temp
|
smoothed_temp = self.smoothed_temp
|
||||||
return {'temperature': smoothed_temp, 'target': target_temp}
|
return {'temperature': smoothed_temp, 'target': target_temp}
|
||||||
cmd_SET_HEATER_TEMPERATURE_help = "Sets a heater temperature"
|
cmd_SET_HEATER_TEMPERATURE_help = "Sets a heater temperature"
|
||||||
def cmd_SET_HEATER_TEMPERATURE(self, params):
|
def cmd_SET_HEATER_TEMPERATURE(self, gcmd):
|
||||||
temp = self.gcode.get_float('TARGET', params, 0.)
|
temp = gcmd.get_float('TARGET', 0.)
|
||||||
self.set_temp(temp)
|
self.set_temp(temp)
|
||||||
|
|
||||||
|
|
||||||
|
@ -288,7 +287,7 @@ class PrinterHeaters:
|
||||||
for heater in self.heaters.values():
|
for heater in self.heaters.values():
|
||||||
heater.set_temp(0.)
|
heater.set_temp(0.)
|
||||||
cmd_TURN_OFF_HEATERS_help = "Turn off all heaters"
|
cmd_TURN_OFF_HEATERS_help = "Turn off all heaters"
|
||||||
def cmd_TURN_OFF_HEATERS(self, params):
|
def cmd_TURN_OFF_HEATERS(self, gcmd):
|
||||||
self.turn_off_all_heaters()
|
self.turn_off_all_heaters()
|
||||||
# G-Code M105 temperature reporting
|
# G-Code M105 temperature reporting
|
||||||
def _handle_ready(self):
|
def _handle_ready(self):
|
||||||
|
@ -303,14 +302,14 @@ class PrinterHeaters:
|
||||||
if not out:
|
if not out:
|
||||||
return "T:0"
|
return "T:0"
|
||||||
return " ".join(out)
|
return " ".join(out)
|
||||||
def cmd_M105(self, params):
|
def cmd_M105(self, gcmd):
|
||||||
# Get Extruder Temperature
|
# Get Extruder Temperature
|
||||||
gcode = self.printer.lookup_object("gcode")
|
gcode = self.printer.lookup_object("gcode")
|
||||||
reactor = self.printer.get_reactor()
|
reactor = self.printer.get_reactor()
|
||||||
msg = self._get_temp(reactor.monotonic())
|
msg = self._get_temp(reactor.monotonic())
|
||||||
did_ack = gcode.ack(msg)
|
did_ack = gcode.ack(msg)
|
||||||
if not did_ack:
|
if not did_ack:
|
||||||
gcode.respond_raw(msg)
|
gcmd.respond_raw(msg)
|
||||||
def wait_for_temperature(self, heater):
|
def wait_for_temperature(self, heater):
|
||||||
# Helper to wait on heater.check_busy() and report M105 temperatures
|
# Helper to wait on heater.check_busy() and report M105 temperatures
|
||||||
if self.printer.get_start_args().get('debugoutput') is not None:
|
if self.printer.get_start_args().get('debugoutput') is not None:
|
||||||
|
|
Loading…
Reference in New Issue