From 4af9908764d3629d8abec0ad8a72f8939ab2e0ac Mon Sep 17 00:00:00 2001 From: Acenotass <44540957+Acenotass@users.noreply.github.com> Date: Tue, 6 Aug 2019 07:01:40 +0600 Subject: [PATCH] Update M48 command in the status line (#14816) --- Marlin/src/gcode/calibrate/M48.cpp | 52 +++++++++++++-------------- Marlin/src/lcd/language/language_en.h | 3 ++ Marlin/src/lcd/language/language_ru.h | 1 + 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 1746543cf2..5201e7c10c 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -123,45 +123,47 @@ void GcodeSuite::M48() { randomSeed(millis()); for (uint8_t n = 0; n < n_samples; n++) { + #if HAS_SPI_LCD + // Display M48 progress in the status bar + ui.status_printf_P(0, PSTR(MSG_M48_POINT ": %d/%d"), int(n + 1), int(n_samples)); + #endif if (n_legs) { const int dir = (random(0, 10) > 5.0) ? -1 : 1; // clockwise or counter clockwise float angle = random(0, 360); const float radius = random( #if ENABLED(DELTA) - (int) (0.1250000000 * (DELTA_PRINTABLE_RADIUS)), - (int) (0.3333333333 * (DELTA_PRINTABLE_RADIUS)) + int(0.1250000000 * (DELTA_PRINTABLE_RADIUS)), + int(0.3333333333 * (DELTA_PRINTABLE_RADIUS)) #else - (int) 5.0, (int) (0.125 * _MIN(X_BED_SIZE, Y_BED_SIZE)) + int(5), int(0.125 * _MIN(X_BED_SIZE, Y_BED_SIZE)) #endif ); if (verbose_level > 3) { - SERIAL_ECHOPAIR("Starting radius: ", radius); - SERIAL_ECHOPAIR(" angle: ", angle); - SERIAL_ECHOPGM(" Direction: "); - if (dir > 0) SERIAL_ECHOPGM("Counter-"); - SERIAL_ECHOLNPGM("Clockwise"); + SERIAL_ECHOPAIR("Start radius:", radius, " angle:", angle, " dir:"); + if (dir > 0) SERIAL_CHAR('C'); + SERIAL_ECHOLNPGM("CW"); } for (uint8_t l = 0; l < n_legs - 1; l++) { float delta_angle; - if (schizoid_flag) + if (schizoid_flag) { // The points of a 5 point star are 72 degrees apart. We need to // skip a point and go to the next one on the star. delta_angle = dir * 2.0 * 72.0; - - else + } + else { // If we do this line, we are just trying to move further // around the circle. delta_angle = dir * (float) random(25, 45); + } angle += delta_angle; - - while (angle > 360.0) // We probably do not need to keep the angle between 0 and 2*PI, but the - angle -= 360.0; // Arduino documentation says the trig functions should not be given values - while (angle < 0.0) // outside of this range. It looks like they behave correctly with - angle += 360.0; // numbers outside of the range, but just to be safe we clamp them. + while (angle > 360.0) angle -= 360.0; // We probably do not need to keep the angle between 0 and 2*PI, but the + // Arduino documentation says the trig functions should not be given values + while (angle < 0.0) angle += 360.0; // outside of this range. It looks like they behave correctly with + // numbers outside of the range, but just to be safe we clamp them. X_current = X_probe_location - (X_PROBE_OFFSET_FROM_EXTRUDER) + cos(RADIANS(angle)) * radius; Y_current = Y_probe_location - (Y_PROBE_OFFSET_FROM_EXTRUDER) + sin(RADIANS(angle)) * radius; @@ -175,18 +177,14 @@ void GcodeSuite::M48() { while (!position_is_reachable_by_probe(X_current, Y_current)) { X_current *= 0.8; Y_current *= 0.8; - if (verbose_level > 3) { - SERIAL_ECHOPAIR("Pulling point towards center:", X_current); - SERIAL_ECHOLNPAIR(", ", Y_current); - } + if (verbose_level > 3) + SERIAL_ECHOLNPAIR("Moving inward: X", X_current, " Y", Y_current); } #endif - if (verbose_level > 3) { - SERIAL_ECHOPGM("Going to:"); - SERIAL_ECHOPAIR(" X", X_current); - SERIAL_ECHOPAIR(" Y", Y_current); - SERIAL_ECHOLNPAIR(" Z", current_position[Z_AXIS]); - } + + if (verbose_level > 3) + SERIAL_ECHOLNPAIR("Going to: X", X_current, " Y", Y_current, " Z", current_position[Z_AXIS]); + do_blocking_move_to_xy(X_current, Y_current); } // n_legs loop } // n_legs @@ -220,7 +218,7 @@ void GcodeSuite::M48() { if (verbose_level > 0) { if (verbose_level > 1) { SERIAL_ECHO(n + 1); - SERIAL_ECHOPAIR(" of ", (int)n_samples); + SERIAL_ECHOPAIR(" of ", int(n_samples)); SERIAL_ECHOPAIR_F(": z: ", sample_set[n], 3); if (verbose_level > 2) { SERIAL_ECHOPAIR_F(" mean: ", mean, 4); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index a9e000b504..0d1cd4f8df 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -256,6 +256,9 @@ #ifndef MSG_M48_TEST #define MSG_M48_TEST _UxGT("M48 Probe Test") #endif +#ifndef MSG_M48_POINT + #define MSG_M48_POINT _UxGT("M48 Point") +#endif #ifndef MSG_M48_DEVIATION #define MSG_M48_DEVIATION _UxGT("Deviation") #endif diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index c47af44177..47cb06fc04 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -86,6 +86,7 @@ #define MSG_M48_TEST _UxGT("Проверка датчика Z") #define MSG_M48_DEVIATION _UxGT("Отклонение") +#define MSG_M48_POINT _UxGT("Точка") // TODO: IDEX Menu #define MSG_OFFSETS_MENU _UxGT("Размещение сопел")