Browse Source

Backlash linker error workaround

Fix #14045
Scott Lahteine 6 years ago
parent
commit
cfca07852a
2 changed files with 16 additions and 9 deletions
  1. 8
    3
      Marlin/src/feature/backlash.cpp
  2. 8
    6
      Marlin/src/feature/backlash.h

+ 8
- 3
Marlin/src/feature/backlash.cpp View File

29
 #include "../module/motion.h"
29
 #include "../module/motion.h"
30
 #include "../module/planner.h"
30
 #include "../module/planner.h"
31
 
31
 
32
-#if ENABLED(BACKLASH_GCODE)
33
-  uint8_t Backlash::correction = (BACKLASH_CORRECTION) * 0xFF;
34
-  #ifdef BACKLASH_DISTANCE_MM
32
+#ifdef BACKLASH_DISTANCE_MM
33
+  #if ENABLED(BACKLASH_GCODE)
35
     float Backlash::distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
34
     float Backlash::distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
35
+  #else
36
+    const float Backlash::distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
36
   #endif
37
   #endif
38
+#endif
39
+
40
+#if ENABLED(BACKLASH_GCODE)
41
+  uint8_t Backlash::correction = (BACKLASH_CORRECTION) * 0xFF;
37
   #ifdef BACKLASH_SMOOTHING_MM
42
   #ifdef BACKLASH_SMOOTHING_MM
38
     float Backlash::smoothing_mm = BACKLASH_SMOOTHING_MM;
43
     float Backlash::smoothing_mm = BACKLASH_SMOOTHING_MM;
39
   #endif
44
   #endif

+ 8
- 6
Marlin/src/feature/backlash.h View File

26
 
26
 
27
 class Backlash {
27
 class Backlash {
28
 public:
28
 public:
29
-  #if ENABLED(BACKLASH_GCODE)
30
-    static uint8_t correction;
31
-    #ifdef BACKLASH_DISTANCE_MM
29
+  #ifdef BACKLASH_DISTANCE_MM
30
+    #if ENABLED(BACKLASH_GCODE)
32
       static float distance_mm[XYZ];
31
       static float distance_mm[XYZ];
32
+    #else
33
+      static const float distance_mm[XYZ];
34
+      //static constexpr float distance_mm[XYZ] = BACKLASH_DISTANCE_MM; // compiler barks at this
33
     #endif
35
     #endif
36
+  #endif
37
+  #if ENABLED(BACKLASH_GCODE)
38
+    static uint8_t correction;
34
     #ifdef BACKLASH_SMOOTHING_MM
39
     #ifdef BACKLASH_SMOOTHING_MM
35
       static float smoothing_mm;
40
       static float smoothing_mm;
36
     #endif
41
     #endif
38
     static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
43
     static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
39
   #else
44
   #else
40
     static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
45
     static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
41
-    #ifdef BACKLASH_DISTANCE_MM
42
-      static constexpr float distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
43
-    #endif
44
     #ifdef BACKLASH_SMOOTHING_MM
46
     #ifdef BACKLASH_SMOOTHING_MM
45
       static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM;
47
       static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM;
46
     #endif
48
     #endif

Loading…
Cancel
Save