PA calibration reads Spoolman first; guard resets a sensor left in PA mode

- LANE_CALIBRATE_PA: when a calibration will run, assign the lane's spool
  again (SET_SPOOL_ID) so AFC reads the Spoolman temperature now; AFC
  only reads it at spool assignment and Klipper start (TPU calibrated at
  210C after Spoolman was set to 230C). The calibration moved to
  _LANE_CALIBRATE_PA_RUN, rendered after the refresh.
- bdp_guard: an emergency stop during PA_CALIBRATE leaves the sensor in
  PA mode (FIRMWARE_RESTART does not reset it). When arming, read the
  mode register and switch the sensor back to probe mode with a fresh
  baseline before watching it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-10-19 16:04:40 +02:00
1 parent d49e65c0bb
commit 93ae8795b8
3 files changed
+54 -3

No files matched your search

+23 -1
View File
@@ -395,8 +395,30 @@ gcode:
# ---------------------------------------------------------------------------
# Core: calibrate (or restore from cache) PA for one lane
# ---------------------------------------------------------------------------
# The lane's temperature (and material) come from Spoolman through AFC,
# but AFC only reads them when a spool is assigned or Klipper starts: a
# nozzle temperature changed in Spoolman afterwards was not used (TPU
# calibrated at 210C after Spoolman was set to 230C). When a calibration
# will run, assign the lane's spool again first so AFC reads Spoolman now.
# The calibration is a separate macro, rendered after that refresh.
[gcode_macro LANE_CALIBRATE_PA]
description: Calibrate PA for one AFC lane using bd_pressure, with caching
description: Calibrate PA for one AFC lane using bd_pressure, with caching (reads the lane's Spoolman data again first)
# LANE=<lane_name> [FORCE=1]
gcode:
{% set lane = params.LANE|default("")|string %}
{% set force = params.FORCE|default(0)|int %}
{% set vars = printer.save_variables.variables %}
{% set spool_id = vars["pa_lane_" ~ lane ~ "_spool_id"]|default(0)|int %}
{% set cached = ("pa_value_spool_" ~ spool_id) in vars %}
{% set key = "AFC_stepper " ~ lane %}
{% set afc_spool = printer[key].spool_id|default(none, true) if key in printer else none %}
{% if lane and spool_id > 0 and (force or not cached) and afc_spool %}
SET_SPOOL_ID LANE={lane} SPOOL_ID={afc_spool}
{% endif %}
_LANE_CALIBRATE_PA_RUN {rawparams}
[gcode_macro _LANE_CALIBRATE_PA_RUN]
description: Helper for LANE_CALIBRATE_PA: calibrate PA for one AFC lane using bd_pressure, with caching
# LANE=<lane_name> [FORCE=1]
gcode:
{% set lane = params.LANE|default("")|string %}