Browse Source

🎨 Macros for optional arguments (#21969)

Scott Lahteine 3 years ago
parent
commit
84fd0eff17
No account linked to committer's email address

+ 5
- 0
Marlin/src/core/macros.h View File

@@ -195,6 +195,11 @@
195 195
 #define __TERN(T,V...)      ___TERN(_CAT(_NO,T),V)  // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
196 196
 #define ___TERN(P,V...)     THIRD(P,V)              // If first argument has a comma, A. Else B.
197 197
 
198
+#define _OPTARG(A)          , A
199
+#define OPTARG(O,A)         TERN_(O,DEFER4(_OPTARG)(A))
200
+#define _OPTCODE(A)         A;
201
+#define OPTCODE(O,A)        TERN_(O,DEFER4(_OPTCODE)(A))
202
+
198 203
 // Macros to avoid 'f + 0.0' which is not always optimized away. Minus included for symmetry.
199 204
 // Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc.
200 205
 #define PLUS_TERN0(O,A)     _TERN(_ENA_1(O),,+ (A)) // OPTION ? '+ (A)' : '<nul>'

+ 1
- 3
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h View File

@@ -103,9 +103,7 @@ public:
103 103
   }
104 104
 
105 105
   static float get_z(const xy_pos_t &pos
106
-    #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
107
-      , const_float_t factor=1.0f
108
-    #endif
106
+    OPTARG(ENABLE_LEVELING_FADE_HEIGHT, const_float_t factor=1.0f)
109 107
   ) {
110 108
     #if DISABLED(ENABLE_LEVELING_FADE_HEIGHT)
111 109
       constexpr float factor = 1.0f;

+ 2
- 6
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp View File

@@ -362,15 +362,11 @@
362 362
       while (--segments) {
363 363
         raw += diff;
364 364
         planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm
365
-          #if ENABLED(SCARA_FEEDRATE_SCALING)
366
-            , inv_duration
367
-          #endif
365
+          OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
368 366
         );
369 367
       }
370 368
       planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, segment_xyz_mm
371
-        #if ENABLED(SCARA_FEEDRATE_SCALING)
372
-          , inv_duration
373
-        #endif
369
+        OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
374 370
       );
375 371
       return false; // Did not set current from destination
376 372
     }

+ 1
- 1
Marlin/src/feature/caselight.cpp View File

@@ -41,7 +41,7 @@ bool CaseLight::on = CASE_LIGHT_DEFAULT_ON;
41 41
 #if CASE_LIGHT_IS_COLOR_LED
42 42
   #include "leds/leds.h"
43 43
   constexpr uint8_t init_case_light[] = CASE_LIGHT_DEFAULT_COLOR;
44
-  LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2], TERN_(HAS_WHITE_LED, init_case_light[3]) };
44
+  LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2] OPTARG(HAS_WHITE_LED, init_case_light[3]) };
45 45
 #endif
46 46
 
47 47
 void CaseLight::update(const bool sflag) {

+ 1
- 5
Marlin/src/feature/fwretract.cpp View File

@@ -91,11 +91,7 @@ void FWRetract::reset() {
91 91
  * Note: Auto-retract will apply the set Z hop in addition to any Z hop
92 92
  *       included in the G-code. Use M207 Z0 to to prevent double hop.
93 93
  */
94
-void FWRetract::retract(const bool retracting
95
-  #if HAS_MULTI_EXTRUDER
96
-    , bool swapping/*=false*/
97
-  #endif
98
-) {
94
+void FWRetract::retract(const bool retracting OPTARG(HAS_MULTI_EXTRUDER, bool swapping/*=false*/)) {
99 95
   // Prevent two retracts or recovers in a row
100 96
   if (retracted[active_extruder] == retracting) return;
101 97
 

+ 1
- 5
Marlin/src/feature/fwretract.h View File

@@ -74,11 +74,7 @@ public:
74 74
     #endif
75 75
   }
76 76
 
77
-  static void retract(const bool retracting
78
-    #if HAS_MULTI_EXTRUDER
79
-      , bool swapping = false
80
-    #endif
81
-  );
77
+  static void retract(const bool retracting OPTARG(HAS_MULTI_EXTRUDER, bool swapping = false));
82 78
 
83 79
   static void M207();
84 80
   static void M207_report(const bool forReplay=false);

+ 1
- 3
Marlin/src/feature/leds/leds.cpp View File

@@ -75,9 +75,7 @@ void LEDLights::setup() {
75 75
 }
76 76
 
77 77
 void LEDLights::set_color(const LEDColor &incol
78
-  #if ENABLED(NEOPIXEL_LED)
79
-    , bool isSequence/*=false*/
80
-  #endif
78
+  OPTARG(NEOPIXEL_LED, bool isSequence/*=false*/)
81 79
 ) {
82 80
 
83 81
   #if ENABLED(NEOPIXEL_LED)

+ 14
- 57
Marlin/src/feature/leds/leds.h View File

@@ -43,46 +43,21 @@
43 43
  */
44 44
 typedef struct LEDColor {
45 45
   uint8_t r, g, b
46
-    #if HAS_WHITE_LED
47
-      , w
48
-      #if ENABLED(NEOPIXEL_LED)
49
-        , i
50
-      #endif
51
-    #endif
46
+    OPTARG(HAS_WHITE_LED, w)
47
+    OPTARG(NEOPIXEL_LED, i)
52 48
   ;
53 49
 
54 50
   LEDColor() : r(255), g(255), b(255)
55
-    #if HAS_WHITE_LED
56
-      , w(255)
57
-      #if ENABLED(NEOPIXEL_LED)
58
-        , i(NEOPIXEL_BRIGHTNESS)
59
-      #endif
60
-    #endif
51
+    OPTARG(HAS_WHITE_LED, w(255))
52
+    OPTARG(NEOPIXEL_LED, i(NEOPIXEL_BRIGHTNESS))
61 53
   {}
62 54
 
63
-  LEDColor(uint8_t r, uint8_t g, uint8_t b
64
-    #if HAS_WHITE_LED
65
-      , uint8_t w=0
66
-      #if ENABLED(NEOPIXEL_LED)
67
-        , uint8_t i=NEOPIXEL_BRIGHTNESS
68
-      #endif
69
-    #endif
70
-    ) : r(r), g(g), b(b)
71
-    #if HAS_WHITE_LED
72
-      , w(w)
73
-      #if ENABLED(NEOPIXEL_LED)
74
-        , i(i)
75
-      #endif
76
-    #endif
77
-  {}
55
+  LEDColor(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS))
56
+    : r(r), g(g), b(b) OPTARG(HAS_WHITE_LED, w(w)) OPTARG(NEOPIXEL_LED, i(i)) {}
78 57
 
79 58
   LEDColor(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2])
80
-    #if HAS_WHITE_LED
81
-      , w(rgbw[3])
82
-      #if ENABLED(NEOPIXEL_LED)
83
-        , i(NEOPIXEL_BRIGHTNESS)
84
-      #endif
85
-    #endif
59
+    OPTARG(HAS_WHITE_LED, w(rgbw[3]))
60
+    OPTARG(NEOPIXEL_LED, i(NEOPIXEL_BRIGHTNESS))
86 61
   {}
87 62
 
88 63
   LEDColor& operator=(const uint8_t (&rgbw)[4]) {
@@ -111,15 +86,7 @@ typedef struct LEDColor {
111 86
 /**
112 87
  * Color helpers and presets
113 88
  */
114
-#if HAS_WHITE_LED
115
-  #if ENABLED(NEOPIXEL_LED)
116
-    #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W, I)
117
-  #else
118
-    #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W)
119
-  #endif
120
-#else
121
-  #define MakeLEDColor(R,G,B,W,I)   LEDColor(R, G, B)
122
-#endif
89
+#define MakeLEDColor(R,G,B,W,I)   LEDColor(R, G, B OPTARG(HAS_WHITE_LED, W) OPTARG(NEOPIXEL_LED, I))
123 90
 
124 91
 #define LEDColorOff()             LEDColor(  0,   0,   0)
125 92
 #define LEDColorRed()             LEDColor(255,   0,   0)
@@ -147,25 +114,15 @@ public:
147 114
   static void setup(); // init()
148 115
 
149 116
   static void set_color(const LEDColor &color
150
-    #if ENABLED(NEOPIXEL_LED)
151
-      , bool isSequence=false
152
-    #endif
117
+    OPTARG(NEOPIXEL_LED, bool isSequence=false)
153 118
   );
154 119
 
155 120
   static inline void set_color(uint8_t r, uint8_t g, uint8_t b
156
-    #if HAS_WHITE_LED
157
-      , uint8_t w=0
158
-    #endif
159
-    #if ENABLED(NEOPIXEL_LED)
160
-      , uint8_t i=NEOPIXEL_BRIGHTNESS
161
-      , bool isSequence=false
162
-    #endif
121
+    OPTARG(HAS_WHITE_LED, uint8_t w=0)
122
+    OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)
123
+    OPTARG(NEOPIXEL_LED, bool isSequence=false)
163 124
   ) {
164
-    set_color(MakeLEDColor(r, g, b, w, i)
165
-      #if ENABLED(NEOPIXEL_LED)
166
-        , isSequence
167
-      #endif
168
-    );
125
+    set_color(MakeLEDColor(r, g, b, w, i) OPTARG(NEOPIXEL_LED, isSequence));
169 126
   }
170 127
 
171 128
   static inline void set_off()   { set_color(LEDColorOff()); }

+ 2
- 6
Marlin/src/feature/leds/pca9632.cpp View File

@@ -93,9 +93,7 @@ static void PCA9632_WriteRegister(const byte addr, const byte regadd, const byte
93 93
 }
94 94
 
95 95
 static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const byte vr, const byte vg, const byte vb
96
-  #if ENABLED(PCA9632_RGBW)
97
-    , const byte vw
98
-  #endif
96
+  OPTARG(PCA9632_RGBW, const byte vw)
99 97
 ) {
100 98
   #if DISABLED(PCA9632_NO_AUTO_INC)
101 99
     uint8_t data[4];
@@ -143,9 +141,7 @@ void PCA9632_set_led_color(const LEDColor &color) {
143 141
                     ;
144 142
 
145 143
   PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, color.r, color.g, color.b
146
-    #if ENABLED(PCA9632_RGBW)
147
-      , color.w
148
-    #endif
144
+    OPTARG(PCA9632_RGBW, color.w)
149 145
   );
150 146
   PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT);
151 147
 }

+ 3
- 9
Marlin/src/feature/tmc_util.h View File

@@ -70,15 +70,9 @@ class TMCStorage {
70 70
     }
71 71
 
72 72
     struct {
73
-      #if ENABLED(HAS_STEALTHCHOP)
74
-        bool stealthChop_enabled = false;
75
-      #endif
76
-      #if ENABLED(HYBRID_THRESHOLD)
77
-        uint8_t hybrid_thrs = 0;
78
-      #endif
79
-      #if ENABLED(USE_SENSORLESS)
80
-        int16_t homing_thrs = 0;
81
-      #endif
73
+      OPTCODE(HAS_STEALTHCHOP,  bool stealthChop_enabled = false)
74
+      OPTCODE(HYBRID_THRESHOLD, uint8_t hybrid_thrs = 0)
75
+      OPTCODE(USE_SENSORLESS,   int16_t homing_thrs = 0)
82 76
     } stored;
83 77
 };
84 78
 

+ 4
- 11
Marlin/src/gcode/bedlevel/G26.cpp View File

@@ -330,12 +330,8 @@ typedef struct {
330 330
         thermalManager.setTargetBed(bed_temp);
331 331
 
332 332
         // Wait for the temperature to stabilize
333
-        if (!thermalManager.wait_for_bed(true
334
-            #if G26_CLICK_CAN_CANCEL
335
-              , true
336
-            #endif
337
-          )
338
-        ) return G26_ERR;
333
+        if (!thermalManager.wait_for_bed(true OPTARG(G26_CLICK_CAN_CANCEL, true)))
334
+          return G26_ERR;
339 335
       }
340 336
 
341 337
     #else
@@ -352,11 +348,8 @@ typedef struct {
352 348
     thermalManager.setTargetHotend(hotend_temp, active_extruder);
353 349
 
354 350
     // Wait for the temperature to stabilize
355
-    if (!thermalManager.wait_for_hotend(active_extruder, true
356
-      #if G26_CLICK_CAN_CANCEL
357
-        , true
358
-      #endif
359
-    )) return G26_ERR;
351
+    if (!thermalManager.wait_for_hotend(active_extruder, true OPTARG(G26_CLICK_CAN_CANCEL, true)))
352
+      return G26_ERR;
360 353
 
361 354
     #if HAS_WIRED_LCD
362 355
       ui.reset_status();

+ 2
- 6
Marlin/src/gcode/motion/G2_G3.cpp View File

@@ -249,9 +249,7 @@ void plan_arc(
249 249
     #endif
250 250
 
251 251
     if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0
252
-      #if ENABLED(SCARA_FEEDRATE_SCALING)
253
-        , inv_duration
254
-      #endif
252
+      OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
255 253
     )) break;
256 254
   }
257 255
 
@@ -266,9 +264,7 @@ void plan_arc(
266 264
   #endif
267 265
 
268 266
   planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0
269
-    #if ENABLED(SCARA_FEEDRATE_SCALING)
270
-      , inv_duration
271
-    #endif
267
+    OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
272 268
   );
273 269
 
274 270
   TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L);

+ 2
- 6
Marlin/src/gcode/queue.cpp View File

@@ -84,9 +84,7 @@ char GCodeQueue::injected_commands[64]; // = { 0 }
84 84
 
85 85
 
86 86
 void GCodeQueue::RingBuffer::commit_command(bool skip_ok
87
-  #if HAS_MULTI_SERIAL
88
-    , serial_index_t serial_ind/*=-1*/
89
-  #endif
87
+  OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/)
90 88
 ) {
91 89
   commands[index_w].skip_ok = skip_ok;
92 90
   TERN_(HAS_MULTI_SERIAL, commands[index_w].port = serial_ind);
@@ -100,9 +98,7 @@ void GCodeQueue::RingBuffer::commit_command(bool skip_ok
100 98
  * Return false for a full buffer, or if the 'command' is a comment.
101 99
  */
102 100
 bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/
103
-  #if HAS_MULTI_SERIAL
104
-    , serial_index_t serial_ind/*=-1*/
105
-  #endif
101
+  OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/)
106 102
 ) {
107 103
   if (*cmd == ';' || length >= BUFSIZE) return false;
108 104
   strcpy(commands[index_w].buffer, cmd);

+ 2
- 6
Marlin/src/gcode/queue.h View File

@@ -80,15 +80,11 @@ public:
80 80
     void advance_pos(uint8_t &p, const int inc) { if (++p >= BUFSIZE) p = 0; length += inc; }
81 81
 
82 82
     void commit_command(bool skip_ok
83
-      #if HAS_MULTI_SERIAL
84
-        , serial_index_t serial_ind = serial_index_t()
85
-      #endif
83
+      OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t())
86 84
     );
87 85
 
88 86
     bool enqueue(const char *cmd, bool skip_ok = true
89
-      #if HAS_MULTI_SERIAL
90
-        , serial_index_t serial_ind = serial_index_t()
91
-      #endif
87
+      OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t())
92 88
     );
93 89
 
94 90
     void ok_to_send();

+ 2
- 6
Marlin/src/lcd/marlinui.cpp View File

@@ -758,13 +758,9 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {
758 758
   // Tell ui.update() to start a move to current_position after a short delay.
759 759
   //
760 760
   void ManualMove::soon(const AxisEnum move_axis
761
-    #if MULTI_E_MANUAL
762
-      , const int8_t eindex/*=-1*/
763
-    #endif
761
+    OPTARG(MULTI_E_MANUAL, const int8_t eindex/*=active_extruder*/)
764 762
   ) {
765
-    #if MULTI_E_MANUAL
766
-      if (move_axis == E_AXIS) e_index = eindex >= 0 ? eindex : active_extruder;
767
-    #endif
763
+    TERN_(MULTI_E_MANUAL, if (move_axis == E_AXIS) e_index = eindex);
768 764
     start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
769 765
     axis = move_axis;
770 766
     //SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon.");

+ 1
- 5
Marlin/src/lcd/marlinui.h View File

@@ -182,11 +182,7 @@
182 182
       static bool constexpr processing = false;
183 183
     #endif
184 184
     static void task();
185
-    static void soon(const AxisEnum axis
186
-      #if MULTI_E_MANUAL
187
-        , const int8_t eindex=-1
188
-      #endif
189
-    );
185
+    static void soon(const AxisEnum axis OPTARG(MULTI_E_MANUAL, const int8_t eindex=active_extruder));
190 186
   };
191 187
 
192 188
 #endif

+ 4
- 8
Marlin/src/lcd/menu/menu_motion.cpp View File

@@ -94,17 +94,13 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); }
94 94
 
95 95
 #if E_MANUAL
96 96
 
97
-  static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=-1)) {
97
+  static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=active_extruder)) {
98 98
     if (ui.use_click()) return ui.goto_previous_screen_no_defer();
99 99
     if (ui.encoderPosition) {
100 100
       if (!ui.manual_move.processing) {
101 101
         const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale;
102 102
         TERN(IS_KINEMATIC, ui.manual_move.offset, current_position.e) += diff;
103
-        ui.manual_move.soon(E_AXIS
104
-          #if MULTI_E_MANUAL
105
-            , eindex
106
-          #endif
107
-        );
103
+        ui.manual_move.soon(E_AXIS OPTARG(MULTI_E_MANUAL, eindex));
108 104
         ui.refresh(LCDVIEW_REDRAW_NOW);
109 105
       }
110 106
       ui.encoderPosition = 0;
@@ -139,7 +135,7 @@ void _goto_manual_move(const_float_t scale) {
139 135
   ui.goto_screen(_manual_move_func_ptr);
140 136
 }
141 137
 
142
-void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=-1) {
138
+void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=active_extruder) {
143 139
   _manual_move_func_ptr = func;
144 140
   START_MENU();
145 141
   if (LCD_HEIGHT >= 4) {
@@ -188,7 +184,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
188 184
 #if E_MANUAL
189 185
 
190 186
   inline void _goto_menu_move_distance_e() {
191
-    ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(TERN_(MULTI_E_MANUAL, active_extruder)); }, -1); });
187
+    ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(); }); });
192 188
   }
193 189
 
194 190
   inline void _menu_move_distance_e_maybe() {

+ 1
- 5
Marlin/src/lcd/tft/ui_1024x600.cpp View File

@@ -724,11 +724,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
724 724
       drawMessage(msg);
725 725
     #endif
726 726
 
727
-    ui.manual_move.soon(axis
728
-      #if MULTI_E_MANUAL
729
-        , motionAxisState.e_selection
730
-      #endif
731
-    );
727
+    ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection));
732 728
   }
733 729
 
734 730
   drawAxisValue(axis);

+ 1
- 5
Marlin/src/lcd/tft/ui_320x240.cpp View File

@@ -709,11 +709,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
709 709
       drawMessage(msg);
710 710
     #endif
711 711
 
712
-    ui.manual_move.soon(axis
713
-      #if MULTI_E_MANUAL
714
-        , motionAxisState.e_selection
715
-      #endif
716
-    );
712
+    ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection));
717 713
   }
718 714
 
719 715
   drawAxisValue(axis);

+ 1
- 5
Marlin/src/lcd/tft/ui_480x320.cpp View File

@@ -711,11 +711,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
711 711
       drawMessage(msg);
712 712
     #endif
713 713
 
714
-    ui.manual_move.soon(axis
715
-      #if MULTI_E_MANUAL
716
-        , motionAxisState.e_selection
717
-      #endif
718
-    );
714
+    ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection));
719 715
   }
720 716
 
721 717
   drawAxisValue(axis);

+ 7
- 19
Marlin/src/module/motion.cpp View File

@@ -411,9 +411,7 @@ void line_to_current_position(const_feedRate_t fr_mm_s/*=feedrate_mm_s*/) {
411 411
  *  - Extrude the specified length regardless of flow percentage.
412 412
  */
413 413
 void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/
414
-  #if IS_KINEMATIC
415
-    , const bool is_fast/*=false*/
416
-  #endif
414
+  OPTARG(IS_KINEMATIC, const bool is_fast/*=false*/)
417 415
 ) {
418 416
   const feedRate_t old_feedrate = feedrate_mm_s;
419 417
   if (fr_mm_s) feedrate_mm_s = fr_mm_s;
@@ -433,9 +431,7 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/
433 431
 
434 432
   feedrate_mm_s = old_feedrate;
435 433
   feedrate_percentage = old_pct;
436
-  #if HAS_EXTRUDERS
437
-    planner.e_factor[active_extruder] = old_fac;
438
-  #endif
434
+  TERN_(HAS_EXTRUDERS, planner.e_factor[active_extruder] = old_fac);
439 435
 }
440 436
 
441 437
 /**
@@ -607,10 +603,8 @@ void restore_feedrate_and_scaling() {
607 603
    * at the same positions relative to the machine.
608 604
    */
609 605
   void update_software_endstops(const AxisEnum axis
610
-    #if HAS_HOTEND_OFFSET
611
-      , const uint8_t old_tool_index/*=0*/
612
-      , const uint8_t new_tool_index/*=0*/
613
-    #endif
606
+    OPTARG(HAS_HOTEND_OFFSET, const uint8_t old_tool_index/*=0*/)
607
+    OPTARG(HAS_HOTEND_OFFSET, const uint8_t new_tool_index/*=0*/)
614 608
   ) {
615 609
 
616 610
     #if ENABLED(DUAL_X_CARRIAGE)
@@ -858,17 +852,13 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) {
858 852
       segment_idle(next_idle_ms);
859 853
       raw += segment_distance;
860 854
       if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, cartesian_segment_mm
861
-        #if ENABLED(SCARA_FEEDRATE_SCALING)
862
-          , inv_duration
863
-        #endif
855
+        OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
864 856
       )) break;
865 857
     }
866 858
 
867 859
     // Ensure last segment arrives at target location.
868 860
     planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, cartesian_segment_mm
869
-      #if ENABLED(SCARA_FEEDRATE_SCALING)
870
-        , inv_duration
871
-      #endif
861
+      OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
872 862
     );
873 863
 
874 864
     return false; // caller will update current_position
@@ -929,9 +919,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) {
929 919
         segment_idle(next_idle_ms);
930 920
         raw += segment_distance;
931 921
         if (!planner.buffer_line(raw, fr_mm_s, active_extruder, cartesian_segment_mm
932
-          #if ENABLED(SCARA_FEEDRATE_SCALING)
933
-            , inv_duration
934
-          #endif
922
+          OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
935 923
         )) break;
936 924
       }
937 925
 

+ 1
- 5
Marlin/src/module/motion.h View File

@@ -278,11 +278,7 @@ void line_to_current_position(const_feedRate_t fr_mm_s=feedrate_mm_s);
278 278
 
279 279
 void prepare_line_to_destination();
280 280
 
281
-void _internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f
282
-  #if IS_KINEMATIC
283
-    , const bool is_fast=false
284
-  #endif
285
-);
281
+void _internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f OPTARG(IS_KINEMATIC, const bool is_fast=false));
286 282
 
287 283
 inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f) {
288 284
   _internal_move_to_destination(fr_mm_s);

+ 6
- 18
Marlin/src/module/planner.cpp View File

@@ -1757,12 +1757,8 @@ void Planner::synchronize() {
1757 1757
  * Returns true if movement was properly queued, false otherwise (if cleaning)
1758 1758
  */
1759 1759
 bool Planner::_buffer_steps(const xyze_long_t &target
1760
-  #if HAS_POSITION_FLOAT
1761
-    , const xyze_pos_t &target_float
1762
-  #endif
1763
-  #if HAS_DIST_MM_ARG
1764
-    , const xyze_float_t &cart_dist_mm
1765
-  #endif
1760
+  OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float)
1761
+  OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
1766 1762
   , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters
1767 1763
 ) {
1768 1764
 
@@ -1823,12 +1819,8 @@ bool Planner::_buffer_steps(const xyze_long_t &target
1823 1819
  */
1824 1820
 bool Planner::_populate_block(block_t * const block, bool split_move,
1825 1821
   const abce_long_t &target
1826
-  #if HAS_POSITION_FLOAT
1827
-    , const xyze_pos_t &target_float
1828
-  #endif
1829
-  #if HAS_DIST_MM_ARG
1830
-    , const xyze_float_t &cart_dist_mm
1831
-  #endif
1822
+  OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float)
1823
+  OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
1832 1824
   , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
1833 1825
 ) {
1834 1826
 
@@ -2763,9 +2755,7 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_
2763 2755
  * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc.
2764 2756
  */
2765 2757
 bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e
2766
-  #if HAS_DIST_MM_ARG
2767
-    , const xyze_float_t &cart_dist_mm
2768
-  #endif
2758
+  OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
2769 2759
   , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
2770 2760
 ) {
2771 2761
 
@@ -2857,9 +2847,7 @@ bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c,
2857 2847
  *  inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
2858 2848
  */
2859 2849
 bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters
2860
-  #if ENABLED(SCARA_FEEDRATE_SCALING)
2861
-    , const_float_t inv_duration
2862
-  #endif
2850
+  OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration)
2863 2851
 ) {
2864 2852
   xyze_pos_t machine = { rx, ry, rz, e };
2865 2853
   TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine));

+ 11
- 32
Marlin/src/module/planner.h View File

@@ -707,12 +707,8 @@ class Planner {
707 707
      * Returns true if movement was buffered, false otherwise
708 708
      */
709 709
     static bool _buffer_steps(const xyze_long_t &target
710
-      #if HAS_POSITION_FLOAT
711
-        , const xyze_pos_t &target_float
712
-      #endif
713
-      #if HAS_DIST_MM_ARG
714
-        , const xyze_float_t &cart_dist_mm
715
-      #endif
710
+      OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float)
711
+      OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
716 712
       , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
717 713
     );
718 714
 
@@ -728,14 +724,9 @@ class Planner {
728 724
      *
729 725
      * Returns true is movement is acceptable, false otherwise
730 726
      */
731
-    static bool _populate_block(block_t * const block, bool split_move,
732
-        const xyze_long_t &target
733
-      #if HAS_POSITION_FLOAT
734
-        , const xyze_pos_t &target_float
735
-      #endif
736
-      #if HAS_DIST_MM_ARG
737
-        , const xyze_float_t &cart_dist_mm
738
-      #endif
727
+    static bool _populate_block(block_t * const block, bool split_move, const xyze_long_t &target
728
+      OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float)
729
+      OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
739 730
       , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
740 731
     );
741 732
 
@@ -768,22 +759,16 @@ class Planner {
768 759
      *  millimeters - the length of the movement, if known
769 760
      */
770 761
     static bool buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e
771
-      #if HAS_DIST_MM_ARG
772
-        , const xyze_float_t &cart_dist_mm
773
-      #endif
762
+      OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
774 763
       , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
775 764
     );
776 765
 
777 766
     FORCE_INLINE static bool buffer_segment(abce_pos_t &abce
778
-      #if HAS_DIST_MM_ARG
779
-        , const xyze_float_t &cart_dist_mm
780
-      #endif
767
+      OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
781 768
       , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
782 769
     ) {
783 770
       return buffer_segment(abce.a, abce.b, abce.c, abce.e
784
-        #if HAS_DIST_MM_ARG
785
-          , cart_dist_mm
786
-        #endif
771
+        OPTARG(HAS_DIST_MM_ARG, cart_dist_mm)
787 772
         , fr_mm_s, extruder, millimeters);
788 773
     }
789 774
 
@@ -801,20 +786,14 @@ class Planner {
801 786
      *  inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
802 787
      */
803 788
     static bool buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0
804
-      #if ENABLED(SCARA_FEEDRATE_SCALING)
805
-        , const_float_t inv_duration=0.0
806
-      #endif
789
+      OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0)
807 790
     );
808 791
 
809 792
     FORCE_INLINE static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0
810
-      #if ENABLED(SCARA_FEEDRATE_SCALING)
811
-        , const_float_t inv_duration=0.0
812
-      #endif
793
+      OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0)
813 794
     ) {
814 795
       return buffer_line(cart.x, cart.y, cart.z, cart.e, fr_mm_s, extruder, millimeters
815
-        #if ENABLED(SCARA_FEEDRATE_SCALING)
816
-          , inv_duration
817
-        #endif
796
+        OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
818 797
       );
819 798
     }
820 799
 

+ 15
- 62
Marlin/src/module/temperature.cpp View File

@@ -3335,11 +3335,8 @@ void Temperature::isr() {
3335 3335
    *   Extruder: " T0:nnn.nn /nnn.nn"
3336 3336
    *   With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)"
3337 3337
    */
3338
-  static void print_heater_state(const_celsius_float_t c, const_celsius_float_t t
3339
-    #if ENABLED(SHOW_TEMP_ADC_VALUES)
3340
-      , const float r
3341
-    #endif
3342
-    , const heater_id_t e=INDEX_NONE
3338
+  static void print_heater_state(const heater_id_t e, const_celsius_float_t c, const_celsius_float_t t
3339
+    OPTARG(SHOW_TEMP_ADC_VALUES, const float r)
3343 3340
   ) {
3344 3341
     char k;
3345 3342
     switch (e) {
@@ -3385,64 +3382,28 @@ void Temperature::isr() {
3385 3382
   }
3386 3383
 
3387 3384
   void Temperature::print_heater_states(const uint8_t target_extruder
3388
-    #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
3389
-      , const bool include_r/*=false*/
3390
-    #endif
3385
+    OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r/*=false*/)
3391 3386
   ) {
3392 3387
     #if HAS_TEMP_HOTEND
3393
-      print_heater_state(degHotend(target_extruder), degTargetHotend(target_extruder)
3394
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
3395
-          , rawHotendTemp(target_extruder)
3396
-        #endif
3397
-      );
3388
+      print_heater_state(H_NONE, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder)));
3398 3389
       #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
3399
-        if (include_r) print_heater_state(degHotendRedundant(), degTargetHotend(0)
3400
-          #if ENABLED(SHOW_TEMP_ADC_VALUES)
3401
-            , rawHotendTempRedundant()
3402
-          #endif
3403
-          , H_REDUNDANT
3404
-        );
3390
+        if (include_r) print_heater_state(H_REDUNDANT, degHotendRedundant(), degTargetHotend(0) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTempRedundant()));
3405 3391
       #endif
3406 3392
     #endif
3407 3393
     #if HAS_HEATED_BED
3408
-      print_heater_state(degBed(), degTargetBed()
3409
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
3410
-          , rawBedTemp()
3411
-        #endif
3412
-        , H_BED
3413
-      );
3394
+      print_heater_state(H_BED, degBed(), degTargetBed() OPTARG(SHOW_TEMP_ADC_VALUES, rawBedTemp()));
3414 3395
     #endif
3415 3396
     #if HAS_TEMP_CHAMBER
3416
-      print_heater_state(degChamber(), TERN0(HAS_HEATED_CHAMBER, degTargetChamber())
3417
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
3418
-          , rawChamberTemp()
3419
-        #endif
3420
-        , H_CHAMBER
3421
-      );
3422
-    #endif // HAS_TEMP_CHAMBER
3397
+      print_heater_state(H_CHAMBER, degChamber(), TERN0(HAS_HEATED_CHAMBER, degTargetChamber()) OPTARG(SHOW_TEMP_ADC_VALUES, rawChamberTemp()));
3398
+    #endif
3423 3399
     #if HAS_TEMP_COOLER
3424
-      print_heater_state(degCooler(), TERN0(HAS_COOLER, degTargetCooler())
3425
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
3426
-          , rawCoolerTemp()
3427
-        #endif
3428
-        , H_COOLER
3429
-      );
3430
-    #endif // HAS_TEMP_COOLER
3400
+      print_heater_state(H_COOLER, degCooler(), TERN0(HAS_COOLER, degTargetCooler()) OPTARG(SHOW_TEMP_ADC_VALUES, rawCoolerTemp()));
3401
+    #endif
3431 3402
     #if HAS_TEMP_PROBE
3432
-      print_heater_state(degProbe(), 0
3433
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
3434
-          , rawProbeTemp()
3435
-        #endif
3436
-        , H_PROBE
3437
-      );
3403
+      print_heater_state(H_PROBE, degProbe(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawProbeTemp()) );
3438 3404
     #endif
3439 3405
     #if HAS_MULTI_HOTEND
3440
-      HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e)
3441
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
3442
-          , rawHotendTemp(e)
3443
-        #endif
3444
-        , (heater_id_t)e
3445
-      );
3406
+      HOTEND_LOOP() print_heater_state((heater_id_t)e, degHotend(e), degTargetHotend(e) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(e)));
3446 3407
     #endif
3447 3408
     SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_id_t)target_extruder));
3448 3409
     #if HAS_HEATED_BED
@@ -3465,10 +3426,7 @@ void Temperature::isr() {
3465 3426
 
3466 3427
   #if ENABLED(AUTO_REPORT_TEMPERATURES)
3467 3428
     AutoReporter<Temperature::AutoReportTemp> Temperature::auto_reporter;
3468
-    void Temperature::AutoReportTemp::report() {
3469
-      print_heater_states(active_extruder);
3470
-      SERIAL_EOL();
3471
-    }
3429
+    void Temperature::AutoReportTemp::report() { print_heater_states(active_extruder); SERIAL_EOL(); }
3472 3430
   #endif
3473 3431
 
3474 3432
   #if HAS_HOTEND && HAS_STATUS_MESSAGE
@@ -3495,11 +3453,8 @@ void Temperature::isr() {
3495 3453
     #endif
3496 3454
 
3497 3455
     bool Temperature::wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling/*=true*/
3498
-      #if G26_CLICK_CAN_CANCEL
3499
-        , const bool click_to_cancel/*=false*/
3500
-      #endif
3456
+      OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel/*=false*/)
3501 3457
     ) {
3502
-
3503 3458
       #if ENABLED(AUTOTEMP)
3504 3459
         REMEMBER(1, planner.autotemp_enabled, false);
3505 3460
       #endif
@@ -3638,9 +3593,7 @@ void Temperature::isr() {
3638 3593
     #endif
3639 3594
 
3640 3595
     bool Temperature::wait_for_bed(const bool no_wait_for_cooling/*=true*/
3641
-      #if G26_CLICK_CAN_CANCEL
3642
-        , const bool click_to_cancel/*=false*/
3643
-      #endif
3596
+      OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel/*=false*/)
3644 3597
     ) {
3645 3598
       #if TEMP_BED_RESIDENCY_TIME > 0
3646 3599
         millis_t residency_start_ms = 0;

+ 27
- 44
Marlin/src/module/temperature.h View File

@@ -46,7 +46,7 @@
46 46
 
47 47
 // Element identifiers. Positive values are hotends. Negative values are other heaters or coolers.
48 48
 typedef enum : int8_t {
49
-  INDEX_NONE = -6,
49
+  H_NONE = -6,
50 50
   H_COOLER, H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED,
51 51
   H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7
52 52
 } heater_id_t;
@@ -395,21 +395,21 @@ class Temperature {
395 395
       } heater_idle_t;
396 396
 
397 397
       // Indices and size for the heater_idle array
398
-      #define _ENUM_FOR_E(N) IDLE_INDEX_E##N,
399
-      enum IdleIndex : uint8_t {
400
-        REPEAT(HOTENDS, _ENUM_FOR_E)
401
-        #if ENABLED(HAS_HEATED_BED)
402
-          IDLE_INDEX_BED,
403
-        #endif
404
-        NR_HEATER_IDLE
398
+      enum IdleIndex : int8_t {
399
+        _II = -1
400
+
401
+        #define _IDLE_INDEX_E(N) ,IDLE_INDEX_E##N
402
+        REPEAT(HOTENDS, _IDLE_INDEX_E)
403
+        #undef _IDLE_INDEX_E
404
+
405
+        OPTARG(HAS_HEATED_BED, IDLE_INDEX_BED)
406
+
407
+        , NR_HEATER_IDLE
405 408
       };
406
-      #undef _ENUM_FOR_E
407 409
 
408 410
       // Convert the given heater_id_t to idle array index
409 411
       static inline IdleIndex idle_index_for_id(const int8_t heater_id) {
410
-        #if HAS_HEATED_BED
411
-          if (heater_id == H_BED) return IDLE_INDEX_BED;
412
-        #endif
412
+        TERN_(HAS_HEATED_BED, if (heater_id == H_BED) return IDLE_INDEX_BED);
413 413
         return (IdleIndex)_MAX(heater_id, 0);
414 414
       }
415 415
 
@@ -672,9 +672,7 @@ class Temperature {
672 672
 
673 673
       #if HAS_TEMP_HOTEND
674 674
         static bool wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling=true
675
-          #if G26_CLICK_CAN_CANCEL
676
-            , const bool click_to_cancel=false
677
-          #endif
675
+          OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel=false)
678 676
         );
679 677
 
680 678
         #if ENABLED(WAIT_FOR_HOTEND)
@@ -721,9 +719,7 @@ class Temperature {
721 719
       }
722 720
 
723 721
       static bool wait_for_bed(const bool no_wait_for_cooling=true
724
-        #if G26_CLICK_CAN_CANCEL
725
-          , const bool click_to_cancel=false
726
-        #endif
722
+        OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel=false)
727 723
       );
728 724
 
729 725
       static void wait_for_bed_heating();
@@ -859,9 +855,7 @@ class Temperature {
859 855
 
860 856
     #if HAS_TEMP_SENSOR
861 857
       static void print_heater_states(const uint8_t target_extruder
862
-        #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
863
-          , const bool include_r=false
864
-        #endif
858
+        OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r=false)
865 859
       );
866 860
       #if ENABLED(AUTO_REPORT_TEMPERATURES)
867 861
         struct AutoReportTemp { static void report(); };
@@ -925,35 +919,24 @@ class Temperature {
925 919
     #if HAS_THERMAL_PROTECTION
926 920
 
927 921
       // Indices and size for the tr_state_machine array. One for each protected heater.
928
-      #define _ENUM_FOR_E(N) RUNAWAY_IND_E##N,
929
-      enum RunawayIndex : uint8_t {
922
+      enum RunawayIndex : int8_t {
923
+        _RI = -1
930 924
         #if ENABLED(THERMAL_PROTECTION_HOTENDS)
931
-          REPEAT(HOTENDS, _ENUM_FOR_E)
925
+          #define _RUNAWAY_IND_E(N) ,RUNAWAY_IND_E##N
926
+          REPEAT(HOTENDS, _RUNAWAY_IND_E)
927
+          #undef _RUNAWAY_IND_E
932 928
         #endif
933
-        #if ENABLED(HAS_THERMALLY_PROTECTED_BED)
934
-          RUNAWAY_IND_BED,
935
-        #endif
936
-        #if ENABLED(THERMAL_PROTECTION_CHAMBER)
937
-          RUNAWAY_IND_CHAMBER,
938
-        #endif
939
-        #if ENABLED(THERMAL_PROTECTION_COOLER)
940
-          RUNAWAY_IND_COOLER,
941
-        #endif
942
-        NR_HEATER_RUNAWAY
929
+        OPTARG(HAS_THERMALLY_PROTECTED_BED, RUNAWAY_IND_BED)
930
+        OPTARG(THERMAL_PROTECTION_CHAMBER, RUNAWAY_IND_CHAMBER)
931
+        OPTARG(THERMAL_PROTECTION_COOLER, RUNAWAY_IND_COOLER)
932
+        , NR_HEATER_RUNAWAY
943 933
       };
944
-      #undef _ENUM_FOR_E
945 934
 
946 935
       // Convert the given heater_id_t to runaway state array index
947 936
       static inline RunawayIndex runaway_index_for_id(const int8_t heater_id) {
948
-        #if HAS_THERMALLY_PROTECTED_CHAMBER
949
-          if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER;
950
-        #endif
951
-        #if HAS_THERMALLY_PROTECTED_CHAMBER
952
-          if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER;
953
-        #endif
954
-        #if HAS_THERMALLY_PROTECTED_BED
955
-          if (heater_id == H_BED) return RUNAWAY_IND_BED;
956
-        #endif
937
+        TERN_(HAS_THERMALLY_PROTECTED_CHAMBER, if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER);
938
+        TERN_(HAS_THERMALLY_PROTECTED_CHAMBER, if (heater_id == H_COOLER)  return RUNAWAY_IND_COOLER);
939
+        TERN_(HAS_THERMALLY_PROTECTED_BED,     if (heater_id == H_BED)     return RUNAWAY_IND_BED);
957 940
         return (RunawayIndex)_MAX(heater_id, 0);
958 941
       }
959 942
 

+ 1
- 9
Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp View File

@@ -956,12 +956,6 @@ uint8_t BulkOnly::HandleUsbError(uint8_t error, uint8_t index) {
956 956
   return ((error && !count) ? MASS_ERR_GENERAL_USB_ERROR : MASS_ERR_SUCCESS);
957 957
 }
958 958
 
959
-#if MS_WANT_PARSER
960
-  uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf) {
961
-    return Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf, 0);
962
-  }
963
-#endif
964
-
965 959
 /**
966 960
  * For driver use only.
967 961
  *
@@ -972,9 +966,7 @@ uint8_t BulkOnly::HandleUsbError(uint8_t error, uint8_t index) {
972 966
  * @return
973 967
  */
974 968
 uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf
975
-  #if MS_WANT_PARSER
976
-    , uint8_t flags
977
-  #endif
969
+  OPTARG(MS_WANT_PARSER, uint8_t flags/*=0*/)
978 970
 ) {
979 971
   #if MS_WANT_PARSER
980 972
     uint16_t bytes = (pcbw->dCBWDataTransferLength > buf_size) ? buf_size : pcbw->dCBWDataTransferLength;

+ 1
- 4
Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h View File

@@ -553,10 +553,7 @@ private:
553 553
   bool IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw);
554 554
 
555 555
   uint8_t ClearEpHalt(uint8_t index);
556
-  #if MS_WANT_PARSER
557
-    uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf, uint8_t flags);
558
-  #endif
559
-  uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf);
556
+  uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf OPTARG(MS_WANT_PARSER, uint8_t flags=0));
560 557
   uint8_t HandleUsbError(uint8_t error, uint8_t index);
561 558
   uint8_t HandleSCSIError(uint8_t status);
562 559
 };

Loading…
Cancel
Save