Przeglądaj źródła

Apply TERN to compact code (#17619)

Scott Lahteine 4 lat temu
rodzic
commit
6d90d1e1f5
No account linked to committer's email address
100 zmienionych plików z 643 dodań i 1652 usunięć
  1. 2
    6
      Marlin/src/HAL/DUE/MarlinSerialUSB.cpp
  2. 17
    39
      Marlin/src/HAL/DUE/endstop_interrupts.h
  3. 1
    1
      Marlin/src/HAL/DUE/fastio.h
  4. 13
    39
      Marlin/src/HAL/ESP32/HAL.cpp
  5. 1
    3
      Marlin/src/HAL/ESP32/Servo.cpp
  6. 17
    39
      Marlin/src/HAL/ESP32/endstop_interrupts.h
  7. 1
    3
      Marlin/src/HAL/HAL.h
  8. 1
    5
      Marlin/src/HAL/LPC1768/DebugMonitor.cpp
  9. 1
    3
      Marlin/src/HAL/LPC1768/HAL.cpp
  10. 2
    3
      Marlin/src/HAL/LPC1768/MarlinSerial.h
  11. 1
    3
      Marlin/src/HAL/LPC1768/Servo.h
  12. 22
    75
      Marlin/src/HAL/SAMD51/HAL.cpp
  13. 5
    7
      Marlin/src/HAL/STM32/HAL.cpp
  14. 1
    1
      Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp
  15. 1
    3
      Marlin/src/HAL/STM32/Servo.cpp
  16. 18
    39
      Marlin/src/HAL/STM32/endstop_interrupts.h
  17. 1
    3
      Marlin/src/HAL/STM32F1/Servo.cpp
  18. 18
    39
      Marlin/src/HAL/STM32F1/endstop_interrupts.h
  19. 1
    3
      Marlin/src/HAL/STM32_F4_F7/Servo.cpp
  20. 18
    39
      Marlin/src/HAL/STM32_F4_F7/endstop_interrupts.h
  21. 1
    3
      Marlin/src/HAL/TEENSY31_32/Servo.cpp
  22. 17
    27
      Marlin/src/HAL/TEENSY31_32/endstop_interrupts.h
  23. 1
    3
      Marlin/src/HAL/TEENSY35_36/Servo.cpp
  24. 17
    39
      Marlin/src/HAL/TEENSY35_36/endstop_interrupts.h
  25. 1
    3
      Marlin/src/HAL/shared/servo.cpp
  26. 27
    83
      Marlin/src/MarlinCore.cpp
  27. 7
    2
      Marlin/src/core/drivers.h
  28. 16
    16
      Marlin/src/core/utility.cpp
  29. 4
    9
      Marlin/src/feature/babystep.cpp
  30. 2
    5
      Marlin/src/feature/babystep.h
  31. 6
    16
      Marlin/src/feature/backlash.h
  32. 2
    6
      Marlin/src/feature/bedlevel/abl/abl.cpp
  33. 2
    6
      Marlin/src/feature/bedlevel/bedlevel.cpp
  34. 1
    3
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  35. 37
    103
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  36. 3
    9
      Marlin/src/feature/binary_protocol.h
  37. 1
    3
      Marlin/src/feature/bltouch.cpp
  38. 2
    5
      Marlin/src/feature/controllerfan.cpp
  39. 1
    5
      Marlin/src/feature/controllerfan.h
  40. 1
    3
      Marlin/src/feature/encoder_i2c.cpp
  41. 8
    8
      Marlin/src/feature/fwretract.cpp
  42. 2
    8
      Marlin/src/feature/host_actions.cpp
  43. 1
    3
      Marlin/src/feature/joystick.cpp
  44. 4
    12
      Marlin/src/feature/joystick.h
  45. 4
    12
      Marlin/src/feature/leds/leds.cpp
  46. 4
    4
      Marlin/src/feature/leds/leds.h
  47. 11
    12
      Marlin/src/feature/leds/neopixel.h
  48. 4
    4
      Marlin/src/feature/leds/printer_event_leds.cpp
  49. 1
    4
      Marlin/src/feature/leds/tempstat.cpp
  50. 4
    8
      Marlin/src/feature/mixing.cpp
  51. 15
    23
      Marlin/src/feature/mixing.h
  52. 2
    6
      Marlin/src/feature/mmu2/mmu2.cpp
  53. 27
    80
      Marlin/src/feature/pause.cpp
  54. 4
    10
      Marlin/src/feature/power.cpp
  55. 9
    31
      Marlin/src/feature/powerloss.cpp
  56. 1
    3
      Marlin/src/feature/probe_temp_comp.h
  57. 2
    6
      Marlin/src/feature/runout.cpp
  58. 2
    6
      Marlin/src/feature/spindle_laser.cpp
  59. 1
    3
      Marlin/src/feature/spindle_laser.h
  60. 6
    12
      Marlin/src/feature/tmc_util.cpp
  61. 10
    30
      Marlin/src/feature/tmc_util.h
  62. 12
    29
      Marlin/src/gcode/bedlevel/G26.cpp
  63. 4
    12
      Marlin/src/gcode/bedlevel/M420.cpp
  64. 18
    54
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  65. 2
    6
      Marlin/src/gcode/bedlevel/abl/M421.cpp
  66. 4
    12
      Marlin/src/gcode/bedlevel/mbl/G29.cpp
  67. 1
    3
      Marlin/src/gcode/bedlevel/ubl/M421.cpp
  68. 19
    49
      Marlin/src/gcode/calibrate/G28.cpp
  69. 8
    25
      Marlin/src/gcode/calibrate/G33.cpp
  70. 8
    20
      Marlin/src/gcode/calibrate/G34_M422.cpp
  71. 12
    38
      Marlin/src/gcode/calibrate/G425.cpp
  72. 4
    12
      Marlin/src/gcode/calibrate/G76_M871.cpp
  73. 1
    3
      Marlin/src/gcode/calibrate/M48.cpp
  74. 1
    3
      Marlin/src/gcode/config/M200-M205.cpp
  75. 3
    9
      Marlin/src/gcode/config/M43.cpp
  76. 1
    3
      Marlin/src/gcode/control/M108_M112_M410.cpp
  77. 2
    6
      Marlin/src/gcode/control/M17_M18_M84.cpp
  78. 2
    6
      Marlin/src/gcode/feature/digipot/M907-M910.cpp
  79. 6
    19
      Marlin/src/gcode/feature/pause/M125.cpp
  80. 4
    12
      Marlin/src/gcode/feature/pause/M600.cpp
  81. 6
    18
      Marlin/src/gcode/feature/pause/M701_M702.cpp
  82. 1
    3
      Marlin/src/gcode/feature/powerloss/M1000.cpp
  83. 1
    3
      Marlin/src/gcode/gcode.cpp
  84. 69
    207
      Marlin/src/gcode/gcode.h
  85. 1
    3
      Marlin/src/gcode/host/M114.cpp
  86. 3
    7
      Marlin/src/gcode/host/M115.cpp
  87. 2
    6
      Marlin/src/gcode/lcd/M0_M1.cpp
  88. 7
    16
      Marlin/src/gcode/motion/G2_G3.cpp
  89. 8
    21
      Marlin/src/gcode/parser.cpp
  90. 1
    3
      Marlin/src/gcode/probe/G30.cpp
  91. 2
    6
      Marlin/src/gcode/probe/M951.cpp
  92. 3
    9
      Marlin/src/gcode/queue.cpp
  93. 5
    15
      Marlin/src/gcode/sd/M1001.cpp
  94. 1
    3
      Marlin/src/gcode/sd/M23.cpp
  95. 3
    9
      Marlin/src/gcode/sd/M24_M25.cpp
  96. 2
    6
      Marlin/src/gcode/temp/M104_M109.cpp
  97. 1
    3
      Marlin/src/gcode/temp/M140_M190.cpp
  98. 1
    3
      Marlin/src/gcode/temp/M141_M191.cpp
  99. 1
    3
      Marlin/src/gcode/temp/M303.cpp
  100. 0
    0
      Marlin/src/inc/Conditionals_LCD.h

+ 2
- 6
Marlin/src/HAL/DUE/MarlinSerialUSB.cpp Wyświetl plik

@@ -73,9 +73,7 @@ int MarlinSerialUSB::peek() {
73 73
 
74 74
   pending_char = udi_cdc_getc();
75 75
 
76
-  #if ENABLED(EMERGENCY_PARSER)
77
-    emergency_parser.update(emergency_state, (char)pending_char);
78
-  #endif
76
+  TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)pending_char));
79 77
 
80 78
   return pending_char;
81 79
 }
@@ -97,9 +95,7 @@ int MarlinSerialUSB::read() {
97 95
 
98 96
   int c = udi_cdc_getc();
99 97
 
100
-  #if ENABLED(EMERGENCY_PARSER)
101
-    emergency_parser.update(emergency_state, (char)c);
102
-  #endif
98
+  TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)c));
103 99
 
104 100
   return c;
105 101
 }

+ 17
- 39
Marlin/src/HAL/DUE/endstop_interrupts.h Wyświetl plik

@@ -47,43 +47,21 @@ void endstop_ISR() { endstops.update(); }
47 47
 
48 48
 void setup_endstop_interrupts() {
49 49
   #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
50
-  #if HAS_X_MAX
51
-    _ATTACH(X_MAX_PIN);
52
-  #endif
53
-  #if HAS_X_MIN
54
-    _ATTACH(X_MIN_PIN);
55
-  #endif
56
-  #if HAS_Y_MAX
57
-    _ATTACH(Y_MAX_PIN);
58
-  #endif
59
-  #if HAS_Y_MIN
60
-    _ATTACH(Y_MIN_PIN);
61
-  #endif
62
-  #if HAS_Z_MAX
63
-    _ATTACH(Z_MAX_PIN);
64
-  #endif
65
-  #if HAS_Z_MIN
66
-     _ATTACH(Z_MIN_PIN);
67
-  #endif
68
-  #if HAS_Z2_MAX
69
-    _ATTACH(Z2_MAX_PIN);
70
-  #endif
71
-  #if HAS_Z2_MIN
72
-    _ATTACH(Z2_MIN_PIN);
73
-  #endif
74
-  #if HAS_Z3_MAX
75
-    _ATTACH(Z3_MAX_PIN);
76
-  #endif
77
-  #if HAS_Z3_MIN
78
-    _ATTACH(Z3_MIN_PIN);
79
-  #endif
80
-  #if HAS_Z4_MAX
81
-    _ATTACH(Z4_MAX_PIN);
82
-  #endif
83
-  #if HAS_Z4_MIN
84
-    _ATTACH(Z4_MIN_PIN);
85
-  #endif
86
-  #if HAS_Z_MIN_PROBE_PIN
87
-    _ATTACH(Z_MIN_PROBE_PIN);
88
-  #endif
50
+  TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
51
+  TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
52
+  TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
53
+  TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
54
+  TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
55
+  TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
56
+  TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
57
+  TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
58
+  TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
59
+  TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
60
+  TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
61
+  TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
62
+  TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
63
+  TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
64
+  TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
65
+  TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
66
+  TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
89 67
 }

+ 1
- 1
Marlin/src/HAL/DUE/fastio.h Wyświetl plik

@@ -174,7 +174,7 @@
174 174
 #define IS_OUTPUT(IO)        ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
175 175
 
176 176
 // Shorthand
177
-#define OUT_WRITE(IO,V)       { SET_OUTPUT(IO); WRITE(IO,V); }
177
+#define OUT_WRITE(IO,V)      do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
178 178
 
179 179
 // digitalRead/Write wrappers
180 180
 #define extDigitalRead(IO)    digitalRead(IO)

+ 13
- 39
Marlin/src/HAL/ESP32/HAL.cpp Wyświetl plik

@@ -97,9 +97,7 @@ void HAL_init_board() {
97 97
     esp3dlib.init();
98 98
   #elif ENABLED(WIFISUPPORT)
99 99
     wifi_init();
100
-    #if ENABLED(OTASUPPORT)
101
-      OTA_init();
102
-    #endif
100
+    TERN_(OTASUPPORT, OTA_init());
103 101
     #if ENABLED(WEBSUPPORT)
104 102
       spiffs_init();
105 103
       web_init();
@@ -133,9 +131,7 @@ void HAL_idletask() {
133 131
   #if BOTH(WIFISUPPORT, OTASUPPORT)
134 132
     OTA_handle();
135 133
   #endif
136
-  #if ENABLED(ESP3D_WIFISUPPORT)
137
-    esp3dlib.idletask();
138
-  #endif
134
+  TERN_(ESP3D_WIFISUPPORT, esp3dlib.idletask());
139 135
 }
140 136
 
141 137
 void HAL_clear_reset_source() { }
@@ -176,39 +172,17 @@ void HAL_adc_init() {
176 172
   adc1_config_width(ADC_WIDTH_12Bit);
177 173
 
178 174
   // Configure channels only if used as (re-)configuring a pin for ADC that is used elsewhere might have adverse effects
179
-  #if HAS_TEMP_ADC_0
180
-    adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db);
181
-  #endif
182
-  #if HAS_TEMP_ADC_1
183
-    adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db);
184
-  #endif
185
-  #if HAS_TEMP_ADC_2
186
-    adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db);
187
-  #endif
188
-  #if HAS_TEMP_ADC_3
189
-    adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db);
190
-  #endif
191
-  #if HAS_TEMP_ADC_4
192
-    adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db);
193
-  #endif
194
-  #if HAS_TEMP_ADC_5
195
-    adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db);
196
-  #endif
197
-  #if HAS_TEMP_ADC_6
198
-    adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db);
199
-  #endif
200
-  #if HAS_TEMP_ADC_7
201
-    adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db);
202
-  #endif
203
-  #if HAS_HEATED_BED
204
-    adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db);
205
-  #endif
206
-  #if HAS_TEMP_CHAMBER
207
-    adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db);
208
-  #endif
209
-  #if ENABLED(FILAMENT_WIDTH_SENSOR)
210
-    adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db);
211
-  #endif
175
+  TERN_(HAS_TEMP_ADC_0, adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db));
176
+  TERN_(HAS_TEMP_ADC_1, adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db));
177
+  TERN_(HAS_TEMP_ADC_2, adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db));
178
+  TERN_(HAS_TEMP_ADC_3, adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db));
179
+  TERN_(HAS_TEMP_ADC_4, adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db));
180
+  TERN_(HAS_TEMP_ADC_5, adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db));
181
+  TERN_(HAS_TEMP_ADC_6, adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db));
182
+  TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db));
183
+  TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db));
184
+  TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db));
185
+  TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db));
212 186
 
213 187
   // Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail.
214 188
   // That's why we're not setting it up here.

+ 1
- 3
Marlin/src/HAL/ESP32/Servo.cpp Wyświetl plik

@@ -61,9 +61,7 @@ void Servo::move(const int value) {
61 61
   if (attach(0) >= 0) {
62 62
     write(value);
63 63
     safe_delay(servo_delay[channel]);
64
-    #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
65
-      detach();
66
-    #endif
64
+    TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
67 65
   }
68 66
 }
69 67
 #endif // HAS_SERVOS

+ 17
- 39
Marlin/src/HAL/ESP32/endstop_interrupts.h Wyświetl plik

@@ -42,43 +42,21 @@ void ICACHE_RAM_ATTR endstop_ISR() { endstops.update(); }
42 42
 
43 43
 void setup_endstop_interrupts() {
44 44
   #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
45
-  #if HAS_X_MAX
46
-    _ATTACH(X_MAX_PIN);
47
-  #endif
48
-  #if HAS_X_MIN
49
-    _ATTACH(X_MIN_PIN);
50
-  #endif
51
-  #if HAS_Y_MAX
52
-    _ATTACH(Y_MAX_PIN);
53
-  #endif
54
-  #if HAS_Y_MIN
55
-    _ATTACH(Y_MIN_PIN);
56
-  #endif
57
-  #if HAS_Z_MAX
58
-    _ATTACH(Z_MAX_PIN);
59
-  #endif
60
-  #if HAS_Z_MIN
61
-     _ATTACH(Z_MIN_PIN);
62
-  #endif
63
-  #if HAS_Z2_MAX
64
-    _ATTACH(Z2_MAX_PIN);
65
-  #endif
66
-  #if HAS_Z2_MIN
67
-    _ATTACH(Z2_MIN_PIN);
68
-  #endif
69
-  #if HAS_Z3_MAX
70
-    _ATTACH(Z3_MAX_PIN);
71
-  #endif
72
-  #if HAS_Z3_MIN
73
-    _ATTACH(Z3_MIN_PIN);
74
-  #endif
75
-  #if HAS_Z4_MAX
76
-    _ATTACH(Z4_MAX_PIN);
77
-  #endif
78
-  #if HAS_Z4_MIN
79
-    _ATTACH(Z4_MIN_PIN);
80
-  #endif
81
-  #if HAS_Z_MIN_PROBE_PIN
82
-    _ATTACH(Z_MIN_PROBE_PIN);
83
-  #endif
45
+  TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
46
+  TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
47
+  TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
48
+  TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
49
+  TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
50
+  TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
51
+  TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
52
+  TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
53
+  TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
54
+  TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
55
+  TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
56
+  TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
57
+  TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
58
+  TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
59
+  TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
60
+  TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
61
+  TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
84 62
 }

+ 1
- 3
Marlin/src/HAL/HAL.h Wyświetl plik

@@ -28,7 +28,5 @@
28 28
 #define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION)
29 29
 
30 30
 inline void watchdog_refresh() {
31
-  #if ENABLED(USE_WATCHDOG)
32
-    HAL_watchdog_refresh();
33
-  #endif
31
+  TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
34 32
 }

+ 1
- 5
Marlin/src/HAL/LPC1768/DebugMonitor.cpp Wyświetl plik

@@ -211,11 +211,7 @@ void HardFault_HandlerC(unsigned long *sp, unsigned long lr, unsigned long cause
211 211
 
212 212
   // Nothing below here is compiled because NVIC_SystemReset loops forever
213 213
 
214
-  for (;;) {
215
-    #if ENABLED(USE_WATCHDOG)
216
-      watchdog_init();
217
-    #endif
218
-  }
214
+  for (;;) { TERN_(USE_WATCHDOG, watchdog_init()); }
219 215
 }
220 216
 
221 217
 extern "C" {

+ 1
- 3
Marlin/src/HAL/LPC1768/HAL.cpp Wyświetl plik

@@ -70,9 +70,7 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
70 70
 void flashFirmware(const int16_t) { NVIC_SystemReset(); }
71 71
 
72 72
 void HAL_clear_reset_source(void) {
73
-  #if ENABLED(USE_WATCHDOG)
74
-    watchdog_clear_timeout_flag();
75
-  #endif
73
+  TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag());
76 74
 }
77 75
 
78 76
 uint8_t HAL_get_reset_source(void) {

+ 2
- 3
Marlin/src/HAL/LPC1768/MarlinSerial.h Wyświetl plik

@@ -44,10 +44,9 @@ public:
44 44
   MarlinSerial(LPC_UART_TypeDef *UARTx) :
45 45
     HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE>(UARTx)
46 46
     #if ENABLED(EMERGENCY_PARSER)
47
-       , emergency_state(EmergencyParser::State::EP_RESET)
47
+      , emergency_state(EmergencyParser::State::EP_RESET)
48 48
     #endif
49
-    {
50
-    }
49
+    { }
51 50
 
52 51
   void end() {}
53 52
 

+ 1
- 3
Marlin/src/HAL/LPC1768/Servo.h Wyświetl plik

@@ -60,9 +60,7 @@ class libServo: public Servo {
60 60
     if (attach(servo_info[servoIndex].Pin.nbr) >= 0) {    // try to reattach
61 61
       write(value);
62 62
       safe_delay(servo_delay[servoIndex]); // delay to allow servo to reach position
63
-      #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
64
-        detach();
65
-      #endif
63
+      TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
66 64
     }
67 65
 
68 66
   }

+ 22
- 75
Marlin/src/HAL/SAMD51/HAL.cpp Wyświetl plik

@@ -29,71 +29,19 @@
29 29
 // Local defines
30 30
 // ------------------------
31 31
 
32
-#if HAS_TEMP_ADC_0
33
-  #define GET_TEMP_0_ADC()          PIN_TO_ADC(TEMP_0_PIN)
34
-#else
35
-  #define GET_TEMP_0_ADC()          -1
36
-#endif
37
-#if HAS_TEMP_ADC_1
38
-  #define GET_TEMP_1_ADC()          PIN_TO_ADC(TEMP_1_PIN)
39
-#else
40
-  #define GET_TEMP_1_ADC()          -1
41
-#endif
42
-#if HAS_TEMP_ADC_2
43
-  #define GET_TEMP_2_ADC()          PIN_TO_ADC(TEMP_2_PIN)
44
-#else
45
-  #define GET_TEMP_2_ADC()          -1
46
-#endif
47
-#if HAS_TEMP_ADC_3
48
-  #define GET_TEMP_3_ADC()          PIN_TO_ADC(TEMP_3_PIN)
49
-#else
50
-  #define GET_TEMP_3_ADC()          -1
51
-#endif
52
-#if HAS_TEMP_ADC_4
53
-  #define GET_TEMP_4_ADC()          PIN_TO_ADC(TEMP_4_PIN)
54
-#else
55
-  #define GET_TEMP_4_ADC()          -1
56
-#endif
57
-#if HAS_TEMP_ADC_5
58
-  #define GET_TEMP_5_ADC()          PIN_TO_ADC(TEMP_5_PIN)
59
-#else
60
-  #define GET_TEMP_5_ADC()          -1
61
-#endif
62
-#if HAS_TEMP_ADC_6
63
-  #define GET_TEMP_6_ADC()          PIN_TO_ADC(TEMP_6_PIN)
64
-#else
65
-  #define GET_TEMP_6_ADC()          -1
66
-#endif
67
-#if HAS_TEMP_ADC_7
68
-  #define GET_TEMP_7_ADC()          PIN_TO_ADC(TEMP_7_PIN)
69
-#else
70
-  #define GET_TEMP_7_ADC()          -1
71
-#endif
72
-#if HAS_TEMP_PROBE
73
-  #define GET_PROBE_ADC()           PIN_TO_ADC(TEMP_PROBE_PIN)
74
-#else
75
-  #define GET_PROBE_ADC()           -1
76
-#endif
77
-#if HAS_TEMP_ADC_BED
78
-  #define GET_BED_ADC()             PIN_TO_ADC(TEMP_BED_PIN)
79
-#else
80
-  #define GET_BED_ADC()             -1
81
-#endif
82
-#if HAS_TEMP_ADC_CHAMBER
83
-  #define GET_CHAMBER_ADC()         PIN_TO_ADC(TEMP_CHAMBER_PIN)
84
-#else
85
-  #define GET_CHAMBER_ADC()         -1
86
-#endif
87
-#if ENABLED(FILAMENT_WIDTH_SENSOR)
88
-  #define GET_FILAMENT_WIDTH_ADC()  PIN_TO_ADC(FILWIDTH_PIN)
89
-#else
90
-  #define GET_FILAMENT_WIDTH_ADC()  -1
91
-#endif
92
-#if HAS_ADC_BUTTONS
93
-  #define GET_BUTTONS_ADC()         PIN_TO_ADC(ADC_KEYPAD_PIN)
94
-#else
95
-  #define GET_BUTTONS_ADC()         -1
96
-#endif
32
+#define GET_TEMP_0_ADC()          TERN(HAS_TEMP_ADC_0,        PIN_TO_ADC(TEMP_0_PIN),       -1)
33
+#define GET_TEMP_1_ADC()          TERN(HAS_TEMP_ADC_1,        PIN_TO_ADC(TEMP_1_PIN),       -1)
34
+#define GET_TEMP_2_ADC()          TERN(HAS_TEMP_ADC_2,        PIN_TO_ADC(TEMP_2_PIN),       -1)
35
+#define GET_TEMP_3_ADC()          TERN(HAS_TEMP_ADC_3,        PIN_TO_ADC(TEMP_3_PIN),       -1)
36
+#define GET_TEMP_4_ADC()          TERN(HAS_TEMP_ADC_4,        PIN_TO_ADC(TEMP_4_PIN),       -1)
37
+#define GET_TEMP_5_ADC()          TERN(HAS_TEMP_ADC_5,        PIN_TO_ADC(TEMP_5_PIN),       -1)
38
+#define GET_TEMP_6_ADC()          TERN(HAS_TEMP_ADC_6,        PIN_TO_ADC(TEMP_6_PIN),       -1)
39
+#define GET_TEMP_7_ADC()          TERN(HAS_TEMP_ADC_7,        PIN_TO_ADC(TEMP_7_PIN),       -1)
40
+#define GET_PROBE_ADC()           TERN(HAS_TEMP_PROBE,        PIN_TO_ADC(TEMP_PROBE_PIN),   -1)
41
+#define GET_BED_ADC()             TERN(HAS_TEMP_ADC_BED,      PIN_TO_ADC(TEMP_BED_PIN),     -1)
42
+#define GET_CHAMBER_ADC()         TERN(HAS_TEMP_ADC_CHAMBER,  PIN_TO_ADC(TEMP_CHAMBER_PIN), -1)
43
+#define GET_FILAMENT_WIDTH_ADC()  TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN),     -1)
44
+#define GET_BUTTONS_ADC()         TERN(HAS_ADC_BUTTONS,       PIN_TO_ADC(ADC_KEYPAD_PIN),   -1)
97 45
 
98 46
 #define IS_ADC_REQUIRED(n) ( \
99 47
      GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \
@@ -105,21 +53,22 @@
105 53
   || GET_BUTTONS_ADC() == n        \
106 54
 )
107 55
 
108
-#define ADC0_IS_REQUIRED    IS_ADC_REQUIRED(0)
109
-#define ADC1_IS_REQUIRED    IS_ADC_REQUIRED(1)
110
-#define ADC_IS_REQUIRED     (ADC0_IS_REQUIRED || ADC1_IS_REQUIRED)
111
-#if ADC0_IS_REQUIRED
56
+#if IS_ADC_REQUIRED(0)
57
+  #define ADC0_IS_REQUIRED 1
112 58
   #define FIRST_ADC     0
113 59
 #else
114 60
   #define FIRST_ADC     1
115 61
 #endif
116
-#if ADC1_IS_REQUIRED
62
+#if IS_ADC_REQUIRED(1)
63
+  #define ADC1_IS_REQUIRED 1
117 64
   #define LAST_ADC      1
118 65
 #else
119 66
   #define LAST_ADC      0
120 67
 #endif
121
-
122
-#define DMA_IS_REQUIRED     ADC_IS_REQUIRED
68
+#if ADC0_IS_REQUIRED || ADC1_IS_REQUIRED
69
+  #define ADC_IS_REQUIRED 1
70
+  #define DMA_IS_REQUIRED 1
71
+#endif
123 72
 
124 73
 // ------------------------
125 74
 // Types
@@ -423,9 +372,7 @@ uint16_t HAL_adc_result;
423 372
 
424 373
 // HAL initialization task
425 374
 void HAL_init() {
426
-  #if DMA_IS_REQUIRED
427
-    dma_init();
428
-  #endif
375
+  TERN_(DMA_IS_REQUIRED, dma_init());
429 376
   #if ENABLED(SDSUPPORT)
430 377
     #if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT)
431 378
       SET_INPUT_PULLUP(SD_DETECT_PIN);

+ 5
- 7
Marlin/src/HAL/STM32/HAL.cpp Wyświetl plik

@@ -76,20 +76,18 @@ void HAL_init() {
76 76
   #endif
77 77
 
78 78
   #if ENABLED(SRAM_EEPROM_EMULATION)
79
-    // Enable access to backup SRAM
80 79
     __HAL_RCC_PWR_CLK_ENABLE();
81
-    HAL_PWR_EnableBkUpAccess();
80
+    HAL_PWR_EnableBkUpAccess();           // Enable access to backup SRAM
82 81
     __HAL_RCC_BKPSRAM_CLK_ENABLE();
83
-
84
-    // Enable backup regulator
85
-    LL_PWR_EnableBkUpRegulator();
86
-    // Wait until backup regulator is initialized
87
-    while (!LL_PWR_IsActiveFlag_BRR());
82
+    LL_PWR_EnableBkUpRegulator();         // Enable backup regulator
83
+    while (!LL_PWR_IsActiveFlag_BRR());   // Wait until backup regulator is initialized
88 84
   #endif
89 85
 
90 86
   #if HAS_TMC_SW_SERIAL
91 87
     SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);
92 88
   #endif
89
+
90
+  TERN_(HAS_TMC_SW_SERIAL, SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0));
93 91
 }
94 92
 
95 93
 void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }

+ 1
- 1
Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp Wyświetl plik

@@ -148,7 +148,7 @@
148 148
     __HAL_RCC_SDIO_CLK_ENABLE();  // turn on SDIO clock
149 149
   }
150 150
 
151
-  constexpr uint8_t SD_RETRY_COUNT = 1 + 2 * ENABLED(SD_CHECK_AND_RETRY);
151
+  constexpr uint8_t SD_RETRY_COUNT = TERN(SD_CHECK_AND_RETRY, 3, 1);
152 152
 
153 153
   bool SDIO_Init() {
154 154
     //init SDIO and get SD card info

+ 1
- 3
Marlin/src/HAL/STM32/Servo.cpp Wyświetl plik

@@ -52,9 +52,7 @@ void libServo::move(const int value) {
52 52
   if (attach(0) >= 0) {
53 53
     write(value);
54 54
     safe_delay(delay);
55
-    #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
56
-      detach();
57
-    #endif
55
+    TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
58 56
   }
59 57
 }
60 58
 #endif // HAS_SERVOS

+ 18
- 39
Marlin/src/HAL/STM32/endstop_interrupts.h Wyświetl plik

@@ -28,43 +28,22 @@
28 28
 void endstop_ISR() { endstops.update(); }
29 29
 
30 30
 void setup_endstop_interrupts() {
31
-  #if HAS_X_MAX
32
-    attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
33
-  #endif
34
-  #if HAS_X_MIN
35
-    attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
36
-  #endif
37
-  #if HAS_Y_MAX
38
-    attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
39
-  #endif
40
-  #if HAS_Y_MIN
41
-    attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
42
-  #endif
43
-  #if HAS_Z_MAX
44
-    attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
45
-  #endif
46
-  #if HAS_Z_MIN
47
-    attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
48
-  #endif
49
-  #if HAS_Z2_MAX
50
-    attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
51
-  #endif
52
-  #if HAS_Z2_MIN
53
-    attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
54
-  #endif
55
-  #if HAS_Z3_MAX
56
-    attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
57
-  #endif
58
-  #if HAS_Z3_MIN
59
-    attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
60
-  #endif
61
-  #if HAS_Z4_MAX
62
-    attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
63
-  #endif
64
-  #if HAS_Z4_MIN
65
-    attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
66
-  #endif
67
-  #if HAS_Z_MIN_PROBE_PIN
68
-    attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
69
-  #endif
31
+  #define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
32
+  TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
33
+  TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
34
+  TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
35
+  TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
36
+  TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
37
+  TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
38
+  TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
39
+  TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
40
+  TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
41
+  TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
42
+  TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
43
+  TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
44
+  TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
45
+  TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
46
+  TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
47
+  TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
48
+  TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
70 49
 }

+ 1
- 3
Marlin/src/HAL/STM32F1/Servo.cpp Wyświetl plik

@@ -138,9 +138,7 @@ void libServo::move(const int32_t value) {
138 138
     angle = constrain(value, minAngle, maxAngle);
139 139
     servoWrite(pin, US_TO_COMPARE(ANGLE_TO_US(angle)));
140 140
     safe_delay(servo_delay[servoIndex]);
141
-    #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
142
-      detach();
143
-    #endif
141
+    TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
144 142
   }
145 143
 }
146 144
 

+ 18
- 39
Marlin/src/HAL/STM32F1/endstop_interrupts.h Wyświetl plik

@@ -53,43 +53,22 @@
53 53
 void endstop_ISR() { endstops.update(); }
54 54
 
55 55
 void setup_endstop_interrupts() {
56
-  #if HAS_X_MAX
57
-    attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE); // assign it
58
-  #endif
59
-  #if HAS_X_MIN
60
-    attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
61
-  #endif
62
-  #if HAS_Y_MAX
63
-    attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
64
-  #endif
65
-  #if HAS_Y_MIN
66
-    attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
67
-  #endif
68
-  #if HAS_Z_MAX
69
-    attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
70
-  #endif
71
-  #if HAS_Z_MIN
72
-    attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
73
-  #endif
74
-  #if HAS_Z2_MAX
75
-    attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
76
-  #endif
77
-  #if HAS_Z2_MIN
78
-    attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
79
-  #endif
80
-  #if HAS_Z3_MAX
81
-    attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
82
-  #endif
83
-  #if HAS_Z3_MIN
84
-    attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
85
-  #endif
86
-    #if HAS_Z4_MAX
87
-    attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
88
-  #endif
89
-  #if HAS_Z4_MIN
90
-    attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
91
-  #endif
92
-  #if HAS_Z_MIN_PROBE_PIN
93
-    attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
94
-  #endif
56
+  #define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
57
+  TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
58
+  TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
59
+  TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
60
+  TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
61
+  TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
62
+  TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
63
+  TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
64
+  TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
65
+  TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
66
+  TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
67
+  TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
68
+  TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
69
+  TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
70
+  TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
71
+  TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
72
+  TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
73
+  TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
95 74
 }

+ 1
- 3
Marlin/src/HAL/STM32_F4_F7/Servo.cpp Wyświetl plik

@@ -44,9 +44,7 @@ void libServo::move(const int value) {
44 44
   if (attach(0) >= 0) {
45 45
     write(value);
46 46
     safe_delay(servo_delay[servoIndex]);
47
-    #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
48
-      detach();
49
-    #endif
47
+    TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
50 48
   }
51 49
 }
52 50
 

+ 18
- 39
Marlin/src/HAL/STM32_F4_F7/endstop_interrupts.h Wyświetl plik

@@ -28,43 +28,22 @@
28 28
 void endstop_ISR() { endstops.update(); }
29 29
 
30 30
 void setup_endstop_interrupts() {
31
-  #if HAS_X_MAX
32
-    attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
33
-  #endif
34
-  #if HAS_X_MIN
35
-    attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
36
-  #endif
37
-  #if HAS_Y_MAX
38
-    attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
39
-  #endif
40
-  #if HAS_Y_MIN
41
-    attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
42
-  #endif
43
-  #if HAS_Z_MAX
44
-    attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
45
-  #endif
46
-  #if HAS_Z_MIN
47
-    attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
48
-  #endif
49
-  #if HAS_Z2_MAX
50
-    attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
51
-  #endif
52
-  #if HAS_Z2_MIN
53
-    attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
54
-  #endif
55
-  #if HAS_Z3_MAX
56
-    attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
57
-  #endif
58
-  #if HAS_Z3_MIN
59
-    attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
60
-  #endif
61
-  #if HAS_Z4_MAX
62
-    attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
63
-  #endif
64
-  #if HAS_Z4_MIN
65
-    attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
66
-  #endif
67
-  #if HAS_Z_MIN_PROBE_PIN
68
-    attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
69
-  #endif
31
+  #define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
32
+  TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
33
+  TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
34
+  TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
35
+  TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
36
+  TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
37
+  TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
38
+  TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
39
+  TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
40
+  TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
41
+  TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
42
+  TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
43
+  TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
44
+  TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
45
+  TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
46
+  TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
47
+  TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
48
+  TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
70 49
 }

+ 1
- 3
Marlin/src/HAL/TEENSY31_32/Servo.cpp Wyświetl plik

@@ -46,9 +46,7 @@ void libServo::move(const int value) {
46 46
   if (attach(0) >= 0) {
47 47
     write(value);
48 48
     safe_delay(servo_delay[servoIndex]);
49
-    #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
50
-      detach();
51
-    #endif
49
+    TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
52 50
   }
53 51
 }
54 52
 

+ 17
- 27
Marlin/src/HAL/TEENSY31_32/endstop_interrupts.h Wyświetl plik

@@ -47,31 +47,21 @@ void endstop_ISR() { endstops.update(); }
47 47
 
48 48
 void setup_endstop_interrupts() {
49 49
   #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
50
-  #if HAS_X_MAX
51
-    _ATTACH(X_MAX_PIN);
52
-  #endif
53
-  #if HAS_X_MIN
54
-    _ATTACH(X_MIN_PIN);
55
-  #endif
56
-  #if HAS_Y_MAX
57
-    _ATTACH(Y_MAX_PIN);
58
-  #endif
59
-  #if HAS_Y_MIN
60
-    _ATTACH(Y_MIN_PIN);
61
-  #endif
62
-  #if HAS_Z_MAX
63
-    _ATTACH(Z_MAX_PIN);
64
-  #endif
65
-  #if HAS_Z_MIN
66
-     _ATTACH(Z_MIN_PIN);
67
-  #endif
68
-  #if HAS_Z2_MAX
69
-    _ATTACH(Z2_MAX_PIN);
70
-  #endif
71
-  #if HAS_Z2_MIN
72
-    _ATTACH(Z2_MIN_PIN);
73
-  #endif
74
-  #if HAS_Z_MIN_PROBE_PIN
75
-    _ATTACH(Z_MIN_PROBE_PIN);
76
-  #endif
50
+  TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
51
+  TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
52
+  TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
53
+  TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
54
+  TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
55
+  TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
56
+  TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
57
+  TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
58
+  TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
59
+  TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
60
+  TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
61
+  TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
62
+  TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
63
+  TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
64
+  TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
65
+  TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
66
+  TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
77 67
 }

+ 1
- 3
Marlin/src/HAL/TEENSY35_36/Servo.cpp Wyświetl plik

@@ -46,9 +46,7 @@ void libServo::move(const int value) {
46 46
   if (attach(0) >= 0) {
47 47
     write(value);
48 48
     safe_delay(servo_delay[servoIndex]);
49
-    #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
50
-      detach();
51
-    #endif
49
+    TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
52 50
   }
53 51
 }
54 52
 

+ 17
- 39
Marlin/src/HAL/TEENSY35_36/endstop_interrupts.h Wyświetl plik

@@ -46,43 +46,21 @@ void endstop_ISR() { endstops.update(); }
46 46
  */
47 47
 void setup_endstop_interrupts() {
48 48
   #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
49
-  #if HAS_X_MAX
50
-    _ATTACH(X_MAX_PIN);
51
-  #endif
52
-  #if HAS_X_MIN
53
-    _ATTACH(X_MIN_PIN);
54
-  #endif
55
-  #if HAS_Y_MAX
56
-    _ATTACH(Y_MAX_PIN);
57
-  #endif
58
-  #if HAS_Y_MIN
59
-    _ATTACH(Y_MIN_PIN);
60
-  #endif
61
-  #if HAS_Z_MAX
62
-    _ATTACH(Z_MAX_PIN);
63
-  #endif
64
-  #if HAS_Z_MIN
65
-     _ATTACH(Z_MIN_PIN);
66
-  #endif
67
-  #if HAS_Z2_MAX
68
-    _ATTACH(Z2_MAX_PIN);
69
-  #endif
70
-  #if HAS_Z2_MIN
71
-    _ATTACH(Z2_MIN_PIN);
72
-  #endif
73
-  #if HAS_Z3_MAX
74
-    _ATTACH(Z3_MAX_PIN);
75
-  #endif
76
-  #if HAS_Z3_MIN
77
-    _ATTACH(Z3_MIN_PIN);
78
-  #endif
79
-  #if HAS_Z4_MAX
80
-    _ATTACH(Z4_MAX_PIN);
81
-  #endif
82
-  #if HAS_Z4_MIN
83
-    _ATTACH(Z4_MIN_PIN);
84
-  #endif
85
-  #if HAS_Z_MIN_PROBE_PIN
86
-    _ATTACH(Z_MIN_PROBE_PIN);
87
-  #endif
49
+  TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
50
+  TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
51
+  TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
52
+  TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
53
+  TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
54
+  TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
55
+  TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
56
+  TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
57
+  TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
58
+  TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
59
+  TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
60
+  TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
61
+  TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
62
+  TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
63
+  TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
64
+  TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
65
+  TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
88 66
 }

+ 1
- 3
Marlin/src/HAL/shared/servo.cpp Wyświetl plik

@@ -150,9 +150,7 @@ void Servo::move(const int value) {
150 150
   if (attach(0) >= 0) {
151 151
     write(value);
152 152
     safe_delay(servo_delay[servoIndex]);
153
-    #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
154
-      detach();
155
-    #endif
153
+    TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
156 154
   }
157 155
 }
158 156
 

+ 27
- 83
Marlin/src/MarlinCore.cpp Wyświetl plik

@@ -313,9 +313,7 @@ void enable_e_steppers() {
313 313
 }
314 314
 
315 315
 void enable_all_steppers() {
316
-  #if ENABLED(AUTO_POWER_CONTROL)
317
-    powerManager.power_on();
318
-  #endif
316
+  TERN_(AUTO_POWER_CONTROL, powerManager.power_on());
319 317
   ENABLE_AXIS_X();
320 318
   ENABLE_AXIS_Y();
321 319
   ENABLE_AXIS_Z();
@@ -359,9 +357,7 @@ void disable_all_steppers() {
359 357
   }
360 358
 
361 359
   void event_probe_recover() {
362
-    #if ENABLED(HOST_PROMPT_SUPPORT)
363
-      host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), DISMISS_STR);
364
-    #endif
360
+    TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), DISMISS_STR));
365 361
     #ifdef ACTION_ON_G29_RECOVER
366 362
       host_action(PSTR(ACTION_ON_G29_RECOVER));
367 363
     #endif
@@ -394,12 +390,8 @@ bool printingIsPaused() {
394 390
 
395 391
 void startOrResumeJob() {
396 392
   if (!printingIsPaused()) {
397
-    #if ENABLED(CANCEL_OBJECTS)
398
-      cancelable.reset();
399
-    #endif
400
-    #if ENABLED(LCD_SHOW_E_TOTAL)
401
-      e_move_accumulator = 0;
402
-    #endif
393
+    TERN_(CANCEL_OBJECTS, cancelable.reset());
394
+    TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0);
403 395
     #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
404 396
       ui.reset_remaining_time();
405 397
     #endif
@@ -410,11 +402,7 @@ void startOrResumeJob() {
410 402
 #if ENABLED(SDSUPPORT)
411 403
 
412 404
   inline void abortSDPrinting() {
413
-    card.endFilePrint(
414
-      #if SD_RESORT
415
-        true
416
-      #endif
417
-    );
405
+    card.endFilePrint(TERN_(SD_RESORT, true));
418 406
     queue.clear();
419 407
     quickstop_stepper();
420 408
     print_job_timer.stop();
@@ -427,9 +415,7 @@ void startOrResumeJob() {
427 415
       cutter.kill();              // Full cutter shutdown including ISR control
428 416
     #endif
429 417
     wait_for_heatup = false;
430
-    #if ENABLED(POWER_LOSS_RECOVERY)
431
-      recovery.purge();
432
-    #endif
418
+    TERN_(POWER_LOSS_RECOVERY, recovery.purge());
433 419
     #ifdef EVENT_GCODE_SD_STOP
434 420
       queue.inject_P(PSTR(EVENT_GCODE_SD_STOP));
435 421
     #endif
@@ -534,13 +520,9 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
534 520
     }
535 521
   #endif
536 522
 
537
-  #if ENABLED(USE_CONTROLLER_FAN)
538
-    controllerFan.update(); // Check if fan should be turned on to cool stepper drivers down
539
-  #endif
523
+  TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down
540 524
 
541
-  #if ENABLED(AUTO_POWER_CONTROL)
542
-    powerManager.check();
543
-  #endif
525
+  TERN_(AUTO_POWER_CONTROL, powerManager.check());
544 526
 
545 527
   #if ENABLED(EXTRUDER_RUNOUT_PREVENT)
546 528
     if (thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP
@@ -608,17 +590,11 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
608 590
     }
609 591
   #endif
610 592
 
611
-  #if ENABLED(TEMP_STAT_LEDS)
612
-    handle_status_leds();
613
-  #endif
593
+  TERN_(TEMP_STAT_LEDS, handle_status_leds());
614 594
 
615
-  #if ENABLED(MONITOR_DRIVER_STATUS)
616
-    monitor_tmc_drivers();
617
-  #endif
595
+  TERN_(MONITOR_DRIVER_STATUS, monitor_tmc_drivers());
618 596
 
619
-  #if ENABLED(MONITOR_L6470_DRIVER_STATUS)
620
-    L64xxManager.monitor_driver();
621
-  #endif
597
+  TERN_(MONITOR_L6470_DRIVER_STATUS, L64xxManager.monitor_driver());
622 598
 
623 599
   // Limit check_axes_activity frequency to 10Hz
624 600
   static millis_t next_check_axes_ms = 0;
@@ -669,17 +645,13 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
669 645
   thermalManager.manage_heater();
670 646
 
671 647
   // Max7219 heartbeat, animation, etc
672
-  #if ENABLED(MAX7219_DEBUG)
673
-    max7219.idle_tasks();
674
-  #endif
648
+  TERN_(MAX7219_DEBUG, max7219.idle_tasks());
675 649
 
676 650
   // Return if setup() isn't completed
677 651
   if (marlin_state == MF_INITIALIZING) return;
678 652
 
679 653
   // Handle filament runout sensors
680
-  #if HAS_FILAMENT_SENSOR
681
-    runout.run();
682
-  #endif
654
+  TERN_(HAS_FILAMENT_SENSOR, runout.run());
683 655
 
684 656
   // Run HAL idle tasks
685 657
   #ifdef HAL_IDLETASK
@@ -700,29 +672,19 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
700 672
   #endif
701 673
 
702 674
   // Handle SD Card insert / remove
703
-  #if ENABLED(SDSUPPORT)
704
-    card.manage_media();
705
-  #endif
675
+  TERN_(SDSUPPORT, card.manage_media());
706 676
 
707 677
   // Handle USB Flash Drive insert / remove
708
-  #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
709
-    Sd2Card::idle();
710
-  #endif
678
+  TERN_(USB_FLASH_DRIVE_SUPPORT, Sd2Card::idle());
711 679
 
712 680
   // Announce Host Keepalive state (if any)
713
-  #if ENABLED(HOST_KEEPALIVE_FEATURE)
714
-    gcode.host_keepalive();
715
-  #endif
681
+  TERN_(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive());
716 682
 
717 683
   // Update the Print Job Timer state
718
-  #if ENABLED(PRINTCOUNTER)
719
-    print_job_timer.tick();
720
-  #endif
684
+  TERN_(PRINTCOUNTER, print_job_timer.tick());
721 685
 
722 686
   // Update the Beeper queue
723
-  #if USE_BEEPER
724
-    buzzer.tick();
725
-  #endif
687
+  TERN_(USE_BEEPER, buzzer.tick());
726 688
 
727 689
   // Read Buttons and Update the LCD
728 690
   ui.update();
@@ -742,24 +704,16 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
742 704
   // Auto-report Temperatures / SD Status
743 705
   #if HAS_AUTO_REPORTING
744 706
     if (!gcode.autoreport_paused) {
745
-      #if ENABLED(AUTO_REPORT_TEMPERATURES)
746
-        thermalManager.auto_report_temperatures();
747
-      #endif
748
-      #if ENABLED(AUTO_REPORT_SD_STATUS)
749
-        card.auto_report_sd_status();
750
-      #endif
707
+      TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_report_temperatures());
708
+      TERN_(AUTO_REPORT_SD_STATUS, card.auto_report_sd_status());
751 709
     }
752 710
   #endif
753 711
 
754 712
   // Update the Prusa MMU2
755
-  #if ENABLED(PRUSA_MMU2)
756
-    mmu2.mmu_loop();
757
-  #endif
713
+  TERN_(PRUSA_MMU2, mmu2.mmu_loop());
758 714
 
759 715
   // Handle Joystick jogging
760
-  #if ENABLED(POLL_JOG)
761
-    joystick.inject_jog_moves();
762
-  #endif
716
+  TERN_(POLL_JOG, joystick.inject_jog_moves());
763 717
 }
764 718
 
765 719
 /**
@@ -769,9 +723,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
769 723
 void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
770 724
   thermalManager.disable_all_heaters();
771 725
 
772
-  #if HAS_CUTTER
773
-    cutter.kill();              // Full cutter shutdown including ISR control
774
-  #endif
726
+  TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control
775 727
 
776 728
   SERIAL_ERROR_MSG(STR_ERR_KILLED);
777 729
 
@@ -802,20 +754,14 @@ void minkill(const bool steppers_off/*=false*/) {
802 754
   // Reiterate heaters off
803 755
   thermalManager.disable_all_heaters();
804 756
 
805
-  #if HAS_CUTTER
806
-    cutter.kill();  // Reiterate cutter shutdown
807
-  #endif
757
+  TERN_(HAS_CUTTER, cutter.kill());  // Reiterate cutter shutdown
808 758
 
809 759
   // Power off all steppers (for M112) or just the E steppers
810 760
   steppers_off ? disable_all_steppers() : disable_e_steppers();
811 761
 
812
-  #if ENABLED(PSU_CONTROL)
813
-    PSU_OFF();
814
-  #endif
762
+  TERN_(PSU_CONTROL, PSU_OFF());
815 763
 
816
-  #if HAS_SUICIDE
817
-    suicide();
818
-  #endif
764
+  TERN_(HAS_SUICIDE, suicide());
819 765
 
820 766
   #if HAS_KILL
821 767
 
@@ -1016,9 +962,7 @@ void setup() {
1016 962
     SETUP_RUN(touch.init());
1017 963
   #endif
1018 964
 
1019
-  #if HAS_M206_COMMAND
1020
-    current_position += home_offset;  // Init current position based on home_offset
1021
-  #endif
965
+  TERN_(HAS_M206_COMMAND, current_position += home_offset); // Init current position based on home_offset
1022 966
 
1023 967
   sync_plan_position();               // Vital to init stepper/planner equivalent for current_position
1024 968
 

+ 7
- 2
Marlin/src/core/drivers.h Wyświetl plik

@@ -86,6 +86,10 @@
86 86
                       || AXIS_DRIVER_TYPE_X2(T) || AXIS_DRIVER_TYPE_Y2(T) || AXIS_DRIVER_TYPE_Z2(T) \
87 87
                       || AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) || HAS_E_DRIVER(T) )
88 88
 
89
+//
90
+// Trinamic Stepper Drivers
91
+//
92
+
89 93
 // Test for supported TMC drivers that require advanced configuration
90 94
 // Does not match standalone configurations
91 95
 #if (    HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) \
@@ -171,8 +175,9 @@
171 175
   #define HAS_TMC_SPI 1
172 176
 #endif
173 177
 
174
-// Defines that can't be evaluated now
175
-#define HAS_TMC_SW_SERIAL ANY_AXIS_HAS(SW_SERIAL)
178
+//
179
+// L64XX Stepper Drivers
180
+//
176 181
 
177 182
 #if HAS_DRIVER(L6470) || HAS_DRIVER(L6474) || HAS_DRIVER(L6480) || HAS_DRIVER(POWERSTEP01)
178 183
   #define HAS_L64XX 1

+ 16
- 16
Marlin/src/core/utility.cpp Wyświetl plik

@@ -57,21 +57,21 @@ void safe_delay(millis_t ms) {
57 57
 
58 58
   void log_machine_info() {
59 59
     SERIAL_ECHOLNPGM("Machine Type: "
60
-      TERN(DELTA, "Delta", "")
61
-      TERN(IS_SCARA, "SCARA", "")
62
-      TERN(IS_CORE, "Core", "")
63
-      TERN(IS_CARTESIAN, "Cartesian", "")
60
+      TERN_(DELTA, "Delta")
61
+      TERN_(IS_SCARA, "SCARA")
62
+      TERN_(IS_CORE, "Core")
63
+      TERN_(IS_CARTESIAN, "Cartesian")
64 64
     );
65 65
 
66 66
     SERIAL_ECHOLNPGM("Probe: "
67
-      TERN(PROBE_MANUALLY, "PROBE_MANUALLY", "")
68
-      TERN(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE", "")
69
-      TERN(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE", "")
70
-      TERN(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE"), "")
71
-      TERN(TOUCH_MI_PROBE, "TOUCH_MI_PROBE", "")
72
-      TERN(Z_PROBE_SLED, "Z_PROBE_SLED", "")
73
-      TERN(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY", "")
74
-      TERN(SOLENOID_PROBE, "SOLENOID_PROBE", "")
67
+      TERN_(PROBE_MANUALLY, "PROBE_MANUALLY")
68
+      TERN_(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE")
69
+      TERN_(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE")
70
+      TERN_(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE"))
71
+      TERN_(TOUCH_MI_PROBE, "TOUCH_MI_PROBE")
72
+      TERN_(Z_PROBE_SLED, "Z_PROBE_SLED")
73
+      TERN_(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY")
74
+      TERN_(SOLENOID_PROBE, "SOLENOID_PROBE")
75 75
       TERN(PROBE_SELECTED, "", "NONE")
76 76
     );
77 77
 
@@ -108,10 +108,10 @@ void safe_delay(millis_t ms) {
108 108
 
109 109
     #if HAS_ABL_OR_UBL
110 110
       SERIAL_ECHOPGM("Auto Bed Leveling: "
111
-        TERN(AUTO_BED_LEVELING_LINEAR, "LINEAR", "")
112
-        TERN(AUTO_BED_LEVELING_BILINEAR, "BILINEAR", "")
113
-        TERN(AUTO_BED_LEVELING_3POINT, "3POINT", "")
114
-        TERN(AUTO_BED_LEVELING_UBL, "UBL", "")
111
+        TERN_(AUTO_BED_LEVELING_LINEAR, "LINEAR")
112
+        TERN_(AUTO_BED_LEVELING_BILINEAR, "BILINEAR")
113
+        TERN_(AUTO_BED_LEVELING_3POINT, "3POINT")
114
+        TERN_(AUTO_BED_LEVELING_UBL, "UBL")
115 115
       );
116 116
 
117 117
       if (planner.leveling_active) {

+ 4
- 9
Marlin/src/feature/babystep.cpp Wyświetl plik

@@ -58,9 +58,7 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
58 58
   if (DISABLED(BABYSTEP_WITHOUT_HOMING) && !TEST(axis_known_position, axis)) return;
59 59
 
60 60
   accum += distance; // Count up babysteps for the UI
61
-  #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
62
-    axis_total[BS_TOTAL_IND(axis)] += distance;
63
-  #endif
61
+  TERN_(BABYSTEP_DISPLAY_TOTAL, axis_total[BS_TOTAL_IND(axis)] += distance);
64 62
 
65 63
   #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
66 64
     #define BSA_ENABLE(AXIS) do{ switch (AXIS) { case X_AXIS: ENABLE_AXIS_X(); break; case Y_AXIS: ENABLE_AXIS_Y(); break; case Z_AXIS: ENABLE_AXIS_Z(); break; default: break; } }while(0)
@@ -107,13 +105,10 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
107 105
     #endif
108 106
     steps[BS_AXIS_IND(axis)] += distance;
109 107
   #endif
110
-  #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
111
-    gcode.reset_stepper_timeout();
112
-  #endif
113 108
 
114
-  #if ENABLED(INTEGRATED_BABYSTEPPING)
115
-    if (has_steps()) stepper.initiateBabystepping();
116
-  #endif
109
+  TERN_(BABYSTEP_ALWAYS_AVAILABLE, gcode.reset_stepper_timeout());
110
+
111
+  TERN_(INTEGRATED_BABYSTEPPING, if (has_steps()) stepper.initiateBabystepping());
117 112
 }
118 113
 
119 114
 #endif // BABYSTEPPING

+ 2
- 5
Marlin/src/feature/babystep.h Wyświetl plik

@@ -55,11 +55,8 @@ public:
55 55
   #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
56 56
     static int16_t axis_total[BS_TOTAL_IND(Z_AXIS) + 1];   // Total babysteps since G28
57 57
     static inline void reset_total(const AxisEnum axis) {
58
-      if (true
59
-        #if ENABLED(BABYSTEP_XY)
60
-          && axis == Z_AXIS
61
-        #endif
62
-      ) axis_total[BS_TOTAL_IND(axis)] = 0;
58
+      if (TERN1(BABYSTEP_XY, axis == Z_AXIS))
59
+        axis_total[BS_TOTAL_IND(axis)] = 0;
63 60
     }
64 61
   #endif
65 62
 

+ 6
- 16
Marlin/src/feature/backlash.h Wyświetl plik

@@ -55,26 +55,16 @@ public:
55 55
 
56 56
   static inline float get_measurement(const AxisEnum a) {
57 57
     // Return the measurement averaged over all readings
58
-    return (
59
-      #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
60
-        measured_count[a] > 0 ? measured_mm[a] / measured_count[a] :
61
-      #endif
62
-      0
58
+    return TERN(MEASURE_BACKLASH_WHEN_PROBING
59
+      , measured_count[a] > 0 ? measured_mm[a] / measured_count[a] : 0
60
+      , 0
63 61
     );
64
-    #if DISABLED(MEASURE_BACKLASH_WHEN_PROBING)
65
-      UNUSED(a);
66
-    #endif
62
+    TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a));
67 63
   }
68 64
 
69 65
   static inline bool has_measurement(const AxisEnum a) {
70
-    return (false
71
-      #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
72
-        || (measured_count[a] > 0)
73
-      #endif
74
-    );
75
-    #if DISABLED(MEASURE_BACKLASH_WHEN_PROBING)
76
-      UNUSED(a);
77
-    #endif
66
+    return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0);
67
+    TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a));
78 68
   }
79 69
 
80 70
   static inline bool has_any_measurement() {

+ 2
- 6
Marlin/src/feature/bedlevel/abl/abl.cpp Wyświetl plik

@@ -74,9 +74,7 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t
74 74
 
75 75
   // Take the average instead of the median
76 76
   z_values[x][y] = (a + b + c) / 3.0;
77
-  #if ENABLED(EXTENSIBLE_UI)
78
-    ExtUI::onMeshUpdate(x, y, z_values[x][y]);
79
-  #endif
77
+  TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
80 78
 
81 79
   // Median is robust (ignores outliers).
82 80
   // z_values[x][y] = (a < b) ? ((b < c) ? b : (c < a) ? a : c)
@@ -241,9 +239,7 @@ void print_bilinear_leveling_grid() {
241 239
 // Refresh after other values have been updated
242 240
 void refresh_bed_level() {
243 241
   bilinear_grid_factor = bilinear_grid_spacing.reciprocal();
244
-  #if ENABLED(ABL_BILINEAR_SUBDIVISION)
245
-    bed_level_virt_interpolate();
246
-  #endif
242
+  TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
247 243
 }
248 244
 
249 245
 #if ENABLED(ABL_BILINEAR_SUBDIVISION)

+ 2
- 6
Marlin/src/feature/bedlevel/bedlevel.cpp Wyświetl plik

@@ -145,9 +145,7 @@ void reset_bed_level() {
145 145
       bilinear_grid_spacing.reset();
146 146
       GRID_LOOP(x, y) {
147 147
         z_values[x][y] = NAN;
148
-        #if ENABLED(EXTENSIBLE_UI)
149
-          ExtUI::onMeshUpdate(x, y, 0);
150
-        #endif
148
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0));
151 149
       }
152 150
     #elif ABL_PLANAR
153 151
       planner.bed_level_matrix.set_to_identity();
@@ -245,9 +243,7 @@ void reset_bed_level() {
245 243
 
246 244
     current_position = pos;
247 245
 
248
-    #if ENABLED(LCD_BED_LEVELING)
249
-      ui.wait_for_move = false;
250
-    #endif
246
+    TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
251 247
   }
252 248
 
253 249
 #endif

+ 1
- 3
Marlin/src/feature/bedlevel/ubl/ubl.cpp Wyświetl plik

@@ -113,9 +113,7 @@
113 113
   void unified_bed_leveling::set_all_mesh_points_to_value(const float value) {
114 114
     GRID_LOOP(x, y) {
115 115
       z_values[x][y] = value;
116
-      #if ENABLED(EXTENSIBLE_UI)
117
-        ExtUI::onMeshUpdate(x, y, value);
118
-      #endif
116
+      TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, value));
119 117
     }
120 118
   }
121 119
 

+ 37
- 103
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Wyświetl plik

@@ -305,17 +305,13 @@
305 305
 
306 306
     const int8_t p_val = parser.intval('P', -1);
307 307
     const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J');
308
-    #if HOTENDS > 1
309
-      const uint8_t old_tool_index = active_extruder;
310
-    #endif
308
+    TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder);
311 309
 
312 310
     // Check for commands that require the printer to be homed
313 311
     if (may_move) {
314 312
       planner.synchronize();
315 313
       if (axes_need_homing()) gcode.home_all_axes();
316
-      #if HOTENDS > 1
317
-        if (active_extruder != 0) tool_change(0);
318
-      #endif
314
+      TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
319 315
     }
320 316
 
321 317
     // Invalidate Mesh Points. This command is a little bit asymmetrical because
@@ -340,9 +336,7 @@
340 336
             break;            // No more invalid Mesh Points to populate
341 337
           }
342 338
           z_values[cpos.x][cpos.y] = NAN;
343
-          #if ENABLED(EXTENSIBLE_UI)
344
-            ExtUI::onMeshUpdate(cpos, 0.0f);
345
-          #endif
339
+          TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(cpos, 0.0f));
346 340
           cnt++;
347 341
         }
348 342
       }
@@ -369,9 +363,7 @@
369 363
             const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
370 364
                         p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
371 365
             z_values[x][y] += 2.0f * HYPOT(p1, p2);
372
-            #if ENABLED(EXTENSIBLE_UI)
373
-              ExtUI::onMeshUpdate(x, y, z_values[x][y]);
374
-            #endif
366
+            TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
375 367
           }
376 368
           break;
377 369
 
@@ -392,9 +384,7 @@
392 384
           for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++)     // Create a rectangular raised area in
393 385
             for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) { // the center of the bed
394 386
               z_values[x][y] += parser.seen('C') ? g29_constant : 9.99f;
395
-              #if ENABLED(EXTENSIBLE_UI)
396
-                ExtUI::onMeshUpdate(x, y, z_values[x][y]);
397
-              #endif
387
+              TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
398 388
             }
399 389
           break;
400 390
       }
@@ -540,9 +530,7 @@
540 530
                 }
541 531
                 else {
542 532
                   z_values[cpos.x][cpos.y] = g29_constant;
543
-                  #if ENABLED(EXTENSIBLE_UI)
544
-                    ExtUI::onMeshUpdate(cpos, g29_constant);
545
-                  #endif
533
+                  TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(cpos, g29_constant));
546 534
                 }
547 535
               }
548 536
             }
@@ -683,9 +671,7 @@
683 671
       UNUSED(probe_deployed);
684 672
     #endif
685 673
 
686
-    #if HOTENDS > 1
687
-      tool_change(old_tool_index);
688
-    #endif
674
+    TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index));
689 675
     return;
690 676
   }
691 677
 
@@ -718,9 +704,7 @@
718 704
       GRID_LOOP(x, y)
719 705
         if (!isnan(z_values[x][y])) {
720 706
           z_values[x][y] -= mean + value;
721
-          #if ENABLED(EXTENSIBLE_UI)
722
-            ExtUI::onMeshUpdate(x, y, z_values[x][y]);
723
-          #endif
707
+          TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
724 708
         }
725 709
   }
726 710
 
@@ -728,9 +712,7 @@
728 712
     GRID_LOOP(x, y)
729 713
       if (!isnan(z_values[x][y])) {
730 714
         z_values[x][y] += g29_constant;
731
-        #if ENABLED(EXTENSIBLE_UI)
732
-          ExtUI::onMeshUpdate(x, y, z_values[x][y]);
733
-        #endif
715
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
734 716
       }
735 717
   }
736 718
 
@@ -742,9 +724,7 @@
742 724
     void unified_bed_leveling::probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) {
743 725
       probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW
744 726
 
745
-      #if HAS_LCD_MENU
746
-        ui.capture();
747
-      #endif
727
+      TERN_(HAS_LCD_MENU, ui.capture());
748 728
 
749 729
       save_ubl_active_state_and_disable();  // No bed level correction so only raw data is obtained
750 730
       uint8_t count = GRID_MAX_POINTS;
@@ -755,9 +735,7 @@
755 735
 
756 736
         const int point_num = (GRID_MAX_POINTS) - count + 1;
757 737
         SERIAL_ECHOLNPAIR("\nProbing mesh point ", point_num, "/", int(GRID_MAX_POINTS), ".\n");
758
-        #if HAS_DISPLAY
759
-          ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS));
760
-        #endif
738
+        TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS)));
761 739
 
762 740
         #if HAS_LCD_MENU
763 741
           if (ui.button_pressed()) {
@@ -776,9 +754,7 @@
776 754
           : find_closest_mesh_point_of_type(INVALID, near, true);
777 755
 
778 756
         if (best.pos.x >= 0) {    // mesh point found and is reachable by probe
779
-          #if ENABLED(EXTENSIBLE_UI)
780
-            ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START);
781
-          #endif
757
+          TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START));
782 758
           const float measured_z = probe.probe_at_point(
783 759
                         best.meshpos(),
784 760
                         stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level
@@ -793,13 +769,10 @@
793 769
 
794 770
       } while (best.pos.x >= 0 && --count);
795 771
 
796
-      #if HAS_LCD_MENU
797
-        ui.release();
798
-      #endif
799
-      probe.stow(); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
800
-      #if HAS_LCD_MENU
801
-        ui.capture();
802
-      #endif
772
+      // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
773
+      TERN_(HAS_LCD_MENU, ui.release());
774
+      probe.stow();
775
+      TERN_(HAS_LCD_MENU, ui.capture());
803 776
 
804 777
       #ifdef Z_AFTER_PROBING
805 778
         probe.move_z_after_probing();
@@ -858,9 +831,7 @@
858 831
     static void echo_and_take_a_measurement() { SERIAL_ECHOLNPGM(" and take a measurement."); }
859 832
 
860 833
     float unified_bed_leveling::measure_business_card_thickness(float in_height) {
861
-      #if HAS_LCD_MENU
862
-        ui.capture();
863
-      #endif
834
+      TERN_(HAS_LCD_MENU, ui.capture());
864 835
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
865 836
 
866 837
       do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
@@ -899,9 +870,7 @@
899 870
     }
900 871
 
901 872
     void unified_bed_leveling::manually_probe_remaining_mesh(const xy_pos_t &pos, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
902
-      #if HAS_LCD_MENU
903
-        ui.capture();
904
-      #endif
873
+      TERN_(HAS_LCD_MENU, ui.capture());
905 874
 
906 875
       save_ubl_active_state_and_disable();  // No bed level correction so only raw data is obtained
907 876
       do_blocking_move_to_xy_z(current_position, z_clearance);
@@ -929,9 +898,7 @@
929 898
         do_blocking_move_to_z(z_clearance);
930 899
 
931 900
         KEEPALIVE_STATE(PAUSED_FOR_USER);
932
-        #if HAS_LCD_MENU
933
-          ui.capture();
934
-        #endif
901
+        TERN_(HAS_LCD_MENU, ui.capture());
935 902
 
936 903
         if (do_ubl_mesh_map) display_map(g29_map_type);  // show user where we're probing
937 904
 
@@ -950,9 +917,7 @@
950 917
         }
951 918
 
952 919
         z_values[lpos.x][lpos.y] = current_position.z - thick;
953
-        #if ENABLED(EXTENSIBLE_UI)
954
-          ExtUI::onMeshUpdate(location, z_values[lpos.x][lpos.y]);
955
-        #endif
920
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, z_values[lpos.x][lpos.y]));
956 921
 
957 922
         if (g29_verbose_level > 2)
958 923
           SERIAL_ECHOLNPAIR_F("Mesh Point Measured at: ", z_values[lpos.x][lpos.y], 6);
@@ -998,14 +963,11 @@
998 963
       save_ubl_active_state_and_disable();
999 964
 
1000 965
       LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
1001
-      #if HAS_LCD_MENU
1002
-        ui.capture();                                         // Take over control of the LCD encoder
1003
-      #endif
966
+      TERN_(HAS_LCD_MENU, ui.capture());                    // Take over control of the LCD encoder
967
+
1004 968
       do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES); // Move to the given XY with probe clearance
1005 969
 
1006
-      #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1007
-        do_blocking_move_to_z(h_offset);                    // Move Z to the given 'H' offset
1008
-      #endif
970
+      TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset));  // Move Z to the given 'H' offset
1009 971
 
1010 972
       MeshFlags done_flags{0};
1011 973
       const xy_int8_t &lpos = location.pos;
@@ -1026,9 +988,7 @@
1026 988
 
1027 989
         do_blocking_move_to(raw);                           // Move the nozzle to the edit point with probe clearance
1028 990
 
1029
-        #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1030
-          do_blocking_move_to_z(h_offset);                  // Move Z to the given 'H' offset before editing
1031
-        #endif
991
+        TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset)); // Move Z to the given 'H' offset before editing
1032 992
 
1033 993
         KEEPALIVE_STATE(PAUSED_FOR_USER);
1034 994
 
@@ -1044,9 +1004,7 @@
1044 1004
 
1045 1005
         do {
1046 1006
           new_z = lcd_mesh_edit();
1047
-          #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1048
-            do_blocking_move_to_z(h_offset + new_z);        // Move the nozzle as the point is edited
1049
-          #endif
1007
+          TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset + new_z)); // Move the nozzle as the point is edited
1050 1008
           idle();
1051 1009
           SERIAL_FLUSH();                                   // Prevent host M105 buffer overrun.
1052 1010
         } while (!ui.button_pressed());
@@ -1056,9 +1014,7 @@
1056 1014
         if (click_and_hold(abort_fine_tune)) break;         // Button held down? Abort editing
1057 1015
 
1058 1016
         z_values[lpos.x][lpos.y] = new_z;                   // Save the updated Z value
1059
-        #if ENABLED(EXTENSIBLE_UI)
1060
-          ExtUI::onMeshUpdate(location, new_z);
1061
-        #endif
1017
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, new_z));
1062 1018
 
1063 1019
         serial_delay(20);                                   // No switch noise
1064 1020
         ui.refresh();
@@ -1086,9 +1042,7 @@
1086 1042
   bool unified_bed_leveling::g29_parameter_parsing() {
1087 1043
     bool err_flag = false;
1088 1044
 
1089
-    #if HAS_LCD_MENU
1090
-      set_message_with_feedback(GET_TEXT(MSG_UBL_DOING_G29));
1091
-    #endif
1045
+    TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_DOING_G29)));
1092 1046
 
1093 1047
     g29_constant = 0;
1094 1048
     g29_repetition_cnt = 0;
@@ -1210,9 +1164,7 @@
1210 1164
       ubl_state_recursion_chk++;
1211 1165
       if (ubl_state_recursion_chk != 1) {
1212 1166
         SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
1213
-        #if HAS_LCD_MENU
1214
-          set_message_with_feedback(GET_TEXT(MSG_UBL_SAVE_ERROR));
1215
-        #endif
1167
+        TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_SAVE_ERROR)));
1216 1168
         return;
1217 1169
       }
1218 1170
     #endif
@@ -1224,9 +1176,7 @@
1224 1176
     #if ENABLED(UBL_DEVEL_DEBUGGING)
1225 1177
       if (--ubl_state_recursion_chk) {
1226 1178
         SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
1227
-        #if HAS_LCD_MENU
1228
-          set_message_with_feedback(GET_TEXT(MSG_UBL_RESTORE_ERROR));
1229
-        #endif
1179
+        TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_RESTORE_ERROR)));
1230 1180
         return;
1231 1181
       }
1232 1182
     #endif
@@ -1341,9 +1291,7 @@
1341 1291
         const float v2 = z_values[dx + xdir][dy + ydir];
1342 1292
         if (!isnan(v2)) {
1343 1293
           z_values[x][y] = v1 < v2 ? v1 : v1 + v1 - v2;
1344
-          #if ENABLED(EXTENSIBLE_UI)
1345
-            ExtUI::onMeshUpdate(x, y, z_values[x][y]);
1346
-          #endif
1294
+          TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
1347 1295
           return true;
1348 1296
         }
1349 1297
       }
@@ -1407,9 +1355,7 @@
1407 1355
 
1408 1356
       if (do_3_pt_leveling) {
1409 1357
         SERIAL_ECHOLNPGM("Tilting mesh (1/3)");
1410
-        #if HAS_DISPLAY
1411
-          ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1412
-        #endif
1358
+        TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
1413 1359
 
1414 1360
         measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level);
1415 1361
         if (isnan(measured_z))
@@ -1428,9 +1374,7 @@
1428 1374
 
1429 1375
         if (!abort_flag) {
1430 1376
           SERIAL_ECHOLNPGM("Tilting mesh (2/3)");
1431
-          #if HAS_DISPLAY
1432
-            ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1433
-          #endif
1377
+          TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
1434 1378
 
1435 1379
           measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level);
1436 1380
           #ifdef VALIDATE_MESH_TILT
@@ -1450,9 +1394,7 @@
1450 1394
 
1451 1395
         if (!abort_flag) {
1452 1396
           SERIAL_ECHOLNPGM("Tilting mesh (3/3)");
1453
-          #if HAS_DISPLAY
1454
-            ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1455
-          #endif
1397
+          TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
1456 1398
 
1457 1399
           measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level);
1458 1400
           #ifdef VALIDATE_MESH_TILT
@@ -1495,9 +1437,7 @@
1495 1437
 
1496 1438
             if (!abort_flag) {
1497 1439
               SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n");
1498
-              #if HAS_DISPLAY
1499
-                ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points);
1500
-              #endif
1440
+              TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points));
1501 1441
 
1502 1442
               measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
1503 1443
 
@@ -1586,9 +1526,7 @@
1586 1526
         }
1587 1527
 
1588 1528
         z_values[i][j] = mz - lsf_results.D;
1589
-        #if ENABLED(EXTENSIBLE_UI)
1590
-          ExtUI::onMeshUpdate(i, j, z_values[i][j]);
1591
-        #endif
1529
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, z_values[i][j]));
1592 1530
       }
1593 1531
 
1594 1532
       if (DEBUGGING(LEVELING)) {
@@ -1684,9 +1622,7 @@
1684 1622
             }
1685 1623
             const float ez = -lsf_results.D - lsf_results.A * ppos.x - lsf_results.B * ppos.y;
1686 1624
             z_values[ix][iy] = ez;
1687
-            #if ENABLED(EXTENSIBLE_UI)
1688
-              ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]);
1689
-            #endif
1625
+            TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]));
1690 1626
             idle(); // housekeeping
1691 1627
           }
1692 1628
         }
@@ -1826,9 +1762,7 @@
1826 1762
 
1827 1763
       GRID_LOOP(x, y) {
1828 1764
         z_values[x][y] -= tmp_z_values[x][y];
1829
-        #if ENABLED(EXTENSIBLE_UI)
1830
-          ExtUI::onMeshUpdate(x, y, z_values[x][y]);
1831
-        #endif
1765
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
1832 1766
       }
1833 1767
     }
1834 1768
 

+ 3
- 9
Marlin/src/feature/binary_protocol.h Wyświetl plik

@@ -82,9 +82,7 @@ private:
82 82
     }
83 83
     transfer_active = true;
84 84
     data_waiting = 0;
85
-    #if ENABLED(BINARY_STREAM_COMPRESSION)
86
-      heatshrink_decoder_reset(&hsd);
87
-    #endif
85
+    TERN_(BINARY_STREAM_COMPRESSION, heatshrink_decoder_reset(&hsd));
88 86
     return true;
89 87
   }
90 88
 
@@ -127,9 +125,7 @@ private:
127 125
       card.closefile();
128 126
       card.release();
129 127
     }
130
-    #if ENABLED(BINARY_STREAM_COMPRESSION)
131
-      heatshrink_decoder_finish(&hsd);
132
-    #endif
128
+    TERN_(BINARY_STREAM_COMPRESSION, heatshrink_decoder_finish(&hsd));
133 129
     transfer_active = false;
134 130
     return true;
135 131
   }
@@ -139,9 +135,7 @@ private:
139 135
       card.closefile();
140 136
       card.removeFile(card.filename);
141 137
       card.release();
142
-      #if ENABLED(BINARY_STREAM_COMPRESSION)
143
-        heatshrink_decoder_finish(&hsd);
144
-      #endif
138
+      TERN_(BINARY_STREAM_COMPRESSION, heatshrink_decoder_finish(&hsd));
145 139
     }
146 140
     transfer_active = false;
147 141
     return;

+ 1
- 3
Marlin/src/feature/bltouch.cpp Wyświetl plik

@@ -124,9 +124,7 @@ bool BLTouch::deploy_proc() {
124 124
   }
125 125
 
126 126
   // One of the recommended ANTClabs ways to probe, using SW MODE
127
-  #if ENABLED(BLTOUCH_FORCE_SW_MODE)
128
-   _set_SW_mode();
129
-  #endif
127
+  TERN_(BLTOUCH_FORCE_SW_MODE, _set_SW_mode());
130 128
 
131 129
   // Now the probe is ready to issue a 10ms pulse when the pin goes up.
132 130
   // The trigger STOW (see motion.cpp for example) will pull up the probes pin as soon as the pulse

+ 2
- 5
Marlin/src/feature/controllerfan.cpp Wyświetl plik

@@ -81,11 +81,8 @@ void ControllerFan::update() {
81 81
     ;
82 82
 
83 83
     // If any of the drivers or the heated bed are enabled...
84
-    if (motor_on
85
-      #if HAS_HEATED_BED
86
-        || thermalManager.temp_bed.soft_pwm_amount > 0
87
-      #endif
88
-    ) lastMotorOn = ms; //... set time to NOW so the fan will turn on
84
+    if (motor_on || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0))
85
+      lastMotorOn = ms; //... set time to NOW so the fan will turn on
89 86
 
90 87
     // Fan Settings. Set fan > 0:
91 88
     //  - If AutoMode is on and steppers have been enabled for CONTROLLERFAN_IDLE_TIME seconds.

+ 1
- 5
Marlin/src/feature/controllerfan.h Wyświetl plik

@@ -62,11 +62,7 @@ class ControllerFan {
62 62
     #endif
63 63
     static inline bool state() { return speed > 0; }
64 64
     static inline void init() { reset(); }
65
-    static inline void reset() {
66
-      #if ENABLED(CONTROLLER_FAN_EDITABLE)
67
-        settings = controllerFan_defaults;
68
-      #endif
69
-    }
65
+    static inline void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); }
70 66
     static void setup();
71 67
     static void update();
72 68
 };

+ 1
- 3
Marlin/src/feature/encoder_i2c.cpp Wyświetl plik

@@ -459,9 +459,7 @@ void I2CPositionEncoder::reset() {
459 459
   Wire.write(I2CPE_RESET_COUNT);
460 460
   Wire.endTransmission();
461 461
 
462
-  #if ENABLED(I2CPE_ERR_ROLLING_AVERAGE)
463
-    ZERO(err);
464
-  #endif
462
+  TERN_(I2CPE_ERR_ROLLING_AVERAGE, ZERO(err));
465 463
 }
466 464
 
467 465
 

+ 8
- 8
Marlin/src/feature/fwretract.cpp Wyświetl plik

@@ -60,9 +60,7 @@ float FWRetract::current_retract[EXTRUDERS],          // Retract value used by p
60 60
       FWRetract::current_hop;
61 61
 
62 62
 void FWRetract::reset() {
63
-  #if ENABLED(FWRETRACT_AUTORETRACT)
64
-    autoretract_enabled = false;
65
-  #endif
63
+  TERN_(FWRETRACT_AUTORETRACT, autoretract_enabled = false);
66 64
   settings.retract_length = RETRACT_LENGTH;
67 65
   settings.retract_feedrate_mm_s = RETRACT_FEEDRATE;
68 66
   settings.retract_zraise = RETRACT_ZRAISE;
@@ -128,7 +126,7 @@ void FWRetract::retract(const bool retracting
128 126
     SERIAL_ECHOLNPAIR("current_hop ", current_hop);
129 127
   //*/
130 128
 
131
-  const float base_retract = TERN(RETRACT_SYNC_MIXING, MIXING_STEPPERS, 1)
129
+  const float base_retract = TERN1(RETRACT_SYNC_MIXING, (MIXING_STEPPERS))
132 130
                 * (swapping ? settings.swap_retract_length : settings.retract_length);
133 131
 
134 132
   // The current position will be the destination for E and Z moves
@@ -144,7 +142,7 @@ void FWRetract::retract(const bool retracting
144 142
     // Retract by moving from a faux E position back to the current E position
145 143
     current_retract[active_extruder] = base_retract;
146 144
     prepare_internal_move_to_destination(                 // set current to destination
147
-      settings.retract_feedrate_mm_s * TERN(RETRACT_SYNC_MIXING, MIXING_STEPPERS, 1)
145
+      settings.retract_feedrate_mm_s * TERN1(RETRACT_SYNC_MIXING, (MIXING_STEPPERS))
148 146
     );
149 147
 
150 148
     // Is a Z hop set, and has the hop not yet been done?
@@ -170,9 +168,11 @@ void FWRetract::retract(const bool retracting
170 168
 
171 169
     current_retract[active_extruder] = 0;
172 170
 
173
-    const feedRate_t fr_mm_s = TERN(RETRACT_SYNC_MIXING, MIXING_STEPPERS, 1)
174
-      * (swapping ? settings.swap_retract_recover_feedrate_mm_s : settings.retract_recover_feedrate_mm_s);
175
-    prepare_internal_move_to_destination(fr_mm_s);        // Recover E, set_current_to_destination
171
+    // Recover E, set_current_to_destination
172
+    prepare_internal_move_to_destination(
173
+      (swapping ? settings.swap_retract_recover_feedrate_mm_s : settings.retract_recover_feedrate_mm_s)
174
+      * TERN1(RETRACT_SYNC_MIXING, (MIXING_STEPPERS))
175
+    );
176 176
   }
177 177
 
178 178
   TERN_(RETRACT_SYNC_MIXING, mixer.T(old_mixing_tool));   // Restore original mixing tool

+ 2
- 8
Marlin/src/feature/host_actions.cpp Wyświetl plik

@@ -108,11 +108,7 @@ void host_action(const char * const pstr, const bool eol) {
108 108
   }
109 109
 
110 110
   void filament_load_host_prompt() {
111
-    const bool disable_to_continue = (false
112
-      #if HAS_FILAMENT_SENSOR
113
-        || runout.filament_ran_out
114
-      #endif
115
-    );
111
+    const bool disable_to_continue = TERN0(HAS_FILAMENT_SENSOR, runout.filament_ran_out);
116 112
     host_prompt_do(PROMPT_FILAMENT_RUNOUT, PSTR("Paused"), PSTR("PurgeMore"),
117 113
       disable_to_continue ? PSTR("DisableRunout") : CONTINUE_STR
118 114
     );
@@ -160,9 +156,7 @@ void host_action(const char * const pstr, const bool eol) {
160 156
         }
161 157
         break;
162 158
       case PROMPT_USER_CONTINUE:
163
-        #if HAS_RESUME_CONTINUE
164
-          wait_for_user = false;
165
-        #endif
159
+        TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
166 160
         msg = PSTR("FILAMENT_RUNOUT_CONTINUE");
167 161
         break;
168 162
       case PROMPT_PAUSE_RESUME:

+ 1
- 3
Marlin/src/feature/joystick.cpp Wyświetl plik

@@ -154,9 +154,7 @@ Joystick joystick;
154 154
     // Other non-joystick poll-based jogging could be implemented here
155 155
     // with "jogging" encapsulated as a more general class.
156 156
 
157
-    #if ENABLED(EXTENSIBLE_UI)
158
-      ExtUI::_joystick_update(norm_jog);
159
-    #endif
157
+    TERN_(EXTENSIBLE_UI, ExtUI::_joystick_update(norm_jog));
160 158
 
161 159
     // norm_jog values of [-1 .. 1] maps linearly to [-feedrate .. feedrate]
162 160
     xyz_float_t move_dist{0};

+ 4
- 12
Marlin/src/feature/joystick.h Wyświetl plik

@@ -35,19 +35,11 @@
35 35
 class Joystick {
36 36
   friend class Temperature;
37 37
   private:
38
-    #if HAS_JOY_ADC_X
39
-      static temp_info_t x;
40
-    #endif
41
-    #if HAS_JOY_ADC_Y
42
-      static temp_info_t y;
43
-    #endif
44
-    #if HAS_JOY_ADC_Z
45
-      static temp_info_t z;
46
-    #endif
38
+    TERN_(HAS_JOY_ADC_X, static temp_info_t x);
39
+    TERN_(HAS_JOY_ADC_Y, static temp_info_t y);
40
+    TERN_(HAS_JOY_ADC_Z, static temp_info_t z);
47 41
   public:
48
-    #if ENABLED(JOYSTICK_DEBUG)
49
-      static void report();
50
-    #endif
42
+    TERN_(JOYSTICK_DEBUG, static void report());
51 43
     static void calculate(xyz_float_t &norm_jog);
52 44
     static void inject_jog_moves();
53 45
 };

+ 4
- 12
Marlin/src/feature/leds/leds.cpp Wyświetl plik

@@ -68,15 +68,9 @@ void LEDLights::setup() {
68 68
       if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN);
69 69
     #endif
70 70
   #endif
71
-  #if ENABLED(NEOPIXEL_LED)
72
-    neo.init();
73
-  #endif
74
-  #if ENABLED(PCA9533)
75
-    PCA9533_init();
76
-  #endif
77
-  #if ENABLED(LED_USER_PRESET_STARTUP)
78
-    set_default();
79
-  #endif
71
+  TERN_(NEOPIXEL_LED, neo.init());
72
+  TERN_(PCA9533, PCA9533_init());
73
+  TERN_(LED_USER_PRESET_STARTUP, set_default());
80 74
 }
81 75
 
82 76
 void LEDLights::set_color(const LEDColor &incol
@@ -140,9 +134,7 @@ void LEDLights::set_color(const LEDColor &incol
140 134
     pca9632_set_led_color(incol);
141 135
   #endif
142 136
 
143
-  #if ENABLED(PCA9533)
144
-    PCA9533_setColor(incol.r, incol.g, incol.b);
145
-  #endif
137
+  TERN_(PCA9533, PCA9533_setColor(incol.r, incol.g, incol.b));
146 138
 
147 139
   #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS)
148 140
     // Don't update the color when OFF

+ 4
- 4
Marlin/src/feature/leds/leds.h Wyświetl plik

@@ -34,7 +34,9 @@
34 34
 #endif
35 35
 
36 36
 // A white component can be passed
37
-#define HAS_WHITE_LED EITHER(RGBW_LED, NEOPIXEL_LED)
37
+#if EITHER(RGBW_LED, NEOPIXEL_LED)
38
+  #define HAS_WHITE_LED 1
39
+#endif
38 40
 
39 41
 /**
40 42
  * LEDcolor type for use with leds.set_color
@@ -85,9 +87,7 @@ typedef struct LEDColor {
85 87
 
86 88
   LEDColor& operator=(const uint8_t (&rgbw)[4]) {
87 89
     r = rgbw[0]; g = rgbw[1]; b = rgbw[2];
88
-    #if HAS_WHITE_LED
89
-      w = rgbw[3];
90
-    #endif
90
+    TERN_(HAS_WHITE_LED, w = rgbw[3]);
91 91
     return *this;
92 92
   }
93 93
 

+ 11
- 12
Marlin/src/feature/leds/neopixel.h Wyświetl plik

@@ -38,10 +38,15 @@
38 38
 // Defines
39 39
 // ------------------------
40 40
 
41
-#define MULTIPLE_NEOPIXEL_TYPES (defined(NEOPIXEL2_TYPE) && (NEOPIXEL2_TYPE != NEOPIXEL_TYPE))
41
+#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE
42
+  #define MULTIPLE_NEOPIXEL_TYPES 1
43
+#endif
42 44
 
43
-#define NEOPIXEL_IS_RGB  (NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR)
44
-#define NEOPIXEL_IS_RGBW !NEOPIXEL_IS_RGB
45
+#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR
46
+  #define NEOPIXEL_IS_RGB 1
47
+#else
48
+  #define NEOPIXEL_IS_RGBW 1
49
+#endif
45 50
 
46 51
 #if NEOPIXEL_IS_RGB
47 52
   #define NEO_WHITE 255, 255, 255, 0
@@ -73,23 +78,17 @@ public:
73 78
 
74 79
   static inline void begin() {
75 80
     adaneo1.begin();
76
-    #if MULTIPLE_NEOPIXEL_TYPES
77
-      adaneo2.begin();
78
-    #endif
81
+    TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.begin());
79 82
   }
80 83
 
81 84
   static inline void set_pixel_color(const uint16_t n, const uint32_t c) {
82 85
     adaneo1.setPixelColor(n, c);
83
-    #if MULTIPLE_NEOPIXEL_TYPES
84
-      adaneo2.setPixelColor(n, c);
85
-    #endif
86
+    TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c));
86 87
   }
87 88
 
88 89
   static inline void set_brightness(const uint8_t b) {
89 90
     adaneo1.setBrightness(b);
90
-    #if MULTIPLE_NEOPIXEL_TYPES
91
-      adaneo2.setBrightness(b);
92
-    #endif
91
+    TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setBrightness(b));
93 92
   }
94 93
 
95 94
   static inline void show() {

+ 4
- 4
Marlin/src/feature/leds/printer_event_leds.cpp Wyświetl plik

@@ -47,10 +47,10 @@ PrinterEventLEDs printerEventLEDs;
47 47
   inline void pel_set_rgb(const uint8_t r, const uint8_t g, const uint8_t b) {
48 48
     leds.set_color(
49 49
       MakeLEDColor(r, g, b, 0, neo.brightness())
50
-        #if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
51
-          , true
52
-        #endif
53
-      );
50
+      #if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
51
+        , true
52
+      #endif
53
+    );
54 54
   }
55 55
 
56 56
 #endif

+ 1
- 4
Marlin/src/feature/leds/tempstat.cpp Wyświetl plik

@@ -36,10 +36,7 @@ void handle_status_leds() {
36 36
   static millis_t next_status_led_update_ms = 0;
37 37
   if (ELAPSED(millis(), next_status_led_update_ms)) {
38 38
     next_status_led_update_ms += 500; // Update every 0.5s
39
-    float max_temp = 0.0;
40
-    #if HAS_HEATED_BED
41
-      max_temp = _MAX(thermalManager.degTargetBed(), thermalManager.degBed());
42
-    #endif
39
+    float max_temp = TERN0(HAS_HEATED_BED, _MAX(thermalManager.degTargetBed(), thermalManager.degBed()));
43 40
     HOTEND_LOOP()
44 41
       max_temp = _MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
45 42
     const int8_t new_red = (max_temp > 55.0) ? HIGH : (max_temp < 54.0 || old_red < 0) ? LOW : old_red;

+ 4
- 8
Marlin/src/feature/mixing.cpp Wyświetl plik

@@ -44,7 +44,7 @@ int_fast8_t   Mixer::runner = 0;
44 44
 mixer_comp_t  Mixer::s_color[MIXING_STEPPERS];
45 45
 mixer_accu_t  Mixer::accu[MIXING_STEPPERS] = { 0 };
46 46
 
47
-#if DUAL_MIXING_EXTRUDER || ENABLED(GRADIENT_MIX)
47
+#if EITHER(HAS_DUAL_MIXING, GRADIENT_MIX)
48 48
   mixer_perc_t Mixer::mix[MIXING_STEPPERS];
49 49
 #endif
50 50
 
@@ -90,9 +90,7 @@ void Mixer::normalize(const uint8_t tool_index) {
90 90
     SERIAL_ECHOLNPGM("]");
91 91
   #endif
92 92
 
93
-  #if ENABLED(GRADIENT_MIX)
94
-    refresh_gradient();
95
-  #endif
93
+  TERN_(GRADIENT_MIX, refresh_gradient());
96 94
 }
97 95
 
98 96
 void Mixer::reset_vtools() {
@@ -123,13 +121,11 @@ void Mixer::init() {
123 121
 
124 122
   ZERO(collector);
125 123
 
126
-  #if DUAL_MIXING_EXTRUDER || ENABLED(GRADIENT_MIX)
124
+  #if EITHER(HAS_DUAL_MIXING, GRADIENT_MIX)
127 125
     update_mix_from_vtool();
128 126
   #endif
129 127
 
130
-  #if ENABLED(GRADIENT_MIX)
131
-    update_gradient_for_planner_z();
132
-  #endif
128
+  TERN_(GRADIENT_MIX, update_gradient_for_planner_z());
133 129
 }
134 130
 
135 131
 void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=selected_vtool*/, float (&c)[MIXING_STEPPERS]/*=collector*/) {

+ 15
- 23
Marlin/src/feature/mixing.h Wyświetl plik

@@ -25,7 +25,7 @@
25 25
 
26 26
 //#define MIXER_NORMALIZER_DEBUG
27 27
 
28
-#ifndef __AVR__ // || DUAL_MIXING_EXTRUDER
28
+#ifndef __AVR__ // || HAS_DUAL_MIXING
29 29
   // Use 16-bit (or fastest) data for the integer mix factors
30 30
   typedef uint_fast16_t mixer_comp_t;
31 31
   typedef uint_fast16_t mixer_accu_t;
@@ -48,14 +48,14 @@ typedef int8_t mixer_perc_t;
48 48
 #endif
49 49
 
50 50
 enum MixTool {
51
-  FIRST_USER_VIRTUAL_TOOL = 0,
52
-  LAST_USER_VIRTUAL_TOOL = MIXING_VIRTUAL_TOOLS - 1,
53
-  NR_USER_VIRTUAL_TOOLS,
54
-  MIXER_DIRECT_SET_TOOL = NR_USER_VIRTUAL_TOOLS,
51
+    FIRST_USER_VIRTUAL_TOOL = 0
52
+  , LAST_USER_VIRTUAL_TOOL = MIXING_VIRTUAL_TOOLS - 1
53
+  , NR_USER_VIRTUAL_TOOLS
54
+  , MIXER_DIRECT_SET_TOOL = NR_USER_VIRTUAL_TOOLS
55 55
   #if HAS_MIXER_SYNC_CHANNEL
56
-    MIXER_AUTORETRACT_TOOL,
56
+    , MIXER_AUTORETRACT_TOOL
57 57
   #endif
58
-  NR_MIXING_VIRTUAL_TOOLS
58
+  , NR_MIXING_VIRTUAL_TOOLS
59 59
 };
60 60
 
61 61
 #define MAX_VTOOLS TERN(HAS_MIXER_SYNC_CHANNEL, 254, 255)
@@ -75,9 +75,7 @@ static_assert(NR_MIXING_VIRTUAL_TOOLS <= MAX_VTOOLS, "MIXING_VIRTUAL_TOOLS must
75 75
     int8_t start_vtool, end_vtool;        // Start and end virtual tools
76 76
     mixer_perc_t start_mix[MIXING_STEPPERS],   // Start and end mixes from those tools
77 77
                  end_mix[MIXING_STEPPERS];
78
-    #if ENABLED(GRADIENT_VTOOL)
79
-      int8_t vtool_index;                 // Use this virtual tool number as index
80
-    #endif
78
+    TERN_(GRADIENT_VTOOL, int8_t vtool_index); // Use this virtual tool number as index
81 79
   } gradient_t;
82 80
 
83 81
 #endif
@@ -106,12 +104,8 @@ class Mixer {
106 104
 
107 105
   FORCE_INLINE static void T(const uint_fast8_t c) {
108 106
     selected_vtool = c;
109
-    #if ENABLED(GRADIENT_VTOOL)
110
-      refresh_gradient();
111
-    #endif
112
-    #if DUAL_MIXING_EXTRUDER
113
-      update_mix_from_vtool();
114
-    #endif
107
+    TERN_(GRADIENT_VTOOL, refresh_gradient());
108
+    TERN_(HAS_DUAL_MIXING, update_mix_from_vtool());
115 109
   }
116 110
 
117 111
   // Used when dealing with blocks
@@ -129,7 +123,7 @@ class Mixer {
129 123
     MIXER_STEPPER_LOOP(i) s_color[i] = b_color[i];
130 124
   }
131 125
 
132
-  #if DUAL_MIXING_EXTRUDER || ENABLED(GRADIENT_MIX)
126
+  #if EITHER(HAS_DUAL_MIXING, GRADIENT_MIX)
133 127
 
134 128
     static mixer_perc_t mix[MIXING_STEPPERS];  // Scratch array for the Mix in proportion to 100
135 129
 
@@ -167,21 +161,19 @@ class Mixer {
167 161
       #endif
168 162
     }
169 163
 
170
-  #endif // DUAL_MIXING_EXTRUDER || GRADIENT_MIX
164
+  #endif // HAS_DUAL_MIXING || GRADIENT_MIX
171 165
 
172
-  #if DUAL_MIXING_EXTRUDER
166
+  #if HAS_DUAL_MIXING
173 167
 
174 168
     // Update the virtual tool from an edited mix
175 169
     static inline void update_vtool_from_mix() {
176 170
       copy_mix_to_color(color[selected_vtool]);
177
-      #if ENABLED(GRADIENT_MIX)
178
-        refresh_gradient();
179
-      #endif
171
+      TERN_(GRADIENT_MIX, refresh_gradient());
180 172
       // MIXER_STEPPER_LOOP(i) collector[i] = mix[i];
181 173
       // normalize();
182 174
     }
183 175
 
184
-  #endif // DUAL_MIXING_EXTRUDER
176
+  #endif // HAS_DUAL_MIXING
185 177
 
186 178
   #if ENABLED(GRADIENT_MIX)
187 179
 

+ 2
- 6
Marlin/src/feature/mmu2/mmu2.cpp Wyświetl plik

@@ -707,12 +707,8 @@ void MMU2::filament_runout() {
707 707
     if (recover)  {
708 708
       LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER);
709 709
       BUZZ(200, 404);
710
-      #if ENABLED(HOST_PROMPT_SUPPORT)
711
-        host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR);
712
-      #endif
713
-      #if ENABLED(EXTENSIBLE_UI)
714
-        ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover"));
715
-      #endif
710
+      TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR));
711
+      TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover")));
716 712
       wait_for_user_response();
717 713
       BUZZ(200, 404);
718 714
       BUZZ(200, 404);

+ 27
- 80
Marlin/src/feature/pause.cpp Wyświetl plik

@@ -86,9 +86,7 @@ fil_change_settings_t fc_settings[EXTRUDERS];
86 86
 #if HAS_BUZZER
87 87
   static void filament_change_beep(const int8_t max_beep_count, const bool init=false) {
88 88
 
89
-    #if HAS_LCD_MENU
90
-      if (pause_mode == PAUSE_MODE_PAUSE_PRINT) return;
91
-    #endif
89
+    if (TERN0(HAS_LCD_MENU, pause_mode == PAUSE_MODE_PAUSE_PRINT)) return;
92 90
 
93 91
     static millis_t next_buzz = 0;
94 92
     static int8_t runout_beep = 0;
@@ -184,13 +182,9 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
184 182
       host_action_prompt_button(CONTINUE_STR);
185 183
       host_action_prompt_show();
186 184
     #endif
187
-    #if ENABLED(EXTENSIBLE_UI)
188
-      ExtUI::onUserConfirmRequired_P(PSTR("Load Filament"));
189
-    #endif
185
+    TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Load Filament")));
190 186
     while (wait_for_user) {
191
-      #if HAS_BUZZER
192
-        filament_change_beep(max_beep_count);
193
-      #endif
187
+      TERN_(HAS_BUZZER, filament_change_beep(max_beep_count));
194 188
       idle_no_sleep();
195 189
     }
196 190
   }
@@ -235,12 +229,8 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
235 229
       if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
236 230
     #endif
237 231
 
238
-    #if ENABLED(HOST_PROMPT_SUPPORT)
239
-      host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR);
240
-    #endif
241
-    #if ENABLED(EXTENSIBLE_UI)
242
-      ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging..."));
243
-    #endif
232
+    TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR));
233
+    TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging...")));
244 234
     wait_for_user = true; // A click or M108 breaks the purge_length loop
245 235
     for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
246 236
       unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
@@ -259,9 +249,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
259 249
         unscaled_e_move(purge_length, ADVANCED_PAUSE_PURGE_FEEDRATE);
260 250
       }
261 251
 
262
-      #if ENABLED(HOST_PROMPT_SUPPORT)
263
-        filament_load_host_prompt();  // Initiate another host prompt. (NOTE: host_response_handler may also do this!)
264
-      #endif
252
+      TERN_(HOST_PROMPT_SUPPORT, filament_load_host_prompt()); // Initiate another host prompt. (NOTE: host_response_handler may also do this!)
265 253
 
266 254
       #if HAS_LCD_MENU
267 255
         if (show_lcd) {
@@ -274,11 +262,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
274 262
       #endif
275 263
 
276 264
       // Keep looping if "Purge More" was selected
277
-    } while (false
278
-      #if HAS_LCD_MENU
279
-        || (show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE)
280
-      #endif
281
-    );
265
+    } while (TERN0(HAS_LCD_MENU, show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE));
282 266
 
283 267
   #endif
284 268
 
@@ -384,9 +368,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
384 368
     #endif
385 369
   #endif
386 370
 
387
-  #if ENABLED(HOST_PROMPT_SUPPORT)
388
-    host_prompt_open(PROMPT_INFO, PSTR("Pause"), DISMISS_STR);
389
-  #endif
371
+  TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Pause"), DISMISS_STR));
390 372
 
391 373
   if (!DEBUGGING(DRYRUN) && unload_length && thermalManager.targetTooColdToExtrude(active_extruder)) {
392 374
     SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD);
@@ -465,9 +447,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
465 447
  */
466 448
 
467 449
 void show_continue_prompt(const bool is_reload) {
468
-  #if HAS_LCD_MENU
469
-    lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING);
470
-  #endif
450
+  TERN_(HAS_LCD_MENU, lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING));
471 451
   SERIAL_ECHO_START();
472 452
   serialprintPGM(is_reload ? PSTR(_PMSG(STR_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(STR_FILAMENT_CHANGE_WAIT) "\n"));
473 453
 }
@@ -497,17 +477,11 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
497 477
 
498 478
   // Wait for filament insert by user and press button
499 479
   KEEPALIVE_STATE(PAUSED_FOR_USER);
500
-  #if ENABLED(HOST_PROMPT_SUPPORT)
501
-    host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_NOZZLE_PARKED), CONTINUE_STR);
502
-  #endif
503
-  #if ENABLED(EXTENSIBLE_UI)
504
-    ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_NOZZLE_PARKED));
505
-  #endif
480
+  TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_NOZZLE_PARKED), CONTINUE_STR));
481
+  TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_NOZZLE_PARKED)));
506 482
   wait_for_user = true;    // LCD click or M108 will clear this
507 483
   while (wait_for_user) {
508
-    #if HAS_BUZZER
509
-      filament_change_beep(max_beep_count);
510
-    #endif
484
+    TERN_(HAS_BUZZER, filament_change_beep(max_beep_count));
511 485
 
512 486
     // If the nozzle has timed out...
513 487
     if (!nozzle_timed_out)
@@ -516,27 +490,18 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
516 490
     // Wait for the user to press the button to re-heat the nozzle, then
517 491
     // re-heat the nozzle, re-show the continue prompt, restart idle timers, start over
518 492
     if (nozzle_timed_out) {
519
-      #if HAS_LCD_MENU
520
-        lcd_pause_show_message(PAUSE_MESSAGE_HEAT);
521
-      #endif
493
+      TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_HEAT));
522 494
       SERIAL_ECHO_MSG(_PMSG(STR_FILAMENT_CHANGE_HEAT));
523 495
 
524
-      #if ENABLED(HOST_PROMPT_SUPPORT)
525
-        host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_HEATER_TIMEOUT), GET_TEXT(MSG_REHEAT));
526
-      #endif
496
+      TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_HEATER_TIMEOUT), GET_TEXT(MSG_REHEAT)));
527 497
 
528
-      #if ENABLED(EXTENSIBLE_UI)
529
-        ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_HEATER_TIMEOUT));
530
-      #endif
498
+      TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_HEATER_TIMEOUT)));
531 499
 
532 500
       wait_for_user_response(0, true); // Wait for LCD click or M108
533 501
 
534
-      #if ENABLED(HOST_PROMPT_SUPPORT)
535
-        host_prompt_do(PROMPT_INFO, GET_TEXT(MSG_REHEATING));
536
-      #endif
537
-      #if ENABLED(EXTENSIBLE_UI)
538
-        ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING));
539
-      #endif
502
+      TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, GET_TEXT(MSG_REHEATING)));
503
+
504
+      TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING)));
540 505
 
541 506
       // Re-enable the heaters if they timed out
542 507
       HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e);
@@ -551,18 +516,12 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
551 516
       const millis_t nozzle_timeout = SEC_TO_MS(PAUSE_PARK_NOZZLE_TIMEOUT);
552 517
 
553 518
       HOTEND_LOOP() thermalManager.hotend_idle[e].start(nozzle_timeout);
554
-      #if ENABLED(HOST_PROMPT_SUPPORT)
555
-        host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), CONTINUE_STR);
556
-      #endif
557
-      #if ENABLED(EXTENSIBLE_UI)
558
-        ExtUI::onUserConfirmRequired_P(PSTR("Reheat finished."));
559
-      #endif
519
+      TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), CONTINUE_STR));
520
+      TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Reheat finished.")));
560 521
       wait_for_user = true;
561 522
       nozzle_timed_out = false;
562 523
 
563
-      #if HAS_BUZZER
564
-        filament_change_beep(max_beep_count, true);
565
-      #endif
524
+      TERN_(HAS_BUZZER, filament_change_beep(max_beep_count, true));
566 525
     }
567 526
     idle_no_sleep();
568 527
   }
@@ -613,9 +572,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
613 572
   if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) // Load the new filament
614 573
     load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, PAUSE_MODE_SAME DXC_PASS);
615 574
 
616
-  #if HAS_LCD_MENU
617
-    lcd_pause_show_message(PAUSE_MESSAGE_RESUME);
618
-  #endif
575
+  TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_RESUME));
619 576
 
620 577
   // Intelligent resuming
621 578
   #if ENABLED(FWRETRACT)
@@ -641,9 +598,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
641 598
   // Set extruder to saved position
642 599
   planner.set_e_position_mm((destination.e = current_position.e = resume_position.e));
643 600
 
644
-  #if HAS_LCD_MENU
645
-    lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
646
-  #endif
601
+  TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_STATUS));
647 602
 
648 603
   #ifdef ACTION_ON_RESUMED
649 604
     host_action_resumed();
@@ -653,9 +608,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
653 608
 
654 609
   --did_pause_print;
655 610
 
656
-  #if ENABLED(HOST_PROMPT_SUPPORT)
657
-    host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR);
658
-  #endif
611
+  TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR));
659 612
 
660 613
   #if ENABLED(SDSUPPORT)
661 614
     if (did_pause_print) {
@@ -668,19 +621,13 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
668 621
     thermalManager.set_fans_paused(false);
669 622
   #endif
670 623
 
671
-  #if HAS_FILAMENT_SENSOR
672
-    runout.reset();
673
-  #endif
624
+  TERN_(HAS_FILAMENT_SENSOR, runout.reset());
674 625
 
675 626
   // Resume the print job timer if it was running
676 627
   if (print_job_timer.isPaused()) print_job_timer.start();
677 628
 
678
-  #if HAS_DISPLAY
679
-    ui.reset_status();
680
-    #if HAS_LCD_MENU
681
-      ui.return_to_status();
682
-    #endif
683
-  #endif
629
+  TERN_(HAS_DISPLAY, ui.reset_status());
630
+  TERN_(HAS_LCD_MENU, ui.return_to_status());
684 631
 }
685 632
 
686 633
 #endif // ADVANCED_PAUSE_FEATURE

+ 4
- 10
Marlin/src/feature/power.cpp Wyświetl plik

@@ -50,15 +50,12 @@ bool Power::is_power_needed() {
50 50
     if (controllerFan.state()) return true;
51 51
   #endif
52 52
 
53
-  #if ENABLED(AUTO_POWER_CHAMBER_FAN)
54
-    if (thermalManager.chamberfan_speed) return true;
55
-  #endif
53
+  if (TERN0(AUTO_POWER_CHAMBER_FAN, thermalManager.chamberfan_speed))
54
+    return true;
56 55
 
57 56
   // If any of the drivers or the bed are enabled...
58 57
   if (X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON || Z_ENABLE_READ() == Z_ENABLE_ON
59
-    #if HAS_HEATED_BED
60
-      || thermalManager.temp_bed.soft_pwm_amount > 0
61
-    #endif
58
+    || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0)
62 59
     #if HAS_X2_ENABLE
63 60
       || X2_ENABLE_READ() == X_ENABLE_ON
64 61
     #endif
@@ -75,10 +72,7 @@ bool Power::is_power_needed() {
75 72
   ) return true;
76 73
 
77 74
   HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0) return true;
78
-
79
-  #if HAS_HEATED_BED
80
-    if (thermalManager.degTargetBed() > 0) return true;
81
-  #endif
75
+  if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed() > 0)) return true;
82 76
 
83 77
   #if HOTENDS && AUTO_POWER_E_TEMP
84 78
     HOTEND_LOOP() if (thermalManager.degHotend(e) >= AUTO_POWER_E_TEMP) return true;

+ 9
- 31
Marlin/src/feature/powerloss.cpp Wyświetl plik

@@ -172,12 +172,8 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
172 172
 
173 173
     // Machine state
174 174
     info.current_position = current_position;
175
-    #if HAS_HOME_OFFSET
176
-      info.home_offset = home_offset;
177
-    #endif
178
-    #if HAS_POSITION_SHIFT
179
-      info.position_shift = position_shift;
180
-    #endif
175
+    TERN_(HAS_HOME_OFFSET, info.home_offset = home_offset);
176
+    TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift);
181 177
     info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
182 178
 
183 179
     #if EXTRUDERS > 1
@@ -197,9 +193,7 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
197 193
       HOTEND_LOOP() info.target_temperature[e] = thermalManager.temp_hotend[e].target;
198 194
     #endif
199 195
 
200
-    #if HAS_HEATED_BED
201
-      info.target_temperature_bed = thermalManager.temp_bed.target;
202
-    #endif
196
+    TERN_(HAS_HEATED_BED, info.target_temperature_bed = thermalManager.temp_bed.target);
203 197
 
204 198
     #if FAN_COUNT
205 199
       COPY(info.fan_speed, thermalManager.fan_speed);
@@ -207,18 +201,10 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
207 201
 
208 202
     #if HAS_LEVELING
209 203
       info.leveling = planner.leveling_active;
210
-      info.fade = (
211
-        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
212
-          planner.z_fade_height
213
-        #else
214
-          0
215
-        #endif
216
-      );
204
+      info.fade = TERN0(ENABLE_LEVELING_FADE_HEIGHT, planner.z_fade_height);
217 205
     #endif
218 206
 
219
-    #if ENABLED(GRADIENT_MIX)
220
-      memcpy(&info.gradient, &mixer.gradient, sizeof(info.gradient));
221
-    #endif
207
+    TERN_(GRADIENT_MIX, memcpy(&info.gradient, &mixer.gradient, sizeof(info.gradient)));
222 208
 
223 209
     #if ENABLED(FWRETRACT)
224 210
       COPY(info.retract, fwretract.current_retract);
@@ -244,9 +230,7 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
244 230
       lock = true;
245 231
     #endif
246 232
     if (IS_SD_PRINTING()) save(true);
247
-    #if ENABLED(BACKUP_POWER_SUPPLY)
248
-      raise_z();
249
-    #endif
233
+    TERN_(BACKUP_POWER_SUPPLY, raise_z());
250 234
 
251 235
     kill(GET_TEXT(MSG_OUTAGE_RECOVERY));
252 236
   }
@@ -299,9 +283,7 @@ void PrintJobRecovery::resume() {
299 283
       // If Z homing goes to max, just reset E and home all
300 284
       "\n"
301 285
       "G28R0"
302
-      #if ENABLED(MARLIN_DEV_MODE)
303
-        "S"
304
-      #endif
286
+      TERN_(MARLIN_DEV_MODE, "S")
305 287
 
306 288
     #else // "G92.9 E0 ..."
307 289
 
@@ -460,12 +442,8 @@ void PrintJobRecovery::resume() {
460 442
   // Relative axis modes
461 443
   gcode.axis_relative = info.axis_relative;
462 444
 
463
-  #if HAS_HOME_OFFSET
464
-    home_offset = info.home_offset;
465
-  #endif
466
-  #if HAS_POSITION_SHIFT
467
-    position_shift = info.position_shift;
468
-  #endif
445
+  TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset);
446
+  TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift);
469 447
   #if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
470 448
     LOOP_XYZ(i) update_workspace_offset((AxisEnum)i);
471 449
   #endif

+ 1
- 3
Marlin/src/feature/probe_temp_comp.h Wyświetl plik

@@ -82,9 +82,7 @@ class ProbeTempComp {
82 82
     static inline void clear_all_offsets() {
83 83
       clear_offsets(TSI_BED);
84 84
       clear_offsets(TSI_PROBE);
85
-      #if ENABLED(USE_TEMP_EXT_COMPENSATION)
86
-        clear_offsets(TSI_EXT);
87
-      #endif
85
+      TERN_(USE_TEMP_EXT_COMPENSATION, clear_offsets(TSI_EXT));
88 86
     }
89 87
     static bool set_offset(const TempSensorID tsi, const uint8_t idx, const int16_t offset);
90 88
     static void print_offsets();

+ 2
- 6
Marlin/src/feature/runout.cpp Wyświetl plik

@@ -74,13 +74,9 @@ void FilamentSensorBase::filament_present(const uint8_t extruder) {
74 74
 
75 75
 void event_filament_runout() {
76 76
 
77
-  #if ENABLED(ADVANCED_PAUSE_FEATURE)
78
-    if (did_pause_print) return;  // Action already in progress. Purge triggered repeated runout.
79
-  #endif
77
+  if (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return;  // Action already in progress. Purge triggered repeated runout.
80 78
 
81
-  #if ENABLED(EXTENSIBLE_UI)
82
-    ExtUI::onFilamentRunout(ExtUI::getActiveTool());
83
-  #endif
79
+  TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));
84 80
 
85 81
   #if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
86 82
     const char tool = '0'

+ 2
- 6
Marlin/src/feature/spindle_laser.cpp Wyświetl plik

@@ -54,9 +54,7 @@ void SpindleLaser::init() {
54 54
   #endif
55 55
   #if ENABLED(HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY)
56 56
     set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY);
57
-    #if ENABLED(MARLIN_DEV_MODE)
58
-      frequency = SPINDLE_LASER_FREQUENCY;
59
-    #endif
57
+    TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY);
60 58
   #endif
61 59
 }
62 60
 
@@ -99,9 +97,7 @@ void SpindleLaser::apply_power(const cutter_power_t inpow) {
99 97
   //
100 98
   void SpindleLaser::set_direction(const bool reverse) {
101 99
     const bool dir_state = (reverse == SPINDLE_INVERT_DIR); // Forward (M3) HIGH when not inverted
102
-    #if ENABLED(SPINDLE_STOP_ON_DIR_CHANGE)
103
-      if (enabled() && READ(SPINDLE_DIR_PIN) != dir_state) disable();
104
-    #endif
100
+    if (TERN0(SPINDLE_STOP_ON_DIR_CHANGE, enabled()) && READ(SPINDLE_DIR_PIN) != dir_state) disable();
105 101
     WRITE(SPINDLE_DIR_PIN, dir_state);
106 102
   }
107 103
 

+ 1
- 3
Marlin/src/feature/spindle_laser.h Wyświetl plik

@@ -162,9 +162,7 @@ public:
162 162
   #endif
163 163
 
164 164
   static inline void kill() {
165
-    #if ENABLED(LASER_POWER_INLINE)
166
-      inline_disable();
167
-    #endif
165
+    TERN_(LASER_POWER_INLINE, inline_disable());
168 166
     disable();
169 167
   }
170 168
 };

+ 6
- 12
Marlin/src/feature/tmc_util.cpp Wyświetl plik

@@ -63,9 +63,9 @@
63 63
            , is_stall:1
64 64
            , is_stealth:1
65 65
            , is_standstill:1
66
-          #if HAS_STALLGUARD
67
-           , sg_result_reasonable:1
68
-          #endif
66
+           #if HAS_STALLGUARD
67
+             , sg_result_reasonable:1
68
+           #endif
69 69
          #endif
70 70
       ;
71 71
     #if ENABLED(TMC_DEBUG)
@@ -169,9 +169,7 @@
169 169
           data.is_stealth = TEST(ds, STEALTH_bp);
170 170
           data.is_standstill = TEST(ds, STST_bp);
171 171
         #endif
172
-        #if HAS_STALLGUARD
173
-          data.sg_result_reasonable = false;
174
-        #endif
172
+        TERN_(HAS_STALLGUARD, data.sg_result_reasonable = false);
175 173
       #endif
176 174
       return data;
177 175
     }
@@ -213,9 +211,7 @@
213 211
       SERIAL_PRINTLN(data.drv_status, HEX);
214 212
       if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature");
215 213
       if (data.is_s2g) SERIAL_ECHOLNPGM("coil short circuit");
216
-      #if ENABLED(TMC_DEBUG)
217
-        tmc_report_all(true, true, true, true);
218
-      #endif
214
+      TERN_(TMC_DEBUG, tmc_report_all(true, true, true, true));
219 215
       kill(PSTR("Driver error"));
220 216
     }
221 217
   #endif
@@ -446,9 +442,7 @@
446 442
         (void)monitor_tmc_driver(stepperE7, need_update_error_counters, need_debug_reporting);
447 443
       #endif
448 444
 
449
-      #if ENABLED(TMC_DEBUG)
450
-        if (need_debug_reporting) SERIAL_EOL();
451
-      #endif
445
+      if (TERN0(TMC_DEBUG, need_debug_reporting)) SERIAL_EOL();
452 446
     }
453 447
   }
454 448
 

+ 10
- 30
Marlin/src/feature/tmc_util.h Wyświetl plik

@@ -69,15 +69,9 @@ class TMCStorage {
69 69
     }
70 70
 
71 71
     struct {
72
-      #if HAS_STEALTHCHOP
73
-        bool stealthChop_enabled = false;
74
-      #endif
75
-      #if ENABLED(HYBRID_THRESHOLD)
76
-        uint8_t hybrid_thrs = 0;
77
-      #endif
78
-      #if USE_SENSORLESS
79
-        int16_t homing_thrs = 0;
80
-      #endif
72
+      TERN_(HAS_STEALTHCHOP, bool stealthChop_enabled = false);
73
+      TERN_(HYBRID_THRESHOLD, uint8_t hybrid_thrs = 0);
74
+      TERN_(USE_SENSORLESS, int16_t homing_thrs = 0);
81 75
     } stored;
82 76
 };
83 77
 
@@ -118,9 +112,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
118 112
       }
119 113
       void set_pwm_thrs(const uint32_t thrs) {
120 114
         TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
121
-        #if HAS_LCD_MENU
122
-          this->stored.hybrid_thrs = thrs;
123
-        #endif
115
+        TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs);
124 116
       }
125 117
     #endif
126 118
 
@@ -129,9 +121,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
129 121
       void homing_threshold(int16_t sgt_val) {
130 122
         sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
131 123
         TMC::sgt(sgt_val);
132
-        #if HAS_LCD_MENU
133
-          this->stored.homing_thrs = sgt_val;
134
-        #endif
124
+        TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val);
135 125
       }
136 126
       #if ENABLED(SPI_ENDSTOPS)
137 127
         bool test_stall_status();
@@ -184,9 +174,7 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
184 174
       }
185 175
       void set_pwm_thrs(const uint32_t thrs) {
186 176
         TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
187
-        #if HAS_LCD_MENU
188
-          this->stored.hybrid_thrs = thrs;
189
-        #endif
177
+        TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs);
190 178
       }
191 179
     #endif
192 180
 
@@ -231,9 +219,7 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
231 219
       }
232 220
       void set_pwm_thrs(const uint32_t thrs) {
233 221
         TMC2209Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
234
-        #if HAS_LCD_MENU
235
-          this->stored.hybrid_thrs = thrs;
236
-        #endif
222
+        TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs);
237 223
       }
238 224
     #endif
239 225
     #if USE_SENSORLESS
@@ -241,9 +227,7 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
241 227
       void homing_threshold(int16_t sgt_val) {
242 228
         sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
243 229
         TMC2209Stepper::SGTHRS(sgt_val);
244
-        #if HAS_LCD_MENU
245
-          this->stored.homing_thrs = sgt_val;
246
-        #endif
230
+        TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val);
247 231
       }
248 232
     #endif
249 233
 
@@ -283,9 +267,7 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC266
283 267
       void homing_threshold(int16_t sgt_val) {
284 268
         sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
285 269
         TMC2660Stepper::sgt(sgt_val);
286
-        #if HAS_LCD_MENU
287
-          this->stored.homing_thrs = sgt_val;
288
-        #endif
270
+        TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val);
289 271
       }
290 272
     #endif
291 273
 
@@ -367,9 +349,7 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
367 349
 
368 350
     struct slow_homing_t {
369 351
       xy_ulong_t acceleration;
370
-      #if HAS_CLASSIC_JERK
371
-        xy_float_t jerk_xy;
372
-      #endif
352
+      TERN_(HAS_CLASSIC_JERK, xy_float_t jerk_xy);
373 353
     };
374 354
   #endif
375 355
 

+ 12
- 29
Marlin/src/gcode/bedlevel/G26.cpp Wyświetl plik

@@ -165,9 +165,7 @@ int8_t g26_prime_flag;
165 165
   bool user_canceled() {
166 166
     if (!ui.button_pressed()) return false; // Return if the button isn't pressed
167 167
     ui.set_status_P(GET_TEXT(MSG_G26_CANCELED), 99);
168
-    #if HAS_LCD_MENU
169
-      ui.quick_feedback();
170
-    #endif
168
+    TERN_(HAS_LCD_MENU, ui.quick_feedback());
171 169
     ui.wait_for_release();
172 170
     return true;
173 171
   }
@@ -301,9 +299,7 @@ inline bool look_for_lines_to_connect() {
301 299
 
302 300
   GRID_LOOP(i, j) {
303 301
 
304
-    #if HAS_LCD_MENU
305
-      if (user_canceled()) return true;
306
-    #endif
302
+    if (TERN0(HAS_LCD_MENU, user_canceled())) return true;
307 303
 
308 304
     if (i < (GRID_MAX_POINTS_X)) {  // Can't connect to anything farther to the right than GRID_MAX_POINTS_X.
309 305
                                     // Already a half circle at the edge of the bed.
@@ -364,9 +360,7 @@ inline bool turn_on_heaters() {
364 360
       #if HAS_SPI_LCD
365 361
         ui.set_status_P(GET_TEXT(MSG_G26_HEATING_BED), 99);
366 362
         ui.quick_feedback();
367
-        #if HAS_LCD_MENU
368
-          ui.capture();
369
-        #endif
363
+        TERN_(HAS_LCD_MENU, ui.capture());
370 364
       #endif
371 365
       thermalManager.setTargetBed(g26_bed_temp);
372 366
 
@@ -390,11 +384,10 @@ inline bool turn_on_heaters() {
390 384
 
391 385
   // Wait for the temperature to stabilize
392 386
   if (!thermalManager.wait_for_hotend(active_extruder, true
393
-      #if G26_CLICK_CAN_CANCEL
394
-        , true
395
-      #endif
396
-    )
397
-  ) return G26_ERR;
387
+    #if G26_CLICK_CAN_CANCEL
388
+      , true
389
+    #endif
390
+  )) return G26_ERR;
398 391
 
399 392
   #if HAS_SPI_LCD
400 393
     ui.reset_status();
@@ -665,9 +658,7 @@ void GcodeSuite::G26() {
665 658
   move_to(destination, 0.0);
666 659
   move_to(destination, g26_ooze_amount);
667 660
 
668
-  #if HAS_LCD_MENU
669
-    ui.capture();
670
-  #endif
661
+  TERN_(HAS_LCD_MENU, ui.capture());
671 662
 
672 663
   #if DISABLED(ARC_SUPPORT)
673 664
 
@@ -762,9 +753,7 @@ void GcodeSuite::G26() {
762 753
         feedrate_mm_s = old_feedrate;
763 754
         destination = current_position;
764 755
 
765
-        #if HAS_LCD_MENU
766
-          if (user_canceled()) goto LEAVE; // Check if the user wants to stop the Mesh Validation
767
-        #endif
756
+        if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation
768 757
 
769 758
       #else // !ARC_SUPPORT
770 759
 
@@ -788,9 +777,7 @@ void GcodeSuite::G26() {
788 777
 
789 778
         for (int8_t ind = start_ind; ind <= end_ind; ind++) {
790 779
 
791
-          #if HAS_LCD_MENU
792
-            if (user_canceled()) goto LEAVE;          // Check if the user wants to stop the Mesh Validation
793
-          #endif
780
+          if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation
794 781
 
795 782
           xyz_float_t p = { circle.x + _COS(ind    ), circle.y + _SIN(ind    ), g26_layer_height },
796 783
                       q = { circle.x + _COS(ind + 1), circle.y + _SIN(ind + 1), g26_layer_height };
@@ -833,14 +820,10 @@ void GcodeSuite::G26() {
833 820
     planner.calculate_volumetric_multipliers();
834 821
   #endif
835 822
 
836
-  #if HAS_LCD_MENU
837
-    ui.release();                                             // Give back control of the LCD
838
-  #endif
823
+  TERN_(HAS_LCD_MENU, ui.release()); // Give back control of the LCD
839 824
 
840 825
   if (!g26_keep_heaters_on) {
841
-    #if HAS_HEATED_BED
842
-      thermalManager.setTargetBed(0);
843
-    #endif
826
+    TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(0));
844 827
     thermalManager.setTargetHotend(active_extruder, 0);
845 828
   }
846 829
 }

+ 4
- 12
Marlin/src/gcode/bedlevel/M420.cpp Wyświetl plik

@@ -73,9 +73,7 @@ void GcodeSuite::M420() {
73 73
       #endif
74 74
       GRID_LOOP(x, y) {
75 75
         Z_VALUES(x, y) = 0.001 * random(-200, 200);
76
-        #if ENABLED(EXTENSIBLE_UI)
77
-          ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
78
-        #endif
76
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y)));
79 77
       }
80 78
       SERIAL_ECHOPGM("Simulated " STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh ");
81 79
       SERIAL_ECHOPAIR(" (", x_min);
@@ -178,13 +176,9 @@ void GcodeSuite::M420() {
178 176
             // Subtract the mean from all values
179 177
             GRID_LOOP(x, y) {
180 178
               Z_VALUES(x, y) -= zmean;
181
-              #if ENABLED(EXTENSIBLE_UI)
182
-                ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
183
-              #endif
179
+              TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y)));
184 180
             }
185
-            #if ENABLED(ABL_BILINEAR_SUBDIVISION)
186
-              bed_level_virt_interpolate();
187
-            #endif
181
+            TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
188 182
           }
189 183
 
190 184
         #endif
@@ -206,9 +200,7 @@ void GcodeSuite::M420() {
206 200
       if (leveling_is_valid()) {
207 201
         #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
208 202
           print_bilinear_leveling_grid();
209
-          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
210
-            print_bilinear_leveling_grid_virt();
211
-          #endif
203
+          TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt());
212 204
         #elif ENABLED(MESH_BED_LEVELING)
213 205
           SERIAL_ECHOLNPGM("Mesh Bed Level data:");
214 206
           mbl.report_mesh();

+ 18
- 54
Marlin/src/gcode/bedlevel/abl/G29.cpp Wyświetl plik

@@ -283,9 +283,7 @@ G29_TYPE GcodeSuite::G29() {
283 283
    */
284 284
   if (!g29_in_progress) {
285 285
 
286
-    #if HAS_MULTI_HOTEND
287
-      if (active_extruder != 0) tool_change(0);
288
-    #endif
286
+    TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
289 287
 
290 288
     #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR)
291 289
       abl_probe_index = -1;
@@ -322,12 +320,8 @@ G29_TYPE GcodeSuite::G29() {
322 320
         if (WITHIN(i, 0, GRID_MAX_POINTS_X - 1) && WITHIN(j, 0, GRID_MAX_POINTS_Y)) {
323 321
           set_bed_leveling_enabled(false);
324 322
           z_values[i][j] = rz;
325
-          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
326
-            bed_level_virt_interpolate();
327
-          #endif
328
-          #if ENABLED(EXTENSIBLE_UI)
329
-            ExtUI::onMeshUpdate(i, j, rz);
330
-          #endif
323
+          TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
324
+          TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, rz));
331 325
           set_bed_leveling_enabled(abl_should_enable);
332 326
           if (abl_should_enable) report_current_position();
333 327
         }
@@ -492,14 +486,10 @@ G29_TYPE GcodeSuite::G29() {
492 486
     // Abort current G29 procedure, go back to idle state
493 487
     if (seenA && g29_in_progress) {
494 488
       SERIAL_ECHOLNPGM("Manual G29 aborted");
495
-      #if HAS_SOFTWARE_ENDSTOPS
496
-        soft_endstops_enabled = saved_soft_endstops_state;
497
-      #endif
489
+      TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
498 490
       set_bed_leveling_enabled(abl_should_enable);
499 491
       g29_in_progress = false;
500
-      #if ENABLED(LCD_BED_LEVELING)
501
-        ui.wait_for_move = false;
502
-      #endif
492
+      TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
503 493
     }
504 494
 
505 495
     // Query G29 status
@@ -517,9 +507,7 @@ G29_TYPE GcodeSuite::G29() {
517 507
 
518 508
     if (abl_probe_index == 0) {
519 509
       // For the initial G29 S2 save software endstop state
520
-      #if HAS_SOFTWARE_ENDSTOPS
521
-        saved_soft_endstops_state = soft_endstops_enabled;
522
-      #endif
510
+      TERN_(HAS_SOFTWARE_ENDSTOPS, saved_soft_endstops_state = soft_endstops_enabled);
523 511
       // Move close to the bed before the first point
524 512
       do_blocking_move_to_z(0);
525 513
     }
@@ -551,9 +539,7 @@ G29_TYPE GcodeSuite::G29() {
551 539
 
552 540
         const float newz = measured_z + zoffset;
553 541
         z_values[meshCount.x][meshCount.y] = newz;
554
-        #if ENABLED(EXTENSIBLE_UI)
555
-          ExtUI::onMeshUpdate(meshCount, newz);
556
-        #endif
542
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(meshCount, newz));
557 543
 
558 544
         if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_P(PSTR("Save X"), meshCount.x, SP_Y_STR, meshCount.y, SP_Z_STR, measured_z + zoffset);
559 545
 
@@ -580,9 +566,7 @@ G29_TYPE GcodeSuite::G29() {
580 566
 
581 567
         probePos = probe_position_lf + gridSpacing * meshCount.asFloat();
582 568
 
583
-        #if ENABLED(AUTO_BED_LEVELING_LINEAR)
584
-          indexIntoAB[meshCount.x][meshCount.y] = abl_probe_index;
585
-        #endif
569
+        TERN_(AUTO_BED_LEVELING_LINEAR, indexIntoAB[meshCount.x][meshCount.y] = abl_probe_index);
586 570
 
587 571
         // Keep looping till a reachable point is found
588 572
         if (position_is_reachable(probePos)) break;
@@ -606,9 +590,7 @@ G29_TYPE GcodeSuite::G29() {
606 590
         SERIAL_ECHOLNPGM("Grid probing done.");
607 591
 
608 592
         // Re-enable software endstops, if needed
609
-        #if HAS_SOFTWARE_ENDSTOPS
610
-          soft_endstops_enabled = saved_soft_endstops_state;
611
-        #endif
593
+        TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
612 594
       }
613 595
 
614 596
     #elif ENABLED(AUTO_BED_LEVELING_3POINT)
@@ -629,9 +611,7 @@ G29_TYPE GcodeSuite::G29() {
629 611
         SERIAL_ECHOLNPGM("3-point probing done.");
630 612
 
631 613
         // Re-enable software endstops, if needed
632
-        #if HAS_SOFTWARE_ENDSTOPS
633
-          soft_endstops_enabled = saved_soft_endstops_state;
634
-        #endif
614
+        TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
635 615
 
636 616
         if (!dryrun) {
637 617
           vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal();
@@ -688,9 +668,7 @@ G29_TYPE GcodeSuite::G29() {
688 668
 
689 669
           probePos = probe_position_lf + gridSpacing * meshCount.asFloat();
690 670
 
691
-          #if ENABLED(AUTO_BED_LEVELING_LINEAR)
692
-            indexIntoAB[meshCount.x][meshCount.y] = ++abl_probe_index; // 0...
693
-          #endif
671
+          TERN_(AUTO_BED_LEVELING_LINEAR, indexIntoAB[meshCount.x][meshCount.y] = ++abl_probe_index); // 0...
694 672
 
695 673
           #if IS_KINEMATIC
696 674
             // Avoid probing outside the round or hexagonal area
@@ -698,9 +676,7 @@ G29_TYPE GcodeSuite::G29() {
698 676
           #endif
699 677
 
700 678
           if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", int(pt_index), "/", int(GRID_MAX_POINTS), ".");
701
-          #if HAS_DISPLAY
702
-            ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS));
703
-          #endif
679
+          TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS)));
704 680
 
705 681
           measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level);
706 682
 
@@ -712,9 +688,7 @@ G29_TYPE GcodeSuite::G29() {
712 688
           #if ENABLED(PROBE_TEMP_COMPENSATION)
713 689
             temp_comp.compensate_measurement(TSI_BED, thermalManager.degBed(), measured_z);
714 690
             temp_comp.compensate_measurement(TSI_PROBE, thermalManager.degProbe(), measured_z);
715
-            #if ENABLED(USE_TEMP_EXT_COMPENSATION)
716
-              temp_comp.compensate_measurement(TSI_EXT, thermalManager.degHotend(), measured_z);
717
-            #endif
691
+            TERN_(USE_TEMP_EXT_COMPENSATION, temp_comp.compensate_measurement(TSI_EXT, thermalManager.degHotend(), measured_z));
718 692
           #endif
719 693
 
720 694
           #if ENABLED(AUTO_BED_LEVELING_LINEAR)
@@ -730,9 +704,7 @@ G29_TYPE GcodeSuite::G29() {
730 704
           #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
731 705
 
732 706
             z_values[meshCount.x][meshCount.y] = measured_z + zoffset;
733
-            #if ENABLED(EXTENSIBLE_UI)
734
-              ExtUI::onMeshUpdate(meshCount, z_values[meshCount.x][meshCount.y]);
735
-            #endif
707
+            TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(meshCount, z_values[meshCount.x][meshCount.y]));
736 708
 
737 709
           #endif
738 710
 
@@ -748,9 +720,7 @@ G29_TYPE GcodeSuite::G29() {
748 720
 
749 721
       LOOP_L_N(i, 3) {
750 722
         if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", int(i), "/3.");
751
-        #if HAS_DISPLAY
752
-          ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i));
753
-        #endif
723
+        TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i)));
754 724
 
755 725
         // Retain the last probe position
756 726
         probePos = points[i];
@@ -773,9 +743,7 @@ G29_TYPE GcodeSuite::G29() {
773 743
 
774 744
     #endif // AUTO_BED_LEVELING_3POINT
775 745
 
776
-    #if HAS_DISPLAY
777
-      ui.reset_status();
778
-    #endif
746
+    TERN_(HAS_DISPLAY, ui.reset_status());
779 747
 
780 748
     // Stow the probe. No raise for FIX_MOUNTED_PROBE.
781 749
     if (probe.stow()) {
@@ -799,9 +767,7 @@ G29_TYPE GcodeSuite::G29() {
799 767
 
800 768
   #if ENABLED(PROBE_MANUALLY)
801 769
     g29_in_progress = false;
802
-    #if ENABLED(LCD_BED_LEVELING)
803
-      ui.wait_for_move = false;
804
-    #endif
770
+    TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
805 771
   #endif
806 772
 
807 773
   // Calculate leveling, print reports, correct the position
@@ -813,9 +779,7 @@ G29_TYPE GcodeSuite::G29() {
813 779
 
814 780
       refresh_bed_level();
815 781
 
816
-      #if ENABLED(ABL_BILINEAR_SUBDIVISION)
817
-        print_bilinear_leveling_grid_virt();
818
-      #endif
782
+      TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt());
819 783
 
820 784
     #elif ENABLED(AUTO_BED_LEVELING_LINEAR)
821 785
 

+ 2
- 6
Marlin/src/gcode/bedlevel/abl/M421.cpp Wyświetl plik

@@ -55,12 +55,8 @@ void GcodeSuite::M421() {
55 55
     SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
56 56
   else {
57 57
     z_values[ix][iy] = parser.value_linear_units() + (hasQ ? z_values[ix][iy] : 0);
58
-    #if ENABLED(ABL_BILINEAR_SUBDIVISION)
59
-      bed_level_virt_interpolate();
60
-    #endif
61
-    #if ENABLED(EXTENSIBLE_UI)
62
-      ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]);
63
-    #endif
58
+    TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
59
+    TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]));
64 60
   }
65 61
 }
66 62
 

+ 4
- 12
Marlin/src/gcode/bedlevel/mbl/G29.cpp Wyświetl plik

@@ -62,9 +62,7 @@ inline void echo_not_entered(const char c) { SERIAL_CHAR(c); SERIAL_ECHOLNPGM("
62 62
 void GcodeSuite::G29() {
63 63
 
64 64
   static int mbl_probe_index = -1;
65
-  #if HAS_SOFTWARE_ENDSTOPS
66
-    static bool saved_soft_endstops_state;
67
-  #endif
65
+  TERN_(HAS_SOFTWARE_ENDSTOPS, static bool saved_soft_endstops_state);
68 66
 
69 67
   MeshLevelingState state = (MeshLevelingState)parser.byteval('S', (int8_t)MeshReport);
70 68
   if (!WITHIN(state, 0, 5)) {
@@ -111,9 +109,7 @@ void GcodeSuite::G29() {
111 109
       else {
112 110
         // Save Z for the previous mesh position
113 111
         mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z);
114
-        #if HAS_SOFTWARE_ENDSTOPS
115
-          soft_endstops_enabled = saved_soft_endstops_state;
116
-        #endif
112
+        TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
117 113
       }
118 114
       // If there's another point to sample, move there with optional lift.
119 115
       if (mbl_probe_index < GRID_MAX_POINTS) {
@@ -147,9 +143,7 @@ void GcodeSuite::G29() {
147 143
           planner.synchronize();
148 144
         #endif
149 145
 
150
-        #if ENABLED(LCD_BED_LEVELING)
151
-          ui.wait_for_move = false;
152
-        #endif
146
+        TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
153 147
       }
154 148
       break;
155 149
 
@@ -178,9 +172,7 @@ void GcodeSuite::G29() {
178 172
 
179 173
       if (parser.seenval('Z')) {
180 174
         mbl.z_values[ix][iy] = parser.value_linear_units();
181
-        #if ENABLED(EXTENSIBLE_UI)
182
-          ExtUI::onMeshUpdate(ix, iy, mbl.z_values[ix][iy]);
183
-        #endif
175
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, mbl.z_values[ix][iy]));
184 176
       }
185 177
       else
186 178
         return echo_not_entered('Z');

+ 1
- 3
Marlin/src/gcode/bedlevel/ubl/M421.cpp Wyświetl plik

@@ -63,9 +63,7 @@ void GcodeSuite::M421() {
63 63
   else {
64 64
     float &zval = ubl.z_values[ij.x][ij.y];
65 65
     zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0);
66
-    #if ENABLED(EXTENSIBLE_UI)
67
-      ExtUI::onMeshUpdate(ij.x, ij.y, zval);
68
-    #endif
66
+    TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval));
69 67
   }
70 68
 }
71 69
 

+ 19
- 49
Marlin/src/gcode/calibrate/G28.cpp Wyświetl plik

@@ -126,22 +126,16 @@
126 126
      */
127 127
     destination.set(safe_homing_xy, current_position.z);
128 128
 
129
-    #if HOMING_Z_WITH_PROBE
130
-      destination -= probe.offset_xy;
131
-    #endif
129
+    TERN_(HOMING_Z_WITH_PROBE, destination -= probe.offset_xy);
132 130
 
133 131
     if (position_is_reachable(destination)) {
134 132
 
135 133
       if (DEBUGGING(LEVELING)) DEBUG_POS("home_z_safely", destination);
136 134
 
137 135
       // This causes the carriage on Dual X to unpark
138
-      #if ENABLED(DUAL_X_CARRIAGE)
139
-        active_extruder_parked = false;
140
-      #endif
136
+      TERN_(DUAL_X_CARRIAGE, active_extruder_parked = false);
141 137
 
142
-      #if ENABLED(SENSORLESS_HOMING)
143
-        safe_delay(500); // Short delay needed to settle
144
-      #endif
138
+      TERN_(SENSORLESS_HOMING, safe_delay(500)); // Short delay needed to settle
145 139
 
146 140
       do_blocking_move_to_xy(destination);
147 141
       homeaxis(Z_AXIS);
@@ -175,9 +169,7 @@
175 169
   void end_slow_homing(const slow_homing_t &slow_homing) {
176 170
     planner.settings.max_acceleration_mm_per_s2[X_AXIS] = slow_homing.acceleration.x;
177 171
     planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = slow_homing.acceleration.y;
178
-    #if HAS_CLASSIC_JERK
179
-      planner.max_jerk = slow_homing.jerk_xy;
180
-    #endif
172
+    TERN_(HAS_CLASSIC_JERK, planner.max_jerk = slow_homing.jerk_xy);
181 173
     planner.reset_acceleration_rates();
182 174
   }
183 175
 
@@ -237,22 +229,18 @@ void GcodeSuite::G28() {
237 229
   #if HAS_LEVELING
238 230
 
239 231
     // Cancel the active G29 session
240
-    #if ENABLED(PROBE_MANUALLY)
241
-      g29_in_progress = false;
242
-    #endif
232
+    TERN_(PROBE_MANUALLY, g29_in_progress = false);
243 233
 
244
-    #if ENABLED(RESTORE_LEVELING_AFTER_G28)
245
-      const bool leveling_was_active = planner.leveling_active;
246
-    #endif
234
+    TERN_(RESTORE_LEVELING_AFTER_G28, const bool leveling_was_active = planner.leveling_active);
247 235
     set_bed_leveling_enabled(false);
248 236
   #endif
249 237
 
250
-  #if ENABLED(CNC_WORKSPACE_PLANES)
251
-    workspace_plane = PLANE_XY;
252
-  #endif
238
+  TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
253 239
 
254 240
   #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT)
255
-  #define HAS_HOMING_CURRENT (HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2))
241
+  #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2)
242
+    #define HAS_HOMING_CURRENT 1
243
+  #endif
256 244
 
257 245
   #if HAS_HOMING_CURRENT
258 246
     auto debug_current = [](PGM_P const s, const int16_t a, const int16_t b){
@@ -280,9 +268,7 @@ void GcodeSuite::G28() {
280 268
     #endif
281 269
   #endif
282 270
 
283
-  #if ENABLED(IMPROVE_HOMING_RELIABILITY)
284
-    slow_homing_t slow_homing = begin_slow_homing();
285
-  #endif
271
+  TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing_t slow_homing = begin_slow_homing());
286 272
 
287 273
   // Always home with tool 0 active
288 274
   #if HAS_MULTI_HOTEND
@@ -292,9 +278,7 @@ void GcodeSuite::G28() {
292 278
     tool_change(0, true);
293 279
   #endif
294 280
 
295
-  #if HAS_DUPLICATION_MODE
296
-    extruder_duplication_enabled = false;
297
-  #endif
281
+  TERN_(HAS_DUPLICATION_MODE, extruder_duplication_enabled = false);
298 282
 
299 283
   remember_feedrate_scaling_off();
300 284
 
@@ -306,9 +290,7 @@ void GcodeSuite::G28() {
306 290
 
307 291
     home_delta();
308 292
 
309
-    #if ENABLED(IMPROVE_HOMING_RELIABILITY)
310
-      end_slow_homing(slow_homing);
311
-    #endif
293
+    TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
312 294
 
313 295
   #else // NOT DELTA
314 296
 
@@ -380,17 +362,13 @@ void GcodeSuite::G28() {
380 362
     if (DISABLED(HOME_Y_BEFORE_X) && doY)
381 363
       homeaxis(Y_AXIS);
382 364
 
383
-    #if ENABLED(IMPROVE_HOMING_RELIABILITY)
384
-      end_slow_homing(slow_homing);
385
-    #endif
365
+    TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
386 366
 
387 367
     // Home Z last if homing towards the bed
388 368
     #if Z_HOME_DIR < 0
389 369
 
390 370
       if (doZ) {
391
-        #if ENABLED(BLTOUCH)
392
-          bltouch.init();
393
-        #endif
371
+        TERN_(BLTOUCH, bltouch.init());
394 372
         #if ENABLED(Z_SAFE_HOMING)
395 373
           home_z_safely();
396 374
         #else
@@ -425,9 +403,7 @@ void GcodeSuite::G28() {
425 403
 
426 404
     if (dxc_is_duplicating()) {
427 405
 
428
-      #if ENABLED(IMPROVE_HOMING_RELIABILITY)
429
-        slow_homing = begin_slow_homing();
430
-      #endif
406
+      TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing = begin_slow_homing());
431 407
 
432 408
       // Always home the 2nd (right) extruder first
433 409
       active_extruder = 1;
@@ -448,9 +424,7 @@ void GcodeSuite::G28() {
448 424
       dual_x_carriage_mode         = IDEX_saved_mode;
449 425
       stepper.set_directions();
450 426
 
451
-      #if ENABLED(IMPROVE_HOMING_RELIABILITY)
452
-        end_slow_homing(slow_homing);
453
-      #endif
427
+      TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
454 428
     }
455 429
 
456 430
   #endif // DUAL_X_CARRIAGE
@@ -458,18 +432,14 @@ void GcodeSuite::G28() {
458 432
   endstops.not_homing();
459 433
 
460 434
   // Clear endstop state for polled stallGuard endstops
461
-  #if ENABLED(SPI_ENDSTOPS)
462
-    endstops.clear_endstop_state();
463
-  #endif
435
+  TERN_(SPI_ENDSTOPS, endstops.clear_endstop_state());
464 436
 
465 437
   #if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
466 438
     // move to a height where we can use the full xy-area
467 439
     do_blocking_move_to_z(delta_clip_start_height);
468 440
   #endif
469 441
 
470
-  #if ENABLED(RESTORE_LEVELING_AFTER_G28)
471
-    set_bed_leveling_enabled(leveling_was_active);
472
-  #endif
442
+  TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_was_active));
473 443
 
474 444
   restore_feedrate_and_scaling();
475 445
 

+ 8
- 25
Marlin/src/gcode/calibrate/G33.cpp Wyświetl plik

@@ -63,12 +63,7 @@ enum CalEnum : char {                        // the 7 main calibration points -
63 63
 #define LOOP_CAL_RAD(VAR) LOOP_CAL_PT(VAR, __A, _7P_STEP)
64 64
 #define LOOP_CAL_ACT(VAR, _4P, _OP) LOOP_CAL_PT(VAR, _OP ? _AB : __A, _4P ? _4P_STEP : _7P_STEP)
65 65
 
66
-#if HOTENDS > 1
67
-  const uint8_t old_tool_index = active_extruder;
68
-  #define AC_CLEANUP() ac_cleanup(old_tool_index)
69
-#else
70
-  #define AC_CLEANUP() ac_cleanup()
71
-#endif
66
+TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder);
72 67
 
73 68
 float lcd_probe_pt(const xy_pos_t &xy);
74 69
 
@@ -79,9 +74,7 @@ void ac_home() {
79 74
 }
80 75
 
81 76
 void ac_setup(const bool reset_bed) {
82
-  #if HOTENDS > 1
83
-    tool_change(0, true);
84
-  #endif
77
+  TERN_(HAS_MULTI_HOTEND, tool_change(0, true));
85 78
 
86 79
   planner.synchronize();
87 80
   remember_feedrate_scaling_off();
@@ -91,21 +84,11 @@ void ac_setup(const bool reset_bed) {
91 84
   #endif
92 85
 }
93 86
 
94
-void ac_cleanup(
95
-  #if HOTENDS > 1
96
-    const uint8_t old_tool_index
97
-  #endif
98
-) {
99
-  #if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
100
-    do_blocking_move_to_z(delta_clip_start_height);
101
-  #endif
102
-  #if HAS_BED_PROBE
103
-    probe.stow();
104
-  #endif
87
+void ac_cleanup(TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index)) {
88
+  TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height));
89
+  TERN_(HAS_BED_PROBE, probe.stow());
105 90
   restore_feedrate_and_scaling();
106
-  #if HOTENDS > 1
107
-    tool_change(old_tool_index, true);
108
-  #endif
91
+  TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index, true));
109 92
 }
110 93
 
111 94
 void print_signed_float(PGM_P const prefix, const float &f) {
@@ -488,7 +471,7 @@ void GcodeSuite::G33() {
488 471
     zero_std_dev_old = zero_std_dev;
489 472
     if (!probe_calibration_points(z_at_pt, probe_points, towers_set, stow_after_each)) {
490 473
       SERIAL_ECHOLNPGM("Correct delta settings with M665 and M666");
491
-      return AC_CLEANUP();
474
+      return ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index));
492 475
     }
493 476
     zero_std_dev = std_dev_points(z_at_pt, _0p_calibration, _1p_calibration, _4p_calibration, _4p_opposite_points);
494 477
 
@@ -659,7 +642,7 @@ void GcodeSuite::G33() {
659 642
   }
660 643
   while (((zero_std_dev < test_precision && iterations < 31) || iterations <= force_iterations) && zero_std_dev > calibration_precision);
661 644
 
662
-  AC_CLEANUP();
645
+  ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index));
663 646
 }
664 647
 
665 648
 #endif // DELTA_AUTO_CALIBRATION

+ 8
- 20
Marlin/src/gcode/calibrate/G34_M422.cpp Wyświetl plik

@@ -113,15 +113,11 @@ void GcodeSuite::G34() {
113 113
 
114 114
     // Disable the leveling matrix before auto-aligning
115 115
     #if HAS_LEVELING
116
-      #if ENABLED(RESTORE_LEVELING_AFTER_G34)
117
-        const bool leveling_was_active = planner.leveling_active;
118
-      #endif
116
+      TERN_(RESTORE_LEVELING_AFTER_G34, const bool leveling_was_active = planner.leveling_active);
119 117
       set_bed_leveling_enabled(false);
120 118
     #endif
121 119
 
122
-    #if ENABLED(CNC_WORKSPACE_PLANES)
123
-      workspace_plane = PLANE_XY;
124
-    #endif
120
+    TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
125 121
 
126 122
     // Always home with tool 0 active
127 123
     #if HAS_MULTI_HOTEND
@@ -129,18 +125,12 @@ void GcodeSuite::G34() {
129 125
       tool_change(0, true);
130 126
     #endif
131 127
 
132
-    #if HAS_DUPLICATION_MODE
133
-      extruder_duplication_enabled = false;
134
-    #endif
128
+    TERN_(HAS_DUPLICATION_MODE, extruder_duplication_enabled = false);
135 129
 
136
-    #if BOTH(BLTOUCH, BLTOUCH_HS_MODE)
137
-        // In BLTOUCH HS mode, the probe travels in a deployed state.
138
-        // Users of G34 might have a badly misaligned bed, so raise Z by the
139
-        // length of the deployed pin (BLTOUCH stroke < 7mm)
140
-      #define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES + 7.0f
141
-    #else
142
-      #define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES
143
-    #endif
130
+    // In BLTOUCH HS mode, the probe travels in a deployed state.
131
+    // Users of G34 might have a badly misaligned bed, so raise Z by the
132
+    // length of the deployed pin (BLTOUCH stroke < 7mm)
133
+    #define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES + 7.0f * BOTH(BLTOUCH, BLTOUCH_HS_MODE)
144 134
 
145 135
     // Compute a worst-case clearance height to probe from. After the first
146 136
     // iteration this will be re-calculated based on the actual bed position
@@ -386,9 +376,7 @@ void GcodeSuite::G34() {
386 376
     #endif
387 377
 
388 378
     // Restore the active tool after homing
389
-    #if HAS_MULTI_HOTEND
390
-      tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous tool for parking extruder
391
-    #endif
379
+    TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER))); // Fetch previous tool for parking extruder
392 380
 
393 381
     #if HAS_LEVELING && ENABLED(RESTORE_LEVELING_AFTER_G34)
394 382
       set_bed_leveling_enabled(leveling_was_active);

+ 12
- 38
Marlin/src/gcode/calibrate/G425.cpp Wyświetl plik

@@ -285,37 +285,19 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
285 285
     probe_side(m, uncertainty, TOP);
286 286
   #endif
287 287
 
288
-  #if ENABLED(CALIBRATION_MEASURE_RIGHT)
289
-    probe_side(m, uncertainty, RIGHT, probe_top_at_edge);
290
-  #endif
291
-
292
-  #if ENABLED(CALIBRATION_MEASURE_FRONT)
293
-    probe_side(m, uncertainty, FRONT, probe_top_at_edge);
294
-  #endif
295
-
296
-  #if ENABLED(CALIBRATION_MEASURE_LEFT)
297
-    probe_side(m, uncertainty, LEFT,  probe_top_at_edge);
298
-  #endif
299
-  #if ENABLED(CALIBRATION_MEASURE_BACK)
300
-    probe_side(m, uncertainty, BACK,  probe_top_at_edge);
301
-  #endif
288
+  TERN_(CALIBRATION_MEASURE_RIGHT, probe_side(m, uncertainty, RIGHT, probe_top_at_edge));
289
+  TERN_(CALIBRATION_MEASURE_FRONT, probe_side(m, uncertainty, FRONT, probe_top_at_edge));
290
+  TERN_(CALIBRATION_MEASURE_LEFT,  probe_side(m, uncertainty, LEFT,  probe_top_at_edge));
291
+  TERN_(CALIBRATION_MEASURE_BACK,  probe_side(m, uncertainty, BACK,  probe_top_at_edge));
302 292
 
303 293
   // Compute the measured center of the calibration object.
304
-  #if HAS_X_CENTER
305
-    m.obj_center.x = (m.obj_side[LEFT] + m.obj_side[RIGHT]) / 2;
306
-  #endif
307
-  #if HAS_Y_CENTER
308
-    m.obj_center.y = (m.obj_side[FRONT] + m.obj_side[BACK]) / 2;
309
-  #endif
294
+  TERN_(HAS_X_CENTER, m.obj_center.x = (m.obj_side[LEFT] + m.obj_side[RIGHT]) / 2);
295
+  TERN_(HAS_Y_CENTER, m.obj_center.y = (m.obj_side[FRONT] + m.obj_side[BACK]) / 2);
310 296
 
311 297
   // Compute the outside diameter of the nozzle at the height
312 298
   // at which it makes contact with the calibration object
313
-  #if HAS_X_CENTER
314
-    m.nozzle_outer_dimension.x = m.obj_side[RIGHT] - m.obj_side[LEFT] - dimensions.x;
315
-  #endif
316
-  #if HAS_Y_CENTER
317
-    m.nozzle_outer_dimension.y = m.obj_side[BACK]  - m.obj_side[FRONT] - dimensions.y;
318
-  #endif
299
+  TERN_(HAS_X_CENTER, m.nozzle_outer_dimension.x = m.obj_side[RIGHT] - m.obj_side[LEFT] - dimensions.x);
300
+  TERN_(HAS_Y_CENTER, m.nozzle_outer_dimension.y = m.obj_side[BACK]  - m.obj_side[FRONT] - dimensions.y);
319 301
 
320 302
   park_above_object(m, uncertainty);
321 303
 
@@ -544,13 +526,9 @@ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty)
544 526
 
545 527
   HOTEND_LOOP() calibrate_toolhead(m, uncertainty, e);
546 528
 
547
-  #if HAS_HOTEND_OFFSET
548
-    normalize_hotend_offsets();
549
-  #endif
529
+  TERN_(HAS_HOTEND_OFFSET, normalize_hotend_offsets());
550 530
 
551
-  #if HAS_MULTI_HOTEND
552
-    set_nozzle(m, 0);
553
-  #endif
531
+  TERN_(HAS_MULTI_HOTEND, set_nozzle(m, 0));
554 532
 }
555 533
 
556 534
 /**
@@ -567,9 +545,7 @@ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty)
567 545
 inline void calibrate_all() {
568 546
   measurements_t m;
569 547
 
570
-  #if HAS_HOTEND_OFFSET
571
-    reset_hotend_offsets();
572
-  #endif
548
+  TERN_(HAS_HOTEND_OFFSET, reset_hotend_offsets());
573 549
 
574 550
   TEMPORARY_BACKLASH_CORRECTION(all_on);
575 551
   TEMPORARY_BACKLASH_SMOOTHING(0.0f);
@@ -577,9 +553,7 @@ inline void calibrate_all() {
577 553
   // Do a fast and rough calibration of the toolheads
578 554
   calibrate_all_toolheads(m, CALIBRATION_MEASUREMENT_UNKNOWN);
579 555
 
580
-  #if ENABLED(BACKLASH_GCODE)
581
-    calibrate_backlash(m, CALIBRATION_MEASUREMENT_UNCERTAIN);
582
-  #endif
556
+  TERN_(BACKLASH_GCODE, calibrate_backlash(m, CALIBRATION_MEASUREMENT_UNCERTAIN));
583 557
 
584 558
   // Cycle the toolheads so the servos settle into their "natural" positions
585 559
   #if HAS_MULTI_HOTEND

+ 4
- 12
Marlin/src/gcode/calibrate/G76_M871.cpp Wyświetl plik

@@ -178,9 +178,7 @@ void GcodeSuite::G76() {
178 178
       report_temps(next_temp_report);
179 179
 
180 180
     // Disable leveling so it won't mess with us
181
-    #if HAS_LEVELING
182
-      set_bed_leveling_enabled(false);
183
-    #endif
181
+    TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
184 182
 
185 183
     for (;;) {
186 184
       thermalManager.setTargetBed(target_bed);
@@ -214,9 +212,7 @@ void GcodeSuite::G76() {
214 212
 
215 213
     // Cleanup
216 214
     thermalManager.setTargetBed(0);
217
-    #if HAS_LEVELING
218
-      set_bed_leveling_enabled(true);
219
-    #endif
215
+    TERN_(HAS_LEVELING, set_bed_leveling_enabled(true));
220 216
   } // do_bed_cal
221 217
 
222 218
   /********************************************
@@ -240,9 +236,7 @@ void GcodeSuite::G76() {
240 236
     wait_for_temps(target_bed, target_probe, next_temp_report);
241 237
 
242 238
     // Disable leveling so it won't mess with us
243
-    #if HAS_LEVELING
244
-      set_bed_leveling_enabled(false);
245
-    #endif
239
+    TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
246 240
 
247 241
     bool timeout = false;
248 242
     for (;;) {
@@ -273,9 +267,7 @@ void GcodeSuite::G76() {
273 267
 
274 268
     // Cleanup
275 269
     thermalManager.setTargetBed(0);
276
-    #if HAS_LEVELING
277
-      set_bed_leveling_enabled(true);
278
-    #endif
270
+    TERN_(HAS_LEVELING, set_bed_leveling_enabled(true));
279 271
 
280 272
     SERIAL_ECHOLNPGM("Final compensation values:");
281 273
     temp_comp.print_offsets();

+ 1
- 3
Marlin/src/gcode/calibrate/M48.cpp Wyświetl plik

@@ -263,9 +263,7 @@ void GcodeSuite::M48() {
263 263
   restore_feedrate_and_scaling();
264 264
 
265 265
   // Re-enable bed level correction if it had been on
266
-  #if HAS_LEVELING
267
-    set_bed_leveling_enabled(was_enabled);
268
-  #endif
266
+  TERN_(HAS_LEVELING, set_bed_leveling_enabled(was_enabled));
269 267
 
270 268
   report_current_position();
271 269
 }

+ 1
- 3
Marlin/src/gcode/config/M200-M205.cpp Wyświetl plik

@@ -142,9 +142,7 @@ void GcodeSuite::M205() {
142 142
       const float junc_dev = parser.value_linear_units();
143 143
       if (WITHIN(junc_dev, 0.01f, 0.3f)) {
144 144
         planner.junction_deviation_mm = junc_dev;
145
-        #if ENABLED(LIN_ADVANCE)
146
-          planner.recalculate_max_e_jerk();
147
-        #endif
145
+        TERN_(LIN_ADVANCE, planner.recalculate_max_e_jerk());
148 146
       }
149 147
       else
150 148
         SERIAL_ERROR_MSG("?J out of range (0.01 to 0.3)");

+ 3
- 9
Marlin/src/gcode/config/M43.cpp Wyświetl plik

@@ -340,12 +340,8 @@ void GcodeSuite::M43() {
340 340
     #if HAS_RESUME_CONTINUE
341 341
       KEEPALIVE_STATE(PAUSED_FOR_USER);
342 342
       wait_for_user = true;
343
-      #if ENABLED(HOST_PROMPT_SUPPORT)
344
-        host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M43 Wait Called"), CONTINUE_STR);
345
-      #endif
346
-      #if ENABLED(EXTENSIBLE_UI)
347
-        ExtUI::onUserConfirmRequired_P(PSTR("M43 Wait Called"));
348
-      #endif
343
+      TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M43 Wait Called"), CONTINUE_STR));
344
+      TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("M43 Wait Called")));
349 345
     #endif
350 346
 
351 347
     for (;;) {
@@ -366,9 +362,7 @@ void GcodeSuite::M43() {
366 362
         }
367 363
       }
368 364
 
369
-      #if HAS_RESUME_CONTINUE
370
-        if (!wait_for_user) break;
371
-      #endif
365
+      if (TERN0(HAS_RESUME_CONTINUE, !wait_for_user)) break;
372 366
 
373 367
       safe_delay(200);
374 368
     }

+ 1
- 3
Marlin/src/gcode/control/M108_M112_M410.cpp Wyświetl plik

@@ -31,9 +31,7 @@
31 31
  * M108: Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature.
32 32
  */
33 33
 void GcodeSuite::M108() {
34
-  #if HAS_RESUME_CONTINUE
35
-    wait_for_user = false;
36
-  #endif
34
+  TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
37 35
   wait_for_heatup = false;
38 36
 }
39 37
 

+ 2
- 6
Marlin/src/gcode/control/M17_M18_M84.cpp Wyświetl plik

@@ -37,9 +37,7 @@ void GcodeSuite::M17() {
37 37
     if (parser.seen('X')) ENABLE_AXIS_X();
38 38
     if (parser.seen('Y')) ENABLE_AXIS_Y();
39 39
     if (parser.seen('Z')) ENABLE_AXIS_Z();
40
-    #if HAS_E_STEPPER_ENABLE
41
-      if (parser.seen('E')) enable_e_steppers();
42
-    #endif
40
+    if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen('E'))) enable_e_steppers();
43 41
   }
44 42
   else {
45 43
     LCD_MESSAGEPGM(MSG_NO_MOVE);
@@ -60,9 +58,7 @@ void GcodeSuite::M18_M84() {
60 58
       if (parser.seen('X')) DISABLE_AXIS_X();
61 59
       if (parser.seen('Y')) DISABLE_AXIS_Y();
62 60
       if (parser.seen('Z')) DISABLE_AXIS_Z();
63
-      #if HAS_E_STEPPER_ENABLE
64
-        if (parser.seen('E')) disable_e_steppers();
65
-      #endif
61
+      if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen('E'))) disable_e_steppers();
66 62
     }
67 63
     else
68 64
       planner.finish_and_disable();

+ 2
- 6
Marlin/src/gcode/feature/digipot/M907-M910.cpp Wyświetl plik

@@ -86,12 +86,8 @@ void GcodeSuite::M907() {
86 86
    * M908: Control digital trimpot directly (M908 P<pin> S<current>)
87 87
    */
88 88
   void GcodeSuite::M908() {
89
-    #if HAS_DIGIPOTSS
90
-      stepper.digitalPotWrite(parser.intval('P'), parser.intval('S'));
91
-    #endif
92
-    #if ENABLED(DAC_STEPPER_CURRENT)
93
-      dac_current_raw(parser.byteval('P', -1), parser.ushortval('S', 0));
94
-    #endif
89
+    TERN_(HAS_DIGIPOTSS, stepper.digitalPotWrite(parser.intval('P'), parser.intval('S')));
90
+    TERN_(DAC_STEPPER_CURRENT, dac_current_raw(parser.byteval('P', -1), parser.ushortval('S', 0)));
95 91
   }
96 92
 
97 93
 #endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT

+ 6
- 19
Marlin/src/gcode/feature/pause/M125.cpp Wyświetl plik

@@ -56,11 +56,7 @@
56 56
  */
57 57
 void GcodeSuite::M125() {
58 58
   // Initial retract before move to filament change position
59
-  const float retract = -ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
60
-    #ifdef PAUSE_PARK_RETRACT_LENGTH
61
-      + (PAUSE_PARK_RETRACT_LENGTH)
62
-    #endif
63
-  );
59
+  const float retract = -ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) : (PAUSE_PARK_RETRACT_LENGTH));
64 60
 
65 61
   xyz_pos_t park_point = NOZZLE_PARK_POINT;
66 62
 
@@ -75,23 +71,14 @@ void GcodeSuite::M125() {
75 71
     park_point += hotend_offset[active_extruder];
76 72
   #endif
77 73
 
78
-  #if ENABLED(SDSUPPORT)
79
-    const bool sd_printing = IS_SD_PRINTING();
80
-  #else
81
-    constexpr bool sd_printing = false;
82
-  #endif
74
+  const bool sd_printing = TERN0(SDSUPPORT, IS_SD_PRINTING());
83 75
 
84
-  #if HAS_LCD_MENU
85
-    lcd_pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT);
86
-    const bool show_lcd = parser.seenval('P');
87
-  #else
88
-    constexpr bool show_lcd = false;
89
-  #endif
76
+  TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT));
77
+
78
+  const bool show_lcd = TERN0(HAS_LCD_MENU, parser.seenval('P'));
90 79
 
91 80
   if (pause_print(retract, park_point, 0, show_lcd)) {
92
-    #if ENABLED(POWER_LOSS_RECOVERY)
93
-      if (recovery.enabled) recovery.save(true);
94
-    #endif
81
+    TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true));
95 82
     if (!sd_printing || show_lcd) {
96 83
       wait_for_confirmation(false, 0);
97 84
       resume_print(0, 0, -retract, 0);

+ 4
- 12
Marlin/src/gcode/feature/pause/M600.cpp Wyświetl plik

@@ -112,11 +112,7 @@ void GcodeSuite::M600() {
112 112
   #endif
113 113
 
114 114
   // Initial retract before move to filament change position
115
-  const float retract = -ABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0
116
-    #ifdef PAUSE_PARK_RETRACT_LENGTH
117
-      + (PAUSE_PARK_RETRACT_LENGTH)
118
-    #endif
119
-  );
115
+  const float retract = -ABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : (PAUSE_PARK_RETRACT_LENGTH));
120 116
 
121 117
   xyz_pos_t park_point NOZZLE_PARK_POINT;
122 118
 
@@ -149,11 +145,9 @@ void GcodeSuite::M600() {
149 145
                                                         : fc_settings[active_extruder].load_length);
150 146
   #endif
151 147
 
152
-  const int beep_count = parser.intval('B',
148
+  const int beep_count = parser.intval('B', -1
153 149
     #ifdef FILAMENT_CHANGE_ALERT_BEEPS
154
-      FILAMENT_CHANGE_ALERT_BEEPS
155
-    #else
156
-      -1
150
+      + 1 + FILAMENT_CHANGE_ALERT_BEEPS
157 151
     #endif
158 152
   );
159 153
 
@@ -173,9 +167,7 @@ void GcodeSuite::M600() {
173 167
       tool_change(active_extruder_before_filament_change, false);
174 168
   #endif
175 169
 
176
-  #if ENABLED(MIXING_EXTRUDER)
177
-    mixer.T(old_mixing_tool); // Restore original mixing tool
178
-  #endif
170
+  TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool
179 171
 }
180 172
 
181 173
 #endif // ADVANCED_PAUSE_FEATURE

+ 6
- 18
Marlin/src/gcode/feature/pause/M701_M702.cpp Wyświetl plik

@@ -84,9 +84,7 @@ void GcodeSuite::M701() {
84 84
   if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
85 85
 
86 86
   // Show initial "wait for load" message
87
-  #if HAS_LCD_MENU
88
-    lcd_pause_show_message(PAUSE_MESSAGE_LOAD, PAUSE_MODE_LOAD_FILAMENT, target_extruder);
89
-  #endif
87
+  TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_LOAD, PAUSE_MODE_LOAD_FILAMENT, target_extruder));
90 88
 
91 89
   #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
92 90
     // Change toolhead if specified
@@ -129,14 +127,10 @@ void GcodeSuite::M701() {
129 127
       tool_change(active_extruder_before_filament_change, false);
130 128
   #endif
131 129
 
132
-  #if ENABLED(MIXING_EXTRUDER)
133
-    mixer.T(old_mixing_tool); // Restore original mixing tool
134
-  #endif
130
+  TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool
135 131
 
136 132
   // Show status screen
137
-  #if HAS_LCD_MENU
138
-    lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
139
-  #endif
133
+  TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_STATUS));
140 134
 }
141 135
 
142 136
 /**
@@ -190,9 +184,7 @@ void GcodeSuite::M702() {
190 184
   if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
191 185
 
192 186
   // Show initial "wait for unload" message
193
-  #if HAS_LCD_MENU
194
-    lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, PAUSE_MODE_UNLOAD_FILAMENT, target_extruder);
195
-  #endif
187
+  TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, PAUSE_MODE_UNLOAD_FILAMENT, target_extruder));
196 188
 
197 189
   #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
198 190
     // Change toolhead if specified
@@ -241,14 +233,10 @@ void GcodeSuite::M702() {
241 233
       tool_change(active_extruder_before_filament_change, false);
242 234
   #endif
243 235
 
244
-  #if ENABLED(MIXING_EXTRUDER)
245
-    mixer.T(old_mixing_tool); // Restore original mixing tool
246
-  #endif
236
+  TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool
247 237
 
248 238
   // Show status screen
249
-  #if HAS_LCD_MENU
250
-    lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
251
-  #endif
239
+  TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_STATUS));
252 240
 }
253 241
 
254 242
 #endif // ADVANCED_PAUSE_FEATURE

+ 1
- 3
Marlin/src/gcode/feature/powerloss/M1000.cpp Wyświetl plik

@@ -74,9 +74,7 @@ void GcodeSuite::M1000() {
74 74
       #else
75 75
         recovery.cancel();
76 76
       #endif
77
-      #if ENABLED(EXTENSIBLE_UI)
78
-        ExtUI::onPrintTimerStopped();
79
-      #endif
77
+      TERN_(EXTENSIBLE_UI, ExtUI::onPrintTimerStopped());
80 78
     }
81 79
     else
82 80
       recovery.resume();

+ 1
- 3
Marlin/src/gcode/gcode.cpp Wyświetl plik

@@ -218,9 +218,7 @@ void GcodeSuite::dwell(millis_t time) {
218 218
       }
219 219
     }
220 220
 
221
-    #if ENABLED(HOST_PROMPT_SUPPORT)
222
-      host_action_prompt_end();
223
-    #endif
221
+    TERN_(HOST_PROMPT_SUPPORT, host_action_prompt_end());
224 222
 
225 223
     #ifdef G29_SUCCESS_COMMANDS
226 224
       process_subcommands_now_P(PSTR(G29_SUCCESS_COMMANDS));

+ 69
- 207
Marlin/src/gcode/gcode.h Wyświetl plik

@@ -396,24 +396,18 @@ private:
396 396
     #endif
397 397
   );
398 398
 
399
-  #if ENABLED(ARC_SUPPORT)
400
-    static void G2_G3(const bool clockwise);
401
-  #endif
399
+  TERN_(ARC_SUPPORT, static void G2_G3(const bool clockwise));
402 400
 
403 401
   static void G4();
404 402
 
405
-  #if ENABLED(BEZIER_CURVE_SUPPORT)
406
-    static void G5();
407
-  #endif
403
+  TERN_(BEZIER_CURVE_SUPPORT, static void G5());
408 404
 
409 405
   #if ENABLED(FWRETRACT)
410 406
     static void G10();
411 407
     static void G11();
412 408
   #endif
413 409
 
414
-  #if ENABLED(NOZZLE_CLEAN_FEATURE)
415
-    static void G12();
416
-  #endif
410
+  TERN_(NOZZLE_CLEAN_FEATURE, static void G12());
417 411
 
418 412
   #if ENABLED(CNC_WORKSPACE_PLANES)
419 413
     static void G17();
@@ -426,13 +420,9 @@ private:
426 420
     static void G21();
427 421
   #endif
428 422
 
429
-  #if ENABLED(G26_MESH_VALIDATION)
430
-    static void G26();
431
-  #endif
423
+  TERN_(G26_MESH_VALIDATION, static void G26());
432 424
 
433
-  #if ENABLED(NOZZLE_PARK_FEATURE)
434
-    static void G27();
435
-  #endif
425
+  TERN_(NOZZLE_PARK_FEATURE, static void G27());
436 426
 
437 427
   static void G28();
438 428
 
@@ -454,22 +444,16 @@ private:
454 444
     #endif
455 445
   #endif
456 446
 
457
-  #if ENABLED(DELTA_AUTO_CALIBRATION)
458
-    static void G33();
459
-  #endif
447
+  TERN_(DELTA_AUTO_CALIBRATION, static void G33());
460 448
 
461 449
   #if ENABLED(Z_STEPPER_AUTO_ALIGN)
462 450
     static void G34();
463 451
     static void M422();
464 452
   #endif
465 453
 
466
-  #if ENABLED(G38_PROBE_TARGET)
467
-    static void G38(const int8_t subcode);
468
-  #endif
454
+  TERN_(G38_PROBE_TARGET, static void G38(const int8_t subcode));
469 455
 
470
-  #if HAS_MESH
471
-    static void G42();
472
-  #endif
456
+  TERN_(HAS_MESH, static void G42());
473 457
 
474 458
   #if ENABLED(CNC_COORDINATE_SYSTEMS)
475 459
     static void G53();
@@ -481,28 +465,20 @@ private:
481 465
     static void G59();
482 466
   #endif
483 467
 
484
-  #if ENABLED(PROBE_TEMP_COMPENSATION)
485
-    static void G76();
486
-  #endif
468
+  TERN_(PROBE_TEMP_COMPENSATION, static void G76());
487 469
 
488 470
   #if SAVED_POSITIONS
489 471
     static void G60();
490 472
     static void G61();
491 473
   #endif
492 474
 
493
-  #if ENABLED(GCODE_MOTION_MODES)
494
-    static void G80();
495
-  #endif
475
+  TERN_(GCODE_MOTION_MODES, static void G80());
496 476
 
497 477
   static void G92();
498 478
 
499
-  #if ENABLED(CALIBRATION_GCODE)
500
-    static void G425();
501
-  #endif
479
+  TERN_(CALIBRATION_GCODE, static void G425());
502 480
 
503
-  #if HAS_RESUME_CONTINUE
504
-    static void M0_M1();
505
-  #endif
481
+  TERN_(HAS_RESUME_CONTINUE, static void M0_M1());
506 482
 
507 483
   #if HAS_CUTTER
508 484
     static void M3_M4(const bool is_M4);
@@ -510,22 +486,14 @@ private:
510 486
   #endif
511 487
 
512 488
   #if ENABLED(COOLANT_CONTROL)
513
-    #if ENABLED(COOLANT_MIST)
514
-      static void M7();
515
-    #endif
516
-    #if ENABLED(COOLANT_FLOOD)
517
-      static void M8();
518
-    #endif
489
+    TERN_(COOLANT_MIST, static void M7());
490
+    TERN_(COOLANT_FLOOD, static void M8());
519 491
     static void M9();
520 492
   #endif
521 493
 
522
-  #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
523
-    static void M12();
524
-  #endif
494
+  TERN_(EXTERNAL_CLOSED_LOOP_CONTROLLER, static void M12());
525 495
 
526
-  #if ENABLED(EXPECTED_PRINTER_CHECK)
527
-    static void M16();
528
-  #endif
496
+  TERN_(EXPECTED_PRINTER_CHECK, static void M16());
529 497
 
530 498
   static void M17();
531 499
 
@@ -549,9 +517,7 @@ private:
549 517
 
550 518
   #if ENABLED(SDSUPPORT)
551 519
     static void M32();
552
-    #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
553
-      static void M33();
554
-    #endif
520
+    TERN_(LONG_FILENAME_HOST_SUPPORT, static void M33());
555 521
     #if BOTH(SDCARD_SORT_ALPHA, SDSORT_GCODE)
556 522
       static void M34();
557 523
     #endif
@@ -559,29 +525,19 @@ private:
559 525
 
560 526
   static void M42();
561 527
 
562
-  #if ENABLED(PINS_DEBUGGING)
563
-    static void M43();
564
-  #endif
528
+  TERN_(PINS_DEBUGGING, static void M43());
565 529
 
566
-  #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
567
-    static void M48();
568
-  #endif
530
+  TERN_(Z_MIN_PROBE_REPEATABILITY_TEST, static void M48());
569 531
 
570
-  #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
571
-    static void M73();
572
-  #endif
532
+  TERN_(LCD_SET_PROGRESS_MANUALLY, static void M73());
573 533
 
574 534
   static void M75();
575 535
   static void M76();
576 536
   static void M77();
577 537
 
578
-  #if ENABLED(PRINTCOUNTER)
579
-    static void M78();
580
-  #endif
538
+  TERN_(PRINTCOUNTER, static void M78());
581 539
 
582
-  #if ENABLED(PSU_CONTROL)
583
-    static void M80();
584
-  #endif
540
+  TERN_(PSU_CONTROL, static void M80());
585 541
 
586 542
   static void M81();
587 543
   static void M82();
@@ -589,9 +545,7 @@ private:
589 545
   static void M85();
590 546
   static void M92();
591 547
 
592
-  #if ENABLED(M100_FREE_MEMORY_WATCHER)
593
-    static void M100();
594
-  #endif
548
+  TERN_(M100_FREE_MEMORY_WATCHER, static void M100());
595 549
 
596 550
   #if EXTRUDERS
597 551
     static void M104();
@@ -609,17 +563,13 @@ private:
609 563
     static void M108();
610 564
     static void M112();
611 565
     static void M410();
612
-    #if ENABLED(HOST_PROMPT_SUPPORT)
613
-      static void M876();
614
-    #endif
566
+    TERN_(HOST_PROMPT_SUPPORT, static void M876());
615 567
   #endif
616 568
 
617 569
   static void M110();
618 570
   static void M111();
619 571
 
620
-  #if ENABLED(HOST_KEEPALIVE_FEATURE)
621
-    static void M113();
622
-  #endif
572
+  TERN_(HOST_KEEPALIVE_FEATURE, static void M113());
623 573
 
624 574
   static void M114();
625 575
   static void M115();
@@ -629,9 +579,7 @@ private:
629 579
   static void M120();
630 580
   static void M121();
631 581
 
632
-  #if ENABLED(PARK_HEAD_ON_PAUSE)
633
-    static void M125();
634
-  #endif
582
+  TERN_(PARK_HEAD_ON_PAUSE, static void M125());
635 583
 
636 584
   #if ENABLED(BARICUDA)
637 585
     #if HAS_HEATER_1
@@ -658,13 +606,9 @@ private:
658 606
     static void M145();
659 607
   #endif
660 608
 
661
-  #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
662
-    static void M149();
663
-  #endif
609
+  TERN_(TEMPERATURE_UNITS_SUPPORT, static void M149());
664 610
 
665
-  #if HAS_COLOR_LEDS
666
-    static void M150();
667
-  #endif
611
+  TERN_(HAS_COLOR_LEDS, static void M150());
668 612
 
669 613
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && HAS_TEMP_SENSOR
670 614
     static void M155();
@@ -673,12 +617,8 @@ private:
673 617
   #if ENABLED(MIXING_EXTRUDER)
674 618
     static void M163();
675 619
     static void M164();
676
-    #if ENABLED(DIRECT_MIXING_IN_G1)
677
-      static void M165();
678
-    #endif
679
-    #if ENABLED(GRADIENT_MIX)
680
-      static void M166();
681
-    #endif
620
+    TERN_(DIRECT_MIXING_IN_G1, static void M165());
621
+    TERN_(GRADIENT_MIX, static void M166());
682 622
   #endif
683 623
 
684 624
   static void M200();
@@ -692,16 +632,12 @@ private:
692 632
   static void M204();
693 633
   static void M205();
694 634
 
695
-  #if HAS_M206_COMMAND
696
-    static void M206();
697
-  #endif
635
+  TERN_(HAS_M206_COMMAND, static void M206());
698 636
 
699 637
   #if ENABLED(FWRETRACT)
700 638
     static void M207();
701 639
     static void M208();
702
-    #if ENABLED(FWRETRACT_AUTORETRACT)
703
-      static void M209();
704
-    #endif
640
+    TERN_(FWRETRACT_AUTORETRACT, static void M209());
705 641
   #endif
706 642
 
707 643
   static void M211();
@@ -710,9 +646,7 @@ private:
710 646
     static void M217();
711 647
   #endif
712 648
 
713
-  #if HAS_HOTEND_OFFSET
714
-    static void M218();
715
-  #endif
649
+  TERN_(HAS_HOTEND_OFFSET, static void M218());
716 650
 
717 651
   static void M220();
718 652
 
@@ -722,13 +656,9 @@ private:
722 656
 
723 657
   static void M226();
724 658
 
725
-  #if ENABLED(PHOTO_GCODE)
726
-    static void M240();
727
-  #endif
659
+  TERN_(PHOTO_GCODE, static void M240());
728 660
 
729
-  #if HAS_LCD_CONTRAST
730
-    static void M250();
731
-  #endif
661
+  TERN_(HAS_LCD_CONTRAST, static void M250());
732 662
 
733 663
   #if ENABLED(EXPERIMENTAL_I2CBUS)
734 664
     static void M260();
@@ -737,47 +667,29 @@ private:
737 667
 
738 668
   #if HAS_SERVOS
739 669
     static void M280();
740
-    #if ENABLED(EDITABLE_SERVO_ANGLES)
741
-      static void M281();
742
-    #endif
670
+    TERN_(EDITABLE_SERVO_ANGLES, static void M281());
743 671
   #endif
744 672
 
745
-  #if ENABLED(BABYSTEPPING)
746
-    static void M290();
747
-  #endif
673
+  TERN_(BABYSTEPPING, static void M290());
748 674
 
749
-  #if HAS_BUZZER
750
-    static void M300();
751
-  #endif
675
+  TERN_(HAS_BUZZER, static void M300());
752 676
 
753
-  #if ENABLED(PIDTEMP)
754
-    static void M301();
755
-  #endif
677
+  TERN_(PIDTEMP, static void M301());
756 678
 
757
-  #if ENABLED(PREVENT_COLD_EXTRUSION)
758
-    static void M302();
759
-  #endif
679
+  TERN_(PREVENT_COLD_EXTRUSION, static void M302());
760 680
 
761
-  #if HAS_PID_HEATING
762
-    static void M303();
763
-  #endif
681
+  TERN_(HAS_PID_HEATING, static void M303());
764 682
 
765
-  #if ENABLED(PIDTEMPBED)
766
-    static void M304();
767
-  #endif
683
+  TERN_(PIDTEMPBED, static void M304());
768 684
 
769
-  #if HAS_USER_THERMISTORS
770
-    static void M305();
771
-  #endif
685
+  TERN_(HAS_USER_THERMISTORS, static void M305());
772 686
 
773 687
   #if HAS_MICROSTEPS
774 688
     static void M350();
775 689
     static void M351();
776 690
   #endif
777 691
 
778
-  #if HAS_CASE_LIGHT
779
-    static void M355();
780
-  #endif
692
+  TERN_(HAS_CASE_LIGHT, static void M355());
781 693
 
782 694
   #if ENABLED(MORGAN_SCARA)
783 695
     static bool M360();
@@ -799,9 +711,7 @@ private:
799 711
     static void M402();
800 712
   #endif
801 713
 
802
-  #if ENABLED(PRUSA_MMU2)
803
-    static void M403();
804
-  #endif
714
+  TERN_(PRUSA_MMU2, static void M403());
805 715
 
806 716
   #if ENABLED(FILAMENT_WIDTH_SENSOR)
807 717
     static void M404();
@@ -810,26 +720,18 @@ private:
810 720
     static void M407();
811 721
   #endif
812 722
 
813
-  #if HAS_FILAMENT_SENSOR
814
-    static void M412();
815
-  #endif
723
+  TERN_(HAS_FILAMENT_SENSOR, static void M412());
816 724
 
817 725
   #if HAS_LEVELING
818 726
     static void M420();
819 727
     static void M421();
820 728
   #endif
821 729
 
822
-  #if ENABLED(BACKLASH_GCODE)
823
-    static void M425();
824
-  #endif
730
+  TERN_(BACKLASH_GCODE, static void M425());
825 731
 
826
-  #if HAS_M206_COMMAND
827
-    static void M428();
828
-  #endif
732
+  TERN_(HAS_M206_COMMAND, static void M428());
829 733
 
830
-  #if ENABLED(CANCEL_OBJECTS)
831
-    static void M486();
832
-  #endif
734
+  TERN_(CANCEL_OBJECTS, static void M486());
833 735
 
834 736
   static void M500();
835 737
   static void M501();
@@ -837,34 +739,22 @@ private:
837 739
   #if DISABLED(DISABLE_M503)
838 740
     static void M503();
839 741
   #endif
840
-  #if ENABLED(EEPROM_SETTINGS)
841
-    static void M504();
842
-  #endif
742
+  TERN_(EEPROM_SETTINGS, static void M504());
843 743
 
844
-  #if ENABLED(SDSUPPORT)
845
-    static void M524();
846
-  #endif
744
+  TERN_(SDSUPPORT, static void M524());
847 745
 
848
-  #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT)
849
-    static void M540();
850
-  #endif
746
+  TERN_(SD_ABORT_ON_ENDSTOP_HIT, static void M540());
851 747
 
852
-  #if ENABLED(BAUD_RATE_GCODE)
853
-    static void M575();
854
-  #endif
748
+  TERN_(BAUD_RATE_GCODE, static void M575());
855 749
 
856 750
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
857 751
     static void M600();
858 752
     static void M603();
859 753
   #endif
860 754
 
861
-  #if HAS_DUPLICATION_MODE
862
-    static void M605();
863
-  #endif
755
+  TERN_(HAS_DUPLICATION_MODE, static void M605());
864 756
 
865
-  #if IS_KINEMATIC
866
-    static void M665();
867
-  #endif
757
+  TERN_(IS_KINEMATIC, static void M665());
868 758
 
869 759
   #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS
870 760
     static void M666();
@@ -879,17 +769,11 @@ private:
879 769
     static void M702();
880 770
   #endif
881 771
 
882
-  #if ENABLED(GCODE_MACROS)
883
-    static void M810_819();
884
-  #endif
772
+  TERN_(GCODE_MACROS, static void M810_819());
885 773
 
886
-  #if HAS_BED_PROBE
887
-    static void M851();
888
-  #endif
774
+  TERN_(HAS_BED_PROBE, static void M851());
889 775
 
890
-  #if ENABLED(SKEW_CORRECTION_GCODE)
891
-    static void M852();
892
-  #endif
776
+  TERN_(SKEW_CORRECTION_GCODE, static void M852());
893 777
 
894 778
   #if ENABLED(I2C_POSITION_ENCODERS)
895 779
     FORCE_INLINE static void M860() { I2CPEM.M860(); }
@@ -904,30 +788,20 @@ private:
904 788
     FORCE_INLINE static void M869() { I2CPEM.M869(); }
905 789
   #endif
906 790
 
907
-  #if ENABLED(PROBE_TEMP_COMPENSATION)
908
-    static void M871();
909
-  #endif
791
+  TERN_(PROBE_TEMP_COMPENSATION, static void M871());
910 792
 
911
-  #if ENABLED(LIN_ADVANCE)
912
-    static void M900();
913
-  #endif
793
+  TERN_(LIN_ADVANCE, static void M900());
914 794
 
915 795
   #if HAS_TRINAMIC_CONFIG
916 796
     static void M122();
917 797
     static void M906();
918
-    #if HAS_STEALTHCHOP
919
-      static void M569();
920
-    #endif
798
+    TERN_(HAS_STEALTHCHOP, static void M569());
921 799
     #if ENABLED(MONITOR_DRIVER_STATUS)
922 800
       static void M911();
923 801
       static void M912();
924 802
     #endif
925
-    #if ENABLED(HYBRID_THRESHOLD)
926
-      static void M913();
927
-    #endif
928
-    #if USE_SENSORLESS
929
-      static void M914();
930
-    #endif
803
+    TERN_(HYBRID_THRESHOLD, static void M913());
804
+    TERN_(USE_SENSORLESS, static void M914());
931 805
   #endif
932 806
 
933 807
   #if HAS_L64XX
@@ -949,17 +823,11 @@ private:
949 823
     #endif
950 824
   #endif
951 825
 
952
-  #if ENABLED(SDSUPPORT)
953
-    static void M928();
954
-  #endif
826
+  TERN_(SDSUPPORT, static void M928());
955 827
 
956
-  #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
957
-    static void M951();
958
-  #endif
828
+  TERN_(MAGNETIC_PARKING_EXTRUDER, static void M951());
959 829
 
960
-  #if ENABLED(PLATFORM_M997_SUPPORT)
961
-    static void M997();
962
-  #endif
830
+  TERN_(PLATFORM_M997_SUPPORT, static void M997());
963 831
 
964 832
   static void M999();
965 833
 
@@ -968,17 +836,11 @@ private:
968 836
     static void M1000();
969 837
   #endif
970 838
 
971
-  #if ENABLED(SDSUPPORT)
972
-    static void M1001();
973
-  #endif
839
+  TERN_(SDSUPPORT, static void M1001());
974 840
 
975
-  #if ENABLED(MAX7219_GCODE)
976
-    static void M7219();
977
-  #endif
841
+  TERN_(MAX7219_GCODE, static void M7219());
978 842
 
979
-  #if ENABLED(CONTROLLER_FAN_EDITABLE)
980
-    static void M710();
981
-  #endif
843
+  TERN_(CONTROLLER_FAN_EDITABLE, static void M710());
982 844
 
983 845
   static void T(const uint8_t tool_index);
984 846
 

+ 1
- 3
Marlin/src/gcode/host/M114.cpp Wyświetl plik

@@ -213,8 +213,6 @@ void GcodeSuite::M114() {
213 213
     if (parser.seen('R')) { report_real_position(); return; }
214 214
   #endif
215 215
 
216
-  #if ENABLED(M114_LEGACY)
217
-    planner.synchronize();
218
-  #endif
216
+  TERN_(M114_LEGACY, planner.synchronize());
219 217
   report_current_position_projected();
220 218
 }

+ 3
- 7
Marlin/src/gcode/host/M115.cpp Wyświetl plik

@@ -44,14 +44,10 @@ void GcodeSuite::M115() {
44 44
   #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
45 45
 
46 46
     // PAREN_COMMENTS
47
-    #if ENABLED(PAREN_COMMENTS)
48
-      cap_line(PSTR("PAREN_COMMENTS"), true);
49
-    #endif
47
+    TERN_(PAREN_COMMENTS, cap_line(PSTR("PAREN_COMMENTS"), true));
50 48
 
51 49
     // QUOTED_STRINGS
52
-    #if ENABLED(GCODE_QUOTED_STRINGS)
53
-      cap_line(PSTR("QUOTED_STRINGS"), true);
54
-    #endif
50
+    TERN_(GCODE_QUOTED_STRINGS, cap_line(PSTR("QUOTED_STRINGS"), true));
55 51
 
56 52
     // SERIAL_XON_XOFF
57 53
     cap_line(PSTR("SERIAL_XON_XOFF"), ENABLED(SERIAL_XON_XOFF));
@@ -92,7 +88,7 @@ void GcodeSuite::M115() {
92 88
     // CASE LIGHTS (M355)
93 89
     cap_line(PSTR("TOGGLE_LIGHTS"), ENABLED(HAS_CASE_LIGHT));
94 90
 
95
-    cap_line(PSTR("CASE_LIGHT_BRIGHTNESS"), TERN(HAS_CASE_LIGHT, PWM_PIN(CASE_LIGHT_PIN), 0));
91
+    cap_line(PSTR("CASE_LIGHT_BRIGHTNESS"), TERN0(HAS_CASE_LIGHT, PWM_PIN(CASE_LIGHT_PIN)));
96 92
 
97 93
     // EMERGENCY_PARSER (M108, M112, M410, M876)
98 94
     cap_line(PSTR("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER));

+ 2
- 6
Marlin/src/gcode/lcd/M0_M1.cpp Wyświetl plik

@@ -77,15 +77,11 @@ void GcodeSuite::M0_M1() {
77 77
 
78 78
   #endif
79 79
 
80
-  #if ENABLED(HOST_PROMPT_SUPPORT)
81
-    host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR);
82
-  #endif
80
+  TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR));
83 81
 
84 82
   wait_for_user_response(ms);
85 83
 
86
-  #if HAS_LCD_MENU
87
-    ui.reset_status();
88
-  #endif
84
+  TERN_(HAS_LCD_MENU, ui.reset_status());
89 85
 }
90 86
 
91 87
 #endif // HAS_RESUME_CONTINUE

+ 7
- 16
Marlin/src/gcode/motion/G2_G3.cpp Wyświetl plik

@@ -70,14 +70,12 @@ void plan_arc(
70 70
   ab_float_t rvec = -offset;
71 71
 
72 72
   const float radius = HYPOT(rvec.a, rvec.b),
73
-              #if ENABLED(AUTO_BED_LEVELING_UBL)
74
-                start_L  = current_position[l_axis],
75
-              #endif
76 73
               center_P = current_position[p_axis] - rvec.a,
77 74
               center_Q = current_position[q_axis] - rvec.b,
78 75
               rt_X = cart[p_axis] - center_P,
79 76
               rt_Y = cart[q_axis] - center_Q,
80
-              linear_travel = cart[l_axis] - current_position[l_axis],
77
+              start_L = current_position[l_axis],
78
+              linear_travel = cart[l_axis] - start_L,
81 79
               extruder_travel = cart.e - current_position.e;
82 80
 
83 81
   // CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required.
@@ -157,7 +155,6 @@ void plan_arc(
157 155
   // Initialize the extruder axis
158 156
   raw.e = current_position.e;
159 157
 
160
-
161 158
   #if ENABLED(SCARA_FEEDRATE_SCALING)
162 159
     const float inv_duration = scaled_fr_mm_s / seg_length;
163 160
   #endif
@@ -220,15 +217,12 @@ void plan_arc(
220 217
       #if ENABLED(SCARA_FEEDRATE_SCALING)
221 218
         , inv_duration
222 219
       #endif
223
-    ))
224
-      break;
220
+    )) break;
225 221
   }
226 222
 
227 223
   // Ensure last segment arrives at target location.
228 224
   raw = cart;
229
-  #if ENABLED(AUTO_BED_LEVELING_UBL)
230
-    raw[l_axis] = start_L;
231
-  #endif
225
+  TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L);
232 226
 
233 227
   apply_motion_limits(raw);
234 228
 
@@ -242,10 +236,9 @@ void plan_arc(
242 236
     #endif
243 237
   );
244 238
 
245
-  #if ENABLED(AUTO_BED_LEVELING_UBL)
246
-    raw[l_axis] = start_L;
247
-  #endif
239
+  TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L);
248 240
   current_position = raw;
241
+
249 242
 } // plan_arc
250 243
 
251 244
 /**
@@ -285,9 +278,7 @@ void GcodeSuite::G2_G3(const bool clockwise) {
285 278
 
286 279
     get_destination_from_command();   // Get X Y Z E F (and set cutter power)
287 280
 
288
-    #if ENABLED(SF_ARC_FIX)
289
-      relative_mode = relative_mode_backup;
290
-    #endif
281
+    TERN_(SF_ARC_FIX, relative_mode = relative_mode_backup);
291 282
 
292 283
     ab_float_t arc_offset = { 0, 0 };
293 284
     if (parser.seenval('R')) {

+ 8
- 21
Marlin/src/gcode/parser.cpp Wyświetl plik

@@ -83,9 +83,7 @@ void GCodeParser::reset() {
83 83
   string_arg = nullptr;                 // No whole line argument
84 84
   command_letter = '?';                 // No command letter
85 85
   codenum = 0;                          // No command code
86
-  #if ENABLED(USE_GCODE_SUBCODES)
87
-    subcode = 0;                        // No command sub-code
88
-  #endif
86
+  TERN_(USE_GCODE_SUBCODES, subcode = 0); // No command sub-code
89 87
   #if ENABLED(FASTER_GCODE_PARSER)
90 88
     codebits = 0;                       // No codes yet
91 89
     //ZERO(param);                      // No parameters (should be safe to comment out this line)
@@ -119,9 +117,8 @@ void GCodeParser::parse(char *p) {
119 117
   reset(); // No codes to report
120 118
 
121 119
   auto uppercase = [](char c) {
122
-    #if ENABLED(GCODE_CASE_INSENSITIVE)
123
-      if (WITHIN(c, 'a', 'z')) c += 'A' - 'a';
124
-    #endif
120
+    if (TERN0(GCODE_CASE_INSENSITIVE, WITHIN(c, 'a', 'z')))
121
+      c += 'A' - 'a';
125 122
     return c;
126 123
   };
127 124
 
@@ -130,9 +127,7 @@ void GCodeParser::parse(char *p) {
130 127
 
131 128
   // Skip N[-0-9] if included in the command line
132 129
   if (uppercase(*p) == 'N' && NUMERIC_SIGNED(p[1])) {
133
-    #if ENABLED(FASTER_GCODE_PARSER)
134
-      //set('N', p + 1);     // (optional) Set the 'N' parameter value
135
-    #endif
130
+    //TERN_(FASTER_GCODE_PARSER, set('N', p + 1)); // (optional) Set the 'N' parameter value
136 131
     p += 2;                  // skip N[-0-9]
137 132
     while (NUMERIC(*p)) ++p; // skip [0-9]*
138 133
     while (*p == ' ')   ++p; // skip [ ]*
@@ -213,9 +208,7 @@ void GCodeParser::parse(char *p) {
213 208
                              )
214 209
         ) {
215 210
           motion_mode_codenum = codenum;
216
-          #if ENABLED(USE_GCODE_SUBCODES)
217
-            motion_mode_subcode = subcode;
218
-          #endif
211
+          TERN_(USE_GCODE_SUBCODES, motion_mode_subcode = subcode);
219 212
         }
220 213
       #endif
221 214
 
@@ -232,9 +225,7 @@ void GCodeParser::parse(char *p) {
232 225
         if (motion_mode_codenum < 0) return;
233 226
         command_letter = 'G';
234 227
         codenum = motion_mode_codenum;
235
-        #if ENABLED(USE_GCODE_SUBCODES)
236
-          subcode = motion_mode_subcode;
237
-        #endif
228
+        TERN_(USE_GCODE_SUBCODES, subcode = motion_mode_subcode);
238 229
         p--; // Back up one character to use the current parameter
239 230
       break;
240 231
     #endif // GCODE_MOTION_MODES
@@ -331,13 +322,9 @@ void GCodeParser::parse(char *p) {
331 322
         #endif
332 323
       }
333 324
 
334
-      #if ENABLED(DEBUG_GCODE_PARSER)
335
-        if (debug) SERIAL_EOL();
336
-      #endif
325
+      if (TERN0(DEBUG_GCODE_PARSER, debug)) SERIAL_EOL();
337 326
 
338
-      #if ENABLED(FASTER_GCODE_PARSER)
339
-        set(param, valptr);                     // Set parameter exists and pointer (nullptr for no value)
340
-      #endif
327
+      TERN_(FASTER_GCODE_PARSER, set(param, valptr)); // Set parameter exists and pointer (nullptr for no value)
341 328
     }
342 329
     else if (!string_arg) {                     // Not A-Z? First time, keep as the string_arg
343 330
       string_arg = p - 1;

+ 1
- 3
Marlin/src/gcode/probe/G30.cpp Wyświetl plik

@@ -46,9 +46,7 @@ void GcodeSuite::G30() {
46 46
   if (!probe.can_reach(pos)) return;
47 47
 
48 48
   // Disable leveling so the planner won't mess with us
49
-  #if HAS_LEVELING
50
-    set_bed_leveling_enabled(false);
51
-  #endif
49
+  TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
52 50
 
53 51
   remember_feedrate_scaling_off();
54 52
 

+ 2
- 6
Marlin/src/gcode/probe/M951.cpp Wyświetl plik

@@ -46,9 +46,7 @@ void mpe_settings_init() {
46 46
   mpe_settings.parking_xpos[0]      = pex[0];                         // M951 L
47 47
   mpe_settings.parking_xpos[1]      = pex[1];                         // M951 R
48 48
   mpe_settings.grab_distance        = PARKING_EXTRUDER_GRAB_DISTANCE; // M951 I
49
-  #if HAS_HOME_OFFSET
50
-    set_home_offset(X_AXIS, mpe_settings.grab_distance * -1);
51
-  #endif
49
+  TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, mpe_settings.grab_distance * -1));
52 50
   mpe_settings.slow_feedrate        = MMM_TO_MMS(MPE_SLOW_SPEED);     // M951 J
53 51
   mpe_settings.fast_feedrate        = MMM_TO_MMS(MPE_FAST_SPEED);     // M951 H
54 52
   mpe_settings.travel_distance      = MPE_TRAVEL_DISTANCE;            // M951 D
@@ -61,9 +59,7 @@ void GcodeSuite::M951() {
61 59
   if (parser.seenval('R')) mpe_settings.parking_xpos[1] = parser.value_linear_units();
62 60
   if (parser.seenval('I')) {
63 61
     mpe_settings.grab_distance = parser.value_linear_units();
64
-    #if HAS_HOME_OFFSET
65
-      set_home_offset(X_AXIS, mpe_settings.grab_distance * -1);
66
-    #endif
62
+    TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, mpe_settings.grab_distance * -1));
67 63
   }
68 64
   if (parser.seenval('J')) mpe_settings.slow_feedrate       = MMM_TO_MMS(parser.value_linear_units());
69 65
   if (parser.seenval('H')) mpe_settings.fast_feedrate       = MMM_TO_MMS(parser.value_linear_units());

+ 3
- 9
Marlin/src/gcode/queue.cpp Wyświetl plik

@@ -127,9 +127,7 @@ void GCodeQueue::_commit_command(bool say_ok
127 127
   #if NUM_SERIAL > 1
128 128
     port[index_w] = p;
129 129
   #endif
130
-  #if ENABLED(POWER_LOSS_RECOVERY)
131
-    recovery.commit_sdpos(index_w);
132
-  #endif
130
+  TERN_(POWER_LOSS_RECOVERY, recovery.commit_sdpos(index_w));
133 131
   if (++index_w >= BUFSIZE) index_w = 0;
134 132
   length++;
135 133
 }
@@ -522,9 +520,7 @@ void GCodeQueue::get_serial_commands() {
522 520
           // Process critical commands early
523 521
           if (strcmp(command, "M108") == 0) {
524 522
             wait_for_heatup = false;
525
-            #if HAS_LCD_MENU
526
-              wait_for_user = false;
527
-            #endif
523
+            TERN_(HAS_LCD_MENU, wait_for_user = false);
528 524
           }
529 525
           if (strcmp(command, "M112") == 0) kill(M112_KILL_STR, nullptr, true);
530 526
           if (strcmp(command, "M410") == 0) quickstop_stepper();
@@ -601,9 +597,7 @@ void GCodeQueue::get_available_commands() {
601 597
 
602 598
   get_serial_commands();
603 599
 
604
-  #if ENABLED(SDSUPPORT)
605
-    get_sdcard_commands();
606
-  #endif
600
+  TERN_(SDSUPPORT, get_sdcard_commands());
607 601
 }
608 602
 
609 603
 /**

+ 5
- 15
Marlin/src/gcode/sd/M1001.cpp Wyświetl plik

@@ -72,14 +72,10 @@ void GcodeSuite::M1001() {
72 72
   gcode.process_subcommands_now_P(PSTR("M77"));
73 73
 
74 74
   // Set the progress bar "done" state
75
-  #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
76
-    ui.set_progress_done();
77
-  #endif
75
+  TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done());
78 76
 
79 77
   // Purge the recovery file
80
-  #if ENABLED(POWER_LOSS_RECOVERY)
81
-    recovery.purge();
82
-  #endif
78
+  TERN_(POWER_LOSS_RECOVERY, recovery.purge());
83 79
 
84 80
   // Announce SD file completion
85 81
   SERIAL_ECHOLNPGM(STR_FILE_PRINTED);
@@ -88,12 +84,8 @@ void GcodeSuite::M1001() {
88 84
   #if HAS_LEDS_OFF_FLAG
89 85
     if (long_print) {
90 86
       printerEventLEDs.onPrintCompleted();
91
-      #if ENABLED(EXTENSIBLE_UI)
92
-        ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PRINT_DONE));
93
-      #endif
94
-      #if ENABLED(HOST_PROMPT_SUPPORT)
95
-        host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_PRINT_DONE), CONTINUE_STR);
96
-      #endif
87
+      TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PRINT_DONE)));
88
+      TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_PRINT_DONE), CONTINUE_STR));
97 89
       wait_for_user_response(1000UL * TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30));
98 90
       printerEventLEDs.onResumeAfterWait();
99 91
     }
@@ -105,9 +97,7 @@ void GcodeSuite::M1001() {
105 97
   #endif
106 98
 
107 99
   // Re-select the last printed file in the UI
108
-  #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
109
-    ui.reselect_last_file();
110
-  #endif
100
+  TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file());
111 101
 }
112 102
 
113 103
 #endif // SDSUPPORT

+ 1
- 3
Marlin/src/gcode/sd/M23.cpp Wyświetl plik

@@ -38,9 +38,7 @@ void GcodeSuite::M23() {
38 38
   for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0';
39 39
   card.openFileRead(parser.string_arg);
40 40
 
41
-  #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
42
-    ui.set_progress(0);
43
-  #endif
41
+  TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0));
44 42
 }
45 43
 
46 44
 #endif // SDSUPPORT

+ 3
- 9
Marlin/src/gcode/sd/M24_M25.cpp Wyświetl plik

@@ -64,18 +64,14 @@ void GcodeSuite::M24() {
64 64
   if (card.isFileOpen()) {
65 65
     card.startFileprint();            // SD card will now be read for commands
66 66
     startOrResumeJob();               // Start (or resume) the print job timer
67
-    #if ENABLED(POWER_LOSS_RECOVERY)
68
-      recovery.prepare();
69
-    #endif
67
+    TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
70 68
   }
71 69
 
72 70
   #if ENABLED(HOST_ACTION_COMMANDS)
73 71
     #ifdef ACTION_ON_RESUME
74 72
       host_action_resume();
75 73
     #endif
76
-    #if ENABLED(HOST_PROMPT_SUPPORT)
77
-      host_prompt_open(PROMPT_INFO, PSTR("Resuming SD"), DISMISS_STR);
78
-    #endif
74
+    TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Resuming SD"), DISMISS_STR));
79 75
   #endif
80 76
 
81 77
   ui.reset_status();
@@ -105,9 +101,7 @@ void GcodeSuite::M25() {
105 101
     ui.reset_status();
106 102
 
107 103
     #if ENABLED(HOST_ACTION_COMMANDS)
108
-      #if ENABLED(HOST_PROMPT_SUPPORT)
109
-        host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("Pause SD"), PSTR("Resume"));
110
-      #endif
104
+      TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("Pause SD"), PSTR("Resume")));
111 105
       #ifdef ACTION_ON_PAUSE
112 106
         host_action_pause();
113 107
       #endif

+ 2
- 6
Marlin/src/gcode/temp/M104_M109.cpp Wyświetl plik

@@ -87,9 +87,7 @@ void GcodeSuite::M104() {
87 87
     #endif
88 88
   }
89 89
 
90
-  #if ENABLED(AUTOTEMP)
91
-    planner.autotemp_M104_M109();
92
-  #endif
90
+  TERN_(AUTOTEMP, planner.autotemp_M104_M109());
93 91
 }
94 92
 
95 93
 /**
@@ -139,9 +137,7 @@ void GcodeSuite::M109() {
139 137
     #endif
140 138
   }
141 139
 
142
-  #if ENABLED(AUTOTEMP)
143
-    planner.autotemp_M104_M109();
144
-  #endif
140
+  TERN_(AUTOTEMP, planner.autotemp_M104_M109());
145 141
 
146 142
   if (set_temp)
147 143
     (void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling);

+ 1
- 3
Marlin/src/gcode/temp/M140_M190.cpp Wyświetl plik

@@ -76,9 +76,7 @@ void GcodeSuite::M190() {
76 76
   const bool no_wait_for_cooling = parser.seenval('S');
77 77
   if (no_wait_for_cooling || parser.seenval('R')) {
78 78
     thermalManager.setTargetBed(parser.value_celsius());
79
-    #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
80
-      thermalManager.check_timer_autostart(true, false);
81
-    #endif
79
+    TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.check_timer_autostart(true, false));
82 80
   }
83 81
   else return;
84 82
 

+ 1
- 3
Marlin/src/gcode/temp/M141_M191.cpp Wyświetl plik

@@ -75,9 +75,7 @@ void GcodeSuite::M191() {
75 75
   const bool no_wait_for_cooling = parser.seenval('S');
76 76
   if (no_wait_for_cooling || parser.seenval('R')) {
77 77
     thermalManager.setTargetChamber(parser.value_celsius());
78
-    #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
79
-      thermalManager.check_timer_autostart(true, false);
80
-    #endif
78
+    TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.check_timer_autostart(true, false));
81 79
   }
82 80
   else return;
83 81
 

+ 1
- 3
Marlin/src/gcode/temp/M303.cpp Wyświetl plik

@@ -72,9 +72,7 @@ void GcodeSuite::M303() {
72 72
   const heater_ind_t e = (heater_ind_t)parser.intval('E');
73 73
   if (!WITHIN(e, SI, EI)) {
74 74
     SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM);
75
-    #if ENABLED(EXTENSIBLE_UI)
76
-      ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM);
77
-    #endif
75
+    TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
78 76
     return;
79 77
   }
80 78
 

+ 0
- 0
Marlin/src/inc/Conditionals_LCD.h Wyświetl plik


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików

Ładowanie…
Anuluj
Zapisz