浏览代码

🎨 Macros for optional arguments (#21969)

Scott Lahteine 4 年前
父节点
当前提交
84fd0eff17
没有帐户链接到提交者的电子邮件

+ 5
- 0
Marlin/src/core/macros.h 查看文件

195
 #define __TERN(T,V...)      ___TERN(_CAT(_NO,T),V)  // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
195
 #define __TERN(T,V...)      ___TERN(_CAT(_NO,T),V)  // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
196
 #define ___TERN(P,V...)     THIRD(P,V)              // If first argument has a comma, A. Else B.
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
 // Macros to avoid 'f + 0.0' which is not always optimized away. Minus included for symmetry.
203
 // Macros to avoid 'f + 0.0' which is not always optimized away. Minus included for symmetry.
199
 // Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc.
204
 // Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc.
200
 #define PLUS_TERN0(O,A)     _TERN(_ENA_1(O),,+ (A)) // OPTION ? '+ (A)' : '<nul>'
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 查看文件

103
   }
103
   }
104
 
104
 
105
   static float get_z(const xy_pos_t &pos
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
     #if DISABLED(ENABLE_LEVELING_FADE_HEIGHT)
108
     #if DISABLED(ENABLE_LEVELING_FADE_HEIGHT)
111
       constexpr float factor = 1.0f;
109
       constexpr float factor = 1.0f;

+ 2
- 6
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp 查看文件

362
       while (--segments) {
362
       while (--segments) {
363
         raw += diff;
363
         raw += diff;
364
         planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm
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
       planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, segment_xyz_mm
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
       return false; // Did not set current from destination
371
       return false; // Did not set current from destination
376
     }
372
     }

+ 1
- 1
Marlin/src/feature/caselight.cpp 查看文件

41
 #if CASE_LIGHT_IS_COLOR_LED
41
 #if CASE_LIGHT_IS_COLOR_LED
42
   #include "leds/leds.h"
42
   #include "leds/leds.h"
43
   constexpr uint8_t init_case_light[] = CASE_LIGHT_DEFAULT_COLOR;
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
 #endif
45
 #endif
46
 
46
 
47
 void CaseLight::update(const bool sflag) {
47
 void CaseLight::update(const bool sflag) {

+ 1
- 5
Marlin/src/feature/fwretract.cpp 查看文件

91
  * Note: Auto-retract will apply the set Z hop in addition to any Z hop
91
  * Note: Auto-retract will apply the set Z hop in addition to any Z hop
92
  *       included in the G-code. Use M207 Z0 to to prevent double hop.
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
   // Prevent two retracts or recovers in a row
95
   // Prevent two retracts or recovers in a row
100
   if (retracted[active_extruder] == retracting) return;
96
   if (retracted[active_extruder] == retracting) return;
101
 
97
 

+ 1
- 5
Marlin/src/feature/fwretract.h 查看文件

74
     #endif
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
   static void M207();
79
   static void M207();
84
   static void M207_report(const bool forReplay=false);
80
   static void M207_report(const bool forReplay=false);

+ 1
- 3
Marlin/src/feature/leds/leds.cpp 查看文件

75
 }
75
 }
76
 
76
 
77
 void LEDLights::set_color(const LEDColor &incol
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
   #if ENABLED(NEOPIXEL_LED)
81
   #if ENABLED(NEOPIXEL_LED)

+ 14
- 57
Marlin/src/feature/leds/leds.h 查看文件

43
  */
43
  */
44
 typedef struct LEDColor {
44
 typedef struct LEDColor {
45
   uint8_t r, g, b
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
   LEDColor() : r(255), g(255), b(255)
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
   LEDColor(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2])
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
   LEDColor& operator=(const uint8_t (&rgbw)[4]) {
63
   LEDColor& operator=(const uint8_t (&rgbw)[4]) {
111
 /**
86
 /**
112
  * Color helpers and presets
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
 #define LEDColorOff()             LEDColor(  0,   0,   0)
91
 #define LEDColorOff()             LEDColor(  0,   0,   0)
125
 #define LEDColorRed()             LEDColor(255,   0,   0)
92
 #define LEDColorRed()             LEDColor(255,   0,   0)
147
   static void setup(); // init()
114
   static void setup(); // init()
148
 
115
 
149
   static void set_color(const LEDColor &color
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
   static inline void set_color(uint8_t r, uint8_t g, uint8_t b
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
   static inline void set_off()   { set_color(LEDColorOff()); }
128
   static inline void set_off()   { set_color(LEDColorOff()); }

+ 2
- 6
Marlin/src/feature/leds/pca9632.cpp 查看文件

93
 }
93
 }
94
 
94
 
95
 static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const byte vr, const byte vg, const byte vb
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
   #if DISABLED(PCA9632_NO_AUTO_INC)
98
   #if DISABLED(PCA9632_NO_AUTO_INC)
101
     uint8_t data[4];
99
     uint8_t data[4];
143
                     ;
141
                     ;
144
 
142
 
145
   PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, color.r, color.g, color.b
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
   PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT);
146
   PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT);
151
 }
147
 }

+ 3
- 9
Marlin/src/feature/tmc_util.h 查看文件

70
     }
70
     }
71
 
71
 
72
     struct {
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
     } stored;
76
     } stored;
83
 };
77
 };
84
 
78
 

+ 4
- 11
Marlin/src/gcode/bedlevel/G26.cpp 查看文件

330
         thermalManager.setTargetBed(bed_temp);
330
         thermalManager.setTargetBed(bed_temp);
331
 
331
 
332
         // Wait for the temperature to stabilize
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
     #else
337
     #else
352
     thermalManager.setTargetHotend(hotend_temp, active_extruder);
348
     thermalManager.setTargetHotend(hotend_temp, active_extruder);
353
 
349
 
354
     // Wait for the temperature to stabilize
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
     #if HAS_WIRED_LCD
354
     #if HAS_WIRED_LCD
362
       ui.reset_status();
355
       ui.reset_status();

+ 2
- 6
Marlin/src/gcode/motion/G2_G3.cpp 查看文件

249
     #endif
249
     #endif
250
 
250
 
251
     if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0
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
     )) break;
253
     )) break;
256
   }
254
   }
257
 
255
 
266
   #endif
264
   #endif
267
 
265
 
268
   planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0
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
   TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L);
270
   TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L);

+ 2
- 6
Marlin/src/gcode/queue.cpp 查看文件

84
 
84
 
85
 
85
 
86
 void GCodeQueue::RingBuffer::commit_command(bool skip_ok
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
   commands[index_w].skip_ok = skip_ok;
89
   commands[index_w].skip_ok = skip_ok;
92
   TERN_(HAS_MULTI_SERIAL, commands[index_w].port = serial_ind);
90
   TERN_(HAS_MULTI_SERIAL, commands[index_w].port = serial_ind);
100
  * Return false for a full buffer, or if the 'command' is a comment.
98
  * Return false for a full buffer, or if the 'command' is a comment.
101
  */
99
  */
102
 bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/
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
   if (*cmd == ';' || length >= BUFSIZE) return false;
103
   if (*cmd == ';' || length >= BUFSIZE) return false;
108
   strcpy(commands[index_w].buffer, cmd);
104
   strcpy(commands[index_w].buffer, cmd);

+ 2
- 6
Marlin/src/gcode/queue.h 查看文件

80
     void advance_pos(uint8_t &p, const int inc) { if (++p >= BUFSIZE) p = 0; length += inc; }
80
     void advance_pos(uint8_t &p, const int inc) { if (++p >= BUFSIZE) p = 0; length += inc; }
81
 
81
 
82
     void commit_command(bool skip_ok
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
     bool enqueue(const char *cmd, bool skip_ok = true
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
     void ok_to_send();
90
     void ok_to_send();

+ 2
- 6
Marlin/src/lcd/marlinui.cpp 查看文件

758
   // Tell ui.update() to start a move to current_position after a short delay.
758
   // Tell ui.update() to start a move to current_position after a short delay.
759
   //
759
   //
760
   void ManualMove::soon(const AxisEnum move_axis
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
     start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
764
     start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
769
     axis = move_axis;
765
     axis = move_axis;
770
     //SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon.");
766
     //SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon.");

+ 1
- 5
Marlin/src/lcd/marlinui.h 查看文件

182
       static bool constexpr processing = false;
182
       static bool constexpr processing = false;
183
     #endif
183
     #endif
184
     static void task();
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
 #endif
188
 #endif

+ 4
- 8
Marlin/src/lcd/menu/menu_motion.cpp 查看文件

94
 
94
 
95
 #if E_MANUAL
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
     if (ui.use_click()) return ui.goto_previous_screen_no_defer();
98
     if (ui.use_click()) return ui.goto_previous_screen_no_defer();
99
     if (ui.encoderPosition) {
99
     if (ui.encoderPosition) {
100
       if (!ui.manual_move.processing) {
100
       if (!ui.manual_move.processing) {
101
         const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale;
101
         const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale;
102
         TERN(IS_KINEMATIC, ui.manual_move.offset, current_position.e) += diff;
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
         ui.refresh(LCDVIEW_REDRAW_NOW);
104
         ui.refresh(LCDVIEW_REDRAW_NOW);
109
       }
105
       }
110
       ui.encoderPosition = 0;
106
       ui.encoderPosition = 0;
139
   ui.goto_screen(_manual_move_func_ptr);
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
   _manual_move_func_ptr = func;
139
   _manual_move_func_ptr = func;
144
   START_MENU();
140
   START_MENU();
145
   if (LCD_HEIGHT >= 4) {
141
   if (LCD_HEIGHT >= 4) {
188
 #if E_MANUAL
184
 #if E_MANUAL
189
 
185
 
190
   inline void _goto_menu_move_distance_e() {
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
   inline void _menu_move_distance_e_maybe() {
190
   inline void _menu_move_distance_e_maybe() {

+ 1
- 5
Marlin/src/lcd/tft/ui_1024x600.cpp 查看文件

724
       drawMessage(msg);
724
       drawMessage(msg);
725
     #endif
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
   drawAxisValue(axis);
730
   drawAxisValue(axis);

+ 1
- 5
Marlin/src/lcd/tft/ui_320x240.cpp 查看文件

709
       drawMessage(msg);
709
       drawMessage(msg);
710
     #endif
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
   drawAxisValue(axis);
715
   drawAxisValue(axis);

+ 1
- 5
Marlin/src/lcd/tft/ui_480x320.cpp 查看文件

711
       drawMessage(msg);
711
       drawMessage(msg);
712
     #endif
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
   drawAxisValue(axis);
717
   drawAxisValue(axis);

+ 7
- 19
Marlin/src/module/motion.cpp 查看文件

411
  *  - Extrude the specified length regardless of flow percentage.
411
  *  - Extrude the specified length regardless of flow percentage.
412
  */
412
  */
413
 void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/
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
   const feedRate_t old_feedrate = feedrate_mm_s;
416
   const feedRate_t old_feedrate = feedrate_mm_s;
419
   if (fr_mm_s) feedrate_mm_s = fr_mm_s;
417
   if (fr_mm_s) feedrate_mm_s = fr_mm_s;
433
 
431
 
434
   feedrate_mm_s = old_feedrate;
432
   feedrate_mm_s = old_feedrate;
435
   feedrate_percentage = old_pct;
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
    * at the same positions relative to the machine.
603
    * at the same positions relative to the machine.
608
    */
604
    */
609
   void update_software_endstops(const AxisEnum axis
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
     #if ENABLED(DUAL_X_CARRIAGE)
610
     #if ENABLED(DUAL_X_CARRIAGE)
858
       segment_idle(next_idle_ms);
852
       segment_idle(next_idle_ms);
859
       raw += segment_distance;
853
       raw += segment_distance;
860
       if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, cartesian_segment_mm
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
       )) break;
856
       )) break;
865
     }
857
     }
866
 
858
 
867
     // Ensure last segment arrives at target location.
859
     // Ensure last segment arrives at target location.
868
     planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, cartesian_segment_mm
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
     return false; // caller will update current_position
864
     return false; // caller will update current_position
929
         segment_idle(next_idle_ms);
919
         segment_idle(next_idle_ms);
930
         raw += segment_distance;
920
         raw += segment_distance;
931
         if (!planner.buffer_line(raw, fr_mm_s, active_extruder, cartesian_segment_mm
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
         )) break;
923
         )) break;
936
       }
924
       }
937
 
925
 

+ 1
- 5
Marlin/src/module/motion.h 查看文件

278
 
278
 
279
 void prepare_line_to_destination();
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
 inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f) {
283
 inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f) {
288
   _internal_move_to_destination(fr_mm_s);
284
   _internal_move_to_destination(fr_mm_s);

+ 6
- 18
Marlin/src/module/planner.cpp 查看文件

1757
  * Returns true if movement was properly queued, false otherwise (if cleaning)
1757
  * Returns true if movement was properly queued, false otherwise (if cleaning)
1758
  */
1758
  */
1759
 bool Planner::_buffer_steps(const xyze_long_t &target
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
   , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters
1762
   , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters
1767
 ) {
1763
 ) {
1768
 
1764
 
1823
  */
1819
  */
1824
 bool Planner::_populate_block(block_t * const block, bool split_move,
1820
 bool Planner::_populate_block(block_t * const block, bool split_move,
1825
   const abce_long_t &target
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
   , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
1824
   , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
1833
 ) {
1825
 ) {
1834
 
1826
 
2763
  * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc.
2755
  * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc.
2764
  */
2756
  */
2765
 bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e
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
   , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
2759
   , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
2770
 ) {
2760
 ) {
2771
 
2761
 
2857
  *  inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
2847
  *  inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
2858
  */
2848
  */
2859
 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
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
   xyze_pos_t machine = { rx, ry, rz, e };
2852
   xyze_pos_t machine = { rx, ry, rz, e };
2865
   TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine));
2853
   TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine));

+ 11
- 32
Marlin/src/module/planner.h 查看文件

707
      * Returns true if movement was buffered, false otherwise
707
      * Returns true if movement was buffered, false otherwise
708
      */
708
      */
709
     static bool _buffer_steps(const xyze_long_t &target
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
       , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
712
       , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
717
     );
713
     );
718
 
714
 
728
      *
724
      *
729
      * Returns true is movement is acceptable, false otherwise
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
       , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
730
       , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
740
     );
731
     );
741
 
732
 
768
      *  millimeters - the length of the movement, if known
759
      *  millimeters - the length of the movement, if known
769
      */
760
      */
770
     static bool buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e
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
       , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
763
       , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
775
     );
764
     );
776
 
765
 
777
     FORCE_INLINE static bool buffer_segment(abce_pos_t &abce
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
       , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
768
       , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
782
     ) {
769
     ) {
783
       return buffer_segment(abce.a, abce.b, abce.c, abce.e
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
         , fr_mm_s, extruder, millimeters);
772
         , fr_mm_s, extruder, millimeters);
788
     }
773
     }
789
 
774
 
801
      *  inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
786
      *  inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
802
      */
787
      */
803
     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
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
     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
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
       return buffer_line(cart.x, cart.y, cart.z, cart.e, fr_mm_s, extruder, millimeters
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 查看文件

3335
    *   Extruder: " T0:nnn.nn /nnn.nn"
3335
    *   Extruder: " T0:nnn.nn /nnn.nn"
3336
    *   With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)"
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
     char k;
3341
     char k;
3345
     switch (e) {
3342
     switch (e) {
3385
   }
3382
   }
3386
 
3383
 
3387
   void Temperature::print_heater_states(const uint8_t target_extruder
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
     #if HAS_TEMP_HOTEND
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
       #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
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
       #endif
3391
       #endif
3406
     #endif
3392
     #endif
3407
     #if HAS_HEATED_BED
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
     #endif
3395
     #endif
3415
     #if HAS_TEMP_CHAMBER
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
     #if HAS_TEMP_COOLER
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
     #if HAS_TEMP_PROBE
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
     #endif
3404
     #endif
3439
     #if HAS_MULTI_HOTEND
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
     #endif
3407
     #endif
3447
     SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_id_t)target_extruder));
3408
     SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_id_t)target_extruder));
3448
     #if HAS_HEATED_BED
3409
     #if HAS_HEATED_BED
3465
 
3426
 
3466
   #if ENABLED(AUTO_REPORT_TEMPERATURES)
3427
   #if ENABLED(AUTO_REPORT_TEMPERATURES)
3467
     AutoReporter<Temperature::AutoReportTemp> Temperature::auto_reporter;
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
   #endif
3430
   #endif
3473
 
3431
 
3474
   #if HAS_HOTEND && HAS_STATUS_MESSAGE
3432
   #if HAS_HOTEND && HAS_STATUS_MESSAGE
3495
     #endif
3453
     #endif
3496
 
3454
 
3497
     bool Temperature::wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling/*=true*/
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
       #if ENABLED(AUTOTEMP)
3458
       #if ENABLED(AUTOTEMP)
3504
         REMEMBER(1, planner.autotemp_enabled, false);
3459
         REMEMBER(1, planner.autotemp_enabled, false);
3505
       #endif
3460
       #endif
3638
     #endif
3593
     #endif
3639
 
3594
 
3640
     bool Temperature::wait_for_bed(const bool no_wait_for_cooling/*=true*/
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
       #if TEMP_BED_RESIDENCY_TIME > 0
3598
       #if TEMP_BED_RESIDENCY_TIME > 0
3646
         millis_t residency_start_ms = 0;
3599
         millis_t residency_start_ms = 0;

+ 27
- 44
Marlin/src/module/temperature.h 查看文件

46
 
46
 
47
 // Element identifiers. Positive values are hotends. Negative values are other heaters or coolers.
47
 // Element identifiers. Positive values are hotends. Negative values are other heaters or coolers.
48
 typedef enum : int8_t {
48
 typedef enum : int8_t {
49
-  INDEX_NONE = -6,
49
+  H_NONE = -6,
50
   H_COOLER, H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED,
50
   H_COOLER, H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED,
51
   H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7
51
   H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7
52
 } heater_id_t;
52
 } heater_id_t;
395
       } heater_idle_t;
395
       } heater_idle_t;
396
 
396
 
397
       // Indices and size for the heater_idle array
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
       // Convert the given heater_id_t to idle array index
410
       // Convert the given heater_id_t to idle array index
409
       static inline IdleIndex idle_index_for_id(const int8_t heater_id) {
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
         return (IdleIndex)_MAX(heater_id, 0);
413
         return (IdleIndex)_MAX(heater_id, 0);
414
       }
414
       }
415
 
415
 
672
 
672
 
673
       #if HAS_TEMP_HOTEND
673
       #if HAS_TEMP_HOTEND
674
         static bool wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling=true
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
         #if ENABLED(WAIT_FOR_HOTEND)
678
         #if ENABLED(WAIT_FOR_HOTEND)
721
       }
719
       }
722
 
720
 
723
       static bool wait_for_bed(const bool no_wait_for_cooling=true
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
       static void wait_for_bed_heating();
725
       static void wait_for_bed_heating();
859
 
855
 
860
     #if HAS_TEMP_SENSOR
856
     #if HAS_TEMP_SENSOR
861
       static void print_heater_states(const uint8_t target_extruder
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
       #if ENABLED(AUTO_REPORT_TEMPERATURES)
860
       #if ENABLED(AUTO_REPORT_TEMPERATURES)
867
         struct AutoReportTemp { static void report(); };
861
         struct AutoReportTemp { static void report(); };
925
     #if HAS_THERMAL_PROTECTION
919
     #if HAS_THERMAL_PROTECTION
926
 
920
 
927
       // Indices and size for the tr_state_machine array. One for each protected heater.
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
         #if ENABLED(THERMAL_PROTECTION_HOTENDS)
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
         #endif
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
       // Convert the given heater_id_t to runaway state array index
935
       // Convert the given heater_id_t to runaway state array index
947
       static inline RunawayIndex runaway_index_for_id(const int8_t heater_id) {
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
         return (RunawayIndex)_MAX(heater_id, 0);
940
         return (RunawayIndex)_MAX(heater_id, 0);
958
       }
941
       }
959
 
942
 

+ 1
- 9
Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp 查看文件

956
   return ((error && !count) ? MASS_ERR_GENERAL_USB_ERROR : MASS_ERR_SUCCESS);
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
  * For driver use only.
960
  * For driver use only.
967
  *
961
  *
972
  * @return
966
  * @return
973
  */
967
  */
974
 uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf
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
   #if MS_WANT_PARSER
971
   #if MS_WANT_PARSER
980
     uint16_t bytes = (pcbw->dCBWDataTransferLength > buf_size) ? buf_size : pcbw->dCBWDataTransferLength;
972
     uint16_t bytes = (pcbw->dCBWDataTransferLength > buf_size) ? buf_size : pcbw->dCBWDataTransferLength;

+ 1
- 4
Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h 查看文件

553
   bool IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw);
553
   bool IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw);
554
 
554
 
555
   uint8_t ClearEpHalt(uint8_t index);
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
   uint8_t HandleUsbError(uint8_t error, uint8_t index);
557
   uint8_t HandleUsbError(uint8_t error, uint8_t index);
561
   uint8_t HandleSCSIError(uint8_t status);
558
   uint8_t HandleSCSIError(uint8_t status);
562
 };
559
 };

正在加载...
取消
保存