code wiki / (root) / nx_bed_mesh.nx

nx_bed_mesh.nx

buildroot/runtime/nx_bed_mesh.nx

7866 B207 linesdepth 2pulls 2 transitivereach 47 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_bed_mesh.nx -- slicer-side per-XY Z compensation from a probed bed-mesh model. ===================================================================== EXCEED axis (research baseline) ===================================================================== Industry treatment of bed warp (as of 2026-05): Klipper: BED_MESH_PROFILE_LOAD + Z_TILT_ADJUST -- mesh is probed by firmware, Z-correction applied at GCODE EXECUTION time. Slicer is bed-naive. Marlin: M420 S1 -- runtime correction, same model. RepRapFirmware: M557 + bed-mesh compensation, runtime. OrcaSlicer 2.3.2: single-number "First Layer Print Height Compensation" -- one global offset, not per-XY. PrusaSlicer 2.7: mesh-leveling AWARE (knows the printer does it) but emits FLAT first-layer G-code; relies on firmware to compensate. Bambu Studio: no slicer-side mesh compensation. All four major slicers EMIT FLAT G-code for the first layer and rely on firmware-side Z correction. This breaks for: - Firmware without mesh leveling (older boards, custom builds) - G-code archived / shared / printed on a different machine - Printers with mesh data the operator wants embedded for reproducibility This file ships slicer-side bilinear-interp per-XY Z compensation baked DIRECTLY into the Z coordinates of the emitted G-code, with layer-tapered fade-out so the model still meets nominal Z by the time bed warp stops mattering (typically 1-2 mm above bed). ===================================================================== license_tier: ORIGINAL

dependencies 1 imports · 5 importers

nx_syscalls.nx nx_bed_mesh.nx nx_bed_mesh_adversarial_test.nx nx_bed_mesh_test.nx nx_bedmesh_emit_test.nx nx_gcode_emit.nx nx_print_exceed_compose_test.nx

imports: nx_syscalls.nx

imported by: nx_bed_mesh_adversarial_test.nxnx_bed_mesh_test.nxnx_bedmesh_emit_test.nxnx_gcode_emit.nxnx_print_exceed_compose_test.nx

structs

53struct NxBedMesh

consts

39const NX_MAGIC_16384: i64 = 16384
43const NX_BED_MESH_OK: i64 = 0
44const NX_BED_MESH_ERR_BAD_INPUT: i64 = 1
45const NX_BED_MESH_ERR_BAD_INDEX: i64 = 2
64const NX_BED_MESH_BYTES: i64 = 64
69const NX_BED_MESH_TAPER_LAYERS: i64 = 10

functions

73func nx_bed_mesh_new(n_x: i64, n_y: i64,
called by 4: mainmainmainmain calls 1: sys_mmap
103func nx_bed_mesh_set_point(m: *NxBedMesh, ix: i64, iy: i64,
called by 4: mainmainmainmain
121func nx_bed_mesh_z_offset(m: *NxBedMesh, x_q14: i64, y_q14: i64) -> i64
196func nx_bed_mesh_z_at_layer(m: *NxBedMesh, x_q14: i64, y_q14: i64,