mirror of
git://soft.sys114.com/klipper
synced 2026-02-13 13:40:35 +09:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user