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,7 +181,6 @@ enum AxisEnum : uint8_t {
181 181
 };
182 182
 
183 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 186
 // Loop over axes

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

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

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

@@ -45,9 +45,10 @@
45 45
  *  X, Y, Z          : Specify axes to move during cleaning. Default: ALL.
46 46
  */
47 47
 void GcodeSuite::G12() {
48
+
48 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 53
   #ifdef WIPE_SEQUENCE_COMMANDS
53 54
     if (!parser.seen_any()) {

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

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

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

@@ -1382,10 +1382,10 @@ void prepare_line_to_destination() {
1382 1382
 
1383 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 1389
       if (TEST(b, a) && TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(a))
1390 1390
         CBI(b, a);
1391 1391
     };
@@ -1398,23 +1398,12 @@ void prepare_line_to_destination() {
1398 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 1402
     if ((axis_bits = axes_should_home(axis_bits))) {
1403 1403
       PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
1404 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 1407
       SERIAL_ECHO_START();
1419 1408
       SERIAL_ECHOLN(msg);
1420 1409
       ui.set_status(msg);

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

@@ -407,38 +407,41 @@ void restore_feedrate_and_scaling();
407 407
 /**
408 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 416
 void set_axis_is_at_home(const AxisEnum axis);
414 417
 
415 418
 #if HAS_ENDSTOPS
416 419
   /**
417
-   * axis_homed
420
+   * axes_homed
418 421
    *   Flags that each linear axis was homed.
419 422
    *   XYZ on cartesian, ABC on delta, ABZ on SCARA.
420 423
    *
421
-   * axis_trusted
424
+   * axes_trusted
422 425
    *   Flags that the position is trusted in each linear axis. Set when homed.
423 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 429
   void homeaxis(const AxisEnum axis);
427 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 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 441
   inline void homeaxis(const AxisEnum axis)           {}
439 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 445
   inline void set_axis_unhomed(const AxisEnum axis)   {}
443 446
   inline void set_axis_untrusted(const AxisEnum axis) {}
444 447
   inline void set_all_unhomed()                       {}
@@ -447,13 +450,13 @@ void set_axis_is_at_home(const AxisEnum axis);
447 450
   inline void set_all_homed()                         {}
448 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 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 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 461
 void home_if_needed(const bool keeplev=false);
459 462
 

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

@@ -274,14 +274,14 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
274 274
     #if ENABLED(PROBING_STEPPERS_OFF) && DISABLED(DELTA)
275 275
       static uint8_t old_trusted;
276 276
       if (dopause) {
277
-        old_trusted = axis_trusted;
277
+        old_trusted = axes_trusted;
278 278
         stepper.disable_axis(X_AXIS);
279 279
         stepper.disable_axis(Y_AXIS);
280 280
       }
281 281
       else {
282 282
         if (TEST(old_trusted, X_AXIS)) stepper.enable_axis(X_AXIS);
283 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 286
     #endif
287 287
     if (dopause) safe_delay(_MAX(DELAY_BEFORE_PROBING, 25));

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

@@ -246,7 +246,11 @@
246 246
 #define MIN_STEP_ISR_FREQUENCY (MAX_STEP_ISR_FREQUENCY_1X / 2)
247 247
 
248 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 255
 // Axis flags type, for enabled state or other simple state
252 256
 typedef struct {
@@ -259,8 +263,6 @@ typedef struct {
259 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 266
 } stepper_flags_t;
265 267
 
266 268
 // All the stepper enable pins

Loading…
Cancel
Save