klippy: Add access methods and avoid peeking into the printer classes

Add get_reactor(), lookup_object(), lookup_module_objects(), and
set_rollover_info() to the main Printer class so that callers do not
need to peek into the class' members.  Similarly, add get_printer()
and get_name() methods to the ConfigWrapper class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2018-01-19 22:22:17 -05:00
parent f0a754e496
commit 81013ba5c8
10 changed files with 103 additions and 85 deletions

View File

@@ -1,6 +1,6 @@
# Printer fan support
#
# Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net>
# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import extruder, pins
@@ -35,7 +35,7 @@ class PrinterFan:
class PrinterHeaterFan:
def __init__(self, printer, config):
self.fan = PrinterFan(printer, config)
self.mcu = printer.objects['mcu']
self.mcu = printer.lookup_object('mcu')
heater = config.get("heater", "extruder0")
self.heater = extruder.get_printer_heater(printer, heater)
self.heater_temp = config.getfloat("heater_temp", 50.0)
@@ -43,7 +43,8 @@ class PrinterHeaterFan:
self.fan_speed = config.getfloat(
"fan_speed", max_power, minval=0., maxval=max_power)
self.fan.mcu_fan.setup_start_value(0., max_power)
printer.reactor.register_timer(self.callback, printer.reactor.NOW)
reactor = printer.get_reactor()
reactor.register_timer(self.callback, reactor.NOW)
def callback(self, eventtime):
current_temp, target_temp = self.heater.get_temp(eventtime)
if not current_temp and not target_temp and not self.fan.last_fan_time: