123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920 |
- #include "MarlinConfig.h"
- #if ENABLED(G26_MESH_VALIDATION)
- #include "Marlin.h"
- #include "planner.h"
- #include "stepper.h"
- #include "temperature.h"
- #include "ultralcd.h"
- #include "parser.h"
- #include "serial.h"
- #include "bitmap_flags.h"
- #if ENABLED(MESH_BED_LEVELING)
- #include "mesh_bed_leveling.h"
- #elif ENABLED(AUTO_BED_LEVELING_UBL)
- #include "ubl.h"
- #endif
- #define EXTRUSION_MULTIPLIER 1.0
- #define RETRACTION_MULTIPLIER 1.0
- #define PRIME_LENGTH 10.0
- #define OOZE_AMOUNT 0.3
- #define INTERSECTION_CIRCLE_RADIUS 5
- #define CROSSHAIRS_SIZE 3
- #if CROSSHAIRS_SIZE >= INTERSECTION_CIRCLE_RADIUS
- #error "CROSSHAIRS_SIZE must be less than INTERSECTION_CIRCLE_RADIUS."
- #endif
- #define G26_OK false
- #define G26_ERR true
-
-
- extern Planner planner;
-
- static uint16_t circle_flags[16], horizontal_mesh_line_flags[16], vertical_mesh_line_flags[16];
- float g26_e_axis_feedrate = 0.025,
- random_deviation = 0.0;
- static bool g26_retracted = false;
-
- static float g26_extrusion_multiplier,
- g26_retraction_multiplier,
- g26_layer_height,
- g26_prime_length,
- g26_x_pos, g26_y_pos;
- static int16_t g26_bed_temp,
- g26_hotend_temp;
- static int8_t g26_prime_flag;
- #if ENABLED(ULTIPANEL)
-
- bool user_canceled() {
- if (!is_lcd_clicked()) return false;
- lcd_setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
- #if ENABLED(ULTIPANEL)
- lcd_quick_feedback(true);
- #endif
- wait_for_release();
- return true;
- }
- bool exit_from_g26() {
- lcd_setstatusPGM(PSTR("Leaving G26"), -1);
- wait_for_release();
- return G26_ERR;
- }
- #endif
- void G26_line_to_destination(const float &feed_rate) {
- const float save_feedrate = feedrate_mm_s;
- feedrate_mm_s = feed_rate;
- prepare_move_to_destination();
- feedrate_mm_s = save_feedrate;
- }
- void move_to(const float &rx, const float &ry, const float &z, const float &e_delta) {
- float feed_value;
- static float last_z = -999.99;
- bool has_xy_component = (rx != current_position[X_AXIS] || ry != current_position[Y_AXIS]);
- if (z != last_z) {
- last_z = z;
- feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0);
- destination[X_AXIS] = current_position[X_AXIS];
- destination[Y_AXIS] = current_position[Y_AXIS];
- destination[Z_AXIS] = z;
- destination[E_CART] = current_position[E_CART];
- G26_line_to_destination(feed_value);
- set_destination_from_current();
- }
-
-
- feed_value = has_xy_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.max_feedrate_mm_s[E_AXIS] / 1.5;
- if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
- destination[X_AXIS] = rx;
- destination[Y_AXIS] = ry;
- destination[E_CART] += e_delta;
- G26_line_to_destination(feed_value);
- set_destination_from_current();
- }
- FORCE_INLINE void move_to(const float where[XYZE], const float &de) { move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], de); }
- void retract_filament(const float where[XYZE]) {
- if (!g26_retracted) {
- g26_retracted = true;
- move_to(where, -1.0 * g26_retraction_multiplier);
- }
- }
- void recover_filament(const float where[XYZE]) {
- if (g26_retracted) {
- move_to(where, 1.2 * g26_retraction_multiplier);
- g26_retracted = false;
- }
- }
-
- inline bool prime_nozzle() {
- #if ENABLED(ULTIPANEL)
- float Total_Prime = 0.0;
- if (g26_prime_flag == -1) {
- lcd_external_control = true;
- lcd_setstatusPGM(PSTR("User-Controlled Prime"), 99);
- lcd_chirp();
- set_destination_from_current();
- recover_filament(destination);
- while (!is_lcd_clicked()) {
- lcd_chirp();
- destination[E_CART] += 0.25;
- #ifdef PREVENT_LENGTHY_EXTRUDE
- Total_Prime += 0.25;
- if (Total_Prime >= EXTRUDE_MAXLENGTH) return G26_ERR;
- #endif
- G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
- set_destination_from_current();
- planner.synchronize();
-
-
-
- SERIAL_FLUSH();
- }
- wait_for_release();
- lcd_setstatusPGM(PSTR("Done Priming"), 99);
- lcd_quick_feedback(true);
- lcd_external_control = false;
- }
- else
- #endif
- {
- #if ENABLED(ULTRA_LCD)
- lcd_setstatusPGM(PSTR("Fixed Length Prime."), 99);
- lcd_quick_feedback(true);
- #endif
- set_destination_from_current();
- destination[E_CART] += g26_prime_length;
- G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
- set_destination_from_current();
- retract_filament(destination);
- }
- return G26_OK;
- }
- mesh_index_pair find_closest_circle_to_print(const float &X, const float &Y) {
- float closest = 99999.99;
- mesh_index_pair return_val;
- return_val.x_index = return_val.y_index = -1;
- for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
- for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
- if (!is_bitmap_set(circle_flags, i, j)) {
- const float mx = _GET_MESH_X(i),
- my = _GET_MESH_Y(j);
-
- float f = HYPOT(X - mx, Y - my);
-
-
-
-
- f += HYPOT(g26_x_pos - mx, g26_y_pos - my) / 15.0;
-
- if (random_deviation > 1.0)
- f += random(0.0, random_deviation);
- if (f < closest) {
- closest = f;
- return_val.x_index = i;
- return_val.y_index = j;
- return_val.distance = closest;
- }
- }
- }
- }
- bitmap_set(circle_flags, return_val.x_index, return_val.y_index);
- return return_val;
- }
-
- void print_line_from_here_to_there(const float &sx, const float &sy, const float &sz, const float &ex, const float &ey, const float &ez) {
- const float dx_s = current_position[X_AXIS] - sx,
- dy_s = current_position[Y_AXIS] - sy,
- dist_start = HYPOT2(dx_s, dy_s),
-
- dx_e = current_position[X_AXIS] - ex,
- dy_e = current_position[Y_AXIS] - ey,
- dist_end = HYPOT2(dx_e, dy_e),
- line_length = HYPOT(ex - sx, ey - sy);
-
-
- if (dist_end < dist_start && (INTERSECTION_CIRCLE_RADIUS) < ABS(line_length))
- return print_line_from_here_to_there(ex, ey, ez, sx, sy, sz);
-
- if (dist_start > 2.0) {
- retract_filament(destination);
-
- move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + 0.500, 0.0);
- move_to(sx, sy, sz + 0.500, 0.0);
- }
- move_to(sx, sy, sz, 0.0);
- const float e_pos_delta = line_length * g26_e_axis_feedrate * g26_extrusion_multiplier;
- recover_filament(destination);
- move_to(ex, ey, ez, e_pos_delta);
- }
- inline bool look_for_lines_to_connect() {
- float sx, sy, ex, ey;
- for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
- for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
- #if ENABLED(ULTIPANEL)
- if (user_canceled()) return true;
- #endif
- if (i < GRID_MAX_POINTS_X) {
-
- if (is_bitmap_set(circle_flags, i, j) && is_bitmap_set(circle_flags, i + 1, j)) {
- if (!is_bitmap_set(horizontal_mesh_line_flags, i, j)) {
-
-
-
-
- sx = _GET_MESH_X( i ) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE));
- ex = _GET_MESH_X(i + 1) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE));
- sx = constrain(sx, X_MIN_POS + 1, X_MAX_POS - 1);
- sy = ey = constrain(_GET_MESH_Y(j), Y_MIN_POS + 1, Y_MAX_POS - 1);
- ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
- if (position_is_reachable(sx, sy) && position_is_reachable(ex, ey)) {
- if (g26_debug_flag) {
- SERIAL_ECHOPAIR(" Connecting with horizontal line (sx=", sx);
- SERIAL_ECHOPAIR(", sy=", sy);
- SERIAL_ECHOPAIR(") -> (ex=", ex);
- SERIAL_ECHOPAIR(", ey=", ey);
- SERIAL_CHAR(')');
- SERIAL_EOL();
-
- }
- print_line_from_here_to_there(sx, sy, g26_layer_height, ex, ey, g26_layer_height);
- }
- bitmap_set(horizontal_mesh_line_flags, i, j);
- }
- }
- if (j < GRID_MAX_POINTS_Y) {
-
- if (is_bitmap_set(circle_flags, i, j) && is_bitmap_set(circle_flags, i, j + 1)) {
- if (!is_bitmap_set( vertical_mesh_line_flags, i, j)) {
-
-
-
-
- sy = _GET_MESH_Y( j ) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE));
- ey = _GET_MESH_Y(j + 1) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE));
- sx = ex = constrain(_GET_MESH_X(i), X_MIN_POS + 1, X_MAX_POS - 1);
- sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
- ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
- if (position_is_reachable(sx, sy) && position_is_reachable(ex, ey)) {
- if (g26_debug_flag) {
- SERIAL_ECHOPAIR(" Connecting with vertical line (sx=", sx);
- SERIAL_ECHOPAIR(", sy=", sy);
- SERIAL_ECHOPAIR(") -> (ex=", ex);
- SERIAL_ECHOPAIR(", ey=", ey);
- SERIAL_CHAR(')');
- SERIAL_EOL();
- #if ENABLED(AUTO_BED_LEVELING_UBL)
- debug_current_and_destination(PSTR("Connecting vertical line."));
- #endif
- }
- print_line_from_here_to_there(sx, sy, g26_layer_height, ex, ey, g26_layer_height);
- }
- bitmap_set(vertical_mesh_line_flags, i, j);
- }
- }
- }
- }
- }
- }
- return false;
- }
-
- inline bool turn_on_heaters() {
- millis_t next = millis() + 5000UL;
- #if HAS_HEATED_BED
- #if ENABLED(ULTRA_LCD)
- if (g26_bed_temp > 25) {
- lcd_setstatusPGM(PSTR("G26 Heating Bed."), 99);
- lcd_quick_feedback(true);
- #if ENABLED(ULTIPANEL)
- lcd_external_control = true;
- #endif
- #endif
- thermalManager.setTargetBed(g26_bed_temp);
- while (ABS(thermalManager.degBed() - g26_bed_temp) > 3) {
- #if ENABLED(ULTIPANEL)
- if (is_lcd_clicked()) return exit_from_g26();
- #endif
- if (ELAPSED(millis(), next)) {
- next = millis() + 5000UL;
- thermalManager.print_heaterstates();
- SERIAL_EOL();
- }
- idle();
- SERIAL_FLUSH();
- }
- #if ENABLED(ULTRA_LCD)
- }
- lcd_setstatusPGM(PSTR("G26 Heating Nozzle."), 99);
- lcd_quick_feedback(true);
- #endif
- #endif
-
- thermalManager.setTargetHotend(g26_hotend_temp, 0);
- while (ABS(thermalManager.degHotend(0) - g26_hotend_temp) > 3) {
- #if ENABLED(ULTIPANEL)
- if (is_lcd_clicked()) return exit_from_g26();
- #endif
- if (ELAPSED(millis(), next)) {
- next = millis() + 5000UL;
- thermalManager.print_heaterstates();
- SERIAL_EOL();
- }
- idle();
- SERIAL_FLUSH();
- }
- #if ENABLED(ULTRA_LCD)
- lcd_reset_status();
- lcd_quick_feedback(true);
- #endif
- return G26_OK;
- }
- float valid_trig_angle(float d) {
- while (d > 360.0) d -= 360.0;
- while (d < 0.0) d += 360.0;
- return d;
- }
-
- void gcode_G26() {
- SERIAL_ECHOLNPGM("G26 command started. Waiting for heater(s).");
-
-
- if (axis_unhomed_error()) return;
- g26_extrusion_multiplier = EXTRUSION_MULTIPLIER;
- g26_retraction_multiplier = RETRACTION_MULTIPLIER;
- g26_layer_height = MESH_TEST_LAYER_HEIGHT;
- g26_prime_length = PRIME_LENGTH;
- g26_bed_temp = MESH_TEST_BED_TEMP;
- g26_hotend_temp = MESH_TEST_HOTEND_TEMP;
- g26_prime_flag = 0;
- float g26_nozzle = MESH_TEST_NOZZLE_SIZE,
- g26_filament_diameter = DEFAULT_NOMINAL_FILAMENT_DIA,
- g26_ooze_amount = parser.linearval('O', OOZE_AMOUNT);
- bool g26_continue_with_closest = parser.boolval('C'),
- g26_keep_heaters_on = parser.boolval('K');
- if (parser.seenval('B')) {
- g26_bed_temp = parser.value_celsius();
- if (g26_bed_temp && !WITHIN(g26_bed_temp, 40, 140)) {
- SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible (40-140C).");
- return;
- }
- }
- if (parser.seenval('L')) {
- g26_layer_height = parser.value_linear_units();
- if (!WITHIN(g26_layer_height, 0.0, 2.0)) {
- SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible.");
- return;
- }
- }
- if (parser.seen('Q')) {
- if (parser.has_value()) {
- g26_retraction_multiplier = parser.value_float();
- if (!WITHIN(g26_retraction_multiplier, 0.05, 15.0)) {
- SERIAL_PROTOCOLLNPGM("?Specified Retraction Multiplier not plausible.");
- return;
- }
- }
- else {
- SERIAL_PROTOCOLLNPGM("?Retraction Multiplier must be specified.");
- return;
- }
- }
- if (parser.seenval('S')) {
- g26_nozzle = parser.value_float();
- if (!WITHIN(g26_nozzle, 0.1, 1.0)) {
- SERIAL_PROTOCOLLNPGM("?Specified nozzle size not plausible.");
- return;
- }
- }
- if (parser.seen('P')) {
- if (!parser.has_value()) {
- #if ENABLED(ULTIPANEL)
- g26_prime_flag = -1;
- #else
- SERIAL_PROTOCOLLNPGM("?Prime length must be specified when not using an LCD.");
- return;
- #endif
- }
- else {
- g26_prime_flag++;
- g26_prime_length = parser.value_linear_units();
- if (!WITHIN(g26_prime_length, 0.0, 25.0)) {
- SERIAL_PROTOCOLLNPGM("?Specified prime length not plausible.");
- return;
- }
- }
- }
- if (parser.seenval('F')) {
- g26_filament_diameter = parser.value_linear_units();
- if (!WITHIN(g26_filament_diameter, 1.0, 4.0)) {
- SERIAL_PROTOCOLLNPGM("?Specified filament size not plausible.");
- return;
- }
- }
- g26_extrusion_multiplier *= sq(1.75) / sq(g26_filament_diameter);
-
-
- g26_extrusion_multiplier *= g26_filament_diameter * sq(g26_nozzle) / sq(0.3);
- if (parser.seenval('H')) {
- g26_hotend_temp = parser.value_celsius();
- if (!WITHIN(g26_hotend_temp, 165, 280)) {
- SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible.");
- return;
- }
- }
- if (parser.seen('U')) {
- randomSeed(millis());
-
- random_deviation = parser.has_value() ? parser.value_float() : 50.0;
- }
- int16_t g26_repeats;
- #if ENABLED(ULTIPANEL)
- g26_repeats = parser.intval('R', GRID_MAX_POINTS + 1);
- #else
- if (!parser.seen('R')) {
- SERIAL_PROTOCOLLNPGM("?(R)epeat must be specified when not using an LCD.");
- return;
- }
- else
- g26_repeats = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS + 1;
- #endif
- if (g26_repeats < 1) {
- SERIAL_PROTOCOLLNPGM("?(R)epeat value not plausible; must be at least 1.");
- return;
- }
- g26_x_pos = parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position[X_AXIS];
- g26_y_pos = parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : current_position[Y_AXIS];
- if (!position_is_reachable(g26_x_pos, g26_y_pos)) {
- SERIAL_PROTOCOLLNPGM("?Specified X,Y coordinate out of bounds.");
- return;
- }
-
- set_bed_leveling_enabled(!parser.seen('D'));
- if (current_position[Z_AXIS] < Z_CLEARANCE_BETWEEN_PROBES) {
- do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
- set_current_from_destination();
- }
- if (turn_on_heaters() != G26_OK) goto LEAVE;
- current_position[E_CART] = 0.0;
- sync_plan_position_e();
- if (g26_prime_flag && prime_nozzle() != G26_OK) goto LEAVE;
-
- ZERO(circle_flags);
- ZERO(horizontal_mesh_line_flags);
- ZERO(vertical_mesh_line_flags);
-
- set_destination_from_current();
- destination[Z_AXIS] = g26_layer_height;
- move_to(destination, 0.0);
- move_to(destination, g26_ooze_amount);
- #if ENABLED(ULTIPANEL)
- lcd_external_control = true;
- #endif
-
- #if DISABLED(ARC_SUPPORT)
-
- #define A_INT 30
- #define _ANGS (360 / A_INT)
- #define A_CNT (_ANGS / 2)
- #define _IND(A) ((A + _ANGS * 8) % _ANGS)
- #define _COS(A) (trig_table[_IND(A) % A_CNT] * (_IND(A) >= A_CNT ? -1 : 1))
- #define _SIN(A) (-_COS((A + A_CNT / 2) % _ANGS))
- #if A_CNT & 1
- #error "A_CNT must be a positive value. Please change A_INT."
- #endif
- float trig_table[A_CNT];
- for (uint8_t i = 0; i < A_CNT; i++)
- trig_table[i] = INTERSECTION_CIRCLE_RADIUS * cos(RADIANS(i * A_INT));
- #endif
- mesh_index_pair location;
- do {
- location = g26_continue_with_closest
- ? find_closest_circle_to_print(current_position[X_AXIS], current_position[Y_AXIS])
- : find_closest_circle_to_print(g26_x_pos, g26_y_pos);
- if (location.x_index >= 0 && location.y_index >= 0) {
- const float circle_x = _GET_MESH_X(location.x_index),
- circle_y = _GET_MESH_Y(location.y_index);
-
- if (!position_is_reachable(circle_x, circle_y)) continue;
-
-
- const uint8_t xi = location.x_index, yi = location.y_index;
- const bool f = yi == 0, r = xi >= GRID_MAX_POINTS_X - 1, b = yi >= GRID_MAX_POINTS_Y - 1;
- #if ENABLED(ARC_SUPPORT)
- #define ARC_LENGTH(quarters) (INTERSECTION_CIRCLE_RADIUS * M_PI * (quarters) / 2)
- float sx = circle_x + INTERSECTION_CIRCLE_RADIUS,
- ex = circle_x + INTERSECTION_CIRCLE_RADIUS,
- sy = circle_y, ey = circle_y,
- arc_length = ARC_LENGTH(4);
-
- if (xi == 0) {
- sx = f ? circle_x + INTERSECTION_CIRCLE_RADIUS : circle_x;
- ex = b ? circle_x + INTERSECTION_CIRCLE_RADIUS : circle_x;
- sy = f ? circle_y : circle_y - INTERSECTION_CIRCLE_RADIUS;
- ey = b ? circle_y : circle_y + INTERSECTION_CIRCLE_RADIUS;
- arc_length = (f || b) ? ARC_LENGTH(1) : ARC_LENGTH(2);
- }
- else if (r) {
- sx = b ? circle_x - INTERSECTION_CIRCLE_RADIUS : circle_x;
- ex = f ? circle_x - INTERSECTION_CIRCLE_RADIUS : circle_x;
- sy = b ? circle_y : circle_y + INTERSECTION_CIRCLE_RADIUS;
- ey = f ? circle_y : circle_y - INTERSECTION_CIRCLE_RADIUS;
- arc_length = (f || b) ? ARC_LENGTH(1) : ARC_LENGTH(2);
- }
- else if (f) {
- sx = circle_x + INTERSECTION_CIRCLE_RADIUS;
- ex = circle_x - INTERSECTION_CIRCLE_RADIUS;
- sy = ey = circle_y;
- arc_length = ARC_LENGTH(2);
- }
- else if (b) {
- sx = circle_x - INTERSECTION_CIRCLE_RADIUS;
- ex = circle_x + INTERSECTION_CIRCLE_RADIUS;
- sy = ey = circle_y;
- arc_length = ARC_LENGTH(2);
- }
- const float arc_offset[2] = {
- circle_x - sx,
- circle_y - sy
- };
- const float dx_s = current_position[X_AXIS] - sx,
- dy_s = current_position[Y_AXIS] - sy,
- dist_start = HYPOT2(dx_s, dy_s);
- const float endpoint[XYZE] = {
- ex, ey,
- g26_layer_height,
- current_position[E_CART] + (arc_length * g26_e_axis_feedrate * g26_extrusion_multiplier)
- };
- if (dist_start > 2.0) {
- retract_filament(destination);
-
- move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + 0.500, 0.0);
- move_to(sx, sy, g26_layer_height + 0.500, 0.0);
- }
- move_to(sx, sy, g26_layer_height, 0.0);
- recover_filament(destination);
- const float save_feedrate = feedrate_mm_s;
- feedrate_mm_s = PLANNER_XY_FEEDRATE() / 10.0;
- plan_arc(endpoint, arc_offset, false);
- feedrate_mm_s = save_feedrate;
- set_destination_from_current();
- #if ENABLED(ULTIPANEL)
- if (user_canceled()) goto LEAVE;
- #endif
- #else
- int8_t start_ind = -2, end_ind = 9;
- if (xi == 0) {
- start_ind = f ? 0 : -3;
- end_ind = b ? 0 : 2;
- }
- else if (r) {
- start_ind = b ? 6 : 3;
- end_ind = f ? 5 : 8;
- }
- else if (f) {
- start_ind = 0;
- end_ind = 5;
- }
- else if (b) {
- start_ind = 6;
- end_ind = 11;
- }
- for (int8_t ind = start_ind; ind <= end_ind; ind++) {
- #if ENABLED(ULTIPANEL)
- if (user_canceled()) goto LEAVE;
- #endif
- float rx = circle_x + _COS(ind),
- ry = circle_y + _SIN(ind),
- xe = circle_x + _COS(ind + 1),
- ye = circle_y + _SIN(ind + 1);
- #if IS_KINEMATIC
-
- if (!position_is_reachable(rx, ry) || !position_is_reachable(xe, ye)) continue;
- #else
- rx = constrain(rx, X_MIN_POS + 1, X_MAX_POS - 1);
- ry = constrain(ry, Y_MIN_POS + 1, Y_MAX_POS - 1);
- xe = constrain(xe, X_MIN_POS + 1, X_MAX_POS - 1);
- ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
- #endif
- print_line_from_here_to_there(rx, ry, g26_layer_height, xe, ye, g26_layer_height);
- SERIAL_FLUSH();
- }
- #endif
- if (look_for_lines_to_connect()) goto LEAVE;
- }
- SERIAL_FLUSH();
- } while (--g26_repeats && location.x_index >= 0 && location.y_index >= 0);
- LEAVE:
- lcd_setstatusPGM(PSTR("Leaving G26"), -1);
- retract_filament(destination);
- destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;
-
- move_to(destination, 0);
-
- destination[X_AXIS] = g26_x_pos;
- destination[Y_AXIS] = g26_y_pos;
-
- move_to(destination, 0);
-
- #if ENABLED(ULTIPANEL)
- lcd_external_control = false;
- #endif
- if (!g26_keep_heaters_on) {
- #if HAS_HEATED_BED
- thermalManager.setTargetBed(0);
- #endif
- thermalManager.setTargetHotend(0, 0);
- }
- }
- #endif
|