From f7d663c7dba807bb30fe7f100585636f82396000 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 29 Feb 2020 04:27:04 -0600 Subject: [PATCH] Improvements for MarlinMesh.scad --- buildroot/share/scripts/MarlinMesh.scad | 160 +++++++++++++++--------- 1 file changed, 104 insertions(+), 56 deletions(-) diff --git a/buildroot/share/scripts/MarlinMesh.scad b/buildroot/share/scripts/MarlinMesh.scad index 7616ded69..6d78bb964 100644 --- a/buildroot/share/scripts/MarlinMesh.scad +++ b/buildroot/share/scripts/MarlinMesh.scad @@ -10,17 +10,13 @@ * * \**************************************/ -//$t = 0.15; // comment out during animation +$t = 0.15; // comment out during animation! +X = 0; Y = 1; +L = 0; R = 1; F = 2; B = 3; // -// Mesh info and points +// Sample Mesh - Replace with your own // - -mesh_width = 200; // X Size in mm of the probed area -mesh_height = 200; // Y Size... -zprobe_offset = 0; // Added to the points -NAN = 0; // Z to use for un-measured points - measured_z = [ [ -1.20, -1.13, -1.09, -1.03, -1.19 ], [ -1.16, -1.25, -1.27, -1.25, -1.08 ], @@ -29,6 +25,28 @@ measured_z = [ [ -1.13, -0.99, -1.03, -1.06, -1.32 ] ]; +// +// An offset to add to all points in the mesh +// +zadjust = 0; + +// +// Mesh characteristics +// +bed_size = [ 200, 200 ]; + +mesh_inset = [ 10, 10, 10, 10 ]; // L, F, R, B + +mesh_bounds = [ + [ mesh_inset[L], mesh_inset[F] ], + [ bed_size[X] - mesh_inset[R], bed_size[Y] - mesh_inset[B] ] +]; + +mesh_size = mesh_bounds[1] - mesh_bounds[0]; + + // NOTE: Marlin meshes already subtract the probe offset +NAN = 0; // Z to use for un-measured points + // // Geometry // @@ -45,6 +63,7 @@ alternation = 2; // direction change modulus (try it) show_plane = true; show_labels = true; +show_coords = true; arrow_length = 5; label_font_lg = "Arial"; @@ -62,8 +81,8 @@ mean_value = (big_z + lil_z) / 2.0; mesh_points_y = len(measured_z); mesh_points_x = len(measured_z[0]); -xspace = mesh_width / (mesh_points_x - 1); -yspace = mesh_height / (mesh_points_y - 1); +xspace = mesh_size[X] / (mesh_points_x - 1); +yspace = mesh_size[Y] / (mesh_points_y - 1); // At $t=0 and $t=1 scale will be 100% z_scale_factor = min_z_scale + (($t > 0.5) ? 1.0 - $t : $t) * (max_z_scale - min_z_scale) * 2; @@ -72,6 +91,8 @@ z_scale_factor = min_z_scale + (($t > 0.5) ? 1.0 - $t : $t) * (max_z_scale - min // Min and max recursive functions for 1D and 2D arrays // Return the smallest or largest value in the array // +function some_1D(b,i) = (i