Skip to content

Add configurable high-resolution K1 Max bed mesh#37

Draft
AlexFridman wants to merge 3 commits into
Guilouz:mainfrom
AlexFridman:agent/configurable-high-resolution-bed-mesh
Draft

Add configurable high-resolution K1 Max bed mesh#37
AlexFridman wants to merge 3 commits into
Guilouz:mainfrom
AlexFridman:agent/configurable-high-resolution-bed-mesh

Conversation

@AlexFridman

@AlexFridman AlexFridman commented Jul 17, 2026

Copy link
Copy Markdown

Summary

Add an optional, configurable full-bed mesh workflow for K1 Max PRTouch v2 printers:

  • BED_LEVELING POINTS=9 produces a 9x9 mesh.
  • BED_LEVELING POINTS=10 produces a 10x10 mesh.
  • Coordinates remain inside the configured mesh_min / mesh_max; Klipper calculates uniform spacing as (max - min) / (points - 1).
  • The configured [bed_mesh] probe_count and stock G29 workflow are not changed.

Why

Creality PRTouch v2 initializes exactly 36 per-point threshold entries and indexes them with the current G29 point number. A grid larger than 6x6 therefore reaches an out-of-range entry at point 37 even though Klipper bed mesh supports larger grids.

The bundled KAMP macro also recalculates its density from the static [bed_mesh] probe_count, so an explicit higher PROBE_COUNT is currently reduced back to the configured density.

Creality source reference: https://github.com/CrealityOfficial/K1_Series_Klipper/blob/main/klippy/extras/prtouch_v2_wrapper.py

A static audit of that backend found no other fixed-size structures indexed by the G29 point counter; the two threshold tables are the only 36-entry limit.

Changes

  • Add POINTS=3..10 to the existing BED_LEVELING useful macro while retaining PROBE_COUNT=x,y compatibility.
  • Calculate and report the actual X/Y spacing from the active mesh bounds.
  • Fail before generated G-code executes when:
    • both POINTS and PROBE_COUNT are supplied;
    • the requested dimensions are outside 3..10;
    • more than 36 total points are requested on a non-PRTouch-v2 backend;
    • the PRTouch extension is missing or too small.
  • Add a K1-only Helper Script improvement that extends the PRTouch v2 threshold tables to 100 entries without replacing probing, homing, or motion code.
  • Refuse installation unless the printer reports pr_version: 2 (current K1 Max configuration); K1/K1C/K1 SE PRTouch v1 configurations are not patched.
  • Detect a pre-existing manual PRTouch extension module or config and stop without changing files, preventing duplicate sections during migration.
  • Let KAMP accept an explicit probe count and add an internal FULL_BED=1 path that bypasses adaptive object bounds, margin, and fuzzing only for this calibration.
  • Add install/remove/info menu integration, dependency checks, documentation, and unit tests.

Safety properties

  • Stock G29 and the static [bed_mesh] probe_count remain unchanged.
  • The feature uses the configured mesh bounds, not physical bed limits.
  • Requests above 10x10 are rejected.
  • Unsupported PRTouch backends fail closed.
  • Existing manual extension installs are never overwritten automatically.
  • New threshold entries are independent copies of the final configured threshold pair; the official K1 Max configurations use identical pairs for all 36 factory entries.
  • No mesh is saved automatically.

Validation

  • python3 -m unittest discover -s tests -v — 10 tests pass with Jinja2 installed (the 4 PRTouch module tests remain stdlib-only).
  • Python module compilation passes.
  • All modified shell files pass syntax checks.
  • A temporary-filesystem installer test passes manual-config conflict detection, manual-module conflict detection, install, repeated install (no duplicate include), and remove.
  • Klipper/Jinja render checks pass for 6x6, 9x9, and 10x10.
  • K1 Max default 5..295 mm bounds render spacings of 58.00, 36.25, and 32.22 mm respectively.
  • KAMP renders full-bed native calls for 6x6, 9x9, and 10x10 without adapting the bounds.
  • Missing-extension and PRTouch-v1 paths reject 9x9 before executing generated G-code.
  • Official current K1 family configs were checked: K1 Max uses PRTouch v2; K1/K1C/K1 SE use PRTouch v1.
  • An equivalent 100-entry extension has completed an 81/81-point 9x9 mesh on a K1 Max, board CR4CU220812S12, firmware 1.3.5.22.

Hardware follow-up before marking ready

  • Install this exact branch through the Helper Script on the test K1 Max.
  • Re-run 9x9 as a regression test.
  • Run and inspect a full 10x10 / 100-point mesh.
  • Verify uninstall restores the normal 6x6 workflow.

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