|
@@ -135,64 +135,78 @@
|
135
|
135
|
float code_value_axis_units(const AxisEnum axis);
|
136
|
136
|
bool code_value_bool();
|
137
|
137
|
bool code_has_value();
|
138
|
|
- void lcd_init();
|
139
|
|
- void lcd_setstatuspgm(const char* const message, const uint8_t level);
|
140
|
138
|
void sync_plan_position_e();
|
141
|
139
|
void chirp_at_user();
|
142
|
140
|
|
143
|
141
|
// Private functions
|
144
|
142
|
|
145
|
|
- void un_retract_filament(float where[XYZE]);
|
146
|
|
- void retract_filament(float where[XYZE]);
|
147
|
|
- bool look_for_lines_to_connect();
|
148
|
|
- bool parse_G26_parameters();
|
149
|
|
- void move_to(const float&, const float&, const float&, const float&) ;
|
150
|
|
- void print_line_from_here_to_there(const float&, const float&, const float&, const float&, const float&, const float&);
|
151
|
|
- bool turn_on_heaters();
|
152
|
|
- bool prime_nozzle();
|
153
|
|
-
|
154
|
143
|
static uint16_t circle_flags[16], horizontal_mesh_line_flags[16], vertical_mesh_line_flags[16];
|
155
|
144
|
float g26_e_axis_feedrate = 0.020,
|
156
|
|
- random_deviation = 0.0,
|
157
|
|
- layer_height = LAYER_HEIGHT;
|
|
145
|
+ random_deviation = 0.0;
|
158
|
146
|
|
159
|
147
|
static bool g26_retracted = false; // Track the retracted state of the nozzle so mismatched
|
160
|
148
|
// retracts/recovers won't result in a bad state.
|
161
|
149
|
|
162
|
150
|
float valid_trig_angle(float);
|
163
|
|
- mesh_index_pair find_closest_circle_to_print(const float&, const float&);
|
164
|
151
|
|
165
|
|
- static float extrusion_multiplier = EXTRUSION_MULTIPLIER,
|
166
|
|
- retraction_multiplier = RETRACTION_MULTIPLIER,
|
167
|
|
- nozzle = NOZZLE,
|
168
|
|
- filament_diameter = FILAMENT,
|
169
|
|
- prime_length = PRIME_LENGTH,
|
170
|
|
- x_pos, y_pos,
|
171
|
|
- ooze_amount = OOZE_AMOUNT;
|
|
152
|
+ float unified_bed_leveling::g26_extrusion_multiplier,
|
|
153
|
+ unified_bed_leveling::g26_retraction_multiplier,
|
|
154
|
+ unified_bed_leveling::g26_nozzle,
|
|
155
|
+ unified_bed_leveling::g26_filament_diameter,
|
|
156
|
+ unified_bed_leveling::g26_layer_height,
|
|
157
|
+ unified_bed_leveling::g26_prime_length,
|
|
158
|
+ unified_bed_leveling::g26_x_pos,
|
|
159
|
+ unified_bed_leveling::g26_y_pos,
|
|
160
|
+ unified_bed_leveling::g26_ooze_amount;
|
172
|
161
|
|
173
|
|
- static int16_t bed_temp = BED_TEMP,
|
174
|
|
- hotend_temp = HOTEND_TEMP;
|
|
162
|
+ int16_t unified_bed_leveling::g26_bed_temp,
|
|
163
|
+ unified_bed_leveling::g26_hotend_temp;
|
175
|
164
|
|
176
|
|
- static int8_t prime_flag = 0;
|
|
165
|
+ int8_t unified_bed_leveling::g26_prime_flag;
|
177
|
166
|
|
178
|
|
- static bool continue_with_closest, keep_heaters_on;
|
|
167
|
+ bool unified_bed_leveling::g26_continue_with_closest,
|
|
168
|
+ unified_bed_leveling::g26_keep_heaters_on;
|
179
|
169
|
|
180
|
|
- static int16_t g26_repeats;
|
|
170
|
+ int16_t unified_bed_leveling::g26_repeats;
|
181
|
171
|
|
182
|
|
- void G26_line_to_destination(const float &feed_rate) {
|
|
172
|
+ void unified_bed_leveling::G26_line_to_destination(const float &feed_rate) {
|
183
|
173
|
const float save_feedrate = feedrate_mm_s;
|
184
|
174
|
feedrate_mm_s = feed_rate; // use specified feed rate
|
185
|
|
- prepare_move_to_destination(); // will ultimately call ubl_line_to_destination_cartesian or ubl_prepare_linear_move_to for UBL_DELTA
|
|
175
|
+ prepare_move_to_destination(); // will ultimately call ubl.line_to_destination_cartesian or ubl.prepare_linear_move_to for UBL_DELTA
|
186
|
176
|
feedrate_mm_s = save_feedrate; // restore global feed rate
|
187
|
177
|
}
|
188
|
178
|
|
189
|
179
|
/**
|
|
180
|
+ * Detect ubl_lcd_clicked, debounce it, and return true for cancel
|
|
181
|
+ */
|
|
182
|
+ bool user_canceled() {
|
|
183
|
+ if (!ubl_lcd_clicked()) return false;
|
|
184
|
+ safe_delay(10); // Wait for click to settle
|
|
185
|
+
|
|
186
|
+ #if ENABLED(ULTRA_LCD)
|
|
187
|
+ lcd_setstatuspgm(PSTR("Mesh Validation Stopped."), 99);
|
|
188
|
+ lcd_quick_feedback();
|
|
189
|
+ #endif
|
|
190
|
+ lcd_reset_alert_level();
|
|
191
|
+
|
|
192
|
+ while (!ubl_lcd_clicked()) idle(); // Wait for button release
|
|
193
|
+
|
|
194
|
+ // If the button is suddenly pressed again,
|
|
195
|
+ // ask the user to resolve the issue
|
|
196
|
+ lcd_setstatuspgm(PSTR("Release button"), 99); // will never appear...
|
|
197
|
+ while (ubl_lcd_clicked()) idle(); // unless this loop happens
|
|
198
|
+ lcd_setstatuspgm(PSTR(""));
|
|
199
|
+
|
|
200
|
+ return true;
|
|
201
|
+ }
|
|
202
|
+
|
|
203
|
+ /**
|
190
|
204
|
* G26: Mesh Validation Pattern generation.
|
191
|
205
|
*
|
192
|
206
|
* Used to interactively edit UBL's Mesh by placing the
|
193
|
207
|
* nozzle in a problem area and doing a G29 P4 R command.
|
194
|
208
|
*/
|
195
|
|
- void gcode_G26() {
|
|
209
|
+ void unified_bed_leveling::G26() {
|
196
|
210
|
SERIAL_ECHOLNPGM("G26 command started. Waiting for heater(s).");
|
197
|
211
|
float tmp, start_angle, end_angle;
|
198
|
212
|
int i, xi, yi;
|
|
@@ -213,7 +227,7 @@
|
213
|
227
|
current_position[E_AXIS] = 0.0;
|
214
|
228
|
sync_plan_position_e();
|
215
|
229
|
|
216
|
|
- if (prime_flag && prime_nozzle()) goto LEAVE;
|
|
230
|
+ if (g26_prime_flag && prime_nozzle()) goto LEAVE;
|
217
|
231
|
|
218
|
232
|
/**
|
219
|
233
|
* Bed is preheated
|
|
@@ -231,11 +245,11 @@
|
231
|
245
|
|
232
|
246
|
// Move nozzle to the specified height for the first layer
|
233
|
247
|
set_destination_to_current();
|
234
|
|
- destination[Z_AXIS] = layer_height;
|
|
248
|
+ destination[Z_AXIS] = g26_layer_height;
|
235
|
249
|
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0.0);
|
236
|
|
- move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount);
|
|
250
|
+ move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], g26_ooze_amount);
|
237
|
251
|
|
238
|
|
- ubl.has_control_of_lcd_panel = true;
|
|
252
|
+ has_control_of_lcd_panel = true;
|
239
|
253
|
//debug_current_and_destination(PSTR("Starting G26 Mesh Validation Pattern."));
|
240
|
254
|
|
241
|
255
|
/**
|
|
@@ -249,13 +263,13 @@
|
249
|
263
|
}
|
250
|
264
|
|
251
|
265
|
do {
|
252
|
|
- location = continue_with_closest
|
|
266
|
+ location = g26_continue_with_closest
|
253
|
267
|
? find_closest_circle_to_print(current_position[X_AXIS], current_position[Y_AXIS])
|
254
|
|
- : find_closest_circle_to_print(x_pos, y_pos); // Find the closest Mesh Intersection to where we are now.
|
|
268
|
+ : find_closest_circle_to_print(g26_x_pos, g26_y_pos); // Find the closest Mesh Intersection to where we are now.
|
255
|
269
|
|
256
|
270
|
if (location.x_index >= 0 && location.y_index >= 0) {
|
257
|
|
- const float circle_x = pgm_read_float(&ubl.mesh_index_to_xpos[location.x_index]),
|
258
|
|
- circle_y = pgm_read_float(&ubl.mesh_index_to_ypos[location.y_index]);
|
|
271
|
+ const float circle_x = mesh_index_to_xpos(location.x_index),
|
|
272
|
+ circle_y = mesh_index_to_ypos(location.y_index);
|
259
|
273
|
|
260
|
274
|
// If this mesh location is outside the printable_radius, skip it.
|
261
|
275
|
|
|
@@ -264,7 +278,7 @@
|
264
|
278
|
xi = location.x_index; // Just to shrink the next few lines and make them easier to understand
|
265
|
279
|
yi = location.y_index;
|
266
|
280
|
|
267
|
|
- if (ubl.g26_debug_flag) {
|
|
281
|
+ if (g26_debug_flag) {
|
268
|
282
|
SERIAL_ECHOPAIR(" Doing circle at: (xi=", xi);
|
269
|
283
|
SERIAL_ECHOPAIR(", yi=", yi);
|
270
|
284
|
SERIAL_CHAR(')');
|
|
@@ -300,25 +314,7 @@
|
300
|
314
|
|
301
|
315
|
for (tmp = start_angle; tmp < end_angle - 0.1; tmp += 30.0) {
|
302
|
316
|
|
303
|
|
- // this sequence to detect an ubl_lcd_clicked() debounce it and leave if it is
|
304
|
|
- // a Press and Hold is repeated in a lot of places (including ubl_G29.cpp). This
|
305
|
|
- // should be redone and compressed.
|
306
|
|
- if (ubl_lcd_clicked()) { // Check if the user wants to stop the Mesh Validation
|
307
|
|
- #if ENABLED(ULTRA_LCD)
|
308
|
|
- lcd_setstatuspgm(PSTR("Mesh Validation Stopped."), 99);
|
309
|
|
- lcd_quick_feedback();
|
310
|
|
- #endif
|
311
|
|
- while (!ubl_lcd_clicked()) { // Wait until the user is done pressing the
|
312
|
|
- idle(); // Encoder Wheel if that is why we are leaving
|
313
|
|
- lcd_reset_alert_level();
|
314
|
|
- lcd_setstatuspgm(PSTR(""));
|
315
|
|
- }
|
316
|
|
- while (ubl_lcd_clicked()) { // Wait until the user is done pressing the
|
317
|
|
- idle(); // Encoder Wheel if that is why we are leaving
|
318
|
|
- lcd_setstatuspgm(PSTR("Unpress Wheel"), 99);
|
319
|
|
- }
|
320
|
|
- goto LEAVE;
|
321
|
|
- }
|
|
317
|
+ if (user_canceled()) goto LEAVE; // Check if the user wants to stop the Mesh Validation
|
322
|
318
|
|
323
|
319
|
int tmp_div_30 = tmp / 30.0;
|
324
|
320
|
if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
|
|
@@ -338,7 +334,7 @@
|
338
|
334
|
ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
|
339
|
335
|
#endif
|
340
|
336
|
|
341
|
|
- //if (ubl.g26_debug_flag) {
|
|
337
|
+ //if (g26_debug_flag) {
|
342
|
338
|
// char ccc, *cptr, seg_msg[50], seg_num[10];
|
343
|
339
|
// strcpy(seg_msg, " segment: ");
|
344
|
340
|
// strcpy(seg_num, " \n");
|
|
@@ -349,7 +345,7 @@
|
349
|
345
|
// debug_current_and_destination(seg_msg);
|
350
|
346
|
//}
|
351
|
347
|
|
352
|
|
- print_line_from_here_to_there(LOGICAL_X_POSITION(x), LOGICAL_Y_POSITION(y), layer_height, LOGICAL_X_POSITION(xe), LOGICAL_Y_POSITION(ye), layer_height);
|
|
348
|
+ print_line_from_here_to_there(LOGICAL_X_POSITION(x), LOGICAL_Y_POSITION(y), g26_layer_height, LOGICAL_X_POSITION(xe), LOGICAL_Y_POSITION(ye), g26_layer_height);
|
353
|
349
|
|
354
|
350
|
}
|
355
|
351
|
if (look_for_lines_to_connect())
|
|
@@ -368,16 +364,16 @@
|
368
|
364
|
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Raise the nozzle
|
369
|
365
|
//debug_current_and_destination(PSTR("done doing Z-Raise."));
|
370
|
366
|
|
371
|
|
- destination[X_AXIS] = x_pos; // Move back to the starting position
|
372
|
|
- destination[Y_AXIS] = y_pos;
|
|
367
|
+ destination[X_AXIS] = g26_x_pos; // Move back to the starting position
|
|
368
|
+ destination[Y_AXIS] = g26_y_pos;
|
373
|
369
|
//destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Keep the nozzle where it is
|
374
|
370
|
|
375
|
371
|
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Move back to the starting position
|
376
|
372
|
//debug_current_and_destination(PSTR("done doing X/Y move."));
|
377
|
373
|
|
378
|
|
- ubl.has_control_of_lcd_panel = false; // Give back control of the LCD Panel!
|
|
374
|
+ has_control_of_lcd_panel = false; // Give back control of the LCD Panel!
|
379
|
375
|
|
380
|
|
- if (!keep_heaters_on) {
|
|
376
|
+ if (!g26_keep_heaters_on) {
|
381
|
377
|
#if HAS_TEMP_BED
|
382
|
378
|
thermalManager.setTargetBed(0);
|
383
|
379
|
#endif
|
|
@@ -385,14 +381,13 @@
|
385
|
381
|
}
|
386
|
382
|
}
|
387
|
383
|
|
388
|
|
-
|
389
|
384
|
float valid_trig_angle(float d) {
|
390
|
385
|
while (d > 360.0) d -= 360.0;
|
391
|
386
|
while (d < 0.0) d += 360.0;
|
392
|
387
|
return d;
|
393
|
388
|
}
|
394
|
389
|
|
395
|
|
- mesh_index_pair find_closest_circle_to_print(const float &X, const float &Y) {
|
|
390
|
+ mesh_index_pair unified_bed_leveling::find_closest_circle_to_print(const float &X, const float &Y) {
|
396
|
391
|
float closest = 99999.99;
|
397
|
392
|
mesh_index_pair return_val;
|
398
|
393
|
|
|
@@ -401,8 +396,8 @@
|
401
|
396
|
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
402
|
397
|
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
403
|
398
|
if (!is_bit_set(circle_flags, i, j)) {
|
404
|
|
- const float mx = pgm_read_float(&ubl.mesh_index_to_xpos[i]), // We found a circle that needs to be printed
|
405
|
|
- my = pgm_read_float(&ubl.mesh_index_to_ypos[j]);
|
|
399
|
+ const float mx = mesh_index_to_xpos(i), // We found a circle that needs to be printed
|
|
400
|
+ my = mesh_index_to_ypos(j);
|
406
|
401
|
|
407
|
402
|
// Get the distance to this intersection
|
408
|
403
|
float f = HYPOT(X - mx, Y - my);
|
|
@@ -411,7 +406,7 @@
|
411
|
406
|
// to let us find the closest circle to the start position.
|
412
|
407
|
// But if this is not the case, add a small weighting to the
|
413
|
408
|
// distance calculation to help it choose a better place to continue.
|
414
|
|
- f += HYPOT(x_pos - mx, y_pos - my) / 15.0;
|
|
409
|
+ f += HYPOT(g26_x_pos - mx, g26_y_pos - my) / 15.0;
|
415
|
410
|
|
416
|
411
|
// Add in the specified amount of Random Noise to our search
|
417
|
412
|
if (random_deviation > 1.0)
|
|
@@ -430,34 +425,16 @@
|
430
|
425
|
return return_val;
|
431
|
426
|
}
|
432
|
427
|
|
433
|
|
- bool look_for_lines_to_connect() {
|
|
428
|
+ bool unified_bed_leveling::look_for_lines_to_connect() {
|
434
|
429
|
float sx, sy, ex, ey;
|
435
|
430
|
|
436
|
431
|
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
437
|
432
|
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
438
|
433
|
|
439
|
|
- // this sequence to detect an ubl_lcd_clicked() debounce it and leave if it is
|
440
|
|
- // a Press and Hold is repeated in a lot of places (including ubl_G29.cpp). This
|
441
|
|
- // should be redone and compressed.
|
442
|
|
- if (ubl_lcd_clicked()) { // Check if the user wants to stop the Mesh Validation
|
443
|
|
- #if ENABLED(ULTRA_LCD)
|
444
|
|
- lcd_setstatuspgm(PSTR("Mesh Validation Stopped."), 99);
|
445
|
|
- lcd_quick_feedback();
|
446
|
|
- #endif
|
447
|
|
- while (!ubl_lcd_clicked()) { // Wait until the user is done pressing the
|
448
|
|
- idle(); // Encoder Wheel if that is why we are leaving
|
449
|
|
- lcd_reset_alert_level();
|
450
|
|
- lcd_setstatuspgm(PSTR(""));
|
451
|
|
- }
|
452
|
|
- while (ubl_lcd_clicked()) { // Wait until the user is done pressing the
|
453
|
|
- idle(); // Encoder Wheel if that is why we are leaving
|
454
|
|
- lcd_setstatuspgm(PSTR("Unpress Wheel"), 99);
|
455
|
|
- }
|
456
|
|
- return true;
|
457
|
|
- }
|
|
434
|
+ if (user_canceled()) return true; // Check if the user wants to stop the Mesh Validation
|
458
|
435
|
|
459
|
436
|
if (i < GRID_MAX_POINTS_X) { // We can't connect to anything to the right than GRID_MAX_POINTS_X.
|
460
|
|
- // This is already a half circle because we are at the edge of the bed.
|
|
437
|
+ // This is already a half circle because we are at the edge of the bed.
|
461
|
438
|
|
462
|
439
|
if (is_bit_set(circle_flags, i, j) && is_bit_set(circle_flags, i + 1, j)) { // check if we can do a line to the left
|
463
|
440
|
if (!is_bit_set(horizontal_mesh_line_flags, i, j)) {
|
|
@@ -466,16 +443,16 @@
|
466
|
443
|
// We found two circles that need a horizontal line to connect them
|
467
|
444
|
// Print it!
|
468
|
445
|
//
|
469
|
|
- sx = pgm_read_float(&ubl.mesh_index_to_xpos[ i ]) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // right edge
|
470
|
|
- ex = pgm_read_float(&ubl.mesh_index_to_xpos[i + 1]) - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // left edge
|
|
446
|
+ sx = mesh_index_to_xpos( i ) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // right edge
|
|
447
|
+ ex = mesh_index_to_xpos(i + 1) - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // left edge
|
471
|
448
|
|
472
|
449
|
sx = constrain(sx, X_MIN_POS + 1, X_MAX_POS - 1);
|
473
|
|
- sy = ey = constrain(pgm_read_float(&ubl.mesh_index_to_ypos[j]), Y_MIN_POS + 1, Y_MAX_POS - 1);
|
|
450
|
+ sy = ey = constrain(mesh_index_to_ypos(j), Y_MIN_POS + 1, Y_MAX_POS - 1);
|
474
|
451
|
ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
|
475
|
452
|
|
476
|
453
|
if (position_is_reachable_raw_xy(sx, sy) && position_is_reachable_raw_xy(ex, ey)) {
|
477
|
454
|
|
478
|
|
- if (ubl.g26_debug_flag) {
|
|
455
|
+ if (g26_debug_flag) {
|
479
|
456
|
SERIAL_ECHOPAIR(" Connecting with horizontal line (sx=", sx);
|
480
|
457
|
SERIAL_ECHOPAIR(", sy=", sy);
|
481
|
458
|
SERIAL_ECHOPAIR(") -> (ex=", ex);
|
|
@@ -485,7 +462,7 @@
|
485
|
462
|
//debug_current_and_destination(PSTR("Connecting horizontal line."));
|
486
|
463
|
}
|
487
|
464
|
|
488
|
|
- print_line_from_here_to_there(LOGICAL_X_POSITION(sx), LOGICAL_Y_POSITION(sy), layer_height, LOGICAL_X_POSITION(ex), LOGICAL_Y_POSITION(ey), layer_height);
|
|
465
|
+ print_line_from_here_to_there(LOGICAL_X_POSITION(sx), LOGICAL_Y_POSITION(sy), g26_layer_height, LOGICAL_X_POSITION(ex), LOGICAL_Y_POSITION(ey), g26_layer_height);
|
489
|
466
|
}
|
490
|
467
|
bit_set(horizontal_mesh_line_flags, i, j); // Mark it as done so we don't do it again, even if we skipped it
|
491
|
468
|
}
|
|
@@ -500,16 +477,16 @@
|
500
|
477
|
// We found two circles that need a vertical line to connect them
|
501
|
478
|
// Print it!
|
502
|
479
|
//
|
503
|
|
- sy = pgm_read_float(&ubl.mesh_index_to_ypos[ j ]) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // top edge
|
504
|
|
- ey = pgm_read_float(&ubl.mesh_index_to_ypos[j + 1]) - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // bottom edge
|
|
480
|
+ sy = mesh_index_to_ypos( j ) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // top edge
|
|
481
|
+ ey = mesh_index_to_ypos(j + 1) - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // bottom edge
|
505
|
482
|
|
506
|
|
- sx = ex = constrain(pgm_read_float(&ubl.mesh_index_to_xpos[i]), X_MIN_POS + 1, X_MAX_POS - 1);
|
|
483
|
+ sx = ex = constrain(mesh_index_to_xpos(i), X_MIN_POS + 1, X_MAX_POS - 1);
|
507
|
484
|
sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
|
508
|
485
|
ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
|
509
|
486
|
|
510
|
487
|
if (position_is_reachable_raw_xy(sx, sy) && position_is_reachable_raw_xy(ex, ey)) {
|
511
|
488
|
|
512
|
|
- if (ubl.g26_debug_flag) {
|
|
489
|
+ if (g26_debug_flag) {
|
513
|
490
|
SERIAL_ECHOPAIR(" Connecting with vertical line (sx=", sx);
|
514
|
491
|
SERIAL_ECHOPAIR(", sy=", sy);
|
515
|
492
|
SERIAL_ECHOPAIR(") -> (ex=", ex);
|
|
@@ -518,7 +495,7 @@
|
518
|
495
|
SERIAL_EOL;
|
519
|
496
|
debug_current_and_destination(PSTR("Connecting vertical line."));
|
520
|
497
|
}
|
521
|
|
- print_line_from_here_to_there(LOGICAL_X_POSITION(sx), LOGICAL_Y_POSITION(sy), layer_height, LOGICAL_X_POSITION(ex), LOGICAL_Y_POSITION(ey), layer_height);
|
|
498
|
+ print_line_from_here_to_there(LOGICAL_X_POSITION(sx), LOGICAL_Y_POSITION(sy), g26_layer_height, LOGICAL_X_POSITION(ex), LOGICAL_Y_POSITION(ey), g26_layer_height);
|
522
|
499
|
}
|
523
|
500
|
bit_set(vertical_mesh_line_flags, i, j); // Mark it as done so we don't do it again, even if skipped
|
524
|
501
|
}
|
|
@@ -530,7 +507,7 @@
|
530
|
507
|
return false;
|
531
|
508
|
}
|
532
|
509
|
|
533
|
|
- void move_to(const float &x, const float &y, const float &z, const float &e_delta) {
|
|
510
|
+ void unified_bed_leveling::move_to(const float &x, const float &y, const float &z, const float &e_delta) {
|
534
|
511
|
float feed_value;
|
535
|
512
|
static float last_z = -999.99;
|
536
|
513
|
|
|
@@ -552,10 +529,10 @@
|
552
|
529
|
}
|
553
|
530
|
|
554
|
531
|
// Check if X or Y is involved in the movement.
|
555
|
|
- // Yes: a 'normal' movement. No: a retract() or un_retract()
|
|
532
|
+ // Yes: a 'normal' movement. No: a retract() or recover()
|
556
|
533
|
feed_value = has_xy_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.max_feedrate_mm_s[E_AXIS] / 1.5;
|
557
|
534
|
|
558
|
|
- if (ubl.g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
|
|
535
|
+ if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
|
559
|
536
|
|
560
|
537
|
destination[X_AXIS] = x;
|
561
|
538
|
destination[Y_AXIS] = y;
|
|
@@ -568,16 +545,16 @@
|
568
|
545
|
|
569
|
546
|
}
|
570
|
547
|
|
571
|
|
- void retract_filament(float where[XYZE]) {
|
|
548
|
+ void unified_bed_leveling::retract_filament(float where[XYZE]) {
|
572
|
549
|
if (!g26_retracted) { // Only retract if we are not already retracted!
|
573
|
550
|
g26_retracted = true;
|
574
|
|
- move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], -1.0 * retraction_multiplier);
|
|
551
|
+ move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], -1.0 * g26_retraction_multiplier);
|
575
|
552
|
}
|
576
|
553
|
}
|
577
|
554
|
|
578
|
|
- void un_retract_filament(float where[XYZE]) {
|
|
555
|
+ void unified_bed_leveling::recover_filament(float where[XYZE]) {
|
579
|
556
|
if (g26_retracted) { // Only un-retract if we are retracted.
|
580
|
|
- move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], 1.2 * retraction_multiplier);
|
|
557
|
+ move_to(where[X_AXIS], where[Y_AXIS], where[Z_AXIS], 1.2 * g26_retraction_multiplier);
|
581
|
558
|
g26_retracted = false;
|
582
|
559
|
}
|
583
|
560
|
}
|
|
@@ -597,7 +574,7 @@
|
597
|
574
|
* segment of a 'circle'. The time this requires is very short and is easily saved by the other
|
598
|
575
|
* cases where the optimization comes into play.
|
599
|
576
|
*/
|
600
|
|
- 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) {
|
|
577
|
+ void unified_bed_leveling::print_line_from_here_to_there(const float &sx, const float &sy, const float &sz, const float &ex, const float &ey, const float &ez) {
|
601
|
578
|
const float dx_s = current_position[X_AXIS] - sx, // find our distance from the start of the actual line segment
|
602
|
579
|
dy_s = current_position[Y_AXIS] - sy,
|
603
|
580
|
dist_start = HYPOT2(dx_s, dy_s), // We don't need to do a sqrt(), we can compare the distance^2
|
|
@@ -625,9 +602,9 @@
|
625
|
602
|
|
626
|
603
|
move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion / un-Z bump
|
627
|
604
|
|
628
|
|
- const float e_pos_delta = line_length * g26_e_axis_feedrate * extrusion_multiplier;
|
|
605
|
+ const float e_pos_delta = line_length * g26_e_axis_feedrate * g26_extrusion_multiplier;
|
629
|
606
|
|
630
|
|
- un_retract_filament(destination);
|
|
607
|
+ recover_filament(destination);
|
631
|
608
|
move_to(ex, ey, ez, e_pos_delta); // Get to the ending point with an appropriate amount of extrusion
|
632
|
609
|
}
|
633
|
610
|
|
|
@@ -636,33 +613,33 @@
|
636
|
613
|
* parameters it made sense to turn them into static globals and get
|
637
|
614
|
* this code out of sight of the main routine.
|
638
|
615
|
*/
|
639
|
|
- bool parse_G26_parameters() {
|
640
|
|
-
|
641
|
|
- extrusion_multiplier = EXTRUSION_MULTIPLIER;
|
642
|
|
- retraction_multiplier = RETRACTION_MULTIPLIER;
|
643
|
|
- nozzle = NOZZLE;
|
644
|
|
- filament_diameter = FILAMENT;
|
645
|
|
- layer_height = LAYER_HEIGHT;
|
646
|
|
- prime_length = PRIME_LENGTH;
|
647
|
|
- bed_temp = BED_TEMP;
|
648
|
|
- hotend_temp = HOTEND_TEMP;
|
649
|
|
- prime_flag = 0;
|
650
|
|
-
|
651
|
|
- ooze_amount = code_seen('O') && code_has_value() ? code_value_linear_units() : OOZE_AMOUNT;
|
652
|
|
- keep_heaters_on = code_seen('K') && code_value_bool();
|
653
|
|
- continue_with_closest = code_seen('C') && code_value_bool();
|
|
616
|
+ bool unified_bed_leveling::parse_G26_parameters() {
|
|
617
|
+
|
|
618
|
+ g26_extrusion_multiplier = EXTRUSION_MULTIPLIER;
|
|
619
|
+ g26_retraction_multiplier = RETRACTION_MULTIPLIER;
|
|
620
|
+ g26_nozzle = NOZZLE;
|
|
621
|
+ g26_filament_diameter = FILAMENT;
|
|
622
|
+ g26_layer_height = LAYER_HEIGHT;
|
|
623
|
+ g26_prime_length = PRIME_LENGTH;
|
|
624
|
+ g26_bed_temp = BED_TEMP;
|
|
625
|
+ g26_hotend_temp = HOTEND_TEMP;
|
|
626
|
+ g26_prime_flag = 0;
|
|
627
|
+
|
|
628
|
+ g26_ooze_amount = code_seen('O') && code_has_value() ? code_value_linear_units() : OOZE_AMOUNT;
|
|
629
|
+ g26_keep_heaters_on = code_seen('K') && code_value_bool();
|
|
630
|
+ g26_continue_with_closest = code_seen('C') && code_value_bool();
|
654
|
631
|
|
655
|
632
|
if (code_seen('B')) {
|
656
|
|
- bed_temp = code_value_temp_abs();
|
657
|
|
- if (!WITHIN(bed_temp, 15, 140)) {
|
|
633
|
+ g26_bed_temp = code_value_temp_abs();
|
|
634
|
+ if (!WITHIN(g26_bed_temp, 15, 140)) {
|
658
|
635
|
SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible.");
|
659
|
636
|
return UBL_ERR;
|
660
|
637
|
}
|
661
|
638
|
}
|
662
|
639
|
|
663
|
640
|
if (code_seen('L')) {
|
664
|
|
- layer_height = code_value_linear_units();
|
665
|
|
- if (!WITHIN(layer_height, 0.0, 2.0)) {
|
|
641
|
+ g26_layer_height = code_value_linear_units();
|
|
642
|
+ if (!WITHIN(g26_layer_height, 0.0, 2.0)) {
|
666
|
643
|
SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible.");
|
667
|
644
|
return UBL_ERR;
|
668
|
645
|
}
|
|
@@ -670,8 +647,8 @@
|
670
|
647
|
|
671
|
648
|
if (code_seen('Q')) {
|
672
|
649
|
if (code_has_value()) {
|
673
|
|
- retraction_multiplier = code_value_float();
|
674
|
|
- if (!WITHIN(retraction_multiplier, 0.05, 15.0)) {
|
|
650
|
+ g26_retraction_multiplier = code_value_float();
|
|
651
|
+ if (!WITHIN(g26_retraction_multiplier, 0.05, 15.0)) {
|
675
|
652
|
SERIAL_PROTOCOLLNPGM("?Specified Retraction Multiplier not plausible.");
|
676
|
653
|
return UBL_ERR;
|
677
|
654
|
}
|
|
@@ -683,8 +660,8 @@
|
683
|
660
|
}
|
684
|
661
|
|
685
|
662
|
if (code_seen('S')) {
|
686
|
|
- nozzle = code_value_float();
|
687
|
|
- if (!WITHIN(nozzle, 0.1, 1.0)) {
|
|
663
|
+ g26_nozzle = code_value_float();
|
|
664
|
+ if (!WITHIN(g26_nozzle, 0.1, 1.0)) {
|
688
|
665
|
SERIAL_PROTOCOLLNPGM("?Specified nozzle size not plausible.");
|
689
|
666
|
return UBL_ERR;
|
690
|
667
|
}
|
|
@@ -692,11 +669,11 @@
|
692
|
669
|
|
693
|
670
|
if (code_seen('P')) {
|
694
|
671
|
if (!code_has_value())
|
695
|
|
- prime_flag = -1;
|
|
672
|
+ g26_prime_flag = -1;
|
696
|
673
|
else {
|
697
|
|
- prime_flag++;
|
698
|
|
- prime_length = code_value_linear_units();
|
699
|
|
- if (!WITHIN(prime_length, 0.0, 25.0)) {
|
|
674
|
+ g26_prime_flag++;
|
|
675
|
+ g26_prime_length = code_value_linear_units();
|
|
676
|
+ if (!WITHIN(g26_prime_length, 0.0, 25.0)) {
|
700
|
677
|
SERIAL_PROTOCOLLNPGM("?Specified prime length not plausible.");
|
701
|
678
|
return UBL_ERR;
|
702
|
679
|
}
|
|
@@ -704,21 +681,21 @@
|
704
|
681
|
}
|
705
|
682
|
|
706
|
683
|
if (code_seen('F')) {
|
707
|
|
- filament_diameter = code_value_linear_units();
|
708
|
|
- if (!WITHIN(filament_diameter, 1.0, 4.0)) {
|
|
684
|
+ g26_filament_diameter = code_value_linear_units();
|
|
685
|
+ if (!WITHIN(g26_filament_diameter, 1.0, 4.0)) {
|
709
|
686
|
SERIAL_PROTOCOLLNPGM("?Specified filament size not plausible.");
|
710
|
687
|
return UBL_ERR;
|
711
|
688
|
}
|
712
|
689
|
}
|
713
|
|
- extrusion_multiplier *= sq(1.75) / sq(filament_diameter); // If we aren't using 1.75mm filament, we need to
|
|
690
|
+ g26_extrusion_multiplier *= sq(1.75) / sq(g26_filament_diameter); // If we aren't using 1.75mm filament, we need to
|
714
|
691
|
// scale up or down the length needed to get the
|
715
|
692
|
// same volume of filament
|
716
|
693
|
|
717
|
|
- extrusion_multiplier *= filament_diameter * sq(nozzle) / sq(0.3); // Scale up by nozzle size
|
|
694
|
+ g26_extrusion_multiplier *= g26_filament_diameter * sq(g26_nozzle) / sq(0.3); // Scale up by nozzle size
|
718
|
695
|
|
719
|
696
|
if (code_seen('H')) {
|
720
|
|
- hotend_temp = code_value_temp_abs();
|
721
|
|
- if (!WITHIN(hotend_temp, 165, 280)) {
|
|
697
|
+ g26_hotend_temp = code_value_temp_abs();
|
|
698
|
+ if (!WITHIN(g26_hotend_temp, 165, 280)) {
|
722
|
699
|
SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible.");
|
723
|
700
|
return UBL_ERR;
|
724
|
701
|
}
|
|
@@ -735,9 +712,9 @@
|
735
|
712
|
return UBL_ERR;
|
736
|
713
|
}
|
737
|
714
|
|
738
|
|
- x_pos = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS];
|
739
|
|
- y_pos = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS];
|
740
|
|
- if (!position_is_reachable_xy(x_pos, y_pos)) {
|
|
715
|
+ g26_x_pos = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS];
|
|
716
|
+ g26_y_pos = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS];
|
|
717
|
+ if (!position_is_reachable_xy(g26_x_pos, g26_y_pos)) {
|
741
|
718
|
SERIAL_PROTOCOLLNPGM("?Specified X,Y coordinate out of bounds.");
|
742
|
719
|
return UBL_ERR;
|
743
|
720
|
}
|
|
@@ -745,12 +722,12 @@
|
745
|
722
|
/**
|
746
|
723
|
* Wait until all parameters are verified before altering the state!
|
747
|
724
|
*/
|
748
|
|
- ubl.state.active = !code_seen('D');
|
|
725
|
+ state.active = !code_seen('D');
|
749
|
726
|
|
750
|
727
|
return UBL_OK;
|
751
|
728
|
}
|
752
|
729
|
|
753
|
|
- bool exit_from_g26() {
|
|
730
|
+ bool unified_bed_leveling::exit_from_g26() {
|
754
|
731
|
lcd_reset_alert_level();
|
755
|
732
|
lcd_setstatuspgm(PSTR("Leaving G26"));
|
756
|
733
|
while (ubl_lcd_clicked()) idle();
|
|
@@ -761,18 +738,18 @@
|
761
|
738
|
* Turn on the bed and nozzle heat and
|
762
|
739
|
* wait for them to get up to temperature.
|
763
|
740
|
*/
|
764
|
|
- bool turn_on_heaters() {
|
|
741
|
+ bool unified_bed_leveling::turn_on_heaters() {
|
765
|
742
|
millis_t next;
|
766
|
743
|
#if HAS_TEMP_BED
|
767
|
744
|
#if ENABLED(ULTRA_LCD)
|
768
|
|
- if (bed_temp > 25) {
|
|
745
|
+ if (g26_bed_temp > 25) {
|
769
|
746
|
lcd_setstatuspgm(PSTR("G26 Heating Bed."), 99);
|
770
|
747
|
lcd_quick_feedback();
|
771
|
748
|
#endif
|
772
|
|
- ubl.has_control_of_lcd_panel = true;
|
773
|
|
- thermalManager.setTargetBed(bed_temp);
|
|
749
|
+ has_control_of_lcd_panel = true;
|
|
750
|
+ thermalManager.setTargetBed(g26_bed_temp);
|
774
|
751
|
next = millis() + 5000UL;
|
775
|
|
- while (abs(thermalManager.degBed() - bed_temp) > 3) {
|
|
752
|
+ while (abs(thermalManager.degBed() - g26_bed_temp) > 3) {
|
776
|
753
|
if (ubl_lcd_clicked()) return exit_from_g26();
|
777
|
754
|
if (PENDING(millis(), next)) {
|
778
|
755
|
next = millis() + 5000UL;
|
|
@@ -788,8 +765,8 @@
|
788
|
765
|
#endif
|
789
|
766
|
|
790
|
767
|
// Start heating the nozzle and wait for it to reach temperature.
|
791
|
|
- thermalManager.setTargetHotend(hotend_temp, 0);
|
792
|
|
- while (abs(thermalManager.degHotend(0) - hotend_temp) > 3) {
|
|
768
|
+ thermalManager.setTargetHotend(g26_hotend_temp, 0);
|
|
769
|
+ while (abs(thermalManager.degHotend(0) - g26_hotend_temp) > 3) {
|
793
|
770
|
if (ubl_lcd_clicked()) return exit_from_g26();
|
794
|
771
|
if (PENDING(millis(), next)) {
|
795
|
772
|
next = millis() + 5000UL;
|
|
@@ -810,19 +787,19 @@
|
810
|
787
|
/**
|
811
|
788
|
* Prime the nozzle if needed. Return true on error.
|
812
|
789
|
*/
|
813
|
|
- bool prime_nozzle() {
|
|
790
|
+ bool unified_bed_leveling::prime_nozzle() {
|
814
|
791
|
float Total_Prime = 0.0;
|
815
|
792
|
|
816
|
|
- if (prime_flag == -1) { // The user wants to control how much filament gets purged
|
|
793
|
+ if (g26_prime_flag == -1) { // The user wants to control how much filament gets purged
|
817
|
794
|
|
818
|
|
- ubl.has_control_of_lcd_panel = true;
|
|
795
|
+ has_control_of_lcd_panel = true;
|
819
|
796
|
|
820
|
797
|
lcd_setstatuspgm(PSTR("User-Controlled Prime"), 99);
|
821
|
798
|
chirp_at_user();
|
822
|
799
|
|
823
|
800
|
set_destination_to_current();
|
824
|
801
|
|
825
|
|
- un_retract_filament(destination); // Make sure G26 doesn't think the filament is retracted().
|
|
802
|
+ recover_filament(destination); // Make sure G26 doesn't think the filament is retracted().
|
826
|
803
|
|
827
|
804
|
while (!ubl_lcd_clicked()) {
|
828
|
805
|
chirp_at_user();
|
|
@@ -850,7 +827,7 @@
|
850
|
827
|
lcd_quick_feedback();
|
851
|
828
|
#endif
|
852
|
829
|
|
853
|
|
- ubl.has_control_of_lcd_panel = false;
|
|
830
|
+ has_control_of_lcd_panel = false;
|
854
|
831
|
|
855
|
832
|
}
|
856
|
833
|
else {
|
|
@@ -859,7 +836,7 @@
|
859
|
836
|
lcd_quick_feedback();
|
860
|
837
|
#endif
|
861
|
838
|
set_destination_to_current();
|
862
|
|
- destination[E_AXIS] += prime_length;
|
|
839
|
+ destination[E_AXIS] += g26_prime_length;
|
863
|
840
|
G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
|
864
|
841
|
stepper.synchronize();
|
865
|
842
|
set_destination_to_current();
|