heater: Support generic gcode_id registration for sensors
Support reading a "gcode_id" parameter from heater/sensor config sections. Signed-off-by: Douglas Hammond <wizhippo@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
34209e6189
commit
3887ad4fce
|
@ -587,6 +587,9 @@
|
|||
#pid_integral_max:
|
||||
# The maximum "windup" the integral term may accumulate. The default
|
||||
# is to use the same value as max_power.
|
||||
#gcode_id:
|
||||
# If set, the temperature will be reported in M105 queries using the
|
||||
# given id. The default is to not report the temperature via M105.
|
||||
|
||||
|
||||
# Additional micro-controllers (one may define any number of sections
|
||||
|
|
|
@ -4,13 +4,5 @@
|
|||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
import logging
|
||||
|
||||
class PrinterHeaterGeneric:
|
||||
def __init__(self, config):
|
||||
self.printer = config.get_printer()
|
||||
gcode_id = config.get("gcode_id")
|
||||
self.heater = self.printer.lookup_object('heater').setup_heater(config, gcode_id)
|
||||
|
||||
def load_config_prefix(config):
|
||||
return PrinterHeaterGeneric(config)
|
||||
return config.get_printer().lookup_object('heater').setup_heater(config)
|
||||
|
|
|
@ -21,6 +21,7 @@ class TemperatureFan:
|
|||
self.sensor = self.printer.lookup_object('heater').setup_sensor(config)
|
||||
self.sensor.setup_minmax(self.min_temp, self.max_temp)
|
||||
self.sensor.setup_callback(self.temperature_callback)
|
||||
self.printer.lookup_object('heater').register_sensor(config, self)
|
||||
self.speed_delay = self.sensor.get_report_time_delta()
|
||||
self.max_speed = config.getfloat('max_speed', 1., above=0., maxval=1.)
|
||||
self.min_speed = config.getfloat('min_speed', 0.3, above=0., maxval=1.)
|
||||
|
@ -52,6 +53,8 @@ class TemperatureFan:
|
|||
def stats(self, eventtime):
|
||||
return False, '%s: temp=%.1f fan_speed=%.3f' % (
|
||||
self.name, self.last_temp, self.last_speed_value)
|
||||
def get_temp(self, eventtime):
|
||||
return self.last_temp, self.target_temp
|
||||
|
||||
######################################################################
|
||||
# Bang-bang control algo
|
||||
|
|
|
@ -248,8 +248,7 @@ class PrinterHeaters:
|
|||
sensor = self.setup_sensor(config)
|
||||
# Create heater
|
||||
self.heaters[heater_name] = heater = Heater(config, sensor)
|
||||
if gcode_id is not None:
|
||||
self.gcode_id_to_sensor[gcode_id] = heater
|
||||
self.register_sensor(config, heater, gcode_id)
|
||||
return heater
|
||||
def lookup_heater(self, heater_name):
|
||||
if heater_name == 'extruder':
|
||||
|
@ -269,6 +268,15 @@ class PrinterHeaters:
|
|||
return self.sensor_factories[sensor_type](config)
|
||||
def get_gcode_sensors(self):
|
||||
return self.gcode_id_to_sensor.items()
|
||||
def register_sensor(self, config, psensor, gcode_id=None):
|
||||
if gcode_id is None:
|
||||
gcode_id = config.get('gcode_id', None)
|
||||
if gcode_id is None:
|
||||
return
|
||||
if gcode_id in self.gcode_id_to_sensor:
|
||||
raise self.printer.config_error(
|
||||
"G-Code sensor id %s already registered" % (gcode_id,))
|
||||
self.gcode_id_to_sensor[gcode_id] = psensor
|
||||
def turn_off_all_heaters(self, print_time):
|
||||
for heater in self.heaters.values():
|
||||
heater.set_temp(print_time, 0.)
|
||||
|
|
Loading…
Reference in New Issue