mirror of https://github.com/Desuuuu/klipper.git
add configuration sanity checks at startup
* Configuration issues will now be reported at startup * `[bed_mesh]`, `[probe]` and `[fan]` sections are now optional * `[pause_resume]` section no longer needs to be set explicitly
This commit is contained in:
parent
7ecfd60947
commit
4be47eb9aa
|
@ -171,7 +171,7 @@ script:
|
||||||
{% do set_variable("wait_return", "leveling_manual") %}
|
{% do set_variable("wait_return", "leveling_manual") %}
|
||||||
G28
|
G28
|
||||||
{% do start_routine("show_wait_screen") %}
|
{% do start_routine("show_wait_screen") %}
|
||||||
{% else %}
|
{% elif 'bed_mesh' in printer %}
|
||||||
BED_MESH_PROFILE SAVE=t5uid1_mesh_backup
|
BED_MESH_PROFILE SAVE=t5uid1_mesh_backup
|
||||||
BED_MESH_CLEAR
|
BED_MESH_CLEAR
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -181,10 +181,27 @@ run_as_gcode: true
|
||||||
trigger: leave
|
trigger: leave
|
||||||
page: leveling_manual
|
page: leveling_manual
|
||||||
script:
|
script:
|
||||||
BED_MESH_PROFILE LOAD=t5uid1_mesh_backup
|
{% if 'bed_mesh' in printer %}
|
||||||
BED_MESH_PROFILE REMOVE=t5uid1_mesh_backup
|
BED_MESH_PROFILE LOAD=t5uid1_mesh_backup
|
||||||
|
BED_MESH_PROFILE REMOVE=t5uid1_mesh_backup
|
||||||
|
{% endif %}
|
||||||
run_as_gcode: true
|
run_as_gcode: true
|
||||||
|
|
||||||
|
[t5uid1_routine __leveling_automatic]
|
||||||
|
trigger: enter_pre
|
||||||
|
page: leveling_automatic
|
||||||
|
script:
|
||||||
|
{% if is_busy() %}
|
||||||
|
{% do set_message("Busy") %}
|
||||||
|
{ abort_page_switch() }
|
||||||
|
{% elif 'bed_mesh' not in printer %}
|
||||||
|
{% do set_message("Missing config: bed_mesh") %}
|
||||||
|
{ abort_page_switch() }
|
||||||
|
{% elif 'probe' not in printer %}
|
||||||
|
{% do set_message("Missing config: probe") %}
|
||||||
|
{ abort_page_switch() }
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
[t5uid1_routine __filament]
|
[t5uid1_routine __filament]
|
||||||
trigger: enter_pre
|
trigger: enter_pre
|
||||||
page: filament
|
page: filament
|
||||||
|
|
|
@ -313,7 +313,7 @@ script:
|
||||||
{% do set_message("Homing required") %}
|
{% do set_message("Homing required") %}
|
||||||
{% elif is_busy() %}
|
{% elif is_busy() %}
|
||||||
{% do set_message("Busy") %}
|
{% do set_message("Busy") %}
|
||||||
{% else %}
|
{% elif 'bed_mesh' in printer %}
|
||||||
BED_MESH_CALIBRATE
|
BED_MESH_CALIBRATE
|
||||||
G28 Z
|
G28 Z
|
||||||
{% do start_routine("show_probing_screen") %}
|
{% do start_routine("show_probing_screen") %}
|
||||||
|
@ -327,7 +327,7 @@ data_type: none
|
||||||
script:
|
script:
|
||||||
{% if is_busy() %}
|
{% if is_busy() %}
|
||||||
{% do set_message("Busy") %}
|
{% do set_message("Busy") %}
|
||||||
{% else %}
|
{% elif 'bed_mesh' in printer %}
|
||||||
BED_MESH_CLEAR
|
BED_MESH_CLEAR
|
||||||
BED_MESH_PROFILE REMOVE=default
|
BED_MESH_PROFILE REMOVE=default
|
||||||
{% do start_routine("trigger_full_update") %}
|
{% do start_routine("trigger_full_update") %}
|
||||||
|
|
|
@ -204,7 +204,7 @@ address: 0x3108
|
||||||
data_type: uint16
|
data_type: uint16
|
||||||
script:
|
script:
|
||||||
{% set t5uid1 = printer.t5uid1 %}
|
{% set t5uid1 = printer.t5uid1 %}
|
||||||
{% if printer.bed_mesh.profile_name != "" %}
|
{% if 'bed_mesh' in printer and printer.bed_mesh.profile_name != "" %}
|
||||||
{% do enable_control(t5uid1.pages.leveling_automatic,
|
{% do enable_control(t5uid1.pages.leveling_automatic,
|
||||||
t5uid1.control_types.return_key_code,
|
t5uid1.control_types.return_key_code,
|
||||||
t5uid1.controls.disable) %}
|
t5uid1.controls.disable) %}
|
||||||
|
@ -222,8 +222,10 @@ address: 0x3109
|
||||||
data_type: array[int16]
|
data_type: array[int16]
|
||||||
array_len: 25
|
array_len: 25
|
||||||
script:
|
script:
|
||||||
{% set grid = printer.bed_mesh.probed_matrix %}
|
{% if 'bed_mesh' in printer %}
|
||||||
{% if not grid or grid|length < 5 %}
|
{% set grid = printer.bed_mesh.probed_matrix %}
|
||||||
|
{% endif %}
|
||||||
|
{% if grid is not defined or grid|length < 5 %}
|
||||||
{% set grid = [] %}
|
{% set grid = [] %}
|
||||||
{% for i in range(5) %}
|
{% for i in range(5) %}
|
||||||
{% do grid.append([0, 0, 0, 0, 0]) %}
|
{% do grid.append([0, 0, 0, 0, 0]) %}
|
||||||
|
@ -446,7 +448,12 @@ script:
|
||||||
type: output
|
type: output
|
||||||
address: 0x4000
|
address: 0x4000
|
||||||
data_type: uint16
|
data_type: uint16
|
||||||
script: { (printer.fan.speed * 100)|round|int }
|
script:
|
||||||
|
{% if 'fan' in printer %}
|
||||||
|
{ (printer.fan.speed * 100)|round|int }
|
||||||
|
{% else %}
|
||||||
|
{ "0" }
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
[t5uid1_var volume]
|
[t5uid1_var volume]
|
||||||
type: output
|
type: output
|
||||||
|
|
|
@ -98,8 +98,13 @@ class T5UID1:
|
||||||
self.gcode = self.printer.lookup_object('gcode')
|
self.gcode = self.printer.lookup_object('gcode')
|
||||||
self.configfile = self.printer.lookup_object('configfile')
|
self.configfile = self.printer.lookup_object('configfile')
|
||||||
|
|
||||||
self.stepper_enable = self.heaters = self.bed_mesh = None
|
self.toolhead = None
|
||||||
self.toolhead = self.probe = self.pause_resume = None
|
self.heaters = self.printer.load_object(config, 'heaters')
|
||||||
|
self.pause_resume = self.printer.load_object(config, 'pause_resume')
|
||||||
|
self.stepper_enable = self.printer.load_object(config, 'stepper_enable')
|
||||||
|
self.bed_mesh = None
|
||||||
|
self.probe = None
|
||||||
|
|
||||||
self.extruders = {}
|
self.extruders = {}
|
||||||
|
|
||||||
self.mcu = mcu.get_printer_mcu(self.printer,
|
self.mcu = mcu.get_printer_mcu(self.printer,
|
||||||
|
@ -330,16 +335,35 @@ class T5UID1:
|
||||||
"t5uid1_received")
|
"t5uid1_received")
|
||||||
|
|
||||||
def _handle_ready(self):
|
def _handle_ready(self):
|
||||||
|
self.toolhead = self.printer.lookup_object('toolhead')
|
||||||
|
|
||||||
|
self.heaters.lookup_heater('extruder')
|
||||||
|
self.heaters.lookup_heater('heater_bed')
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.bed_mesh = self.printer.lookup_object(config, 'bed_mesh')
|
||||||
|
except Exception:
|
||||||
|
logging.debug("No 'bed_mesh' configuration found")
|
||||||
|
self.bed_mesh = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.probe = self.printer.lookup_object(config, 'probe')
|
||||||
|
except Exception:
|
||||||
|
logging.debug("No 'probe' configuration found")
|
||||||
|
self.probe = None
|
||||||
|
|
||||||
has_bltouch = False
|
has_bltouch = False
|
||||||
try:
|
try:
|
||||||
self.printer.lookup_object('bltouch')
|
self.printer.lookup_object('bltouch')
|
||||||
has_bltouch = True
|
has_bltouch = True
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self._status_data.update({
|
self._status_data.update({
|
||||||
'limits': self.limits(),
|
'limits': self.limits(),
|
||||||
'has_bltouch': has_bltouch
|
'has_bltouch': has_bltouch
|
||||||
})
|
})
|
||||||
|
|
||||||
self._is_connected = True
|
self._is_connected = True
|
||||||
self.reactor.register_timer(self._on_ready, self.reactor.NOW)
|
self.reactor.register_timer(self._on_ready, self.reactor.NOW)
|
||||||
|
|
||||||
|
@ -499,11 +523,6 @@ class T5UID1:
|
||||||
def check_paused(self):
|
def check_paused(self):
|
||||||
if not self._is_printing:
|
if not self._is_printing:
|
||||||
return
|
return
|
||||||
if self.pause_resume is None:
|
|
||||||
try:
|
|
||||||
self.pause_resume = self.printer.lookup_object('pause_resume')
|
|
||||||
except Exception:
|
|
||||||
return
|
|
||||||
curtime = self.reactor.monotonic()
|
curtime = self.reactor.monotonic()
|
||||||
if self._print_pause_time < 0 and self.pause_resume.is_paused:
|
if self._print_pause_time < 0 and self.pause_resume.is_paused:
|
||||||
self._print_pause_time = curtime
|
self._print_pause_time = curtime
|
||||||
|
@ -700,37 +719,29 @@ class T5UID1:
|
||||||
self.configfile.set(self.name, 'volume', volume)
|
self.configfile.set(self.name, 'volume', volume)
|
||||||
|
|
||||||
def all_steppers_enabled(self):
|
def all_steppers_enabled(self):
|
||||||
if self.stepper_enable is None:
|
|
||||||
self.stepper_enable = self.printer.lookup_object('stepper_enable')
|
|
||||||
res = True
|
res = True
|
||||||
for name in ['stepper_x', 'stepper_y', 'stepper_z']:
|
for name in ['stepper_x', 'stepper_y', 'stepper_z']:
|
||||||
res &= self.stepper_enable.lookup_enable(name).is_motor_enabled()
|
res &= self.stepper_enable.lookup_enable(name).is_motor_enabled()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def heater_min_temp(self, heater):
|
def heater_min_temp(self, heater):
|
||||||
if self.heaters is None:
|
|
||||||
self.heaters = self.printer.lookup_object('heaters')
|
|
||||||
try:
|
try:
|
||||||
return self.heaters.lookup_heater(heater).min_temp
|
return self.heaters.lookup_heater(heater).min_temp
|
||||||
except Exception:
|
except Exception:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def heater_max_temp(self, heater, margin=0):
|
def heater_max_temp(self, heater, margin=0):
|
||||||
if self.heaters is None:
|
|
||||||
self.heaters = self.printer.lookup_object('heaters')
|
|
||||||
try:
|
try:
|
||||||
return max(0, self.heaters.lookup_heater(heater).max_temp - margin)
|
return max(0, self.heaters.lookup_heater(heater).max_temp - margin)
|
||||||
except Exception:
|
except Exception:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def heater_min_extrude_temp(self, heater):
|
def heater_min_extrude_temp(self, heater):
|
||||||
if self.heaters is None:
|
|
||||||
self.heaters = self.printer.lookup_object('heaters')
|
|
||||||
return self.heaters.lookup_heater(heater).min_extrude_temp
|
return self.heaters.lookup_heater(heater).min_extrude_temp
|
||||||
|
|
||||||
def probed_matrix(self):
|
def probed_matrix(self):
|
||||||
if self.bed_mesh is None:
|
if self.bed_mesh is None:
|
||||||
self.bed_mesh = self.printer.lookup_object('bed_mesh')
|
return 0
|
||||||
count = len(self.bed_mesh.bmc.probe_helper.results)
|
count = len(self.bed_mesh.bmc.probe_helper.results)
|
||||||
points_map = [ 0, 1, 2, 3, 4,
|
points_map = [ 0, 1, 2, 3, 4,
|
||||||
9, 8, 7, 6, 5,
|
9, 8, 7, 6, 5,
|
||||||
|
@ -749,8 +760,6 @@ class T5UID1:
|
||||||
def pid_param(self, heater, param):
|
def pid_param(self, heater, param):
|
||||||
if param not in ['p', 'i', 'd']:
|
if param not in ['p', 'i', 'd']:
|
||||||
raise ValueError("Invalid param")
|
raise ValueError("Invalid param")
|
||||||
if self.heaters is None:
|
|
||||||
self.heaters = self.printer.lookup_object('heaters')
|
|
||||||
try:
|
try:
|
||||||
return getattr(self.heaters.lookup_heater(heater).control,
|
return getattr(self.heaters.lookup_heater(heater).control,
|
||||||
'K' + param) * heaters.PID_PARAM_BASE
|
'K' + param) * heaters.PID_PARAM_BASE
|
||||||
|
@ -770,8 +779,6 @@ class T5UID1:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def limits(self):
|
def limits(self):
|
||||||
if self.toolhead is None:
|
|
||||||
self.toolhead = self.printer.lookup_object('toolhead')
|
|
||||||
kin = self.toolhead.get_kinematics()
|
kin = self.toolhead.get_kinematics()
|
||||||
x_min, x_max = kin.rails[0].get_range()
|
x_min, x_max = kin.rails[0].get_range()
|
||||||
y_min, y_max = kin.rails[1].get_range()
|
y_min, y_max = kin.rails[1].get_range()
|
||||||
|
@ -801,18 +808,15 @@ class T5UID1:
|
||||||
self.start_routine('message_timeout')
|
self.start_routine('message_timeout')
|
||||||
|
|
||||||
def is_busy(self):
|
def is_busy(self):
|
||||||
if self.toolhead is None:
|
|
||||||
self.toolhead = self.printer.lookup_object('toolhead')
|
|
||||||
if self.probe is None:
|
|
||||||
self.probe = self.printer.lookup_object('probe')
|
|
||||||
eventtime = self.reactor.monotonic()
|
eventtime = self.reactor.monotonic()
|
||||||
print_time, est_print_time, lookahead_empty = self.toolhead.check_busy(
|
print_time, est_print_time, lookahead_empty = self.toolhead.check_busy(
|
||||||
eventtime)
|
eventtime)
|
||||||
idle_time = est_print_time - print_time
|
idle_time = est_print_time - print_time
|
||||||
return (not lookahead_empty
|
if (not lookahead_empty
|
||||||
or idle_time < 1.0
|
or idle_time < 1.0
|
||||||
or self.gcode.get_mutex().test()
|
or self.gcode.get_mutex().test()):
|
||||||
or self.probe.multi_probe_pending)
|
return True
|
||||||
|
return (self.probe is not None and self.probe.multi_probe_pending)
|
||||||
|
|
||||||
def cmd_DGUS_ABORT_PAGE_SWITCH(self, gcmd):
|
def cmd_DGUS_ABORT_PAGE_SWITCH(self, gcmd):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue