|
|
|
@ -55,7 +55,7 @@
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define G26_OK false
|
|
|
|
|
#define G26_ERROR true
|
|
|
|
|
#define G26_ERR true
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* G26 Mesh Validation Tool
|
|
|
|
@ -142,10 +142,6 @@
|
|
|
|
|
void prepare_move_to_destination();
|
|
|
|
|
inline void sync_plan_position_e() { planner.set_e_position_mm(current_position[E_AXIS]); }
|
|
|
|
|
inline void set_current_from_destination() { COPY(current_position, destination); }
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
void lcd_setstatusPGM(const char* const message, const int8_t level);
|
|
|
|
|
void chirp_at_user();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Private functions
|
|
|
|
|
|
|
|
|
@ -155,49 +151,24 @@
|
|
|
|
|
|
|
|
|
|
static bool g26_retracted = false; // Track the retracted state of the nozzle so mismatched
|
|
|
|
|
// retracts/recovers won't result in a bad state.
|
|
|
|
|
float valid_trig_angle(float);
|
|
|
|
|
|
|
|
|
|
void G26_line_to_destination(const float &feed_rate) {
|
|
|
|
|
const float save_feedrate = feedrate_mm_s;
|
|
|
|
|
feedrate_mm_s = feed_rate; // use specified feed rate
|
|
|
|
|
prepare_move_to_destination(); // will ultimately call ubl.line_to_destination_cartesian for UBL or ubl.prepare_linear_move_to for UBL_DELTA
|
|
|
|
|
feedrate_mm_s = save_feedrate; // restore global feed rate
|
|
|
|
|
}
|
|
|
|
|
static bool exit_from_g26();
|
|
|
|
|
static bool parse_G26_parameters();
|
|
|
|
|
static mesh_index_pair find_closest_circle_to_print(const float&, const float&);
|
|
|
|
|
static bool look_for_lines_to_connect();
|
|
|
|
|
static bool turn_on_heaters();
|
|
|
|
|
static bool prime_nozzle();
|
|
|
|
|
static void retract_filament(const float where[XYZE]);
|
|
|
|
|
static void recover_filament(const float where[XYZE]);
|
|
|
|
|
static void print_line_from_here_to_there(const float&, const float&, const float&, const float&, const float&, const float&);
|
|
|
|
|
static void move_to(const float&, const float&, const float&, const float&);
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
extern bool ubl_lcd_clicked();
|
|
|
|
|
#endif
|
|
|
|
|
static void move_to(const float where[XYZE], const float &de) { move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], de); }
|
|
|
|
|
|
|
|
|
|
static float g26_extrusion_multiplier,
|
|
|
|
|
g26_retraction_multiplier,
|
|
|
|
|
g26_nozzle,
|
|
|
|
|
g26_filament_diameter,
|
|
|
|
|
g26_layer_height,
|
|
|
|
|
g26_prime_length,
|
|
|
|
|
g26_x_pos, g26_y_pos,
|
|
|
|
|
g26_ooze_amount,
|
|
|
|
|
g26_layer_height;
|
|
|
|
|
g26_x_pos, g26_y_pos;
|
|
|
|
|
|
|
|
|
|
static int16_t g26_bed_temp,
|
|
|
|
|
g26_hotend_temp,
|
|
|
|
|
g26_repeats;
|
|
|
|
|
g26_hotend_temp;
|
|
|
|
|
|
|
|
|
|
static int8_t g26_prime_flag;
|
|
|
|
|
static bool g26_continue_with_closest, g26_keep_heaters_on;
|
|
|
|
|
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
/**
|
|
|
|
|
* Detect ubl_lcd_clicked, debounce it, and return true for cancel
|
|
|
|
|
* Detect is_lcd_clicked, debounce it, and return true for cancel
|
|
|
|
|
*/
|
|
|
|
|
bool user_canceled() {
|
|
|
|
|
if (!ubl_lcd_clicked()) return false;
|
|
|
|
|
if (!is_lcd_clicked()) return false;
|
|
|
|
|
safe_delay(10); // Wait for click to settle
|
|
|
|
|
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
@ -205,209 +176,147 @@
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
while (!ubl_lcd_clicked()) idle(); // Wait for button release
|
|
|
|
|
while (!is_lcd_clicked()) idle(); // Wait for button release
|
|
|
|
|
|
|
|
|
|
// If the button is suddenly pressed again,
|
|
|
|
|
// ask the user to resolve the issue
|
|
|
|
|
lcd_setstatusPGM(PSTR("Release button"), 99); // will never appear...
|
|
|
|
|
while (ubl_lcd_clicked()) idle(); // unless this loop happens
|
|
|
|
|
while (is_lcd_clicked()) idle(); // unless this loop happens
|
|
|
|
|
lcd_reset_status();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* G26: Mesh Validation Pattern generation.
|
|
|
|
|
*
|
|
|
|
|
* Used to interactively edit UBL's Mesh by placing the
|
|
|
|
|
* nozzle in a problem area and doing a G29 P4 R command.
|
|
|
|
|
*/
|
|
|
|
|
void gcode_G26() {
|
|
|
|
|
SERIAL_ECHOLNPGM("G26 command started. Waiting for heater(s).");
|
|
|
|
|
float tmp, start_angle, end_angle;
|
|
|
|
|
int i, xi, yi;
|
|
|
|
|
mesh_index_pair location;
|
|
|
|
|
|
|
|
|
|
// Don't allow Mesh Validation without homing first,
|
|
|
|
|
// or if the parameter parsing did not go OK, abort
|
|
|
|
|
if (axis_unhomed_error() || parse_G26_parameters()) return;
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
bool exit_from_g26() {
|
|
|
|
|
lcd_setstatusPGM(PSTR("Leaving G26"), -1);
|
|
|
|
|
while (is_lcd_clicked()) idle();
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (current_position[Z_AXIS] < Z_CLEARANCE_BETWEEN_PROBES) {
|
|
|
|
|
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
set_current_from_destination();
|
|
|
|
|
void G26_line_to_destination(const float &feed_rate) {
|
|
|
|
|
const float save_feedrate = feedrate_mm_s;
|
|
|
|
|
feedrate_mm_s = feed_rate; // use specified feed rate
|
|
|
|
|
prepare_move_to_destination(); // will ultimately call ubl.line_to_destination_cartesian for UBL or ubl.prepare_linear_move_to for UBL_DELTA
|
|
|
|
|
feedrate_mm_s = save_feedrate; // restore global feed rate
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (turn_on_heaters()) goto LEAVE;
|
|
|
|
|
void move_to(const float &x, const float &y, const float &z, const float &e_delta) {
|
|
|
|
|
float feed_value;
|
|
|
|
|
static float last_z = -999.99;
|
|
|
|
|
|
|
|
|
|
current_position[E_AXIS] = 0.0;
|
|
|
|
|
sync_plan_position_e();
|
|
|
|
|
bool has_xy_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
|
|
|
|
|
|
|
|
|
|
if (g26_prime_flag && prime_nozzle()) goto LEAVE;
|
|
|
|
|
if (z != last_z) {
|
|
|
|
|
last_z = z;
|
|
|
|
|
feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0); // Base the feed rate off of the configured Z_AXIS feed rate
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Bed is preheated
|
|
|
|
|
*
|
|
|
|
|
* Nozzle is at temperature
|
|
|
|
|
*
|
|
|
|
|
* Filament is primed!
|
|
|
|
|
*
|
|
|
|
|
* It's "Show Time" !!!
|
|
|
|
|
*/
|
|
|
|
|
destination[X_AXIS] = current_position[X_AXIS];
|
|
|
|
|
destination[Y_AXIS] = current_position[Y_AXIS];
|
|
|
|
|
destination[Z_AXIS] = z; // We know the last_z==z or we wouldn't be in this block of code.
|
|
|
|
|
destination[E_AXIS] = current_position[E_AXIS];
|
|
|
|
|
|
|
|
|
|
ZERO(circle_flags);
|
|
|
|
|
ZERO(horizontal_mesh_line_flags);
|
|
|
|
|
ZERO(vertical_mesh_line_flags);
|
|
|
|
|
G26_line_to_destination(feed_value);
|
|
|
|
|
|
|
|
|
|
// Move nozzle to the specified height for the first layer
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
destination[Z_AXIS] = g26_layer_height;
|
|
|
|
|
move_to(destination, 0.0);
|
|
|
|
|
move_to(destination, g26_ooze_amount);
|
|
|
|
|
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
lcd_external_control = true;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//debug_current_and_destination(PSTR("Starting G26 Mesh Validation Pattern."));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Declare and generate a sin() & cos() table to be used during the circle drawing. This will lighten
|
|
|
|
|
* the CPU load and make the arc drawing faster and more smooth
|
|
|
|
|
*/
|
|
|
|
|
float sin_table[360 / 30 + 1], cos_table[360 / 30 + 1];
|
|
|
|
|
for (i = 0; i <= 360 / 30; i++) {
|
|
|
|
|
cos_table[i] = SIZE_OF_INTERSECTION_CIRCLES * cos(RADIANS(valid_trig_angle(i * 30.0)));
|
|
|
|
|
sin_table[i] = SIZE_OF_INTERSECTION_CIRCLES * sin(RADIANS(valid_trig_angle(i * 30.0)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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); // Find the closest Mesh Intersection to where we are now.
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
// Check if X or Y is involved in the movement.
|
|
|
|
|
// Yes: a 'normal' movement. No: a retract() or recover()
|
|
|
|
|
feed_value = has_xy_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.max_feedrate_mm_s[E_AXIS] / 1.5;
|
|
|
|
|
|
|
|
|
|
// If this mesh location is outside the printable_radius, skip it.
|
|
|
|
|
if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
|
|
|
|
|
|
|
|
|
|
if (!position_is_reachable(circle_x, circle_y)) continue;
|
|
|
|
|
destination[X_AXIS] = x;
|
|
|
|
|
destination[Y_AXIS] = y;
|
|
|
|
|
destination[E_AXIS] += e_delta;
|
|
|
|
|
|
|
|
|
|
xi = location.x_index; // Just to shrink the next few lines and make them easier to understand
|
|
|
|
|
yi = location.y_index;
|
|
|
|
|
G26_line_to_destination(feed_value);
|
|
|
|
|
|
|
|
|
|
if (g26_debug_flag) {
|
|
|
|
|
SERIAL_ECHOPAIR(" Doing circle at: (xi=", xi);
|
|
|
|
|
SERIAL_ECHOPAIR(", yi=", yi);
|
|
|
|
|
SERIAL_CHAR(')');
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
start_angle = 0.0; // assume it is going to be a full circle
|
|
|
|
|
end_angle = 360.0;
|
|
|
|
|
if (xi == 0) { // Check for bottom edge
|
|
|
|
|
start_angle = -90.0;
|
|
|
|
|
end_angle = 90.0;
|
|
|
|
|
if (yi == 0) // it is an edge, check for the two left corners
|
|
|
|
|
start_angle = 0.0;
|
|
|
|
|
else if (yi == GRID_MAX_POINTS_Y - 1)
|
|
|
|
|
end_angle = 0.0;
|
|
|
|
|
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) { // Only retract if we are not already retracted!
|
|
|
|
|
g26_retracted = true;
|
|
|
|
|
move_to(where, -1.0 * g26_retraction_multiplier);
|
|
|
|
|
}
|
|
|
|
|
else if (xi == GRID_MAX_POINTS_X - 1) { // Check for top edge
|
|
|
|
|
start_angle = 90.0;
|
|
|
|
|
end_angle = 270.0;
|
|
|
|
|
if (yi == 0) // it is an edge, check for the two right corners
|
|
|
|
|
end_angle = 180.0;
|
|
|
|
|
else if (yi == GRID_MAX_POINTS_Y - 1)
|
|
|
|
|
start_angle = 180.0;
|
|
|
|
|
}
|
|
|
|
|
else if (yi == 0) {
|
|
|
|
|
start_angle = 0.0; // only do the top side of the cirlce
|
|
|
|
|
end_angle = 180.0;
|
|
|
|
|
|
|
|
|
|
void recover_filament(const float where[XYZE]) {
|
|
|
|
|
if (g26_retracted) { // Only un-retract if we are retracted.
|
|
|
|
|
move_to(where, 1.2 * g26_retraction_multiplier);
|
|
|
|
|
g26_retracted = false;
|
|
|
|
|
}
|
|
|
|
|
else if (yi == GRID_MAX_POINTS_Y - 1) {
|
|
|
|
|
start_angle = 180.0; // only do the bottom side of the cirlce
|
|
|
|
|
end_angle = 360.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (tmp = start_angle; tmp < end_angle - 0.1; tmp += 30.0) {
|
|
|
|
|
/**
|
|
|
|
|
* Prime the nozzle if needed. Return true on error.
|
|
|
|
|
*/
|
|
|
|
|
inline bool prime_nozzle() {
|
|
|
|
|
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
if (user_canceled()) goto LEAVE; // Check if the user wants to stop the Mesh Validation
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int tmp_div_30 = tmp / 30.0;
|
|
|
|
|
if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
|
|
|
|
|
if (tmp_div_30 > 11) tmp_div_30 -= 360 / 30;
|
|
|
|
|
|
|
|
|
|
float rx = circle_x + cos_table[tmp_div_30], // for speed, these are now a lookup table entry
|
|
|
|
|
ry = circle_y + sin_table[tmp_div_30],
|
|
|
|
|
xe = circle_x + cos_table[tmp_div_30 + 1],
|
|
|
|
|
ye = circle_y + sin_table[tmp_div_30 + 1];
|
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
|
// Check to make sure this segment is entirely on the bed, skip if not.
|
|
|
|
|
if (!position_is_reachable(rx, ry) || !position_is_reachable(xe, ye)) continue;
|
|
|
|
|
#else // not, we need to skip
|
|
|
|
|
rx = constrain(rx, X_MIN_POS + 1, X_MAX_POS - 1); // This keeps us from bumping the endstops
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
//if (g26_debug_flag) {
|
|
|
|
|
// char ccc, *cptr, seg_msg[50], seg_num[10];
|
|
|
|
|
// strcpy(seg_msg, " segment: ");
|
|
|
|
|
// strcpy(seg_num, " \n");
|
|
|
|
|
// cptr = (char*) "01234567890ABCDEF????????";
|
|
|
|
|
// ccc = cptr[tmp_div_30];
|
|
|
|
|
// seg_num[1] = ccc;
|
|
|
|
|
// strcat(seg_msg, seg_num);
|
|
|
|
|
// debug_current_and_destination(seg_msg);
|
|
|
|
|
//}
|
|
|
|
|
float Total_Prime = 0.0;
|
|
|
|
|
|
|
|
|
|
print_line_from_here_to_there(rx, ry, g26_layer_height, xe, ye, g26_layer_height);
|
|
|
|
|
if (g26_prime_flag == -1) { // The user wants to control how much filament gets purged
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (look_for_lines_to_connect())
|
|
|
|
|
goto LEAVE;
|
|
|
|
|
}
|
|
|
|
|
} while (--g26_repeats && location.x_index >= 0 && location.y_index >= 0);
|
|
|
|
|
lcd_external_control = true;
|
|
|
|
|
lcd_setstatusPGM(PSTR("User-Controlled Prime"), 99);
|
|
|
|
|
lcd_chirp();
|
|
|
|
|
|
|
|
|
|
LEAVE:
|
|
|
|
|
lcd_setstatusPGM(PSTR("Leaving G26"), -1);
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
|
|
|
|
|
retract_filament(destination);
|
|
|
|
|
destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;
|
|
|
|
|
recover_filament(destination); // Make sure G26 doesn't think the filament is retracted().
|
|
|
|
|
|
|
|
|
|
//debug_current_and_destination(PSTR("ready to do Z-Raise."));
|
|
|
|
|
move_to(destination, 0); // Raise the nozzle
|
|
|
|
|
//debug_current_and_destination(PSTR("done doing Z-Raise."));
|
|
|
|
|
while (!is_lcd_clicked()) {
|
|
|
|
|
lcd_chirp();
|
|
|
|
|
destination[E_AXIS] += 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);
|
|
|
|
|
|
|
|
|
|
destination[X_AXIS] = g26_x_pos; // Move back to the starting position
|
|
|
|
|
destination[Y_AXIS] = g26_y_pos;
|
|
|
|
|
//destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Keep the nozzle where it is
|
|
|
|
|
stepper.synchronize(); // Without this synchronize, the purge is more consistent,
|
|
|
|
|
// but because the planner has a buffer, we won't be able
|
|
|
|
|
// to stop as quickly. So we put up with the less smooth
|
|
|
|
|
// action to give the user a more responsive 'Stop'.
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
idle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
move_to(destination, 0); // Move back to the starting position
|
|
|
|
|
//debug_current_and_destination(PSTR("done doing X/Y move."));
|
|
|
|
|
while (is_lcd_clicked()) idle(); // Debounce Encoder Wheel
|
|
|
|
|
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
lcd_external_control = false; // Give back control of the LCD Panel!
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (!g26_keep_heaters_on) {
|
|
|
|
|
#if HAS_TEMP_BED
|
|
|
|
|
thermalManager.setTargetBed(0);
|
|
|
|
|
strcpy_P(lcd_status_message, PSTR("Done Priming")); // We can't do lcd_setstatusPGM() without having it continue;
|
|
|
|
|
// So... We cheat to get a message up.
|
|
|
|
|
lcd_setstatusPGM(PSTR("Done Priming"), 99);
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
lcd_external_control = false;
|
|
|
|
|
#endif
|
|
|
|
|
thermalManager.setTargetHotend(0, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
lcd_setstatusPGM(PSTR("Fixed Length Prime."), 99);
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
#endif
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
destination[E_AXIS] += g26_prime_length;
|
|
|
|
|
G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
retract_filament(destination);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float valid_trig_angle(float d) {
|
|
|
|
|
while (d > 360.0) d -= 360.0;
|
|
|
|
|
while (d < 0.0) d += 360.0;
|
|
|
|
|
return d;
|
|
|
|
|
return G26_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mesh_index_pair find_closest_circle_to_print(const float &X, const float &Y) {
|
|
|
|
@ -448,7 +357,55 @@
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool look_for_lines_to_connect() {
|
|
|
|
|
/**
|
|
|
|
|
* print_line_from_here_to_there() takes two cartesian coordinates and draws a line from one
|
|
|
|
|
* to the other. But there are really three sets of coordinates involved. The first coordinate
|
|
|
|
|
* is the present location of the nozzle. We don't necessarily want to print from this location.
|
|
|
|
|
* We first need to move the nozzle to the start of line segment where we want to print. Once
|
|
|
|
|
* there, we can use the two coordinates supplied to draw the line.
|
|
|
|
|
*
|
|
|
|
|
* Note: Although we assume the first set of coordinates is the start of the line and the second
|
|
|
|
|
* set of coordinates is the end of the line, it does not always work out that way. This function
|
|
|
|
|
* optimizes the movement to minimize the travel distance before it can start printing. This saves
|
|
|
|
|
* a lot of time and eliminates a lot of nonsensical movement of the nozzle. However, it does
|
|
|
|
|
* cause a lot of very little short retracement of th nozzle when it draws the very first line
|
|
|
|
|
* segment of a 'circle'. The time this requires is very short and is easily saved by the other
|
|
|
|
|
* cases where the optimization comes into play.
|
|
|
|
|
*/
|
|
|
|
|
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, // find our distance from the start of the actual line segment
|
|
|
|
|
dy_s = current_position[Y_AXIS] - sy,
|
|
|
|
|
dist_start = HYPOT2(dx_s, dy_s), // We don't need to do a sqrt(), we can compare the distance^2
|
|
|
|
|
// to save computation time
|
|
|
|
|
dx_e = current_position[X_AXIS] - ex, // find our distance from the end of the actual line segment
|
|
|
|
|
dy_e = current_position[Y_AXIS] - ey,
|
|
|
|
|
dist_end = HYPOT2(dx_e, dy_e),
|
|
|
|
|
|
|
|
|
|
line_length = HYPOT(ex - sx, ey - sy);
|
|
|
|
|
|
|
|
|
|
// If the end point of the line is closer to the nozzle, flip the direction,
|
|
|
|
|
// moving from the end to the start. On very small lines the optimization isn't worth it.
|
|
|
|
|
if (dist_end < dist_start && (SIZE_OF_INTERSECTION_CIRCLES) < FABS(line_length))
|
|
|
|
|
return print_line_from_here_to_there(ex, ey, ez, sx, sy, sz);
|
|
|
|
|
|
|
|
|
|
// Decide whether to retract & bump
|
|
|
|
|
|
|
|
|
|
if (dist_start > 2.0) {
|
|
|
|
|
retract_filament(destination);
|
|
|
|
|
//todo: parameterize the bump height with a define
|
|
|
|
|
move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + 0.500, 0.0); // Z bump to minimize scraping
|
|
|
|
|
move_to(sx, sy, sz + 0.500, 0.0); // Get to the starting point with no extrusion while bumped
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion / un-Z bump
|
|
|
|
|
|
|
|
|
|
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); // Get to the ending point with an appropriate amount of extrusion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool look_for_lines_to_connect() {
|
|
|
|
|
float sx, sy, ex, ey;
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
|
|
|
@ -534,132 +491,106 @@
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void move_to(const float &x, const float &y, const float &z, const float &e_delta) {
|
|
|
|
|
float feed_value;
|
|
|
|
|
static float last_z = -999.99;
|
|
|
|
|
|
|
|
|
|
bool has_xy_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
|
|
|
|
|
|
|
|
|
|
if (z != last_z) {
|
|
|
|
|
last_z = z;
|
|
|
|
|
feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0); // Base the feed rate off of the configured Z_AXIS feed rate
|
|
|
|
|
|
|
|
|
|
destination[X_AXIS] = current_position[X_AXIS];
|
|
|
|
|
destination[Y_AXIS] = current_position[Y_AXIS];
|
|
|
|
|
destination[Z_AXIS] = z; // We know the last_z==z or we wouldn't be in this block of code.
|
|
|
|
|
destination[E_AXIS] = current_position[E_AXIS];
|
|
|
|
|
|
|
|
|
|
G26_line_to_destination(feed_value);
|
|
|
|
|
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
float valid_trig_angle(float d) {
|
|
|
|
|
while (d > 360.0) d -= 360.0;
|
|
|
|
|
while (d < 0.0) d += 360.0;
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if X or Y is involved in the movement.
|
|
|
|
|
// Yes: a 'normal' movement. No: a retract() or recover()
|
|
|
|
|
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] = x;
|
|
|
|
|
destination[Y_AXIS] = y;
|
|
|
|
|
destination[E_AXIS] += e_delta;
|
|
|
|
|
|
|
|
|
|
G26_line_to_destination(feed_value);
|
|
|
|
|
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
/**
|
|
|
|
|
* Turn on the bed and nozzle heat and
|
|
|
|
|
* wait for them to get up to temperature.
|
|
|
|
|
*/
|
|
|
|
|
bool turn_on_heaters() {
|
|
|
|
|
millis_t next = millis() + 5000UL;
|
|
|
|
|
#if HAS_TEMP_BED
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
if (g26_bed_temp > 25) {
|
|
|
|
|
lcd_setstatusPGM(PSTR("G26 Heating Bed."), 99);
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
lcd_external_control = true;
|
|
|
|
|
#endif
|
|
|
|
|
thermalManager.setTargetBed(g26_bed_temp);
|
|
|
|
|
while (abs(thermalManager.degBed() - g26_bed_temp) > 3) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
if (is_lcd_clicked()) return exit_from_g26();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void retract_filament(const float where[XYZE]) {
|
|
|
|
|
if (!g26_retracted) { // Only retract if we are not already retracted!
|
|
|
|
|
g26_retracted = true;
|
|
|
|
|
move_to(where, -1.0 * g26_retraction_multiplier);
|
|
|
|
|
}
|
|
|
|
|
if (ELAPSED(millis(), next)) {
|
|
|
|
|
next = millis() + 5000UL;
|
|
|
|
|
print_heaterstates();
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void recover_filament(const float where[XYZE]) {
|
|
|
|
|
if (g26_retracted) { // Only un-retract if we are retracted.
|
|
|
|
|
move_to(where, 1.2 * g26_retraction_multiplier);
|
|
|
|
|
g26_retracted = false;
|
|
|
|
|
idle();
|
|
|
|
|
}
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
}
|
|
|
|
|
lcd_setstatusPGM(PSTR("G26 Heating Nozzle."), 99);
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* print_line_from_here_to_there() takes two cartesian coordinates and draws a line from one
|
|
|
|
|
* to the other. But there are really three sets of coordinates involved. The first coordinate
|
|
|
|
|
* is the present location of the nozzle. We don't necessarily want to print from this location.
|
|
|
|
|
* We first need to move the nozzle to the start of line segment where we want to print. Once
|
|
|
|
|
* there, we can use the two coordinates supplied to draw the line.
|
|
|
|
|
*
|
|
|
|
|
* Note: Although we assume the first set of coordinates is the start of the line and the second
|
|
|
|
|
* set of coordinates is the end of the line, it does not always work out that way. This function
|
|
|
|
|
* optimizes the movement to minimize the travel distance before it can start printing. This saves
|
|
|
|
|
* a lot of time and eliminates a lot of nonsensical movement of the nozzle. However, it does
|
|
|
|
|
* cause a lot of very little short retracement of th nozzle when it draws the very first line
|
|
|
|
|
* segment of a 'circle'. The time this requires is very short and is easily saved by the other
|
|
|
|
|
* cases where the optimization comes into play.
|
|
|
|
|
*/
|
|
|
|
|
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, // find our distance from the start of the actual line segment
|
|
|
|
|
dy_s = current_position[Y_AXIS] - sy,
|
|
|
|
|
dist_start = HYPOT2(dx_s, dy_s), // We don't need to do a sqrt(), we can compare the distance^2
|
|
|
|
|
// to save computation time
|
|
|
|
|
dx_e = current_position[X_AXIS] - ex, // find our distance from the end of the actual line segment
|
|
|
|
|
dy_e = current_position[Y_AXIS] - ey,
|
|
|
|
|
dist_end = HYPOT2(dx_e, dy_e),
|
|
|
|
|
|
|
|
|
|
line_length = HYPOT(ex - sx, ey - sy);
|
|
|
|
|
|
|
|
|
|
// If the end point of the line is closer to the nozzle, flip the direction,
|
|
|
|
|
// moving from the end to the start. On very small lines the optimization isn't worth it.
|
|
|
|
|
if (dist_end < dist_start && (SIZE_OF_INTERSECTION_CIRCLES) < FABS(line_length))
|
|
|
|
|
return print_line_from_here_to_there(ex, ey, ez, sx, sy, sz);
|
|
|
|
|
// Start heating the nozzle and wait for it to reach temperature.
|
|
|
|
|
thermalManager.setTargetHotend(g26_hotend_temp, 0);
|
|
|
|
|
while (abs(thermalManager.degHotend(0) - g26_hotend_temp) > 3) {
|
|
|
|
|
|
|
|
|
|
// Decide whether to retract & bump
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
if (is_lcd_clicked()) return exit_from_g26();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (dist_start > 2.0) {
|
|
|
|
|
retract_filament(destination);
|
|
|
|
|
//todo: parameterize the bump height with a define
|
|
|
|
|
move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + 0.500, 0.0); // Z bump to minimize scraping
|
|
|
|
|
move_to(sx, sy, sz + 0.500, 0.0); // Get to the starting point with no extrusion while bumped
|
|
|
|
|
if (ELAPSED(millis(), next)) {
|
|
|
|
|
next = millis() + 5000UL;
|
|
|
|
|
print_heaterstates();
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
}
|
|
|
|
|
idle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion / un-Z bump
|
|
|
|
|
|
|
|
|
|
const float e_pos_delta = line_length * g26_e_axis_feedrate * g26_extrusion_multiplier;
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
lcd_reset_status();
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
recover_filament(destination);
|
|
|
|
|
move_to(ex, ey, ez, e_pos_delta); // Get to the ending point with an appropriate amount of extrusion
|
|
|
|
|
return G26_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This function used to be inline code in G26. But there are so many
|
|
|
|
|
* parameters it made sense to turn them into static globals and get
|
|
|
|
|
* this code out of sight of the main routine.
|
|
|
|
|
* G26: Mesh Validation Pattern generation.
|
|
|
|
|
*
|
|
|
|
|
* Used to interactively edit UBL's Mesh by placing the
|
|
|
|
|
* nozzle in a problem area and doing a G29 P4 R command.
|
|
|
|
|
*/
|
|
|
|
|
bool parse_G26_parameters() {
|
|
|
|
|
void gcode_G26() {
|
|
|
|
|
SERIAL_ECHOLNPGM("G26 command started. Waiting for heater(s).");
|
|
|
|
|
float tmp, start_angle, end_angle;
|
|
|
|
|
int i, xi, yi;
|
|
|
|
|
mesh_index_pair location;
|
|
|
|
|
|
|
|
|
|
// Don't allow Mesh Validation without homing first,
|
|
|
|
|
// or if the parameter parsing did not go OK, abort
|
|
|
|
|
if (axis_unhomed_error()) return;
|
|
|
|
|
|
|
|
|
|
g26_extrusion_multiplier = EXTRUSION_MULTIPLIER;
|
|
|
|
|
g26_retraction_multiplier = RETRACTION_MULTIPLIER;
|
|
|
|
|
g26_nozzle = MESH_TEST_NOZZLE_SIZE;
|
|
|
|
|
g26_filament_diameter = DEFAULT_NOMINAL_FILAMENT_DIA;
|
|
|
|
|
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');
|
|
|
|
|
g26_continue_with_closest = parser.boolval('C');
|
|
|
|
|
|
|
|
|
|
if (parser.seenval('B')) {
|
|
|
|
|
g26_bed_temp = parser.value_celsius();
|
|
|
|
|
if (!WITHIN(g26_bed_temp, 15, 140)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible.");
|
|
|
|
|
return G26_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -667,7 +598,7 @@
|
|
|
|
|
g26_layer_height = parser.value_linear_units();
|
|
|
|
|
if (!WITHIN(g26_layer_height, 0.0, 2.0)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible.");
|
|
|
|
|
return G26_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -676,12 +607,12 @@
|
|
|
|
|
g26_retraction_multiplier = parser.value_float();
|
|
|
|
|
if (!WITHIN(g26_retraction_multiplier, 0.05, 15.0)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Specified Retraction Multiplier not plausible.");
|
|
|
|
|
return G26_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Retraction Multiplier must be specified.");
|
|
|
|
|
return G26_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -689,7 +620,7 @@
|
|
|
|
|
g26_nozzle = parser.value_float();
|
|
|
|
|
if (!WITHIN(g26_nozzle, 0.1, 1.0)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Specified nozzle size not plausible.");
|
|
|
|
|
return G26_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -699,7 +630,7 @@
|
|
|
|
|
g26_prime_flag = -1;
|
|
|
|
|
#else
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Prime length must be specified when not using an LCD.");
|
|
|
|
|
return G26_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -707,7 +638,7 @@
|
|
|
|
|
g26_prime_length = parser.value_linear_units();
|
|
|
|
|
if (!WITHIN(g26_prime_length, 0.0, 25.0)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Specified prime length not plausible.");
|
|
|
|
|
return G26_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -716,7 +647,7 @@
|
|
|
|
|
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_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g26_extrusion_multiplier *= sq(1.75) / sq(g26_filament_diameter); // If we aren't using 1.75mm filament, we need to
|
|
|
|
@ -729,7 +660,7 @@
|
|
|
|
|
g26_hotend_temp = parser.value_celsius();
|
|
|
|
|
if (!WITHIN(g26_hotend_temp, 165, 280)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible.");
|
|
|
|
|
return G26_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -739,26 +670,27 @@
|
|
|
|
|
random_deviation = parser.has_value() ? parser.value_float() : 50.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int16_t g26_repeats;
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
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 G26_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
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_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 G26_ERROR;
|
|
|
|
|
return G26_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -766,137 +698,175 @@
|
|
|
|
|
*/
|
|
|
|
|
set_bed_leveling_enabled(!parser.seen('D'));
|
|
|
|
|
|
|
|
|
|
return G26_OK;
|
|
|
|
|
if (current_position[Z_AXIS] < Z_CLEARANCE_BETWEEN_PROBES) {
|
|
|
|
|
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
set_current_from_destination();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
bool exit_from_g26() {
|
|
|
|
|
lcd_setstatusPGM(PSTR("Leaving G26"), -1);
|
|
|
|
|
while (ubl_lcd_clicked()) idle();
|
|
|
|
|
return G26_ERROR;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
if (turn_on_heaters()) goto LEAVE;
|
|
|
|
|
|
|
|
|
|
current_position[E_AXIS] = 0.0;
|
|
|
|
|
sync_plan_position_e();
|
|
|
|
|
|
|
|
|
|
if (g26_prime_flag && prime_nozzle()) goto LEAVE;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Turn on the bed and nozzle heat and
|
|
|
|
|
* wait for them to get up to temperature.
|
|
|
|
|
* Bed is preheated
|
|
|
|
|
*
|
|
|
|
|
* Nozzle is at temperature
|
|
|
|
|
*
|
|
|
|
|
* Filament is primed!
|
|
|
|
|
*
|
|
|
|
|
* It's "Show Time" !!!
|
|
|
|
|
*/
|
|
|
|
|
bool turn_on_heaters() {
|
|
|
|
|
millis_t next = millis() + 5000UL;
|
|
|
|
|
#if HAS_TEMP_BED
|
|
|
|
|
|
|
|
|
|
ZERO(circle_flags);
|
|
|
|
|
ZERO(horizontal_mesh_line_flags);
|
|
|
|
|
ZERO(vertical_mesh_line_flags);
|
|
|
|
|
|
|
|
|
|
// Move nozzle to the specified height for the first layer
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
destination[Z_AXIS] = g26_layer_height;
|
|
|
|
|
move_to(destination, 0.0);
|
|
|
|
|
move_to(destination, g26_ooze_amount);
|
|
|
|
|
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
if (g26_bed_temp > 25) {
|
|
|
|
|
lcd_setstatusPGM(PSTR("G26 Heating Bed."), 99);
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
lcd_external_control = true;
|
|
|
|
|
#endif
|
|
|
|
|
thermalManager.setTargetBed(g26_bed_temp);
|
|
|
|
|
while (abs(thermalManager.degBed() - g26_bed_temp) > 3) {
|
|
|
|
|
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
if (ubl_lcd_clicked()) return exit_from_g26();
|
|
|
|
|
#endif
|
|
|
|
|
//debug_current_and_destination(PSTR("Starting G26 Mesh Validation Pattern."));
|
|
|
|
|
|
|
|
|
|
if (ELAPSED(millis(), next)) {
|
|
|
|
|
next = millis() + 5000UL;
|
|
|
|
|
print_heaterstates();
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
}
|
|
|
|
|
idle();
|
|
|
|
|
}
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
/**
|
|
|
|
|
* Declare and generate a sin() & cos() table to be used during the circle drawing. This will lighten
|
|
|
|
|
* the CPU load and make the arc drawing faster and more smooth
|
|
|
|
|
*/
|
|
|
|
|
float sin_table[360 / 30 + 1], cos_table[360 / 30 + 1];
|
|
|
|
|
for (i = 0; i <= 360 / 30; i++) {
|
|
|
|
|
cos_table[i] = SIZE_OF_INTERSECTION_CIRCLES * cos(RADIANS(valid_trig_angle(i * 30.0)));
|
|
|
|
|
sin_table[i] = SIZE_OF_INTERSECTION_CIRCLES * sin(RADIANS(valid_trig_angle(i * 30.0)));
|
|
|
|
|
}
|
|
|
|
|
lcd_setstatusPGM(PSTR("G26 Heating Nozzle."), 99);
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Start heating the nozzle and wait for it to reach temperature.
|
|
|
|
|
thermalManager.setTargetHotend(g26_hotend_temp, 0);
|
|
|
|
|
while (abs(thermalManager.degHotend(0) - g26_hotend_temp) > 3) {
|
|
|
|
|
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); // Find the closest Mesh Intersection to where we are now.
|
|
|
|
|
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
if (ubl_lcd_clicked()) return exit_from_g26();
|
|
|
|
|
#endif
|
|
|
|
|
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 (ELAPSED(millis(), next)) {
|
|
|
|
|
next = millis() + 5000UL;
|
|
|
|
|
print_heaterstates();
|
|
|
|
|
// If this mesh location is outside the printable_radius, skip it.
|
|
|
|
|
|
|
|
|
|
if (!position_is_reachable(circle_x, circle_y)) continue;
|
|
|
|
|
|
|
|
|
|
xi = location.x_index; // Just to shrink the next few lines and make them easier to understand
|
|
|
|
|
yi = location.y_index;
|
|
|
|
|
|
|
|
|
|
if (g26_debug_flag) {
|
|
|
|
|
SERIAL_ECHOPAIR(" Doing circle at: (xi=", xi);
|
|
|
|
|
SERIAL_ECHOPAIR(", yi=", yi);
|
|
|
|
|
SERIAL_CHAR(')');
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
}
|
|
|
|
|
idle();
|
|
|
|
|
|
|
|
|
|
start_angle = 0.0; // assume it is going to be a full circle
|
|
|
|
|
end_angle = 360.0;
|
|
|
|
|
if (xi == 0) { // Check for bottom edge
|
|
|
|
|
start_angle = -90.0;
|
|
|
|
|
end_angle = 90.0;
|
|
|
|
|
if (yi == 0) // it is an edge, check for the two left corners
|
|
|
|
|
start_angle = 0.0;
|
|
|
|
|
else if (yi == GRID_MAX_POINTS_Y - 1)
|
|
|
|
|
end_angle = 0.0;
|
|
|
|
|
}
|
|
|
|
|
else if (xi == GRID_MAX_POINTS_X - 1) { // Check for top edge
|
|
|
|
|
start_angle = 90.0;
|
|
|
|
|
end_angle = 270.0;
|
|
|
|
|
if (yi == 0) // it is an edge, check for the two right corners
|
|
|
|
|
end_angle = 180.0;
|
|
|
|
|
else if (yi == GRID_MAX_POINTS_Y - 1)
|
|
|
|
|
start_angle = 180.0;
|
|
|
|
|
}
|
|
|
|
|
else if (yi == 0) {
|
|
|
|
|
start_angle = 0.0; // only do the top side of the cirlce
|
|
|
|
|
end_angle = 180.0;
|
|
|
|
|
}
|
|
|
|
|
else if (yi == GRID_MAX_POINTS_Y - 1) {
|
|
|
|
|
start_angle = 180.0; // only do the bottom side of the cirlce
|
|
|
|
|
end_angle = 360.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
lcd_reset_status();
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
for (tmp = start_angle; tmp < end_angle - 0.1; tmp += 30.0) {
|
|
|
|
|
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
if (user_canceled()) goto LEAVE; // Check if the user wants to stop the Mesh Validation
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return G26_OK;
|
|
|
|
|
}
|
|
|
|
|
int tmp_div_30 = tmp / 30.0;
|
|
|
|
|
if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
|
|
|
|
|
if (tmp_div_30 > 11) tmp_div_30 -= 360 / 30;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prime the nozzle if needed. Return true on error.
|
|
|
|
|
*/
|
|
|
|
|
bool prime_nozzle() {
|
|
|
|
|
float rx = circle_x + cos_table[tmp_div_30], // for speed, these are now a lookup table entry
|
|
|
|
|
ry = circle_y + sin_table[tmp_div_30],
|
|
|
|
|
xe = circle_x + cos_table[tmp_div_30 + 1],
|
|
|
|
|
ye = circle_y + sin_table[tmp_div_30 + 1];
|
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
|
// Check to make sure this segment is entirely on the bed, skip if not.
|
|
|
|
|
if (!position_is_reachable(rx, ry) || !position_is_reachable(xe, ye)) continue;
|
|
|
|
|
#else // not, we need to skip
|
|
|
|
|
rx = constrain(rx, X_MIN_POS + 1, X_MAX_POS - 1); // This keeps us from bumping the endstops
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
float Total_Prime = 0.0;
|
|
|
|
|
//if (g26_debug_flag) {
|
|
|
|
|
// char ccc, *cptr, seg_msg[50], seg_num[10];
|
|
|
|
|
// strcpy(seg_msg, " segment: ");
|
|
|
|
|
// strcpy(seg_num, " \n");
|
|
|
|
|
// cptr = (char*) "01234567890ABCDEF????????";
|
|
|
|
|
// ccc = cptr[tmp_div_30];
|
|
|
|
|
// seg_num[1] = ccc;
|
|
|
|
|
// strcat(seg_msg, seg_num);
|
|
|
|
|
// debug_current_and_destination(seg_msg);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
if (g26_prime_flag == -1) { // The user wants to control how much filament gets purged
|
|
|
|
|
print_line_from_here_to_there(rx, ry, g26_layer_height, xe, ye, g26_layer_height);
|
|
|
|
|
|
|
|
|
|
lcd_external_control = true;
|
|
|
|
|
lcd_setstatusPGM(PSTR("User-Controlled Prime"), 99);
|
|
|
|
|
chirp_at_user();
|
|
|
|
|
}
|
|
|
|
|
if (look_for_lines_to_connect())
|
|
|
|
|
goto LEAVE;
|
|
|
|
|
}
|
|
|
|
|
} while (--g26_repeats && location.x_index >= 0 && location.y_index >= 0);
|
|
|
|
|
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
LEAVE:
|
|
|
|
|
lcd_setstatusPGM(PSTR("Leaving G26"), -1);
|
|
|
|
|
|
|
|
|
|
recover_filament(destination); // Make sure G26 doesn't think the filament is retracted().
|
|
|
|
|
retract_filament(destination);
|
|
|
|
|
destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;
|
|
|
|
|
|
|
|
|
|
while (!ubl_lcd_clicked()) {
|
|
|
|
|
chirp_at_user();
|
|
|
|
|
destination[E_AXIS] += 0.25;
|
|
|
|
|
#ifdef PREVENT_LENGTHY_EXTRUDE
|
|
|
|
|
Total_Prime += 0.25;
|
|
|
|
|
if (Total_Prime >= EXTRUDE_MAXLENGTH) return G26_ERROR;
|
|
|
|
|
#endif
|
|
|
|
|
G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
|
|
|
|
|
//debug_current_and_destination(PSTR("ready to do Z-Raise."));
|
|
|
|
|
move_to(destination, 0); // Raise the nozzle
|
|
|
|
|
//debug_current_and_destination(PSTR("done doing Z-Raise."));
|
|
|
|
|
|
|
|
|
|
stepper.synchronize(); // Without this synchronize, the purge is more consistent,
|
|
|
|
|
// but because the planner has a buffer, we won't be able
|
|
|
|
|
// to stop as quickly. So we put up with the less smooth
|
|
|
|
|
// action to give the user a more responsive 'Stop'.
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
idle();
|
|
|
|
|
}
|
|
|
|
|
destination[X_AXIS] = g26_x_pos; // Move back to the starting position
|
|
|
|
|
destination[Y_AXIS] = g26_y_pos;
|
|
|
|
|
//destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Keep the nozzle where it is
|
|
|
|
|
|
|
|
|
|
while (ubl_lcd_clicked()) idle(); // Debounce Encoder Wheel
|
|
|
|
|
move_to(destination, 0); // Move back to the starting position
|
|
|
|
|
//debug_current_and_destination(PSTR("done doing X/Y move."));
|
|
|
|
|
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
strcpy_P(lcd_status_message, PSTR("Done Priming")); // We can't do lcd_setstatusPGM() without having it continue;
|
|
|
|
|
// So... We cheat to get a message up.
|
|
|
|
|
lcd_setstatusPGM(PSTR("Done Priming"), 99);
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
lcd_external_control = false;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
lcd_external_control = false; // Give back control of the LCD Panel!
|
|
|
|
|
#endif
|
|
|
|
|
#if ENABLED(ULTRA_LCD)
|
|
|
|
|
lcd_setstatusPGM(PSTR("Fixed Length Prime."), 99);
|
|
|
|
|
lcd_quick_feedback();
|
|
|
|
|
|
|
|
|
|
if (!g26_keep_heaters_on) {
|
|
|
|
|
#if HAS_TEMP_BED
|
|
|
|
|
thermalManager.setTargetBed(0);
|
|
|
|
|
#endif
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
destination[E_AXIS] += g26_prime_length;
|
|
|
|
|
G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
|
|
|
|
|
stepper.synchronize();
|
|
|
|
|
set_destination_from_current();
|
|
|
|
|
retract_filament(destination);
|
|
|
|
|
thermalManager.setTargetHotend(0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return G26_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // G26_MESH_VALIDATION
|
|
|
|
|