gcode: The set_temp() takes an extruder number not a heater id

Commit cf6c5e6f did not fix the shared heater case - a set_temp()
request takes the extruder id, not the heater id (nor the gcode sensor
id).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-02-25 20:50:34 -05:00
parent c54c81dc2a
commit ff9605c082
1 changed files with 13 additions and 7 deletions

View File

@ -389,18 +389,24 @@ class GCodeParser:
eventtime = self.reactor.pause(eventtime + 1.)
def set_temp(self, params, is_bed=False, wait=False):
temp = self.get_float('S', params, 0.)
heater = None
if is_bed:
heater_name = 'heater_bed'
else:
index = self.get_int('T', params, 0, minval=0)
heater_name = 'extruder%d' % (index,)
heater = self.printer.lookup_object('heater_bed', None)
elif 'T' in params:
index = self.get_int('T', params, minval=0)
extruder = self.printer.lookup_object('extruder%d' % (index,), None)
if extruder is not None:
heater = extruder.get_heater()
elif self.extruder is not None:
heater = self.extruder.get_heater()
if heater is None:
if temp > 0.:
self.respond_error("Heater not configured")
return
print_time = self.toolhead.get_last_move_time()
try:
heater = self.heaters.lookup_heater(heater_name)
heater.set_temp(print_time, temp)
except heater.error as e:
if not temp:
return
raise error(str(e))
if wait and temp:
self.bg_temp(heater)