Scott Lahteine преди 5 години
родител
ревизия
aeec9ef76b
променени са 4 файла, в които са добавени 28 реда и са изтрити 21 реда
  1. 6
    4
      Marlin/src/feature/backlash.cpp
  2. 1
    5
      Marlin/src/feature/backlash.h
  3. 5
    2
      Marlin/src/gcode/calibrate/G425.cpp
  4. 16
    10
      Marlin/src/module/configuration_store.cpp

+ 6
- 4
Marlin/src/feature/backlash.cpp Целия файл

@@ -20,11 +20,13 @@
20 20
  *
21 21
  */
22 22
 
23
-#include "../Marlin.h"
23
+#include "../inc/MarlinConfigPre.h"
24 24
 
25 25
 #if ENABLED(BACKLASH_COMPENSATION)
26 26
 
27 27
 #include "backlash.h"
28
+
29
+#include "../module/motion.h"
28 30
 #include "../module/planner.h"
29 31
 
30 32
 #if ENABLED(BACKLASH_GCODE)
@@ -75,10 +77,10 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
75 77
     // to segments where there is no direction change.
76 78
     static int32_t residual_error[XYZ] = { 0 };
77 79
   #else
78
-    // No leftover residual error from segment to segment
79
-    int32_t residual_error[XYZ] = { 0 };
80 80
     // No direction change, no correction.
81 81
     if (!changed_dir) return;
82
+    // No leftover residual error from segment to segment
83
+    int32_t residual_error[XYZ] = { 0 };
82 84
   #endif
83 85
 
84 86
   const float f_corr = float(correction) / 255.0f;
@@ -100,7 +102,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
100 102
           if (reversing == (error_correction < 0)) {
101 103
             if (segment_proportion == 0)
102 104
               segment_proportion = MIN(1.0f, block->millimeters / smoothing_mm);
103
-            error_correction = ceil(segment_proportion * error_correction);
105
+            error_correction = CEIL(segment_proportion * error_correction);
104 106
           }
105 107
           else
106 108
             error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps

+ 1
- 5
Marlin/src/feature/backlash.h Целия файл

@@ -36,7 +36,7 @@ public:
36 36
     #endif
37 37
     static inline void set_correction(const float &v) { correction = MAX(0, MIN(1.0, v)) * all_on; }
38 38
     static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
39
-  #elif ENABLED(BACKLASH_COMPENSATION)
39
+  #else
40 40
     static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
41 41
     #ifdef BACKLASH_DISTANCE_MM
42 42
       static constexpr float distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
@@ -46,10 +46,6 @@ public:
46 46
     #endif
47 47
     static inline void set_correction(float) { }
48 48
     static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
49
-  #else
50
-    static constexpr uint8_t correction = 0;
51
-    static inline void set_correction(float) { }
52
-    static inline float get_correction() { return 0; }
53 49
   #endif
54 50
 
55 51
   #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)

+ 5
- 2
Marlin/src/gcode/calibrate/G425.cpp Целия файл

@@ -25,14 +25,17 @@
25 25
 #if ENABLED(CALIBRATION_GCODE)
26 26
 
27 27
 #include "../gcode.h"
28
+
29
+#if ENABLED(BACKLASH_GCODE)
30
+  #include "../../feature/backlash.h"
31
+#endif
32
+
28 33
 #include "../../lcd/ultralcd.h"
29 34
 #include "../../module/motion.h"
30 35
 #include "../../module/planner.h"
31 36
 #include "../../module/tool_change.h"
32 37
 #include "../../module/endstops.h"
33 38
 #include "../../feature/bedlevel/bedlevel.h"
34
-#include "../../feature/backlash.h"
35
-
36 39
 
37 40
 /**
38 41
  * G425 backs away from the calibration object by various distances

+ 16
- 10
Marlin/src/module/configuration_store.cpp Целия файл

@@ -1177,17 +1177,20 @@ void MarlinSettings::postprocess() {
1177 1177
     // Backlash Compensation
1178 1178
     //
1179 1179
     {
1180
+      #ifdef BACKLASH_DISTANCE_MM
1181
+        const float (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
1182
+      #else
1183
+        const float backlash_distance_mm[XYZ] = { 0 };
1184
+      #endif
1180 1185
       #if ENABLED(BACKLASH_COMPENSATION)
1181
-        const float   (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
1182
-        const uint8_t &backlash_correction         = backlash.correction;
1186
+        const uint8_t &backlash_correction = backlash.correction;
1183 1187
       #else
1184
-        const float    backlash_distance_mm[XYZ]   = { 0 };
1185
-        const uint8_t  backlash_correction         = 0;
1188
+        const uint8_t backlash_correction = 0;
1186 1189
       #endif
1187 1190
       #ifdef BACKLASH_SMOOTHING_MM
1188
-        const float   &backlash_smoothing_mm       = backlash.smoothing_mm;
1191
+        const float &backlash_smoothing_mm = backlash.smoothing_mm;
1189 1192
       #else
1190
-        const float    backlash_smoothing_mm       = 3;
1193
+        const float backlash_smoothing_mm = 3;
1191 1194
       #endif
1192 1195
       _FIELD_TEST(backlash_distance_mm);
1193 1196
       EEPROM_WRITE(backlash_distance_mm[X_AXIS]);
@@ -1962,17 +1965,20 @@ void MarlinSettings::postprocess() {
1962 1965
       // Backlash Compensation
1963 1966
       //
1964 1967
       {
1968
+        #ifdef BACKLASH_DISTANCE_MM
1969
+          float (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
1970
+        #else
1971
+          float backlash_distance_mm[XYZ];
1972
+        #endif
1965 1973
         #if ENABLED(BACKLASH_COMPENSATION)
1966
-          float   (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
1967
-          uint8_t &backlash_correction         = backlash.correction;
1974
+          uint8_t &backlash_correction = backlash.correction;
1968 1975
         #else
1969
-          float   backlash_distance_mm[XYZ];
1970 1976
           uint8_t backlash_correction;
1971 1977
         #endif
1972 1978
         #ifdef BACKLASH_SMOOTHING_MM
1973 1979
           float &backlash_smoothing_mm = backlash.smoothing_mm;
1974 1980
         #else
1975
-          float  backlash_smoothing_mm;
1981
+          float backlash_smoothing_mm;
1976 1982
         #endif
1977 1983
         _FIELD_TEST(backlash_distance_mm);
1978 1984
         EEPROM_READ(backlash_distance_mm[X_AXIS]);

Loading…
Отказ
Запис