Browse Source

🎨 Fix comments, formatting

Scott Lahteine 2 years ago
parent
commit
6cbd7a48d1

+ 2
- 3
Marlin/src/core/macros.h View File

@@ -644,8 +644,8 @@
644 644
 #define IS_PROBE(V...) SECOND(V, 0)     // Get the second item passed, or 0
645 645
 #define PROBE() ~, 1                    // Second item will be 1 if this is passed
646 646
 #define _NOT_0 PROBE()
647
-#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
648
-#define _BOOL(x) NOT(NOT(x))            // NOT('0') gets '0'. Anything else gets '1'.
647
+#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) //   NOT('0') gets '1'. Anything else gets '0'.
648
+#define _BOOL(x) NOT(NOT(x))            // _BOOL('0') gets '0'. Anything else gets '1'.
649 649
 
650 650
 #define IF_ELSE(TF) _IF_ELSE(_BOOL(TF))
651 651
 #define _IF_ELSE(TF) _CAT(_IF_, TF)
@@ -659,7 +659,6 @@
659 659
 #define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)())
660 660
 #define _END_OF_ARGUMENTS_() 0
661 661
 
662
-
663 662
 // Simple Inline IF Macros, friendly to use in other macro definitions
664 663
 #define IF(O, A, B) ((O) ? (A) : (B))
665 664
 #define IF_0(O, A) IF(O, A, 0)

+ 2
- 2
Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h View File

@@ -240,8 +240,8 @@
240 240
   #define IS_PROBE(V...) SECOND(V, 0)     // Get the second item passed, or 0
241 241
   #define PROBE() ~, 1                    // Second item will be 1 if this is passed
242 242
   #define _NOT_0 PROBE()
243
-  #define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
244
-  #define _BOOL(x) NOT(NOT(x))            // NOT('0') gets '0'. Anything else gets '1'.
243
+  #define NOT(x) IS_PROBE(_CAT(_NOT_, x)) //   NOT('0') gets '1'. Anything else gets '0'.
244
+  #define _BOOL(x) NOT(NOT(x))            // _BOOL('0') gets '0'. Anything else gets '1'.
245 245
 
246 246
   #define _DO_1(W,C,A)       (_##W##_1(A))
247 247
   #define _DO_2(W,C,A,B)     (_##W##_1(A) C _##W##_1(B))

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

@@ -489,13 +489,10 @@ void MarlinUI::init() {
489 489
         ui.manual_move.menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
490 490
         ui.encoderPosition = dir;
491 491
         switch (axis) {
492
-          case X_AXIS: { void lcd_move_x(); lcd_move_x(); } break;
493
-          #if HAS_Y_AXIS
494
-            case Y_AXIS: { void lcd_move_y(); lcd_move_y(); } break;
495
-          #endif
496
-          #if HAS_Z_AXIS
497
-            case Z_AXIS: { void lcd_move_z(); lcd_move_z(); } break;
498
-          #endif
492
+          case X_AXIS:
493
+          TERN_(HAS_Y_AXIS, case Y_AXIS:)
494
+          TERN_(HAS_Z_AXIS, case Z_AXIS:)
495
+            lcd_move_axis(axis);
499 496
           default: break;
500 497
         }
501 498
       }

+ 29
- 25
Marlin/src/module/planner.cpp View File

@@ -2049,9 +2049,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2049 2049
     #endif
2050 2050
   #elif ENABLED(MARKFORGED_XY)
2051 2051
     steps_dist_mm.a      = (da - db) * mm_per_step[A_AXIS];
2052
-    steps_dist_mm.b      = db * mm_per_step[B_AXIS];
2052
+    steps_dist_mm.b      =       db  * mm_per_step[B_AXIS];
2053 2053
   #elif ENABLED(MARKFORGED_YX)
2054
-    steps_dist_mm.a      = da * mm_per_step[A_AXIS];
2054
+    steps_dist_mm.a      =       da  * mm_per_step[A_AXIS];
2055 2055
     steps_dist_mm.b      = (db - da) * mm_per_step[B_AXIS];
2056 2056
   #else
2057 2057
     XYZ_CODE(
@@ -2097,12 +2097,21 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2097 2097
       block->millimeters = millimeters;
2098 2098
     else {
2099 2099
       /**
2100
-       * Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of NIST
2101
-       * RS274NGC interpreter - version 3) and its default CANON_XYZ feed reference mode.
2102
-       * Assume that X, Y, Z are the primary linear axes and U, V, W are secondary linear axes and A, B, C are
2103
-       * rotational axes. Then dX, dY, dZ are the displacements of the primary linear axes and dU, dV, dW are the displacements of linear axes and
2104
-       * dA, dB, dC are the displacements of rotational axes.
2105
-       * The time it takes to execute move command with feedrate F is t = D/F, where D is the total distance, calculated as follows:
2100
+       * Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of
2101
+       * NIST RS274NGC interpreter - version 3) and its default CANON_XYZ feed reference mode.
2102
+       *
2103
+       * Assume:
2104
+       *   - X, Y, Z are the primary linear axes;
2105
+       *   - U, V, W are secondary linear axes;
2106
+       *   - A, B, C are rotational axes.
2107
+       *
2108
+       * Then:
2109
+       *   - dX, dY, dZ are the displacements of the primary linear axes;
2110
+       *   - dU, dV, dW are the displacements of linear axes;
2111
+       *   - dA, dB, dC are the displacements of rotational axes.
2112
+       *
2113
+       * The time it takes to execute move command with feedrate F is t = D/F,
2114
+       * where D is the total distance, calculated as follows:
2106 2115
        *   D^2 = dX^2 + dY^2 + dZ^2
2107 2116
        *   if D^2 == 0 (none of XYZ move but any secondary linear axes move, whether other axes are moved or not):
2108 2117
        *     D^2 = dU^2 + dV^2 + dW^2
@@ -2111,8 +2120,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2111 2120
        */
2112 2121
       float distance_sqr = (
2113 2122
         #if ENABLED(ARTICULATED_ROBOT_ARM)
2114
-          // For articulated robots, interpreting feedrate like LinuxCNC would require inverse kinematics. As a workaround, pretend that motors sit on n mutually orthogonal
2115
-          // axes and assume that we could think of distance as magnitude of an n-vector in an n-dimensional Euclidian space.
2123
+          // For articulated robots, interpreting feedrate like LinuxCNC would require inverse kinematics. As a workaround,
2124
+          // assume that motors sit on a mutually-orthogonal axes and we can think of distance as magnitude of an n-vector
2125
+          // in an n-dimensional Euclidian space.
2116 2126
           NUM_AXIS_GANG(
2117 2127
               sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z),
2118 2128
             + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k),
@@ -2120,8 +2130,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2120 2130
           );
2121 2131
         #elif ENABLED(FOAMCUTTER_XYUV)
2122 2132
           #if HAS_J_AXIS
2123
-          // Special 5 axis kinematics. Return the largest distance move from either X/Y or I/J plane
2124
-          _MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j))
2133
+            // Special 5 axis kinematics. Return the largest distance move from either X/Y or I/J plane
2134
+            _MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j))
2125 2135
           #else // Foamcutter with only two axes (XY)
2126 2136
             sq(steps_dist_mm.x) + sq(steps_dist_mm.y)
2127 2137
           #endif
@@ -2132,7 +2142,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2132 2142
         #elif CORE_IS_YZ
2133 2143
           XYZ_GANG(sq(steps_dist_mm.x),      + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.head.z))
2134 2144
         #else
2135
-          XYZ_GANG(sq(steps_dist_mm.x),       + sq(steps_dist_mm.y),      + sq(steps_dist_mm.z))
2145
+          XYZ_GANG(sq(steps_dist_mm.x),      + sq(steps_dist_mm.y),      + sq(steps_dist_mm.z))
2136 2146
         #endif
2137 2147
       );
2138 2148
 
@@ -2165,9 +2175,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2165 2175
 
2166 2176
     /**
2167 2177
      * At this point at least one of the axes has more steps than
2168
-     * MIN_STEPS_PER_SEGMENT, ensuring the segment won't get dropped as
2169
-     * zero-length. It's important to not apply corrections
2170
-     * to blocks that would get dropped!
2178
+     * MIN_STEPS_PER_SEGMENT, ensuring the segment won't get dropped
2179
+     * as zero-length. It's important to not apply corrections to blocks
2180
+     * that would get dropped!
2171 2181
      *
2172 2182
      * A correction function is permitted to add steps to an axis, it
2173 2183
      * should *never* remove steps!
@@ -2203,15 +2213,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2203 2213
 
2204 2214
   #if ENABLED(AUTO_POWER_CONTROL)
2205 2215
     if (NUM_AXIS_GANG(
2206
-         block->steps.x,
2207
-      || block->steps.y,
2208
-      || block->steps.z,
2209
-      || block->steps.i,
2210
-      || block->steps.j,
2211
-      || block->steps.k,
2212
-      || block->steps.u,
2213
-      || block->steps.v,
2214
-      || block->steps.w
2216
+         block->steps.x, || block->steps.y, || block->steps.z,
2217
+      || block->steps.i, || block->steps.j, || block->steps.k,
2218
+      || block->steps.u, || block->steps.v, || block->steps.w
2215 2219
     )) powerManager.power_on();
2216 2220
   #endif
2217 2221
 

+ 4
- 8
Marlin/src/module/stepper/trinamic.cpp View File

@@ -1030,10 +1030,8 @@ void reset_trinamic_drivers() {
1030 1030
   // Using a fixed-length character array for the port name allows this to be constexpr compatible.
1031 1031
   struct SanityHwSerialDetails { const char port[20]; uint32_t address; };
1032 1032
   #define TMC_HW_DETAIL_ARGS(A) TERN(A##_HAS_HW_SERIAL, STRINGIFY(A##_HARDWARE_SERIAL), ""), TERN0(A##_HAS_HW_SERIAL, A##_SLAVE_ADDRESS)
1033
-  #define TMC_HW_DETAIL(A) { TMC_HW_DETAIL_ARGS(A) },
1034
-  constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = {
1035
-    MAP(TMC_HW_DETAIL, ALL_AXIS_NAMES)
1036
-  };
1033
+  #define TMC_HW_DETAIL(A) { TMC_HW_DETAIL_ARGS(A) }
1034
+  constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = { MAPLIST(TMC_HW_DETAIL, ALL_AXIS_NAMES) };
1037 1035
 
1038 1036
   // constexpr compatible string comparison
1039 1037
   constexpr bool str_eq_ce(const char * a, const char * b) {
@@ -1057,10 +1055,8 @@ void reset_trinamic_drivers() {
1057 1055
 #if ANY_AXIS_HAS(SW_SERIAL)
1058 1056
   struct SanitySwSerialDetails { int32_t txpin; int32_t rxpin; uint32_t address; };
1059 1057
   #define TMC_SW_DETAIL_ARGS(A) TERN(A##_HAS_SW_SERIAL, A##_SERIAL_TX_PIN, -1), TERN(A##_HAS_SW_SERIAL, A##_SERIAL_RX_PIN, -1), TERN0(A##_HAS_SW_SERIAL, A##_SLAVE_ADDRESS)
1060
-  #define TMC_SW_DETAIL(A) TMC_SW_DETAIL_ARGS(A),
1061
-  constexpr SanitySwSerialDetails sanity_tmc_sw_details[] = {
1062
-    MAP(TMC_SW_DETAIL, ALL_AXIS_NAMES)
1063
-  };
1058
+  #define TMC_SW_DETAIL(A) { TMC_SW_DETAIL_ARGS(A) }
1059
+  constexpr SanitySwSerialDetails sanity_tmc_sw_details[] = { MAPLIST(TMC_SW_DETAIL, ALL_AXIS_NAMES) };
1064 1060
 
1065 1061
   constexpr bool sc_sw_done(size_t start, size_t end) { return start == end; }
1066 1062
   constexpr bool sc_sw_skip(int32_t txpin) { return txpin < 0; }

Loading…
Cancel
Save