@@ -105,13 +105,27 @@ struct measurements_t {
105
105
};
106
106
107
107
#if ENABLED(BACKLASH_GCODE)
108
- #define TEMPORARY_BACKLASH_CORRECTION (value ) REMEMBER(tbst, backlash.correction, value)
108
+ class restorer_correction {
109
+ const uint8_t val_;
110
+ public:
111
+ restorer_correction (const uint8_t temp_val) : val_(backlash.get_correction_uint8()) { backlash.set_correction_uint8 (temp_val); }
112
+ ~restorer_correction () { backlash.set_correction_uint8 (val_); }
113
+ };
114
+
115
+ #define TEMPORARY_BACKLASH_CORRECTION (value ) restorer_correction restorer_tbst (value)
109
116
#else
110
117
#define TEMPORARY_BACKLASH_CORRECTION (value )
111
118
#endif
112
119
113
120
#if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM)
114
- #define TEMPORARY_BACKLASH_SMOOTHING (value ) REMEMBER(tbsm, backlash.smoothing_mm, value)
121
+ class restorer_smoothing {
122
+ const float val_;
123
+ public:
124
+ restorer_smoothing (const float temp_val) : val_(backlash.get_smoothing_mm()) { backlash.set_smoothing_mm (temp_val); }
125
+ ~restorer_smoothing () { backlash.set_smoothing_mm (val_); }
126
+ };
127
+
128
+ #define TEMPORARY_BACKLASH_SMOOTHING (value ) restorer_smoothing restorer_tbsm (value)
115
129
#else
116
130
#define TEMPORARY_BACKLASH_SMOOTHING (value )
117
131
#endif
@@ -524,53 +538,53 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) {
524
538
525
539
{
526
540
// New scope for TEMPORARY_BACKLASH_CORRECTION
527
- TEMPORARY_BACKLASH_CORRECTION (all_off);
541
+ TEMPORARY_BACKLASH_CORRECTION (backlash. all_off );
528
542
TEMPORARY_BACKLASH_SMOOTHING (0 .0f );
529
543
530
544
probe_sides (m, uncertainty);
531
545
532
546
#if ENABLED(BACKLASH_GCODE)
533
547
534
548
#if HAS_X_CENTER
535
- backlash.distance_mm . x = (m.backlash [LEFT] + m.backlash [RIGHT]) / 2 ;
549
+ backlash.set_distance_mm (X_AXIS, (m.backlash [LEFT] + m.backlash [RIGHT]) / 2 ) ;
536
550
#elif ENABLED(CALIBRATION_MEASURE_LEFT)
537
- backlash.distance_mm . x = m.backlash [LEFT];
551
+ backlash.set_distance_mm (X_AXIS, m.backlash [LEFT]) ;
538
552
#elif ENABLED(CALIBRATION_MEASURE_RIGHT)
539
- backlash.distance_mm . x = m.backlash [RIGHT];
553
+ backlash.set_distance_mm (X_AXIS, m.backlash [RIGHT]) ;
540
554
#endif
541
555
542
556
#if HAS_Y_CENTER
543
- backlash.distance_mm . y = (m.backlash [FRONT] + m.backlash [BACK]) / 2 ;
557
+ backlash.set_distance_mm (Y_AXIS, (m.backlash [FRONT] + m.backlash [BACK]) / 2 ) ;
544
558
#elif ENABLED(CALIBRATION_MEASURE_FRONT)
545
- backlash.distance_mm . y = m.backlash [FRONT];
559
+ backlash.set_distance_mm (Y_AXIS, m.backlash [FRONT]) ;
546
560
#elif ENABLED(CALIBRATION_MEASURE_BACK)
547
- backlash.distance_mm . y = m.backlash [BACK];
561
+ backlash.set_distance_mm (Y_AXIS, m.backlash [BACK]) ;
548
562
#endif
549
563
550
- TERN_ (HAS_Z_AXIS, if (AXIS_CAN_CALIBRATE (Z)) backlash.distance_mm . z = m.backlash [TOP]);
564
+ TERN_ (HAS_Z_AXIS, if (AXIS_CAN_CALIBRATE (Z)) backlash.set_distance_mm (Z_AXIS, m.backlash [TOP]) );
551
565
552
566
#if HAS_I_CENTER
553
- backlash.distance_mm . i = (m.backlash [IMINIMUM] + m.backlash [IMAXIMUM]) / 2 ;
567
+ backlash.set_distance_mm (I_AXIS, (m.backlash [IMINIMUM] + m.backlash [IMAXIMUM]) / 2 ) ;
554
568
#elif ENABLED(CALIBRATION_MEASURE_IMIN)
555
- backlash.distance_mm . i = m.backlash [IMINIMUM];
569
+ backlash.set_distance_mm (I_AXIS, m.backlash [IMINIMUM]) ;
556
570
#elif ENABLED(CALIBRATION_MEASURE_IMAX)
557
- backlash.distance_mm . i = m.backlash [IMAXIMUM];
571
+ backlash.set_distance_mm (I_AXIS, m.backlash [IMAXIMUM]) ;
558
572
#endif
559
573
560
574
#if HAS_J_CENTER
561
- backlash.distance_mm . j = (m.backlash [JMINIMUM] + m.backlash [JMAXIMUM]) / 2 ;
575
+ backlash.set_distance_mm (J_AXIS, (m.backlash [JMINIMUM] + m.backlash [JMAXIMUM]) / 2 ) ;
562
576
#elif ENABLED(CALIBRATION_MEASURE_JMIN)
563
- backlash.distance_mm . j = m.backlash [JMINIMUM];
577
+ backlash.set_distance_mm (J_AXIS, m.backlash [JMINIMUM]) ;
564
578
#elif ENABLED(CALIBRATION_MEASURE_JMAX)
565
- backlash.distance_mm . j = m.backlash [JMAXIMUM];
579
+ backlash.set_distance_mm (J_AXIS, m.backlash [JMAXIMUM]) ;
566
580
#endif
567
581
568
582
#if HAS_K_CENTER
569
- backlash.distance_mm . k = (m.backlash [KMINIMUM] + m.backlash [KMAXIMUM]) / 2 ;
583
+ backlash.set_distance_mm (K_AXIS, (m.backlash [KMINIMUM] + m.backlash [KMAXIMUM]) / 2 ) ;
570
584
#elif ENABLED(CALIBRATION_MEASURE_KMIN)
571
- backlash.distance_mm . k = m.backlash [KMINIMUM];
585
+ backlash.set_distance_mm (K_AXIS, m.backlash [KMINIMUM]) ;
572
586
#elif ENABLED(CALIBRATION_MEASURE_KMAX)
573
- backlash.distance_mm . k = m.backlash [KMAXIMUM];
587
+ backlash.set_distance_mm (K_AXIS, m.backlash [KMAXIMUM]) ;
574
588
#endif
575
589
576
590
#endif // BACKLASH_GCODE
@@ -581,7 +595,7 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) {
581
595
// allowed directions to take up any backlash
582
596
{
583
597
// New scope for TEMPORARY_BACKLASH_CORRECTION
584
- TEMPORARY_BACKLASH_CORRECTION (all_on);
598
+ TEMPORARY_BACKLASH_CORRECTION (backlash. all_on );
585
599
TEMPORARY_BACKLASH_SMOOTHING (0 .0f );
586
600
const xyz_float_t move = LINEAR_AXIS_ARRAY (
587
601
AXIS_CAN_CALIBRATE (X) * 3 , AXIS_CAN_CALIBRATE (Y) * 3 , AXIS_CAN_CALIBRATE (Z) * 3 ,
@@ -611,7 +625,7 @@ inline void update_measurements(measurements_t &m, const AxisEnum axis) {
611
625
* - Call calibrate_backlash() beforehand for best accuracy
612
626
*/
613
627
inline void calibrate_toolhead (measurements_t &m, const float uncertainty, const uint8_t extruder) {
614
- TEMPORARY_BACKLASH_CORRECTION (all_on);
628
+ TEMPORARY_BACKLASH_CORRECTION (backlash. all_on );
615
629
TEMPORARY_BACKLASH_SMOOTHING (0 .0f );
616
630
617
631
TERN (HAS_MULTI_HOTEND, set_nozzle (m, extruder), UNUSED (extruder));
@@ -648,7 +662,7 @@ inline void calibrate_toolhead(measurements_t &m, const float uncertainty, const
648
662
* uncertainty in - How far away from the object to begin probing
649
663
*/
650
664
inline void calibrate_all_toolheads (measurements_t &m, const float uncertainty) {
651
- TEMPORARY_BACKLASH_CORRECTION (all_on);
665
+ TEMPORARY_BACKLASH_CORRECTION (backlash. all_on );
652
666
TEMPORARY_BACKLASH_SMOOTHING (0 .0f );
653
667
654
668
HOTEND_LOOP () calibrate_toolhead (m, uncertainty, e);
@@ -674,7 +688,7 @@ inline void calibrate_all() {
674
688
675
689
TERN_ (HAS_HOTEND_OFFSET, reset_hotend_offsets ());
676
690
677
- TEMPORARY_BACKLASH_CORRECTION (all_on);
691
+ TEMPORARY_BACKLASH_CORRECTION (backlash. all_on );
678
692
TEMPORARY_BACKLASH_SMOOTHING (0 .0f );
679
693
680
694
// Do a fast and rough calibration of the toolheads
0 commit comments