|
@@ -135,54 +135,44 @@
|
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
|
|
|
@@ -216,7 +206,7 @@
|
216
|
206
|
* Used to interactively edit UBL's Mesh by placing the
|
217
|
207
|
* nozzle in a problem area and doing a G29 P4 R command.
|
218
|
208
|
*/
|
219
|
|
- void gcode_G26() {
|
|
209
|
+ void unified_bed_leveling::G26() {
|
220
|
210
|
SERIAL_ECHOLNPGM("G26 command started. Waiting for heater(s).");
|
221
|
211
|
float tmp, start_angle, end_angle;
|
222
|
212
|
int i, xi, yi;
|
|
@@ -237,7 +227,7 @@
|
237
|
227
|
current_position[E_AXIS] = 0.0;
|
238
|
228
|
sync_plan_position_e();
|
239
|
229
|
|
240
|
|
- if (prime_flag && prime_nozzle()) goto LEAVE;
|
|
230
|
+ if (g26_prime_flag && prime_nozzle()) goto LEAVE;
|
241
|
231
|
|
242
|
232
|
/**
|
243
|
233
|
* Bed is preheated
|
|
@@ -255,11 +245,11 @@
|
255
|
245
|
|
256
|
246
|
// Move nozzle to the specified height for the first layer
|
257
|
247
|
set_destination_to_current();
|
258
|
|
- destination[Z_AXIS] = layer_height;
|
|
248
|
+ destination[Z_AXIS] = g26_layer_height;
|
259
|
249
|
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0.0);
|
260
|
|
- 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);
|
261
|
251
|
|
262
|
|
- ubl.has_control_of_lcd_panel = true;
|
|
252
|
+ has_control_of_lcd_panel = true;
|
263
|
253
|
//debug_current_and_destination(PSTR("Starting G26 Mesh Validation Pattern."));
|
264
|
254
|
|
265
|
255
|
/**
|
|
@@ -273,13 +263,13 @@
|
273
|
263
|
}
|
274
|
264
|
|
275
|
265
|
do {
|
276
|
|
- location = continue_with_closest
|
|
266
|
+ location = g26_continue_with_closest
|
277
|
267
|
? find_closest_circle_to_print(current_position[X_AXIS], current_position[Y_AXIS])
|
278
|
|
- : 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.
|
279
|
269
|
|
280
|
270
|
if (location.x_index >= 0 && location.y_index >= 0) {
|
281
|
|
- const float circle_x = pgm_read_float(&ubl.mesh_index_to_xpos[location.x_index]),
|
282
|
|
- 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);
|
283
|
273
|
|
284
|
274
|
// If this mesh location is outside the printable_radius, skip it.
|
285
|
275
|
|
|
@@ -288,7 +278,7 @@
|
288
|
278
|
xi = location.x_index; // Just to shrink the next few lines and make them easier to understand
|
289
|
279
|
yi = location.y_index;
|
290
|
280
|
|
291
|
|
- if (ubl.g26_debug_flag) {
|
|
281
|
+ if (g26_debug_flag) {
|
292
|
282
|
SERIAL_ECHOPAIR(" Doing circle at: (xi=", xi);
|
293
|
283
|
SERIAL_ECHOPAIR(", yi=", yi);
|
294
|
284
|
SERIAL_CHAR(')');
|
|
@@ -344,7 +334,7 @@
|
344
|
334
|
ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
|
345
|
335
|
#endif
|
346
|
336
|
|
347
|
|
- //if (ubl.g26_debug_flag) {
|
|
337
|
+ //if (g26_debug_flag) {
|
348
|
338
|
// char ccc, *cptr, seg_msg[50], seg_num[10];
|
349
|
339
|
// strcpy(seg_msg, " segment: ");
|
350
|
340
|
// strcpy(seg_num, " \n");
|
|
@@ -355,7 +345,7 @@
|
355
|
345
|
// debug_current_and_destination(seg_msg);
|
356
|
346
|
//}
|
357
|
347
|
|
358
|
|
- 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);
|
359
|
349
|
|
360
|
350
|
}
|
361
|
351
|
if (look_for_lines_to_connect())
|
|
@@ -374,16 +364,16 @@
|
374
|
364
|
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Raise the nozzle
|
375
|
365
|
//debug_current_and_destination(PSTR("done doing Z-Raise."));
|
376
|
366
|
|
377
|
|
- destination[X_AXIS] = x_pos; // Move back to the starting position
|
378
|
|
- 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;
|
379
|
369
|
//destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Keep the nozzle where it is
|
380
|
370
|
|
381
|
371
|
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Move back to the starting position
|
382
|
372
|
//debug_current_and_destination(PSTR("done doing X/Y move."));
|
383
|
373
|
|
384
|
|
- 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!
|
385
|
375
|
|
386
|
|
- if (!keep_heaters_on) {
|
|
376
|
+ if (!g26_keep_heaters_on) {
|
387
|
377
|
#if HAS_TEMP_BED
|
388
|
378
|
thermalManager.setTargetBed(0);
|
389
|
379
|
#endif
|
|
@@ -391,14 +381,13 @@
|
391
|
381
|
}
|
392
|
382
|
}
|
393
|
383
|
|
394
|
|
-
|
395
|
384
|
float valid_trig_angle(float d) {
|
396
|
385
|
while (d > 360.0) d -= 360.0;
|
397
|
386
|
while (d < 0.0) d += 360.0;
|
398
|
387
|
return d;
|
399
|
388
|
}
|
400
|
389
|
|
401
|
|
- 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) {
|
402
|
391
|
float closest = 99999.99;
|
403
|
392
|
mesh_index_pair return_val;
|
404
|
393
|
|
|
@@ -407,8 +396,8 @@
|
407
|
396
|
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
408
|
397
|
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
409
|
398
|
if (!is_bit_set(circle_flags, i, j)) {
|
410
|
|
- const float mx = pgm_read_float(&ubl.mesh_index_to_xpos[i]), // We found a circle that needs to be printed
|
411
|
|
- 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);
|
412
|
401
|
|
413
|
402
|
// Get the distance to this intersection
|
414
|
403
|
float f = HYPOT(X - mx, Y - my);
|
|
@@ -417,7 +406,7 @@
|
417
|
406
|
// to let us find the closest circle to the start position.
|
418
|
407
|
// But if this is not the case, add a small weighting to the
|
419
|
408
|
// distance calculation to help it choose a better place to continue.
|
420
|
|
- f += HYPOT(x_pos - mx, y_pos - my) / 15.0;
|
|
409
|
+ f += HYPOT(g26_x_pos - mx, g26_y_pos - my) / 15.0;
|
421
|
410
|
|
422
|
411
|
// Add in the specified amount of Random Noise to our search
|
423
|
412
|
if (random_deviation > 1.0)
|
|
@@ -436,7 +425,7 @@
|
436
|
425
|
return return_val;
|
437
|
426
|
}
|
438
|
427
|
|
439
|
|
- bool look_for_lines_to_connect() {
|
|
428
|
+ bool unified_bed_leveling::look_for_lines_to_connect() {
|
440
|
429
|
float sx, sy, ex, ey;
|
441
|
430
|
|
442
|
431
|
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
|
@@ -454,16 +443,16 @@
|
454
|
443
|
// We found two circles that need a horizontal line to connect them
|
455
|
444
|
// Print it!
|
456
|
445
|
//
|
457
|
|
- sx = pgm_read_float(&ubl.mesh_index_to_xpos[ i ]) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // right edge
|
458
|
|
- 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
|
459
|
448
|
|
460
|
449
|
sx = constrain(sx, X_MIN_POS + 1, X_MAX_POS - 1);
|
461
|
|
- 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);
|
462
|
451
|
ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
|
463
|
452
|
|
464
|
453
|
if (position_is_reachable_raw_xy(sx, sy) && position_is_reachable_raw_xy(ex, ey)) {
|
465
|
454
|
|
466
|
|
- if (ubl.g26_debug_flag) {
|
|
455
|
+ if (g26_debug_flag) {
|
467
|
456
|
SERIAL_ECHOPAIR(" Connecting with horizontal line (sx=", sx);
|
468
|
457
|
SERIAL_ECHOPAIR(", sy=", sy);
|
469
|
458
|
SERIAL_ECHOPAIR(") -> (ex=", ex);
|
|
@@ -473,7 +462,7 @@
|
473
|
462
|
//debug_current_and_destination(PSTR("Connecting horizontal line."));
|
474
|
463
|
}
|
475
|
464
|
|
476
|
|
- 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);
|
477
|
466
|
}
|
478
|
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
|
479
|
468
|
}
|
|
@@ -488,16 +477,16 @@
|
488
|
477
|
// We found two circles that need a vertical line to connect them
|
489
|
478
|
// Print it!
|
490
|
479
|
//
|
491
|
|
- sy = pgm_read_float(&ubl.mesh_index_to_ypos[ j ]) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // top edge
|
492
|
|
- 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
|
493
|
482
|
|
494
|
|
- 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);
|
495
|
484
|
sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
|
496
|
485
|
ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
|
497
|
486
|
|
498
|
487
|
if (position_is_reachable_raw_xy(sx, sy) && position_is_reachable_raw_xy(ex, ey)) {
|
499
|
488
|
|
500
|
|
- if (ubl.g26_debug_flag) {
|
|
489
|
+ if (g26_debug_flag) {
|
501
|
490
|
SERIAL_ECHOPAIR(" Connecting with vertical line (sx=", sx);
|
502
|
491
|
SERIAL_ECHOPAIR(", sy=", sy);
|
503
|
492
|
SERIAL_ECHOPAIR(") -> (ex=", ex);
|
|
@@ -506,7 +495,7 @@
|
506
|
495
|
SERIAL_EOL;
|
507
|
496
|
debug_current_and_destination(PSTR("Connecting vertical line."));
|
508
|
497
|
}
|
509
|
|
- 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);
|
510
|
499
|
}
|
511
|
500
|
bit_set(vertical_mesh_line_flags, i, j); // Mark it as done so we don't do it again, even if skipped
|
512
|
501
|
}
|
|
@@ -518,7 +507,7 @@
|
518
|
507
|
return false;
|
519
|
508
|
}
|
520
|
509
|
|
521
|
|
- 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) {
|
522
|
511
|
float feed_value;
|
523
|
512
|
static float last_z = -999.99;
|
524
|
513
|
|
|
@@ -540,10 +529,10 @@
|
540
|
529
|
}
|
541
|
530
|
|
542
|
531
|
// Check if X or Y is involved in the movement.
|
543
|
|
- // Yes: a 'normal' movement. No: a retract() or un_retract()
|
|
532
|
+ // Yes: a 'normal' movement. No: a retract() or recover()
|
544
|
533
|
feed_value = has_xy_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.max_feedrate_mm_s[E_AXIS] / 1.5;
|
545
|
534
|
|
546
|
|
- 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);
|
547
|
536
|
|
548
|
537
|
destination[X_AXIS] = x;
|
549
|
538
|
destination[Y_AXIS] = y;
|
|
@@ -556,16 +545,16 @@
|
556
|
545
|
|
557
|
546
|
}
|
558
|
547
|
|
559
|
|
- void retract_filament(float where[XYZE]) {
|
|
548
|
+ void unified_bed_leveling::retract_filament(float where[XYZE]) {
|
560
|
549
|
if (!g26_retracted) { // Only retract if we are not already retracted!
|
561
|
550
|
g26_retracted = true;
|
562
|
|
- 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);
|
563
|
552
|
}
|
564
|
553
|
}
|
565
|
554
|
|
566
|
|
- void un_retract_filament(float where[XYZE]) {
|
|
555
|
+ void unified_bed_leveling::recover_filament(float where[XYZE]) {
|
567
|
556
|
if (g26_retracted) { // Only un-retract if we are retracted.
|
568
|
|
- 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);
|
569
|
558
|
g26_retracted = false;
|
570
|
559
|
}
|
571
|
560
|
}
|
|
@@ -585,7 +574,7 @@
|
585
|
574
|
* segment of a 'circle'. The time this requires is very short and is easily saved by the other
|
586
|
575
|
* cases where the optimization comes into play.
|
587
|
576
|
*/
|
588
|
|
- 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) {
|
589
|
578
|
const float dx_s = current_position[X_AXIS] - sx, // find our distance from the start of the actual line segment
|
590
|
579
|
dy_s = current_position[Y_AXIS] - sy,
|
591
|
580
|
dist_start = HYPOT2(dx_s, dy_s), // We don't need to do a sqrt(), we can compare the distance^2
|
|
@@ -613,9 +602,9 @@
|
613
|
602
|
|
614
|
603
|
move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion / un-Z bump
|
615
|
604
|
|
616
|
|
- 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;
|
617
|
606
|
|
618
|
|
- un_retract_filament(destination);
|
|
607
|
+ recover_filament(destination);
|
619
|
608
|
move_to(ex, ey, ez, e_pos_delta); // Get to the ending point with an appropriate amount of extrusion
|
620
|
609
|
}
|
621
|
610
|
|
|
@@ -624,33 +613,33 @@
|
624
|
613
|
* parameters it made sense to turn them into static globals and get
|
625
|
614
|
* this code out of sight of the main routine.
|
626
|
615
|
*/
|
627
|
|
- bool parse_G26_parameters() {
|
628
|
|
-
|
629
|
|
- extrusion_multiplier = EXTRUSION_MULTIPLIER;
|
630
|
|
- retraction_multiplier = RETRACTION_MULTIPLIER;
|
631
|
|
- nozzle = NOZZLE;
|
632
|
|
- filament_diameter = FILAMENT;
|
633
|
|
- layer_height = LAYER_HEIGHT;
|
634
|
|
- prime_length = PRIME_LENGTH;
|
635
|
|
- bed_temp = BED_TEMP;
|
636
|
|
- hotend_temp = HOTEND_TEMP;
|
637
|
|
- prime_flag = 0;
|
638
|
|
-
|
639
|
|
- ooze_amount = code_seen('O') && code_has_value() ? code_value_linear_units() : OOZE_AMOUNT;
|
640
|
|
- keep_heaters_on = code_seen('K') && code_value_bool();
|
641
|
|
- 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();
|
642
|
631
|
|
643
|
632
|
if (code_seen('B')) {
|
644
|
|
- bed_temp = code_value_temp_abs();
|
645
|
|
- if (!WITHIN(bed_temp, 15, 140)) {
|
|
633
|
+ g26_bed_temp = code_value_temp_abs();
|
|
634
|
+ if (!WITHIN(g26_bed_temp, 15, 140)) {
|
646
|
635
|
SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible.");
|
647
|
636
|
return UBL_ERR;
|
648
|
637
|
}
|
649
|
638
|
}
|
650
|
639
|
|
651
|
640
|
if (code_seen('L')) {
|
652
|
|
- layer_height = code_value_linear_units();
|
653
|
|
- 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)) {
|
654
|
643
|
SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible.");
|
655
|
644
|
return UBL_ERR;
|
656
|
645
|
}
|
|
@@ -658,8 +647,8 @@
|
658
|
647
|
|
659
|
648
|
if (code_seen('Q')) {
|
660
|
649
|
if (code_has_value()) {
|
661
|
|
- retraction_multiplier = code_value_float();
|
662
|
|
- 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)) {
|
663
|
652
|
SERIAL_PROTOCOLLNPGM("?Specified Retraction Multiplier not plausible.");
|
664
|
653
|
return UBL_ERR;
|
665
|
654
|
}
|
|
@@ -671,8 +660,8 @@
|
671
|
660
|
}
|
672
|
661
|
|
673
|
662
|
if (code_seen('S')) {
|
674
|
|
- nozzle = code_value_float();
|
675
|
|
- if (!WITHIN(nozzle, 0.1, 1.0)) {
|
|
663
|
+ g26_nozzle = code_value_float();
|
|
664
|
+ if (!WITHIN(g26_nozzle, 0.1, 1.0)) {
|
676
|
665
|
SERIAL_PROTOCOLLNPGM("?Specified nozzle size not plausible.");
|
677
|
666
|
return UBL_ERR;
|
678
|
667
|
}
|
|
@@ -680,11 +669,11 @@
|
680
|
669
|
|
681
|
670
|
if (code_seen('P')) {
|
682
|
671
|
if (!code_has_value())
|
683
|
|
- prime_flag = -1;
|
|
672
|
+ g26_prime_flag = -1;
|
684
|
673
|
else {
|
685
|
|
- prime_flag++;
|
686
|
|
- prime_length = code_value_linear_units();
|
687
|
|
- 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)) {
|
688
|
677
|
SERIAL_PROTOCOLLNPGM("?Specified prime length not plausible.");
|
689
|
678
|
return UBL_ERR;
|
690
|
679
|
}
|
|
@@ -692,21 +681,21 @@
|
692
|
681
|
}
|
693
|
682
|
|
694
|
683
|
if (code_seen('F')) {
|
695
|
|
- filament_diameter = code_value_linear_units();
|
696
|
|
- 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)) {
|
697
|
686
|
SERIAL_PROTOCOLLNPGM("?Specified filament size not plausible.");
|
698
|
687
|
return UBL_ERR;
|
699
|
688
|
}
|
700
|
689
|
}
|
701
|
|
- 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
|
702
|
691
|
// scale up or down the length needed to get the
|
703
|
692
|
// same volume of filament
|
704
|
693
|
|
705
|
|
- 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
|
706
|
695
|
|
707
|
696
|
if (code_seen('H')) {
|
708
|
|
- hotend_temp = code_value_temp_abs();
|
709
|
|
- if (!WITHIN(hotend_temp, 165, 280)) {
|
|
697
|
+ g26_hotend_temp = code_value_temp_abs();
|
|
698
|
+ if (!WITHIN(g26_hotend_temp, 165, 280)) {
|
710
|
699
|
SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible.");
|
711
|
700
|
return UBL_ERR;
|
712
|
701
|
}
|
|
@@ -723,9 +712,9 @@
|
723
|
712
|
return UBL_ERR;
|
724
|
713
|
}
|
725
|
714
|
|
726
|
|
- x_pos = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS];
|
727
|
|
- y_pos = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS];
|
728
|
|
- 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)) {
|
729
|
718
|
SERIAL_PROTOCOLLNPGM("?Specified X,Y coordinate out of bounds.");
|
730
|
719
|
return UBL_ERR;
|
731
|
720
|
}
|
|
@@ -733,12 +722,12 @@
|
733
|
722
|
/**
|
734
|
723
|
* Wait until all parameters are verified before altering the state!
|
735
|
724
|
*/
|
736
|
|
- ubl.state.active = !code_seen('D');
|
|
725
|
+ state.active = !code_seen('D');
|
737
|
726
|
|
738
|
727
|
return UBL_OK;
|
739
|
728
|
}
|
740
|
729
|
|
741
|
|
- bool exit_from_g26() {
|
|
730
|
+ bool unified_bed_leveling::exit_from_g26() {
|
742
|
731
|
lcd_reset_alert_level();
|
743
|
732
|
lcd_setstatuspgm(PSTR("Leaving G26"));
|
744
|
733
|
while (ubl_lcd_clicked()) idle();
|
|
@@ -749,18 +738,18 @@
|
749
|
738
|
* Turn on the bed and nozzle heat and
|
750
|
739
|
* wait for them to get up to temperature.
|
751
|
740
|
*/
|
752
|
|
- bool turn_on_heaters() {
|
|
741
|
+ bool unified_bed_leveling::turn_on_heaters() {
|
753
|
742
|
millis_t next;
|
754
|
743
|
#if HAS_TEMP_BED
|
755
|
744
|
#if ENABLED(ULTRA_LCD)
|
756
|
|
- if (bed_temp > 25) {
|
|
745
|
+ if (g26_bed_temp > 25) {
|
757
|
746
|
lcd_setstatuspgm(PSTR("G26 Heating Bed."), 99);
|
758
|
747
|
lcd_quick_feedback();
|
759
|
748
|
#endif
|
760
|
|
- ubl.has_control_of_lcd_panel = true;
|
761
|
|
- thermalManager.setTargetBed(bed_temp);
|
|
749
|
+ has_control_of_lcd_panel = true;
|
|
750
|
+ thermalManager.setTargetBed(g26_bed_temp);
|
762
|
751
|
next = millis() + 5000UL;
|
763
|
|
- while (abs(thermalManager.degBed() - bed_temp) > 3) {
|
|
752
|
+ while (abs(thermalManager.degBed() - g26_bed_temp) > 3) {
|
764
|
753
|
if (ubl_lcd_clicked()) return exit_from_g26();
|
765
|
754
|
if (PENDING(millis(), next)) {
|
766
|
755
|
next = millis() + 5000UL;
|
|
@@ -776,8 +765,8 @@
|
776
|
765
|
#endif
|
777
|
766
|
|
778
|
767
|
// Start heating the nozzle and wait for it to reach temperature.
|
779
|
|
- thermalManager.setTargetHotend(hotend_temp, 0);
|
780
|
|
- 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) {
|
781
|
770
|
if (ubl_lcd_clicked()) return exit_from_g26();
|
782
|
771
|
if (PENDING(millis(), next)) {
|
783
|
772
|
next = millis() + 5000UL;
|
|
@@ -798,19 +787,19 @@
|
798
|
787
|
/**
|
799
|
788
|
* Prime the nozzle if needed. Return true on error.
|
800
|
789
|
*/
|
801
|
|
- bool prime_nozzle() {
|
|
790
|
+ bool unified_bed_leveling::prime_nozzle() {
|
802
|
791
|
float Total_Prime = 0.0;
|
803
|
792
|
|
804
|
|
- 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
|
805
|
794
|
|
806
|
|
- ubl.has_control_of_lcd_panel = true;
|
|
795
|
+ has_control_of_lcd_panel = true;
|
807
|
796
|
|
808
|
797
|
lcd_setstatuspgm(PSTR("User-Controlled Prime"), 99);
|
809
|
798
|
chirp_at_user();
|
810
|
799
|
|
811
|
800
|
set_destination_to_current();
|
812
|
801
|
|
813
|
|
- 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().
|
814
|
803
|
|
815
|
804
|
while (!ubl_lcd_clicked()) {
|
816
|
805
|
chirp_at_user();
|
|
@@ -838,7 +827,7 @@
|
838
|
827
|
lcd_quick_feedback();
|
839
|
828
|
#endif
|
840
|
829
|
|
841
|
|
- ubl.has_control_of_lcd_panel = false;
|
|
830
|
+ has_control_of_lcd_panel = false;
|
842
|
831
|
|
843
|
832
|
}
|
844
|
833
|
else {
|
|
@@ -847,7 +836,7 @@
|
847
|
836
|
lcd_quick_feedback();
|
848
|
837
|
#endif
|
849
|
838
|
set_destination_to_current();
|
850
|
|
- destination[E_AXIS] += prime_length;
|
|
839
|
+ destination[E_AXIS] += g26_prime_length;
|
851
|
840
|
G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
|
852
|
841
|
stepper.synchronize();
|
853
|
842
|
set_destination_to_current();
|