Skip to content

fix(kamp): let BED_MESH_CALIBRATE callers choose the profile; save adaptive meshes as adaptive, not default - #39

Open
arlophoenix wants to merge 1 commit into
Guilouz:mainfrom
arlophoenix:fix/kamp-adaptive-mesh-profile
Open

fix(kamp): let BED_MESH_CALIBRATE callers choose the profile; save adaptive meshes as adaptive, not default#39
arlophoenix wants to merge 1 commit into
Guilouz:mainfrom
arlophoenix:fix/kamp-adaptive-mesh-profile

Conversation

@arlophoenix

Copy link
Copy Markdown

KAMP's BED_MESH_CALIBRATE wrapper never forwards a PROFILE to the built-in it renames, so Klipper defaults it to default (bed_mesh.py:638) and every adaptive calibration overwrites the full-bed mesh with one covering only the part area. On a stock K1-family install that profile is what the printer loads at connect and what a power-loss resume restores.

The result persists to disk: G29, INPUTSHAPER, BEDPID, the bed_mesh update_mesh webhook, the vendor's prtouch path and CXSAVE_CONFIG all flush Klipper's pending buffer into the #*# autosave block. On one affected K1C, a backup from 2026-06-16 (printer-20260616_221553.cfg) has [bed_mesh default] holding a 3×3 grid over a 16 mm square, on a 220 mm bed.

The fix

The wrapper now forwards params.PROFILE when the caller supplies one, and both Start_Print variants pass PROFILE=adaptive on their adaptive branch. Both variants change because scripts/kamp.sh:43-47 links one or the other by model. All three hunks are needed: the KAMP change alone does nothing, since Start_Print passes no PROFILE today.

Start_Print already uses the name adaptive on the following two lines, in BED_MESH_PROFILE SAVE=adaptive and LOAD=adaptive. Passing it to the calibrate call keeps the name in the caller, so Adaptive_Meshing.cfg needs no reference to this repo's pins or profile names.

Callers that pass no PROFILE, including the vendor path, manual G29 and console BED_MESH_CALIBRATE, render an empty parameter and still save to default. Their emitted gcode is identical apart from one inert trailing space.

BED_MESH_PROFILE SAVE=adaptive on the next line stays. It is now a duplicate save under the same name, kept so that anyone who updates Start_Print.cfg while still running an older Adaptive_Meshing.cfg, which swallows PROFILE, still gets default copied to adaptive and a working print.

Known limitations

This fixes the adaptive path only. The FULL BED MESH toggle reaches the same wrapper with polygons already registered, and KAMP adapts to the part area regardless of the toggle, so that path still writes a part-area mesh to default after this PR. It is a separate defect and can be filed separately.

The wrapper also still drops other caller parameters, such as the PROBE_COUNT that BED_LEVELING passes at files/macros/useful-macros.cfg:121. That is a KAMP-upstream design question, out of scope here.

Test plan

  • One K1C, firmware 1.3.3.46: adaptive branch stages bed_mesh adaptive, on-disk default byte-identical before and after
  • G29 with no polygons refreshes default, leaves adaptive untouched, reloads as default after restart
  • 16-case Jinja render harness (lives outside this repo), including an assertion that the three adaptive names in Start_Print agree
  • Real print exercising the in-print path end to end: not run

KAMP's BED_MESH_CALIBRATE wrapper in Adaptive_Meshing.cfg calls through to
_BED_MESH_CALIBRATE without forwarding PROFILE, so Klipper's bed_mesh.py
defaults it to "default" and every adaptive calibration overwrites the
full-bed mesh with a part-area one.

Forward params.PROFILE when the caller supplies it, and have both
Start_Print variants name the profile they already save and load
(SAVE=adaptive / LOAD=adaptive) on the adaptive branch.

Callers that pass no PROFILE - the vendor prtouch path, manual G29,
console BED_MESH_CALIBRATE - render an empty suffix and still save to
"default" exactly as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant