From ecdf68735f692903a9ddece0815c7fe181c1273f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 3 May 2017 01:06:53 -0500 Subject: [PATCH] Compact smart_fill_mesh slightly --- Marlin/ubl_G29.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Marlin/ubl_G29.cpp b/Marlin/ubl_G29.cpp index e9f97b4ad..024ff759b 100644 --- a/Marlin/ubl_G29.cpp +++ b/Marlin/ubl_G29.cpp @@ -1533,21 +1533,6 @@ typedef struct { uint8_t sx, ex, sy, ey; bool yfirst; } smart_fill_info; - void smart_fill_loop(const smart_fill_info &f) { - if (f.yfirst) { - const int8_t dir = f.ex > f.sx ? 1 : -1; - for (uint8_t y = f.sy; y != f.ey; ++y) - for (uint8_t x = f.sx; x != f.ex; x += dir) - if (smart_fill_one(x, y, dir, 0)) break; - } - else { - const int8_t dir = f.ey > f.sy ? 1 : -1; - for (uint8_t x = f.sx; x != f.ex; ++x) - for (uint8_t y = f.sy; y != f.ey; y += dir) - if (smart_fill_one(x, y, 0, dir)) break; - } - } - void smart_fill_mesh() { const smart_fill_info info[] = { { 0, GRID_MAX_POINTS_X, 0, GRID_MAX_POINTS_Y - 2, false }, // Bottom of the mesh looking up @@ -1555,7 +1540,21 @@ { 0, GRID_MAX_POINTS_X - 2, 0, GRID_MAX_POINTS_Y, true }, // Left side of the mesh looking right { GRID_MAX_POINTS_X - 1, 0, 0, GRID_MAX_POINTS_Y, true } // Right side of the mesh looking left }; - for (uint8_t i = 0; i < COUNT(info); ++i) smart_fill_loop(info[i]); + for (uint8_t i = 0; i < COUNT(info); ++i) { + const smart_fill_info &f = info[i]; + if (f.yfirst) { + const int8_t dir = f.ex > f.sx ? 1 : -1; + for (uint8_t y = f.sy; y != f.ey; ++y) + for (uint8_t x = f.sx; x != f.ex; x += dir) + if (smart_fill_one(x, y, dir, 0)) break; + } + else { + const int8_t dir = f.ey > f.sy ? 1 : -1; + for (uint8_t x = f.sx; x != f.ex; ++x) + for (uint8_t y = f.sy; y != f.ey; y += dir) + if (smart_fill_one(x, y, 0, dir)) break; + } + } } void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map) {