|
@ -123,45 +123,47 @@ void GcodeSuite::M48() { |
|
|
randomSeed(millis()); |
|
|
randomSeed(millis()); |
|
|
|
|
|
|
|
|
for (uint8_t n = 0; n < n_samples; n++) { |
|
|
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) { |
|
|
if (n_legs) { |
|
|
const int dir = (random(0, 10) > 5.0) ? -1 : 1; // clockwise or counter clockwise
|
|
|
const int dir = (random(0, 10) > 5.0) ? -1 : 1; // clockwise or counter clockwise
|
|
|
float angle = random(0, 360); |
|
|
float angle = random(0, 360); |
|
|
const float radius = random( |
|
|
const float radius = random( |
|
|
#if ENABLED(DELTA) |
|
|
#if ENABLED(DELTA) |
|
|
(int) (0.1250000000 * (DELTA_PRINTABLE_RADIUS)), |
|
|
int(0.1250000000 * (DELTA_PRINTABLE_RADIUS)), |
|
|
(int) (0.3333333333 * (DELTA_PRINTABLE_RADIUS)) |
|
|
int(0.3333333333 * (DELTA_PRINTABLE_RADIUS)) |
|
|
#else |
|
|
#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 |
|
|
#endif |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if (verbose_level > 3) { |
|
|
if (verbose_level > 3) { |
|
|
SERIAL_ECHOPAIR("Starting radius: ", radius); |
|
|
SERIAL_ECHOPAIR("Start radius:", radius, " angle:", angle, " dir:"); |
|
|
SERIAL_ECHOPAIR(" angle: ", angle); |
|
|
if (dir > 0) SERIAL_CHAR('C'); |
|
|
SERIAL_ECHOPGM(" Direction: "); |
|
|
SERIAL_ECHOLNPGM("CW"); |
|
|
if (dir > 0) SERIAL_ECHOPGM("Counter-"); |
|
|
|
|
|
SERIAL_ECHOLNPGM("Clockwise"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (uint8_t l = 0; l < n_legs - 1; l++) { |
|
|
for (uint8_t l = 0; l < n_legs - 1; l++) { |
|
|
float delta_angle; |
|
|
float delta_angle; |
|
|
|
|
|
|
|
|
if (schizoid_flag) |
|
|
if (schizoid_flag) { |
|
|
// The points of a 5 point star are 72 degrees apart. We need to
|
|
|
// 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.
|
|
|
// skip a point and go to the next one on the star.
|
|
|
delta_angle = dir * 2.0 * 72.0; |
|
|
delta_angle = dir * 2.0 * 72.0; |
|
|
|
|
|
} |
|
|
else |
|
|
else { |
|
|
// If we do this line, we are just trying to move further
|
|
|
// If we do this line, we are just trying to move further
|
|
|
// around the circle.
|
|
|
// around the circle.
|
|
|
delta_angle = dir * (float) random(25, 45); |
|
|
delta_angle = dir * (float) random(25, 45); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
angle += delta_angle; |
|
|
angle += delta_angle; |
|
|
|
|
|
while (angle > 360.0) angle -= 360.0; // We probably do not need to keep the angle between 0 and 2*PI, but the
|
|
|
while (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
|
|
|
angle -= 360.0; // 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
|
|
|
while (angle < 0.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.
|
|
|
angle += 360.0; // 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; |
|
|
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; |
|
|
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)) { |
|
|
while (!position_is_reachable_by_probe(X_current, Y_current)) { |
|
|
X_current *= 0.8; |
|
|
X_current *= 0.8; |
|
|
Y_current *= 0.8; |
|
|
Y_current *= 0.8; |
|
|
if (verbose_level > 3) { |
|
|
if (verbose_level > 3) |
|
|
SERIAL_ECHOPAIR("Pulling point towards center:", X_current); |
|
|
SERIAL_ECHOLNPAIR("Moving inward: X", X_current, " Y", Y_current); |
|
|
SERIAL_ECHOLNPAIR(", ", Y_current); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
if (verbose_level > 3) { |
|
|
|
|
|
SERIAL_ECHOPGM("Going to:"); |
|
|
if (verbose_level > 3) |
|
|
SERIAL_ECHOPAIR(" X", X_current); |
|
|
SERIAL_ECHOLNPAIR("Going to: X", X_current, " Y", Y_current, " Z", current_position[Z_AXIS]); |
|
|
SERIAL_ECHOPAIR(" Y", Y_current); |
|
|
|
|
|
SERIAL_ECHOLNPAIR(" Z", current_position[Z_AXIS]); |
|
|
|
|
|
} |
|
|
|
|
|
do_blocking_move_to_xy(X_current, Y_current); |
|
|
do_blocking_move_to_xy(X_current, Y_current); |
|
|
} // n_legs loop
|
|
|
} // n_legs loop
|
|
|
} // n_legs
|
|
|
} // n_legs
|
|
@ -220,7 +218,7 @@ void GcodeSuite::M48() { |
|
|
if (verbose_level > 0) { |
|
|
if (verbose_level > 0) { |
|
|
if (verbose_level > 1) { |
|
|
if (verbose_level > 1) { |
|
|
SERIAL_ECHO(n + 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); |
|
|
SERIAL_ECHOPAIR_F(": z: ", sample_set[n], 3); |
|
|
if (verbose_level > 2) { |
|
|
if (verbose_level > 2) { |
|
|
SERIAL_ECHOPAIR_F(" mean: ", mean, 4); |
|
|
SERIAL_ECHOPAIR_F(" mean: ", mean, 4); |
|
|