|
@@ -449,49 +449,86 @@ namespace ExtUI {
|
449
|
449
|
void setRetractAcceleration_mm_s2(const float acc) { planner.settings.retract_acceleration = acc; }
|
450
|
450
|
void setTravelAcceleration_mm_s2(const float acc) { planner.settings.travel_acceleration = acc; }
|
451
|
451
|
|
452
|
|
- #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
453
|
|
- float getZOffset_mm() {
|
454
|
|
- #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
455
|
|
- if (active_extruder != 0)
|
456
|
|
- return hotend_offset[Z_AXIS][active_extruder];
|
457
|
|
- else
|
458
|
|
- #endif
|
459
|
|
- return zprobe_zoffset;
|
|
452
|
+ #if ENABLED(BABYSTEPPING)
|
|
453
|
+ bool babystepAxis_steps(const int16_t steps, const axis_t axis) {
|
|
454
|
+ switch (axis) {
|
|
455
|
+ #if ENABLED(BABYSTEP_XY)
|
|
456
|
+ case X: thermalManager.babystep_axis(X_AXIS, steps); break;
|
|
457
|
+ case Y: thermalManager.babystep_axis(Y_AXIS, steps); break;
|
|
458
|
+ #endif
|
|
459
|
+ case Z: thermalManager.babystep_axis(Z_AXIS, steps); break;
|
|
460
|
+ default: return false;
|
|
461
|
+ };
|
|
462
|
+ return true;
|
460
|
463
|
}
|
461
|
464
|
|
462
|
|
- void setZOffset_mm(const float value) {
|
463
|
|
- const float diff = (value - getZOffset_mm()) / planner.steps_to_mm[Z_AXIS];
|
464
|
|
- addZOffset_steps(diff > 0 ? CEIL(diff) : FLOOR(diff));
|
465
|
|
- }
|
|
465
|
+ /**
|
|
466
|
+ * This function adjusts an axis during a print.
|
|
467
|
+ *
|
|
468
|
+ * When linked_nozzles is false, each nozzle in a multi-nozzle
|
|
469
|
+ * printer can be babystepped independently of the others. This
|
|
470
|
+ * lets the user to fine tune the Z-offset and Nozzle Offsets
|
|
471
|
+ * while observing the first layer of a print, regardless of
|
|
472
|
+ * what nozzle is printing.
|
|
473
|
+ */
|
|
474
|
+ void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles) {
|
|
475
|
+ const float mm = steps * planner.steps_to_mm[axis];
|
|
476
|
+
|
|
477
|
+ if (!babystepAxis_steps(steps, axis)) return;
|
|
478
|
+
|
|
479
|
+ #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
|
480
|
+ // Make it so babystepping in Z adjusts the Z probe offset.
|
|
481
|
+ if (axis == Z
|
|
482
|
+ #if EXTRUDERS > 1
|
|
483
|
+ && (linked_nozzles || active_extruder == 0)
|
|
484
|
+ #endif
|
|
485
|
+ ) zprobe_zoffset += mm;
|
|
486
|
+ #endif
|
466
|
487
|
|
467
|
|
- void addZOffset_steps(int16_t babystep_increment) {
|
468
|
|
- #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
469
|
|
- const bool do_probe = (active_extruder == 0);
|
|
488
|
+ #if EXTRUDERS > 1
|
|
489
|
+ /**
|
|
490
|
+ * When linked_nozzles is false, as an axis is babystepped
|
|
491
|
+ * adjust the hotend offsets so that the other nozzles are
|
|
492
|
+ * unaffected by the babystepping of the active nozzle.
|
|
493
|
+ */
|
|
494
|
+ if (!linked_nozzles) {
|
|
495
|
+ HOTEND_LOOP()
|
|
496
|
+ if (e != active_extruder)
|
|
497
|
+ hotend_offset[axis][e] += mm;
|
|
498
|
+
|
|
499
|
+ normalizeNozzleOffset(X);
|
|
500
|
+ normalizeNozzleOffset(Y);
|
|
501
|
+ normalizeNozzleOffset(Z);
|
|
502
|
+ }
|
470
|
503
|
#else
|
471
|
|
- constexpr bool do_probe = true;
|
|
504
|
+ UNUSED(linked_nozzles);
|
472
|
505
|
#endif
|
473
|
|
- const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
|
474
|
|
- new_probe_offset = zprobe_zoffset + diff,
|
475
|
|
- new_offs =
|
476
|
|
- #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
477
|
|
- do_probe ? new_probe_offset : hotend_offset[Z_AXIS][active_extruder] - diff
|
478
|
|
- #else
|
479
|
|
- new_probe_offset
|
480
|
|
- #endif
|
481
|
|
- ;
|
482
|
|
- if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
483
|
|
-
|
484
|
|
- thermalManager.babystep_axis(Z_AXIS, babystep_increment);
|
485
|
|
-
|
486
|
|
- if (do_probe) zprobe_zoffset = new_offs;
|
487
|
|
- #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
488
|
|
- else hotend_offset[Z_AXIS][active_extruder] = new_offs;
|
489
|
|
- #endif
|
|
506
|
+ }
|
|
507
|
+
|
|
508
|
+ /**
|
|
509
|
+ * Converts a mm displacement to a number of whole number of
|
|
510
|
+ * steps that is at least mm long.
|
|
511
|
+ */
|
|
512
|
+ int16_t mmToWholeSteps(const float mm, const axis_t axis) {
|
|
513
|
+ const float steps = mm / planner.steps_to_mm[axis];
|
|
514
|
+ return steps > 0 ? ceil(steps) : floor(steps);
|
|
515
|
+ }
|
|
516
|
+ #endif
|
|
517
|
+
|
|
518
|
+ #if HAS_BED_PROBE
|
|
519
|
+ float getZOffset_mm() {
|
|
520
|
+ return zprobe_zoffset;
|
|
521
|
+ }
|
|
522
|
+
|
|
523
|
+ void setZOffset_mm(const float value) {
|
|
524
|
+ if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
|
525
|
+ zprobe_zoffset = value;
|
490
|
526
|
}
|
491
|
527
|
}
|
492
|
|
- #endif // ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
|
528
|
+ #endif // HAS_BED_PROBE
|
493
|
529
|
|
494
|
530
|
#if HOTENDS > 1
|
|
531
|
+
|
495
|
532
|
float getNozzleOffset_mm(const axis_t axis, const extruder_t extruder) {
|
496
|
533
|
if (extruder - E0 >= HOTENDS) return 0;
|
497
|
534
|
return hotend_offset[axis][extruder - E0];
|
|
@@ -501,7 +538,18 @@ namespace ExtUI {
|
501
|
538
|
if (extruder - E0 >= HOTENDS) return;
|
502
|
539
|
hotend_offset[axis][extruder - E0] = value;
|
503
|
540
|
}
|
504
|
|
- #endif
|
|
541
|
+
|
|
542
|
+ /**
|
|
543
|
+ * The UI should call this if needs to guarantee the first
|
|
544
|
+ * nozzle offset is zero (such as when it doesn't allow the
|
|
545
|
+ * user to edit the offset the first nozzle).
|
|
546
|
+ */
|
|
547
|
+ void normalizeNozzleOffset(const axis_t axis) {
|
|
548
|
+ const float offs = hotend_offset[axis][0];
|
|
549
|
+ HOTEND_LOOP() hotend_offset[axis][e] -= offs;
|
|
550
|
+ }
|
|
551
|
+
|
|
552
|
+ #endif // HOTENDS > 1
|
505
|
553
|
|
506
|
554
|
#if ENABLED(BACKLASH_GCODE)
|
507
|
555
|
float getAxisBacklash_mm(const axis_t axis) { return backlash_distance_mm[axis]; }
|