Browse Source

♻️ More updates for multi-axis

Scott Lahteine 2 years ago
parent
commit
1f322b565f

+ 0
- 1
Marlin/src/core/types.h View File

181
 };
181
 };
182
 
182
 
183
 typedef IF<(NUM_AXIS_ENUMS > 8), uint16_t, uint8_t>::type axis_bits_t;
183
 typedef IF<(NUM_AXIS_ENUMS > 8), uint16_t, uint8_t>::type axis_bits_t;
184
-typedef IF<(NUM_AXES > 8), uint16_t, uint8_t>::type linear_axis_bits_t;
185
 
184
 
186
 //
185
 //
187
 // Loop over axes
186
 // Loop over axes

+ 2
- 1
Marlin/src/gcode/control/M17_M18_M84.cpp View File

23
 #include "../gcode.h"
23
 #include "../gcode.h"
24
 #include "../../MarlinCore.h" // for stepper_inactive_time, disable_e_steppers
24
 #include "../../MarlinCore.h" // for stepper_inactive_time, disable_e_steppers
25
 #include "../../lcd/marlinui.h"
25
 #include "../../lcd/marlinui.h"
26
+#include "../../module/motion.h" // for e_axis_mask
26
 #include "../../module/stepper.h"
27
 #include "../../module/stepper.h"
27
 
28
 
28
 #if ENABLED(AUTO_BED_LEVELING_UBL)
29
 #if ENABLED(AUTO_BED_LEVELING_UBL)
43
           selected.bits = _BV(INDEX_OF_AXIS(E_AXIS, e));
44
           selected.bits = _BV(INDEX_OF_AXIS(E_AXIS, e));
44
       }
45
       }
45
       else
46
       else
46
-        selected.bits = selected.e_bits();
47
+        selected.bits = e_axis_mask;
47
     }
48
     }
48
   #endif
49
   #endif
49
   selected.bits |= NUM_AXIS_GANG(
50
   selected.bits |= NUM_AXIS_GANG(

+ 3
- 2
Marlin/src/gcode/feature/clean/G12.cpp View File

45
  *  X, Y, Z          : Specify axes to move during cleaning. Default: ALL.
45
  *  X, Y, Z          : Specify axes to move during cleaning. Default: ALL.
46
  */
46
  */
47
 void GcodeSuite::G12() {
47
 void GcodeSuite::G12() {
48
+
48
   // Don't allow nozzle cleaning without homing first
49
   // Don't allow nozzle cleaning without homing first
49
-  if (homing_needed_error(linear_bits & ~TERN0(NOZZLE_CLEAN_NO_Z, Z_AXIS) & ~TERN0(NOZZLE_CLEAN_NO_Y, Y_AXIS)))
50
-    return;
50
+  constexpr main_axes_bits_t clean_axis_mask = main_axes_mask & ~TERN0(NOZZLE_CLEAN_NO_Z, Z_AXIS) & ~TERN0(NOZZLE_CLEAN_NO_Y, Y_AXIS);
51
+  if (homing_needed_error(clean_axis_mask)) return;
51
 
52
 
52
   #ifdef WIPE_SEQUENCE_COMMANDS
53
   #ifdef WIPE_SEQUENCE_COMMANDS
53
     if (!parser.seen_any()) {
54
     if (!parser.seen_any()) {

+ 4
- 4
Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp View File

80
     dwin_string.set();
80
     dwin_string.set();
81
     if (blink)
81
     if (blink)
82
       dwin_string.add(value);
82
       dwin_string.add(value);
83
-    else if (!TEST(axis_homed, axis))
83
+    else if (!TEST(axes_homed, axis))
84
       while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?');
84
       while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?');
85
-    else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !TEST(axis_trusted, axis))
85
+    else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !TEST(axes_trusted, axis))
86
       dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR("       ") : PSTR("    "));
86
       dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR("       ") : PSTR("    "));
87
     else
87
     else
88
       dwin_string.add(value);
88
       dwin_string.add(value);
105
     if (blink)
105
     if (blink)
106
       dwin_string.add(value);
106
       dwin_string.add(value);
107
     else {
107
     else {
108
-      if (!TEST(axis_homed, axis))
108
+      if (!TEST(axes_homed, axis))
109
         while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?');
109
         while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?');
110
       else {
110
       else {
111
         #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
111
         #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
112
-          if (!TEST(axis_trusted, axis))
112
+          if (!TEST(axes_trusted, axis))
113
             dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR("       ") : PSTR("    "));
113
             dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR("       ") : PSTR("    "));
114
           else
114
           else
115
         #endif
115
         #endif

+ 6
- 17
Marlin/src/module/motion.cpp View File

1382
 
1382
 
1383
 #if HAS_ENDSTOPS
1383
 #if HAS_ENDSTOPS
1384
 
1384
 
1385
-  linear_axis_bits_t axis_homed, axis_trusted; // = 0
1385
+  main_axes_bits_t axes_homed, axes_trusted; // = 0
1386
 
1386
 
1387
-  linear_axis_bits_t axes_should_home(linear_axis_bits_t axis_bits/*=linear_bits*/) {
1388
-    auto set_should = [](linear_axis_bits_t &b, AxisEnum a) {
1387
+  main_axes_bits_t axes_should_home(main_axes_bits_t axis_bits/*=main_axes_mask*/) {
1388
+    auto set_should = [](main_axes_bits_t &b, AxisEnum a) {
1389
       if (TEST(b, a) && TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(a))
1389
       if (TEST(b, a) && TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(a))
1390
         CBI(b, a);
1390
         CBI(b, a);
1391
     };
1391
     };
1398
     return axis_bits;
1398
     return axis_bits;
1399
   }
1399
   }
1400
 
1400
 
1401
-  bool homing_needed_error(linear_axis_bits_t axis_bits/*=linear_bits*/) {
1401
+  bool homing_needed_error(main_axes_bits_t axis_bits/*=main_axes_mask*/) {
1402
     if ((axis_bits = axes_should_home(axis_bits))) {
1402
     if ((axis_bits = axes_should_home(axis_bits))) {
1403
       PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
1403
       PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
1404
       char msg[30];
1404
       char msg[30];
1405
-      sprintf_P(msg, home_first,
1406
-        NUM_AXIS_LIST(
1407
-          TEST(axis_bits, X_AXIS) ? STR_A : "",
1408
-          TEST(axis_bits, Y_AXIS) ? STR_B : "",
1409
-          TEST(axis_bits, Z_AXIS) ? STR_C : "",
1410
-          TEST(axis_bits, I_AXIS) ? STR_I : "",
1411
-          TEST(axis_bits, J_AXIS) ? STR_J : "",
1412
-          TEST(axis_bits, K_AXIS) ? STR_K : "",
1413
-          TEST(axis_bits, U_AXIS) ? STR_U : "",
1414
-          TEST(axis_bits, V_AXIS) ? STR_V : "",
1415
-          TEST(axis_bits, W_AXIS) ? STR_W : ""
1416
-        )
1417
-      );
1405
+      #define _AXIS_CHAR(N) TEST(axis_bits, _AXIS(N)) ? STR_##N : ""
1406
+      sprintf_P(msg, home_first, MAPLIST(_AXIS_CHAR, MAIN_AXIS_NAMES));
1418
       SERIAL_ECHO_START();
1407
       SERIAL_ECHO_START();
1419
       SERIAL_ECHOLN(msg);
1408
       SERIAL_ECHOLN(msg);
1420
       ui.set_status(msg);
1409
       ui.set_status(msg);

+ 24
- 21
Marlin/src/module/motion.h View File

407
 /**
407
 /**
408
  * Homing and Trusted Axes
408
  * Homing and Trusted Axes
409
  */
409
  */
410
-typedef IF<(NUM_AXES > 8), uint16_t, uint8_t>::type linear_axis_bits_t;
411
-constexpr linear_axis_bits_t linear_bits = _BV(NUM_AXES) - 1;
410
+typedef IF<(NUM_AXES > 8), uint16_t, uint8_t>::type main_axes_bits_t;
411
+constexpr main_axes_bits_t main_axes_mask = _BV(NUM_AXES) - 1;
412
+
413
+typedef IF<(NUM_AXES + EXTRUDERS > 8), uint16_t, uint8_t>::type e_axis_bits_t;
414
+constexpr e_axis_bits_t e_axis_mask = (_BV(EXTRUDERS) - 1) << NUM_AXES;
412
 
415
 
413
 void set_axis_is_at_home(const AxisEnum axis);
416
 void set_axis_is_at_home(const AxisEnum axis);
414
 
417
 
415
 #if HAS_ENDSTOPS
418
 #if HAS_ENDSTOPS
416
   /**
419
   /**
417
-   * axis_homed
420
+   * axes_homed
418
    *   Flags that each linear axis was homed.
421
    *   Flags that each linear axis was homed.
419
    *   XYZ on cartesian, ABC on delta, ABZ on SCARA.
422
    *   XYZ on cartesian, ABC on delta, ABZ on SCARA.
420
    *
423
    *
421
-   * axis_trusted
424
+   * axes_trusted
422
    *   Flags that the position is trusted in each linear axis. Set when homed.
425
    *   Flags that the position is trusted in each linear axis. Set when homed.
423
    *   Cleared whenever a stepper powers off, potentially losing its position.
426
    *   Cleared whenever a stepper powers off, potentially losing its position.
424
    */
427
    */
425
-  extern linear_axis_bits_t axis_homed, axis_trusted;
428
+  extern main_axes_bits_t axes_homed, axes_trusted;
426
   void homeaxis(const AxisEnum axis);
429
   void homeaxis(const AxisEnum axis);
427
   void set_axis_never_homed(const AxisEnum axis);
430
   void set_axis_never_homed(const AxisEnum axis);
428
-  linear_axis_bits_t axes_should_home(linear_axis_bits_t axis_bits=linear_bits);
429
-  bool homing_needed_error(linear_axis_bits_t axis_bits=linear_bits);
430
-  inline void set_axis_unhomed(const AxisEnum axis)   { CBI(axis_homed, axis); }
431
-  inline void set_axis_untrusted(const AxisEnum axis) { CBI(axis_trusted, axis); }
432
-  inline void set_all_unhomed()                       { axis_homed = axis_trusted = 0; }
433
-  inline void set_axis_homed(const AxisEnum axis)     { SBI(axis_homed, axis); }
434
-  inline void set_axis_trusted(const AxisEnum axis)   { SBI(axis_trusted, axis); }
435
-  inline void set_all_homed()                         { axis_homed = axis_trusted = linear_bits; }
431
+  main_axes_bits_t axes_should_home(main_axes_bits_t axes_mask=main_axes_mask);
432
+  bool homing_needed_error(main_axes_bits_t axes_mask=main_axes_mask);
433
+  inline void set_axis_unhomed(const AxisEnum axis)   { CBI(axes_homed, axis); }
434
+  inline void set_axis_untrusted(const AxisEnum axis) { CBI(axes_trusted, axis); }
435
+  inline void set_all_unhomed()                       { axes_homed = axes_trusted = 0; }
436
+  inline void set_axis_homed(const AxisEnum axis)     { SBI(axes_homed, axis); }
437
+  inline void set_axis_trusted(const AxisEnum axis)   { SBI(axes_trusted, axis); }
438
+  inline void set_all_homed()                         { axes_homed = axes_trusted = main_axes_mask; }
436
 #else
439
 #else
437
-  constexpr linear_axis_bits_t axis_homed = linear_bits, axis_trusted = linear_bits; // Zero-endstop machines are always homed and trusted
440
+  constexpr main_axes_bits_t axes_homed = main_axes_mask, axes_trusted = main_axes_mask; // Zero-endstop machines are always homed and trusted
438
   inline void homeaxis(const AxisEnum axis)           {}
441
   inline void homeaxis(const AxisEnum axis)           {}
439
   inline void set_axis_never_homed(const AxisEnum)    {}
442
   inline void set_axis_never_homed(const AxisEnum)    {}
440
-  inline linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return 0; }
441
-  inline bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; }
443
+  inline main_axes_bits_t axes_should_home(main_axes_bits_t=main_axes_mask) { return 0; }
444
+  inline bool homing_needed_error(main_axes_bits_t=main_axes_mask) { return false; }
442
   inline void set_axis_unhomed(const AxisEnum axis)   {}
445
   inline void set_axis_unhomed(const AxisEnum axis)   {}
443
   inline void set_axis_untrusted(const AxisEnum axis) {}
446
   inline void set_axis_untrusted(const AxisEnum axis) {}
444
   inline void set_all_unhomed()                       {}
447
   inline void set_all_unhomed()                       {}
447
   inline void set_all_homed()                         {}
450
   inline void set_all_homed()                         {}
448
 #endif
451
 #endif
449
 
452
 
450
-inline bool axis_was_homed(const AxisEnum axis)       { return TEST(axis_homed, axis); }
451
-inline bool axis_is_trusted(const AxisEnum axis)      { return TEST(axis_trusted, axis); }
453
+inline bool axis_was_homed(const AxisEnum axis)       { return TEST(axes_homed, axis); }
454
+inline bool axis_is_trusted(const AxisEnum axis)      { return TEST(axes_trusted, axis); }
452
 inline bool axis_should_home(const AxisEnum axis)     { return (axes_should_home() & _BV(axis)) != 0; }
455
 inline bool axis_should_home(const AxisEnum axis)     { return (axes_should_home() & _BV(axis)) != 0; }
453
-inline bool no_axes_homed()                           { return !axis_homed; }
454
-inline bool all_axes_homed()                          { return linear_bits == (axis_homed & linear_bits); }
456
+inline bool no_axes_homed()                           { return !axes_homed; }
457
+inline bool all_axes_homed()                          { return main_axes_mask == (axes_homed & main_axes_mask); }
455
 inline bool homing_needed()                           { return !all_axes_homed(); }
458
 inline bool homing_needed()                           { return !all_axes_homed(); }
456
-inline bool all_axes_trusted()                        { return linear_bits == (axis_trusted & linear_bits); }
459
+inline bool all_axes_trusted()                        { return main_axes_mask == (axes_trusted & main_axes_mask); }
457
 
460
 
458
 void home_if_needed(const bool keeplev=false);
461
 void home_if_needed(const bool keeplev=false);
459
 
462
 

+ 2
- 2
Marlin/src/module/probe.cpp View File

274
     #if ENABLED(PROBING_STEPPERS_OFF) && DISABLED(DELTA)
274
     #if ENABLED(PROBING_STEPPERS_OFF) && DISABLED(DELTA)
275
       static uint8_t old_trusted;
275
       static uint8_t old_trusted;
276
       if (dopause) {
276
       if (dopause) {
277
-        old_trusted = axis_trusted;
277
+        old_trusted = axes_trusted;
278
         stepper.disable_axis(X_AXIS);
278
         stepper.disable_axis(X_AXIS);
279
         stepper.disable_axis(Y_AXIS);
279
         stepper.disable_axis(Y_AXIS);
280
       }
280
       }
281
       else {
281
       else {
282
         if (TEST(old_trusted, X_AXIS)) stepper.enable_axis(X_AXIS);
282
         if (TEST(old_trusted, X_AXIS)) stepper.enable_axis(X_AXIS);
283
         if (TEST(old_trusted, Y_AXIS)) stepper.enable_axis(Y_AXIS);
283
         if (TEST(old_trusted, Y_AXIS)) stepper.enable_axis(Y_AXIS);
284
-        axis_trusted = old_trusted;
284
+        axes_trusted = old_trusted;
285
       }
285
       }
286
     #endif
286
     #endif
287
     if (dopause) safe_delay(_MAX(DELAY_BEFORE_PROBING, 25));
287
     if (dopause) safe_delay(_MAX(DELAY_BEFORE_PROBING, 25));

+ 5
- 3
Marlin/src/module/stepper.h View File

246
 #define MIN_STEP_ISR_FREQUENCY (MAX_STEP_ISR_FREQUENCY_1X / 2)
246
 #define MIN_STEP_ISR_FREQUENCY (MAX_STEP_ISR_FREQUENCY_1X / 2)
247
 
247
 
248
 #define ENABLE_COUNT (NUM_AXES + E_STEPPERS)
248
 #define ENABLE_COUNT (NUM_AXES + E_STEPPERS)
249
-typedef IF<(ENABLE_COUNT > 8), uint16_t, uint8_t>::type ena_mask_t;
249
+#if ENABLE_COUNT > 16
250
+  typedef uint32_t ena_mask_t;
251
+#else
252
+  typedef IF<(ENABLE_COUNT > 8), uint16_t, uint8_t>::type ena_mask_t;
253
+#endif
250
 
254
 
251
 // Axis flags type, for enabled state or other simple state
255
 // Axis flags type, for enabled state or other simple state
252
 typedef struct {
256
 typedef struct {
259
       #endif
263
       #endif
260
     };
264
     };
261
   };
265
   };
262
-  constexpr ena_mask_t linear_bits() { return _BV(NUM_AXES) - 1; }
263
-  constexpr ena_mask_t e_bits() { return (_BV(EXTRUDERS) - 1) << NUM_AXES; }
264
 } stepper_flags_t;
266
 } stepper_flags_t;
265
 
267
 
266
 // All the stepper enable pins
268
 // All the stepper enable pins

Loading…
Cancel
Save