Przeglądaj źródła

Followup to hotend_offset[Z] patch

Scott Lahteine 6 lat temu
rodzic
commit
d1c9517903

+ 9
- 14
Marlin/src/gcode/config/M218.cpp Wyświetl plik

22
 
22
 
23
 #include "../../inc/MarlinConfig.h"
23
 #include "../../inc/MarlinConfig.h"
24
 
24
 
25
-#if HOTENDS > 1
25
+#if HAS_HOTEND_OFFSET
26
 
26
 
27
 #include "../gcode.h"
27
 #include "../gcode.h"
28
 #include "../../module/motion.h"
28
 #include "../../module/motion.h"
37
  *   T<tool>
37
  *   T<tool>
38
  *   X<xoffset>
38
  *   X<xoffset>
39
  *   Y<yoffset>
39
  *   Y<yoffset>
40
- *   Z<zoffset> - Available with DUAL_X_CARRIAGE, SWITCHING_NOZZLE and PARKING_EXTRUDER
40
+ *   Z<zoffset>
41
  */
41
  */
42
 void GcodeSuite::M218() {
42
 void GcodeSuite::M218() {
43
   if (get_target_extruder_from_command() || target_extruder == 0) return;
43
   if (get_target_extruder_from_command() || target_extruder == 0) return;
51
     hotend_offset[Y_AXIS][target_extruder] = parser.value_linear_units();
51
     hotend_offset[Y_AXIS][target_extruder] = parser.value_linear_units();
52
     report = false;
52
     report = false;
53
   }
53
   }
54
-
54
+  if (parser.seenval('Z')) {
55
-  #if HAS_HOTEND_OFFSET_Z
55
+    hotend_offset[Z_AXIS][target_extruder] = parser.value_linear_units();
56
-    if (parser.seenval('Z')) {
56
+    report = false;
57
-      hotend_offset[Z_AXIS][target_extruder] = parser.value_linear_units();
57
+  }
58
-      report = false;
59
-    }
60
-  #endif
61
 
58
 
62
   if (report) {
59
   if (report) {
63
     SERIAL_ECHO_START();
60
     SERIAL_ECHO_START();
67
       SERIAL_ECHO(hotend_offset[X_AXIS][e]);
64
       SERIAL_ECHO(hotend_offset[X_AXIS][e]);
68
       SERIAL_CHAR(',');
65
       SERIAL_CHAR(',');
69
       SERIAL_ECHO(hotend_offset[Y_AXIS][e]);
66
       SERIAL_ECHO(hotend_offset[Y_AXIS][e]);
70
-      #if HAS_HOTEND_OFFSET_Z
67
+      SERIAL_CHAR(',');
71
-        SERIAL_CHAR(',');
68
+      SERIAL_ECHO(hotend_offset[Z_AXIS][e]);
72
-        SERIAL_ECHO(hotend_offset[Z_AXIS][e]);
73
-      #endif
74
     }
69
     }
75
     SERIAL_EOL();
70
     SERIAL_EOL();
76
   }
71
   }
81
   #endif
76
   #endif
82
 }
77
 }
83
 
78
 
84
-#endif // HOTENDS > 1
79
+#endif // HAS_HOTEND_OFFSET

+ 1
- 1
Marlin/src/gcode/feature/pause/M125.cpp Wyświetl plik

65
   // Lift Z axis
65
   // Lift Z axis
66
   if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
66
   if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
67
 
67
 
68
-  #if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE) && DISABLED(DELTA)
68
+  #if HAS_HOTEND_OFFSET && DISABLED(DUAL_X_CARRIAGE) && DISABLED(DELTA)
69
     park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
69
     park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
70
     park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
70
     park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
71
   #endif
71
   #endif

+ 1
- 1
Marlin/src/gcode/feature/pause/M600.cpp Wyświetl plik

87
   if (parser.seenval('X')) park_point.x = parser.linearval('X');
87
   if (parser.seenval('X')) park_point.x = parser.linearval('X');
88
   if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
88
   if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
89
 
89
 
90
-  #if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE) && DISABLED(DELTA)
90
+  #if HAS_HOTEND_OFFSET && DISABLED(DUAL_X_CARRIAGE) && DISABLED(DELTA)
91
     park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
91
     park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
92
     park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
92
     park_point.y += (active_extruder ? hotend_offset[Y_AXIS][active_extruder] : 0);
93
   #endif
93
   #endif

+ 2
- 0
Marlin/src/inc/Conditionals_LCD.h Wyświetl plik

458
 
458
 
459
 #define DO_SWITCH_EXTRUDER (ENABLED(SWITCHING_EXTRUDER) && (DISABLED(SWITCHING_NOZZLE) || SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR))
459
 #define DO_SWITCH_EXTRUDER (ENABLED(SWITCHING_EXTRUDER) && (DISABLED(SWITCHING_NOZZLE) || SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR))
460
 
460
 
461
+#define HAS_HOTEND_OFFSET (HOTENDS > 1)
462
+
461
 /**
463
 /**
462
  * DISTINCT_E_FACTORS affects how some E factors are accessed
464
  * DISTINCT_E_FACTORS affects how some E factors are accessed
463
  */
465
  */

+ 2
- 3
Marlin/src/inc/Conditionals_post.h Wyświetl plik

413
 /**
413
 /**
414
  * Default hotend offsets, if not defined
414
  * Default hotend offsets, if not defined
415
  */
415
  */
416
-#define HAS_HOTEND_OFFSET_Z (HOTENDS > 1 && (ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER)))
417
 #if HOTENDS > 1
416
 #if HOTENDS > 1
418
   #ifndef HOTEND_OFFSET_X
417
   #ifndef HOTEND_OFFSET_X
419
     #define HOTEND_OFFSET_X { 0 } // X offsets for each extruder
418
     #define HOTEND_OFFSET_X { 0 } // X offsets for each extruder
421
   #ifndef HOTEND_OFFSET_Y
420
   #ifndef HOTEND_OFFSET_Y
422
     #define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder
421
     #define HOTEND_OFFSET_Y { 0 } // Y offsets for each extruder
423
   #endif
422
   #endif
424
-  #if HAS_HOTEND_OFFSET_Z && !defined(HOTEND_OFFSET_Z)
423
+  #ifndef HOTEND_OFFSET_Z
425
-    #define HOTEND_OFFSET_Z { 0 }
424
+    #define HOTEND_OFFSET_Z { 0 } // Z offsets for each extruder
426
   #endif
425
   #endif
427
 #endif
426
 #endif
428
 
427
 

+ 7
- 17
Marlin/src/module/configuration_store.cpp Wyświetl plik

126
 
126
 
127
   float home_offset[XYZ];                               // M206 XYZ
127
   float home_offset[XYZ];                               // M206 XYZ
128
 
128
 
129
-  #if HOTENDS > 1
129
+  #if HAS_HOTEND_OFFSET
130
     float hotend_offset[XYZ][HOTENDS - 1];              // M218 XYZ
130
     float hotend_offset[XYZ][HOTENDS - 1];              // M218 XYZ
131
   #endif
131
   #endif
132
 
132
 
433
     #endif
433
     #endif
434
     EEPROM_WRITE(home_offset);
434
     EEPROM_WRITE(home_offset);
435
 
435
 
436
-    #if HOTENDS > 1
436
+    #if HAS_HOTEND_OFFSET
437
       // Skip hotend 0 which must be 0
437
       // Skip hotend 0 which must be 0
438
       for (uint8_t e = 1; e < HOTENDS; e++)
438
       for (uint8_t e = 1; e < HOTENDS; e++)
439
         LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
439
         LOOP_XYZ(i) EEPROM_WRITE(hotend_offset[i][e]);
1038
       // Hotend Offsets, if any
1038
       // Hotend Offsets, if any
1039
       //
1039
       //
1040
 
1040
 
1041
-      #if HOTENDS > 1
1041
+      #if HAS_HOTEND_OFFSET
1042
         // Skip hotend 0 which must be 0
1042
         // Skip hotend 0 which must be 0
1043
         for (uint8_t e = 1; e < HOTENDS; e++)
1043
         for (uint8_t e = 1; e < HOTENDS; e++)
1044
           LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
1044
           LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
1749
     ZERO(home_offset);
1749
     ZERO(home_offset);
1750
   #endif
1750
   #endif
1751
 
1751
 
1752
-  #if HOTENDS > 1
1752
+  #if HAS_HOTEND_OFFSET
1753
-    constexpr float tmp4[XYZ][HOTENDS] = {
1753
+    constexpr float tmp4[XYZ][HOTENDS] = { HOTEND_OFFSET_X, HOTEND_OFFSET_Y, HOTEND_OFFSET_Z };
1754
-      HOTEND_OFFSET_X,
1755
-      HOTEND_OFFSET_Y
1756
-      #ifdef HOTEND_OFFSET_Z
1757
-        , HOTEND_OFFSET_Z
1758
-      #else
1759
-        , { 0 }
1760
-      #endif
1761
-    };
1762
     static_assert(
1754
     static_assert(
1763
       tmp4[X_AXIS][0] == 0 && tmp4[Y_AXIS][0] == 0 && tmp4[Z_AXIS][0] == 0,
1755
       tmp4[X_AXIS][0] == 0 && tmp4[Y_AXIS][0] == 0 && tmp4[Z_AXIS][0] == 0,
1764
       "Offsets for the first hotend must be 0.0."
1756
       "Offsets for the first hotend must be 0.0."
2163
       SERIAL_ECHOLNPAIR_P(port, " Z", LINEAR_UNIT(home_offset[Z_AXIS]));
2155
       SERIAL_ECHOLNPAIR_P(port, " Z", LINEAR_UNIT(home_offset[Z_AXIS]));
2164
     #endif
2156
     #endif
2165
 
2157
 
2166
-    #if HOTENDS > 1
2158
+    #if HAS_HOTEND_OFFSET
2167
       if (!forReplay) {
2159
       if (!forReplay) {
2168
         CONFIG_ECHO_START;
2160
         CONFIG_ECHO_START;
2169
         SERIAL_ECHOLNPGM_P(port, "Hotend offsets:");
2161
         SERIAL_ECHOLNPGM_P(port, "Hotend offsets:");
2173
         SERIAL_ECHOPAIR_P(port, "  M218 T", (int)e);
2165
         SERIAL_ECHOPAIR_P(port, "  M218 T", (int)e);
2174
         SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(hotend_offset[X_AXIS][e]));
2166
         SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(hotend_offset[X_AXIS][e]));
2175
         SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(hotend_offset[Y_AXIS][e]));
2167
         SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(hotend_offset[Y_AXIS][e]));
2176
-        #if HAS_HOTEND_OFFSET_Z
2168
+        SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(hotend_offset[Z_AXIS][e]));
2177
-          SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(hotend_offset[Z_AXIS][e]));
2178
-        #endif
2179
         SERIAL_EOL_P(port);
2169
         SERIAL_EOL_P(port);
2180
       }
2170
       }
2181
     #endif
2171
     #endif

+ 1
- 1
Marlin/src/module/delta.cpp Wyświetl plik

102
   }while(0)
102
   }while(0)
103
 
103
 
104
 void inverse_kinematics(const float raw[XYZ]) {
104
 void inverse_kinematics(const float raw[XYZ]) {
105
-  #if HOTENDS > 1
105
+  #if HAS_HOTEND_OFFSET
106
     // Delta hotend offsets must be applied in Cartesian space with no "spoofing"
106
     // Delta hotend offsets must be applied in Cartesian space with no "spoofing"
107
     const float pos[XYZ] = {
107
     const float pos[XYZ] = {
108
       raw[X_AXIS] - hotend_offset[X_AXIS][active_extruder],
108
       raw[X_AXIS] - hotend_offset[X_AXIS][active_extruder],

+ 1
- 1
Marlin/src/module/motion.cpp Wyświetl plik

92
 uint8_t active_extruder; // = 0;
92
 uint8_t active_extruder; // = 0;
93
 
93
 
94
 // Extruder offsets
94
 // Extruder offsets
95
-#if HOTENDS > 1
95
+#if HAS_HOTEND_OFFSET
96
   float hotend_offset[XYZ][HOTENDS]; // Initialized by settings.load()
96
   float hotend_offset[XYZ][HOTENDS]; // Initialized by settings.load()
97
 #endif
97
 #endif
98
 
98
 

+ 1
- 1
Marlin/src/module/motion.h Wyświetl plik

78
 
78
 
79
 extern uint8_t active_extruder;
79
 extern uint8_t active_extruder;
80
 
80
 
81
-#if HOTENDS > 1
81
+#if HAS_HOTEND_OFFSET
82
   extern float hotend_offset[XYZ][HOTENDS];
82
   extern float hotend_offset[XYZ][HOTENDS];
83
 #endif
83
 #endif
84
 
84
 

Ładowanie…
Anuluj
Zapisz