Browse Source

Fix BACKLASH_COMPENSATION compiler issues (#15307)

Jason Smith 5 years ago
parent
commit
514223f960

+ 3
- 10
Marlin/src/feature/backlash.h View File

28
 
28
 
29
 class Backlash {
29
 class Backlash {
30
 public:
30
 public:
31
-  #ifdef BACKLASH_DISTANCE_MM
32
-    #if ENABLED(BACKLASH_GCODE)
33
-      static float distance_mm[XYZ];
34
-    #else
35
-      static const float distance_mm[XYZ];
36
-      //static constexpr float distance_mm[XYZ] = BACKLASH_DISTANCE_MM; // compiler barks at this
37
-    #endif
38
-  #endif
39
   #if ENABLED(BACKLASH_GCODE)
31
   #if ENABLED(BACKLASH_GCODE)
32
+    static float distance_mm[XYZ];
40
     static uint8_t correction;
33
     static uint8_t correction;
41
     #ifdef BACKLASH_SMOOTHING_MM
34
     #ifdef BACKLASH_SMOOTHING_MM
42
       static float smoothing_mm;
35
       static float smoothing_mm;
43
     #endif
36
     #endif
37
+
44
     static inline void set_correction(const float &v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; }
38
     static inline void set_correction(const float &v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; }
45
     static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
39
     static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
46
   #else
40
   #else
47
     static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
41
     static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
42
+    static const float distance_mm[XYZ];
48
     #ifdef BACKLASH_SMOOTHING_MM
43
     #ifdef BACKLASH_SMOOTHING_MM
49
       static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM;
44
       static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM;
50
     #endif
45
     #endif
51
-    static inline void set_correction(float) { }
52
-    static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
53
   #endif
46
   #endif
54
 
47
 
55
   #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
48
   #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)

+ 10
- 2
Marlin/src/inc/SanityCheck.h View File

2324
   #endif
2324
   #endif
2325
 #endif
2325
 #endif
2326
 
2326
 
2327
-#if ENABLED(BACKLASH_COMPENSATION) && IS_CORE
2328
-  #error "BACKLASH_COMPENSATION is incompatible with CORE kinematics."
2327
+#if ENABLED(BACKLASH_COMPENSATION)
2328
+  #if IS_CORE
2329
+    #error "BACKLASH_COMPENSATION is incompatible with CORE kinematics."
2330
+  #endif
2331
+  #ifndef BACKLASH_DISTANCE_MM
2332
+    #error "BACKLASH_COMPENSATION requires BACKLASH_DISTANCE_MM"
2333
+  #endif
2334
+  #ifndef BACKLASH_CORRECTION
2335
+    #error "BACKLASH_COMPENSATION requires BACKLASH_CORRECTION"
2336
+  #endif
2329
 #endif
2337
 #endif
2330
 
2338
 
2331
 #if ENABLED(GRADIENT_MIX) && MIXING_VIRTUAL_TOOLS < 2
2339
 #if ENABLED(GRADIENT_MIX) && MIXING_VIRTUAL_TOOLS < 2

+ 10
- 18
Marlin/src/module/configuration_store.cpp View File

1189
     // Backlash Compensation
1189
     // Backlash Compensation
1190
     //
1190
     //
1191
     {
1191
     {
1192
-      #ifdef BACKLASH_DISTANCE_MM
1192
+      #if ENABLED(BACKLASH_GCODE)
1193
         const float (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
1193
         const float (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
1194
-      #else
1195
-        const float backlash_distance_mm[XYZ] = { 0 };
1196
-      #endif
1197
-      #if ENABLED(BACKLASH_COMPENSATION)
1198
         const uint8_t &backlash_correction = backlash.correction;
1194
         const uint8_t &backlash_correction = backlash.correction;
1199
       #else
1195
       #else
1196
+        const float backlash_distance_mm[XYZ] = { 0 };
1200
         const uint8_t backlash_correction = 0;
1197
         const uint8_t backlash_correction = 0;
1201
       #endif
1198
       #endif
1202
-      #ifdef BACKLASH_SMOOTHING_MM
1199
+      #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM)
1203
         const float &backlash_smoothing_mm = backlash.smoothing_mm;
1200
         const float &backlash_smoothing_mm = backlash.smoothing_mm;
1204
       #else
1201
       #else
1205
         const float backlash_smoothing_mm = 3;
1202
         const float backlash_smoothing_mm = 3;
1992
       // Backlash Compensation
1989
       // Backlash Compensation
1993
       //
1990
       //
1994
       {
1991
       {
1995
-        #ifdef BACKLASH_DISTANCE_MM
1992
+        #if ENABLED(BACKLASH_GCODE)
1996
           float (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
1993
           float (&backlash_distance_mm)[XYZ] = backlash.distance_mm;
1997
-        #else
1998
-          float backlash_distance_mm[XYZ];
1999
-        #endif
2000
-        #if ENABLED(BACKLASH_COMPENSATION)
2001
           uint8_t &backlash_correction = backlash.correction;
1994
           uint8_t &backlash_correction = backlash.correction;
2002
         #else
1995
         #else
1996
+          float backlash_distance_mm[XYZ];
2003
           uint8_t backlash_correction;
1997
           uint8_t backlash_correction;
2004
         #endif
1998
         #endif
2005
-        #ifdef BACKLASH_SMOOTHING_MM
1999
+        #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM)
2006
           float &backlash_smoothing_mm = backlash.smoothing_mm;
2000
           float &backlash_smoothing_mm = backlash.smoothing_mm;
2007
         #else
2001
         #else
2008
           float backlash_smoothing_mm;
2002
           float backlash_smoothing_mm;
2293
 
2287
 
2294
   #if ENABLED(BACKLASH_GCODE)
2288
   #if ENABLED(BACKLASH_GCODE)
2295
     backlash.correction = (BACKLASH_CORRECTION) * 255;
2289
     backlash.correction = (BACKLASH_CORRECTION) * 255;
2296
-    #ifdef BACKLASH_DISTANCE_MM
2297
-      constexpr float tmp[XYZ] = BACKLASH_DISTANCE_MM;
2298
-      backlash.distance_mm[X_AXIS] = tmp[X_AXIS];
2299
-      backlash.distance_mm[Y_AXIS] = tmp[Y_AXIS];
2300
-      backlash.distance_mm[Z_AXIS] = tmp[Z_AXIS];
2301
-    #endif
2290
+    constexpr float tmp[XYZ] = BACKLASH_DISTANCE_MM;
2291
+    backlash.distance_mm[X_AXIS] = tmp[X_AXIS];
2292
+    backlash.distance_mm[Y_AXIS] = tmp[Y_AXIS];
2293
+    backlash.distance_mm[Z_AXIS] = tmp[Z_AXIS];
2302
     #ifdef BACKLASH_SMOOTHING_MM
2294
     #ifdef BACKLASH_SMOOTHING_MM
2303
       backlash.smoothing_mm = BACKLASH_SMOOTHING_MM;
2295
       backlash.smoothing_mm = BACKLASH_SMOOTHING_MM;
2304
     #endif
2296
     #endif

Loading…
Cancel
Save