update code base to Marlin 2.0.9.2
This commit is contained in:
80
Marlin/src/gcode/bedlevel/M420.cpp
Executable file → Normal file
80
Marlin/src/gcode/bedlevel/M420.cpp
Executable file → Normal file
@@ -16,7 +16,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "../../module/probe.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
#include "../../module/configuration_store.h"
|
||||
#include "../../module/settings.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
@@ -68,30 +68,28 @@ void GcodeSuite::M420() {
|
||||
y_min = probe.min_y(), y_max = probe.max_y();
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
bilinear_start.set(x_min, y_min);
|
||||
bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_POINTS_X - 1),
|
||||
(y_max - y_min) / (GRID_MAX_POINTS_Y - 1));
|
||||
bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_CELLS_X),
|
||||
(y_max - y_min) / (GRID_MAX_CELLS_Y));
|
||||
#endif
|
||||
GRID_LOOP(x, y) {
|
||||
Z_VALUES(x, y) = 0.001 * random(-200, 200);
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
|
||||
#endif
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y)));
|
||||
}
|
||||
SERIAL_ECHOPGM("Simulated " STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh ");
|
||||
SERIAL_ECHOPAIR(" (", x_min);
|
||||
SERIAL_ECHOPGM(" (", x_min);
|
||||
SERIAL_CHAR(','); SERIAL_ECHO(y_min);
|
||||
SERIAL_ECHOPAIR(")-(", x_max);
|
||||
SERIAL_ECHOPGM(")-(", x_max);
|
||||
SERIAL_CHAR(','); SERIAL_ECHO(y_max);
|
||||
SERIAL_ECHOLNPGM(")");
|
||||
}
|
||||
#endif
|
||||
|
||||
xyz_pos_t oldpos = current_position;
|
||||
|
||||
// If disabling leveling do it right away
|
||||
// (Don't disable for just M420 or M420 V)
|
||||
if (seen_S && !to_enable) set_bed_leveling_enabled(false);
|
||||
|
||||
xyz_pos_t oldpos = current_position;
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
|
||||
// L to load a mesh from the EEPROM
|
||||
@@ -110,7 +108,7 @@ void GcodeSuite::M420() {
|
||||
|
||||
if (!WITHIN(storage_slot, 0, a - 1)) {
|
||||
SERIAL_ECHOLNPGM("?Invalid storage slot.");
|
||||
SERIAL_ECHOLNPAIR("?Use 0 to ", a - 1);
|
||||
SERIAL_ECHOLNPGM("?Use 0 to ", a - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -130,12 +128,12 @@ void GcodeSuite::M420() {
|
||||
ubl.display_map(parser.byteval('T'));
|
||||
SERIAL_ECHOPGM("Mesh is ");
|
||||
if (!ubl.mesh_is_valid()) SERIAL_ECHOPGM("in");
|
||||
SERIAL_ECHOLNPAIR("valid\nStorage slot: ", ubl.storage_slot);
|
||||
SERIAL_ECHOLNPGM("valid\nStorage slot: ", ubl.storage_slot);
|
||||
}
|
||||
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
||||
|
||||
const bool seenV = parser.seen('V');
|
||||
const bool seenV = parser.seen_test('V');
|
||||
|
||||
#if HAS_MESH
|
||||
|
||||
@@ -155,22 +153,19 @@ void GcodeSuite::M420() {
|
||||
|
||||
// Get the sum and average of all mesh values
|
||||
float mesh_sum = 0;
|
||||
for (uint8_t x = GRID_MAX_POINTS_X; x--;)
|
||||
for (uint8_t y = GRID_MAX_POINTS_Y; y--;)
|
||||
mesh_sum += Z_VALUES(x, y);
|
||||
GRID_LOOP(x, y) mesh_sum += Z_VALUES(x, y);
|
||||
const float zmean = mesh_sum / float(GRID_MAX_POINTS);
|
||||
|
||||
#else
|
||||
#else // midrange
|
||||
|
||||
// Find the low and high mesh values
|
||||
// Find the low and high mesh values.
|
||||
float lo_val = 100, hi_val = -100;
|
||||
for (uint8_t x = GRID_MAX_POINTS_X; x--;)
|
||||
for (uint8_t y = GRID_MAX_POINTS_Y; y--;) {
|
||||
const float z = Z_VALUES(x, y);
|
||||
NOMORE(lo_val, z);
|
||||
NOLESS(hi_val, z);
|
||||
}
|
||||
// Take the mean of the lowest and highest
|
||||
GRID_LOOP(x, y) {
|
||||
const float z = Z_VALUES(x, y);
|
||||
NOMORE(lo_val, z);
|
||||
NOLESS(hi_val, z);
|
||||
}
|
||||
// Get the midrange plus C value. (The median may be better.)
|
||||
const float zmean = (lo_val + hi_val) / 2.0 + cval;
|
||||
|
||||
#endif
|
||||
@@ -179,16 +174,11 @@ void GcodeSuite::M420() {
|
||||
if (!NEAR_ZERO(zmean)) {
|
||||
set_bed_leveling_enabled(false);
|
||||
// Subtract the mean from all values
|
||||
for (uint8_t x = GRID_MAX_POINTS_X; x--;)
|
||||
for (uint8_t y = GRID_MAX_POINTS_Y; y--;) {
|
||||
Z_VALUES(x, y) -= zmean;
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
|
||||
#endif
|
||||
}
|
||||
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
|
||||
bed_level_virt_interpolate();
|
||||
#endif
|
||||
GRID_LOOP(x, y) {
|
||||
Z_VALUES(x, y) -= zmean;
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y)));
|
||||
}
|
||||
TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -210,9 +200,7 @@ void GcodeSuite::M420() {
|
||||
if (leveling_is_valid()) {
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
print_bilinear_leveling_grid();
|
||||
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
|
||||
print_bilinear_leveling_grid_virt();
|
||||
#endif
|
||||
TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt());
|
||||
#elif ENABLED(MESH_BED_LEVELING)
|
||||
SERIAL_ECHOLNPGM("Mesh Bed Level data:");
|
||||
mbl.report_mesh();
|
||||
@@ -254,4 +242,18 @@ void GcodeSuite::M420() {
|
||||
report_current_position();
|
||||
}
|
||||
|
||||
void GcodeSuite::M420_report(const bool forReplay/*=true*/) {
|
||||
report_heading_etc(forReplay, PSTR(
|
||||
TERN(MESH_BED_LEVELING, "Mesh Bed Leveling", TERN(AUTO_BED_LEVELING_UBL, "Unified Bed Leveling", "Auto Bed Leveling"))
|
||||
));
|
||||
SERIAL_ECHOPGM_P(
|
||||
PSTR(" M420 S"), planner.leveling_active
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
, SP_Z_STR, LINEAR_UNIT(planner.z_fade_height)
|
||||
#endif
|
||||
, PSTR(" ; Leveling ")
|
||||
);
|
||||
serialprintln_onoff(planner.leveling_active);
|
||||
}
|
||||
|
||||
#endif // HAS_LEVELING
|
||||
|
Reference in New Issue
Block a user