Ver código fonte

More useful ENABLED / DISABLED macros (#17054)

Scott Lahteine 4 anos atrás
pai
commit
64d092935b
Nenhuma conta vinculada ao e-mail do autor do commit

+ 1
- 1
Marlin/Configuration_adv.h Ver arquivo

@@ -1047,7 +1047,7 @@
1047 1047
    */
1048 1048
   //#define POWER_LOSS_RECOVERY
1049 1049
   #if ENABLED(POWER_LOSS_RECOVERY)
1050
-    //#define PLR_ENABLED_DEFAULT  true // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
1050
+    #define PLR_ENABLED_DEFAULT   false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
1051 1051
     //#define BACKUP_POWER_SUPPLY       // Backup power / UPS to move the steppers on power loss
1052 1052
     //#define POWER_LOSS_ZRAISE       2 // (mm) Z axis raise on resume (on power loss with UPS)
1053 1053
     //#define POWER_LOSS_PIN         44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module.

+ 9
- 9
Marlin/src/HAL/HAL_AVR/MarlinSerial.h Ver arquivo

@@ -31,10 +31,10 @@
31 31
  * Templatized 01 October 2018 by Eduardo José Tagle to allow multiple instances
32 32
  */
33 33
 
34
-#include "../shared/MarlinSerial.h"
35
-
36 34
 #include <WString.h>
37 35
 
36
+#include "../../inc/MarlinConfigPre.h"
37
+
38 38
 #ifndef SERIAL_PORT
39 39
   #define SERIAL_PORT 0
40 40
 #endif
@@ -261,12 +261,12 @@
261 261
     static constexpr int PORT               = serial;
262 262
     static constexpr unsigned int RX_SIZE   = RX_BUFFER_SIZE;
263 263
     static constexpr unsigned int TX_SIZE   = TX_BUFFER_SIZE;
264
-    static constexpr bool XONOFF            = bSERIAL_XON_XOFF;
265
-    static constexpr bool EMERGENCYPARSER   = bEMERGENCY_PARSER;
266
-    static constexpr bool DROPPED_RX        = bSERIAL_STATS_DROPPED_RX;
267
-    static constexpr bool RX_OVERRUNS       = bSERIAL_STATS_RX_BUFFER_OVERRUNS;
268
-    static constexpr bool RX_FRAMING_ERRORS = bSERIAL_STATS_RX_FRAMING_ERRORS;
269
-    static constexpr bool MAX_RX_QUEUED     = bSERIAL_STATS_MAX_RX_QUEUED;
264
+    static constexpr bool XONOFF            = ENABLED(SERIAL_XON_XOFF);
265
+    static constexpr bool EMERGENCYPARSER   = ENABLED(EMERGENCY_PARSER);
266
+    static constexpr bool DROPPED_RX        = ENABLED(SERIAL_STATS_DROPPED_RX);
267
+    static constexpr bool RX_OVERRUNS       = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
268
+    static constexpr bool RX_FRAMING_ERRORS = ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS);
269
+    static constexpr bool MAX_RX_QUEUED     = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
270 270
   };
271 271
   extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
272 272
 
@@ -304,7 +304,7 @@
304 304
     static constexpr bool XONOFF            = false;
305 305
     static constexpr bool EMERGENCYPARSER   = false;
306 306
     static constexpr bool DROPPED_RX        = false;
307
-    static constexpr bool RX_OVERRUNS       = bDGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS;
307
+    static constexpr bool RX_OVERRUNS       = HAS_DGUS_LCD && ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS);
308 308
     static constexpr bool RX_FRAMING_ERRORS = false;
309 309
     static constexpr bool MAX_RX_QUEUED     = false;
310 310
   };

+ 8
- 8
Marlin/src/HAL/HAL_DUE/MarlinSerial.h Ver arquivo

@@ -27,10 +27,10 @@
27 27
  * Based on MarlinSerial for AVR, copyright (c) 2006 Nicholas Zambetti.  All right reserved.
28 28
  */
29 29
 
30
-#include "../shared/MarlinSerial.h"
31
-
32 30
 #include <WString.h>
33 31
 
32
+#include "../../inc/MarlinConfigPre.h"
33
+
34 34
 #define DEC 10
35 35
 #define HEX 16
36 36
 #define OCT 8
@@ -163,12 +163,12 @@ struct MarlinSerialCfg {
163 163
   static constexpr int PORT               = serial;
164 164
   static constexpr unsigned int RX_SIZE   = RX_BUFFER_SIZE;
165 165
   static constexpr unsigned int TX_SIZE   = TX_BUFFER_SIZE;
166
-  static constexpr bool XONOFF            = bSERIAL_XON_XOFF;
167
-  static constexpr bool EMERGENCYPARSER   = bEMERGENCY_PARSER;
168
-  static constexpr bool DROPPED_RX        = bSERIAL_STATS_DROPPED_RX;
169
-  static constexpr bool RX_OVERRUNS       = bSERIAL_STATS_RX_BUFFER_OVERRUNS;
170
-  static constexpr bool RX_FRAMING_ERRORS = bSERIAL_STATS_RX_FRAMING_ERRORS;
171
-  static constexpr bool MAX_RX_QUEUED     = bSERIAL_STATS_MAX_RX_QUEUED;
166
+  static constexpr bool XONOFF            = ENABLED(SERIAL_XON_XOFF);
167
+  static constexpr bool EMERGENCYPARSER   = ENABLED(EMERGENCY_PARSER);
168
+  static constexpr bool DROPPED_RX        = ENABLED(SERIAL_STATS_DROPPED_RX);
169
+  static constexpr bool RX_OVERRUNS       = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
170
+  static constexpr bool RX_FRAMING_ERRORS = ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS);
171
+  static constexpr bool MAX_RX_QUEUED     = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
172 172
 };
173 173
 
174 174
 #if SERIAL_PORT >= 0

+ 6
- 8
Marlin/src/HAL/HAL_LPC1768/inc/SanityCheck.h Ver arquivo

@@ -57,9 +57,7 @@
57 57
  * Because PWM hardware channels all share the same frequency, along with the
58 58
  * fallback software channels, FAST_PWM_FAN is incompatible with Servos.
59 59
  */
60
-#if NUM_SERVOS > 0 && ENABLED(FAST_PWM_FAN)
61
-  #error "BLTOUCH and Servos are incompatible with FAST_PWM_FAN on LPC176x boards."
62
-#endif
60
+static_assert(!(NUM_SERVOS && ENABLED(FAST_PWM_FAN)), "BLTOUCH and Servos are incompatible with FAST_PWM_FAN on LPC176x boards.");
63 61
 
64 62
 /**
65 63
  * Test LPC176x-specific configuration values for errors at compile-time.
@@ -69,13 +67,13 @@
69 67
 //  #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
70 68
 //#endif
71 69
 
72
-#if IS_RE_ARM_BOARD && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI)
73
-  #error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 require TMC_USE_SW_SPI"
70
+#if MB(RAMPS_14_RE_ARM_EFB, RAMPS_14_RE_ARM_EEB, RAMPS_14_RE_ARM_EFF, RAMPS_14_RE_ARM_EEF, RAMPS_14_RE_ARM_SF)
71
+  #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI)
72
+    #error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 requires TMC_USE_SW_SPI."
73
+  #endif
74 74
 #endif
75 75
 
76
-#if ENABLED(BAUD_RATE_GCODE)
77
-  #error "BAUD_RATE_GCODE is not yet supported on LPC176x."
78
-#endif
76
+static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported on LPC176x.");
79 77
 
80 78
 /**
81 79
  * Flag any serial port conflicts

+ 0
- 67
Marlin/src/HAL/shared/MarlinSerial.h Ver arquivo

@@ -1,67 +0,0 @@
1
-/**
2
- * Marlin 3D Printer Firmware
3
- * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
- *
5
- * Based on Sprinter and grbl.
6
- * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
- *
8
- * This program is free software: you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation, either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- */
22
-#pragma once
23
-
24
-/**
25
- * HAL/shared/MarlinSerial.h
26
- */
27
-
28
-#include "../../inc/MarlinConfigPre.h"
29
-
30
-constexpr bool
31
-  #if HAS_DGUS_LCD
32
-    bDGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS = (false
33
-      #if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS)
34
-        || true
35
-      #endif
36
-    ),
37
-  #endif
38
-  bSERIAL_XON_XOFF = (false
39
-    #if ENABLED(SERIAL_XON_XOFF)
40
-      || true
41
-    #endif
42
-  ),
43
-  bEMERGENCY_PARSER = (false
44
-    #if ENABLED(EMERGENCY_PARSER)
45
-      || true
46
-    #endif
47
-  ),
48
-  bSERIAL_STATS_DROPPED_RX = (false
49
-    #if ENABLED(SERIAL_STATS_DROPPED_RX)
50
-      || true
51
-    #endif
52
-  ),
53
-  bSERIAL_STATS_RX_BUFFER_OVERRUNS = (false
54
-    #if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS)
55
-      || true
56
-    #endif
57
-  ),
58
-  bSERIAL_STATS_RX_FRAMING_ERRORS = (false
59
-    #if ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS)
60
-      || true
61
-    #endif
62
-  ),
63
-  bSERIAL_STATS_MAX_RX_QUEUED = (false
64
-    #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
65
-      || true
66
-    #endif
67
-  );

+ 11
- 37
Marlin/src/MarlinCore.cpp Ver arquivo

@@ -241,11 +241,8 @@ void setup_powerhold() {
241 241
     OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING);
242 242
   #endif
243 243
   #if ENABLED(PSU_CONTROL)
244
-    #if ENABLED(PSU_DEFAULT_OFF)
245
-      powersupply_on = true;  PSU_OFF();
246
-    #else
247
-      powersupply_on = false; PSU_ON();
248
-    #endif
244
+    powersupply_on = ENABLED(PSU_DEFAULT_OFF);
245
+    if (ENABLED(PSU_DEFAULT_OFF)) PSU_OFF(); else PSU_ON();
249 246
   #endif
250 247
 }
251 248
 
@@ -425,14 +422,8 @@ void startOrResumeJob() {
425 422
     switch (card.sdprinting_done_state) {
426 423
 
427 424
       #if HAS_RESUME_CONTINUE                   // Display "Click to Continue..."
428
-        case 1:
429
-          did_state = queue.enqueue_P(PSTR("M0Q1S"
430
-            #if HAS_LCD_MENU
431
-              "1800"                            // ...for 30 minutes with LCD
432
-            #else
433
-              "60"                              // ...for 1 minute with no LCD
434
-            #endif
435
-          ));
425
+        case 1:                                 // 30 min timeout with LCD, 1 min without
426
+          did_state = queue.enqueue_P(PSTR("M0Q1S" TERN(HAS_LCD_MENU, "1800", "60")));
436 427
           break;
437 428
       #endif
438 429
 
@@ -501,31 +492,19 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
501 492
   }
502 493
 
503 494
   // Prevent steppers timing-out in the middle of M600
504
-  #if BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT)
505
-    #define MOVE_AWAY_TEST !did_pause_print
506
-  #else
507
-    #define MOVE_AWAY_TEST true
508
-  #endif
495
+  #define STAY_TEST (BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT) && did_pause_print)
509 496
 
510 497
   if (stepper_inactive_time) {
511 498
     static bool already_shutdown_steppers; // = false
512 499
     if (planner.has_blocks_queued())
513 500
       gcode.reset_stepper_timeout();
514
-    else if (MOVE_AWAY_TEST && !ignore_stepper_queue && ELAPSED(ms, gcode.previous_move_ms + stepper_inactive_time)) {
501
+    else if (!STAY_TEST && !ignore_stepper_queue && ELAPSED(ms, gcode.previous_move_ms + stepper_inactive_time)) {
515 502
       if (!already_shutdown_steppers) {
516 503
         already_shutdown_steppers = true;  // L6470 SPI will consume 99% of free time without this
517
-        #if ENABLED(DISABLE_INACTIVE_X)
518
-          DISABLE_AXIS_X();
519
-        #endif
520
-        #if ENABLED(DISABLE_INACTIVE_Y)
521
-          DISABLE_AXIS_Y();
522
-        #endif
523
-        #if ENABLED(DISABLE_INACTIVE_Z)
524
-          DISABLE_AXIS_Z();
525
-        #endif
526
-        #if ENABLED(DISABLE_INACTIVE_E)
527
-          disable_e_steppers();
528
-        #endif
504
+        if (ENABLED(DISABLE_INACTIVE_X)) DISABLE_AXIS_X();
505
+        if (ENABLED(DISABLE_INACTIVE_Y)) DISABLE_AXIS_Y();
506
+        if (ENABLED(DISABLE_INACTIVE_Z)) DISABLE_AXIS_Z();
507
+        if (ENABLED(DISABLE_INACTIVE_E)) disable_e_steppers();
529 508
         #if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL)
530 509
           if (ubl.lcd_map_control) {
531 510
             ubl.lcd_map_control = false;
@@ -1191,7 +1170,6 @@ void setup() {
1191 1170
  */
1192 1171
 void loop() {
1193 1172
   do {
1194
-
1195 1173
     idle();
1196 1174
 
1197 1175
     #if ENABLED(SDSUPPORT)
@@ -1204,9 +1182,5 @@ void loop() {
1204 1182
 
1205 1183
     endstops.event_handler();
1206 1184
 
1207
-  } while (false        // Return to caller for best compatibility
1208
-    #ifdef __AVR__
1209
-      || true           // Loop forever on slower (AVR) boards
1210
-    #endif
1211
-  );
1185
+  } while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
1212 1186
 }

+ 67
- 67
Marlin/src/core/drivers.h Ver arquivo

@@ -82,101 +82,97 @@
82 82
 #define _OR_ADTE(N,T)   || AXIS_DRIVER_TYPE_E(N,T)
83 83
 #define HAS_E_DRIVER(T) (0 RREPEAT2(E_STEPPERS, _OR_ADTE, T))
84 84
 
85
-#define HAS_DRIVER(T) (    AXIS_DRIVER_TYPE_X(T)  || AXIS_DRIVER_TYPE_X2(T) \
86
-                        || AXIS_DRIVER_TYPE_Y(T)  || AXIS_DRIVER_TYPE_Y2(T) \
87
-                        || AXIS_DRIVER_TYPE_Z(T)  || AXIS_DRIVER_TYPE_Z2(T) \
88
-                        || AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) \
89
-                        || HAS_E_DRIVER(T) )
85
+#define HAS_DRIVER(T) (  AXIS_DRIVER_TYPE_X(T)  || AXIS_DRIVER_TYPE_Y(T)  || AXIS_DRIVER_TYPE_Z(T)  \
86
+                      || AXIS_DRIVER_TYPE_X2(T) || AXIS_DRIVER_TYPE_Y2(T) || AXIS_DRIVER_TYPE_Z2(T) \
87
+                      || AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) || HAS_E_DRIVER(T) )
90 88
 
91 89
 // Test for supported TMC drivers that require advanced configuration
92 90
 // Does not match standalone configurations
93
-#define HAS_TRINAMIC_CONFIG (    HAS_DRIVER(TMC2130) \
94
-                              || HAS_DRIVER(TMC2160) \
95
-                              || HAS_DRIVER(TMC2208) \
96
-                              || HAS_DRIVER(TMC2209) \
97
-                              || HAS_DRIVER(TMC2660) \
98
-                              || HAS_DRIVER(TMC5130) \
99
-                              || HAS_DRIVER(TMC5160) )
91
+#if (    HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) \
92
+      || HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209) \
93
+      || HAS_DRIVER(TMC2660) \
94
+      || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) )
95
+  #define HAS_TRINAMIC_CONFIG 1
96
+#endif
100 97
 
101 98
 #define HAS_TRINAMIC HAS_TRINAMIC_CONFIG
102 99
 
103
-#define HAS_TRINAMIC_STANDALONE (    HAS_DRIVER(TMC2130_STANDALONE) \
104
-                                  || HAS_DRIVER(TMC2208_STANDALONE) \
105
-                                  || HAS_DRIVER(TMC2209_STANDALONE) \
106
-                                  || HAS_DRIVER(TMC26X_STANDALONE)  \
107
-                                  || HAS_DRIVER(TMC2660_STANDALONE) \
108
-                                  || HAS_DRIVER(TMC5130_STANDALONE) \
109
-                                  || HAS_DRIVER(TMC5160_STANDALONE) \
110
-                                  || HAS_DRIVER(TMC2160_STANDALONE) )
100
+#if (    HAS_DRIVER(TMC2130_STANDALONE) || HAS_DRIVER(TMC2160_STANDALONE) \
101
+      || HAS_DRIVER(TMC2208_STANDALONE) || HAS_DRIVER(TMC2209_STANDALONE) \
102
+      || HAS_DRIVER(TMC26X_STANDALONE)  || HAS_DRIVER(TMC2660_STANDALONE) \
103
+      || HAS_DRIVER(TMC5130_STANDALONE) || HAS_DRIVER(TMC5160_STANDALONE) )
104
+  #define HAS_TRINAMIC_STANDALONE 1
105
+#endif
111 106
 
112
-#define HAS_TMCX1X0 (    HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) \
113
-                      || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160))
107
+#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160)
108
+  #define HAS_TMCX1X0 1
109
+#endif
114 110
 
115
-#define HAS_TMC220x (HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209))
111
+#if HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209)
112
+  #define HAS_TMC220x 1
113
+#endif
116 114
 
117
-#define AXIS_IS_TMC(A)   (    AXIS_DRIVER_TYPE(A,TMC2130) \
118
-                           || AXIS_DRIVER_TYPE(A,TMC2160) \
119
-                           || AXIS_DRIVER_TYPE(A,TMC2208) \
120
-                           || AXIS_DRIVER_TYPE(A,TMC2209) \
115
+#define AXIS_IS_TMC(A)   (    AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
116
+                           || AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) \
121 117
                            || AXIS_DRIVER_TYPE(A,TMC2660) \
122
-                           || AXIS_DRIVER_TYPE(A,TMC5130) \
123
-                           || AXIS_DRIVER_TYPE(A,TMC5160) )
118
+                           || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
124 119
 
125 120
 // Test for a driver that uses SPI - this allows checking whether a _CS_ pin
126 121
 // is considered sensitive
127
-#define AXIS_HAS_SPI(A)  (    AXIS_DRIVER_TYPE(A,TMC2130) \
128
-                           || AXIS_DRIVER_TYPE(A,TMC2160) \
122
+#define AXIS_HAS_SPI(A)  (    AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
129 123
                            || AXIS_DRIVER_TYPE(A,TMC2660) \
130
-                           || AXIS_DRIVER_TYPE(A,TMC5130) \
131
-                           || AXIS_DRIVER_TYPE(A,TMC5160) )
124
+                           || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
132 125
 
133
-#define AXIS_HAS_UART(A) (    AXIS_DRIVER_TYPE(A,TMC2208) \
134
-                           || AXIS_DRIVER_TYPE(A,TMC2209) )
126
+#define AXIS_HAS_UART(A) ( AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) )
135 127
 
136 128
 #define AXIS_HAS_RXTX AXIS_HAS_UART
137 129
 
138
-#define AXIS_HAS_SW_SERIAL(A) ((AXIS_HAS_UART(A) && !defined(A##_HARDWARE_SERIAL)))
130
+#define AXIS_HAS_SW_SERIAL(A) ( AXIS_HAS_UART(A) && !defined(A##_HARDWARE_SERIAL) )
139 131
 
140
-#define AXIS_HAS_STALLGUARD(A)   (    AXIS_DRIVER_TYPE(A,TMC2130) \
141
-                                   || AXIS_DRIVER_TYPE(A,TMC2160) \
132
+#define AXIS_HAS_STALLGUARD(A)   (    AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
142 133
                                    || AXIS_DRIVER_TYPE(A,TMC2209) \
143 134
                                    || AXIS_DRIVER_TYPE(A,TMC2660) \
144
-                                   || AXIS_DRIVER_TYPE(A,TMC5130) \
145
-                                   || AXIS_DRIVER_TYPE(A,TMC5160) )
135
+                                   || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
146 136
 
147
-#define AXIS_HAS_STEALTHCHOP(A)  (    AXIS_DRIVER_TYPE(A,TMC2130) \
148
-                                   || AXIS_DRIVER_TYPE(A,TMC2160) \
149
-                                   || AXIS_DRIVER_TYPE(A,TMC2208) \
150
-                                   || AXIS_DRIVER_TYPE(A,TMC2209) \
151
-                                   || AXIS_DRIVER_TYPE(A,TMC5130) \
152
-                                   || AXIS_DRIVER_TYPE(A,TMC5160) )
137
+#define AXIS_HAS_STEALTHCHOP(A)  (    AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
138
+                                   || AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) \
139
+                                   || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
153 140
 
154
-#define AXIS_HAS_SG_RESULT(A)    (    AXIS_DRIVER_TYPE(A,TMC2130) \
155
-                                   || AXIS_DRIVER_TYPE(A,TMC2160) \
156
-                                   || AXIS_DRIVER_TYPE(A,TMC2208) \
157
-                                   || AXIS_DRIVER_TYPE(A,TMC2209) )
141
+#define AXIS_HAS_SG_RESULT(A)    (    AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
142
+                                   || AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) )
158 143
 
159 144
 #define AXIS_HAS_COOLSTEP(A)     (    AXIS_DRIVER_TYPE(A,TMC2130) \
160 145
                                    || AXIS_DRIVER_TYPE(A,TMC2209) \
161
-                                   || AXIS_DRIVER_TYPE(A,TMC5130) \
162
-                                   || AXIS_DRIVER_TYPE(A,TMC5160) )
146
+                                   || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
163 147
 
164 148
 #define _OR_EAH(N,T)    || AXIS_HAS_##T(E##N)
165 149
 #define E_AXIS_HAS(T)   (0 _OR_EAH(0,T) _OR_EAH(1,T) _OR_EAH(2,T) _OR_EAH(3,T) _OR_EAH(4,T) _OR_EAH(5,T) _OR_EAH(6,T) _OR_EAH(7,T))
166 150
 
167
-#define ANY_AXIS_HAS(T) (    AXIS_HAS_##T(X)  || AXIS_HAS_##T(X2) \
168
-                          || AXIS_HAS_##T(Y)  || AXIS_HAS_##T(Y2) \
169
-                          || AXIS_HAS_##T(Z)  || AXIS_HAS_##T(Z2) \
170
-                          || AXIS_HAS_##T(Z3) || AXIS_HAS_##T(Z4) \
171
-                          || E_AXIS_HAS(T) )
172
-
173
-#define HAS_STEALTHCHOP    ANY_AXIS_HAS(STEALTHCHOP)
174
-#define HAS_STALLGUARD     ANY_AXIS_HAS(STALLGUARD)
175
-#define HAS_SG_RESULT      ANY_AXIS_HAS(SG_RESULT)
176
-#define HAS_COOLSTEP       ANY_AXIS_HAS(COOLSTEP)
177
-#define HAS_TMC_UART       ANY_AXIS_HAS(RXTX)
178
-#define HAS_TMC_SPI        ANY_AXIS_HAS(SPI)
179
-#define HAS_TMC_SW_SERIAL  ANY_AXIS_HAS(SW_SERIAL)
151
+#define ANY_AXIS_HAS(T) (    AXIS_HAS_##T(X)  || AXIS_HAS_##T(Y)  || AXIS_HAS_##T(Z)  \
152
+                          || AXIS_HAS_##T(X2) || AXIS_HAS_##T(Y2) || AXIS_HAS_##T(Z2) \
153
+                          || AXIS_HAS_##T(Z3) || AXIS_HAS_##T(Z4) || E_AXIS_HAS(T) )
154
+
155
+#if ANY_AXIS_HAS(STEALTHCHOP)
156
+  #define HAS_STEALTHCHOP 1
157
+#endif
158
+#if ANY_AXIS_HAS(STALLGUARD)
159
+  #define HAS_STALLGUARD 1
160
+#endif
161
+#if ANY_AXIS_HAS(SG_RESULT)
162
+  #define HAS_SG_RESULT 1
163
+#endif
164
+#if ANY_AXIS_HAS(COOLSTEP)
165
+  #define HAS_COOLSTEP 1
166
+#endif
167
+#if ANY_AXIS_HAS(RXTX)
168
+  #define HAS_TMC_UART 1
169
+#endif
170
+#if ANY_AXIS_HAS(SPI)
171
+  #define HAS_TMC_SPI 1
172
+#endif
173
+
174
+// Defines that can't be evaluated now
175
+#define HAS_TMC_SW_SERIAL ANY_AXIS_HAS(SW_SERIAL)
180 176
 
181 177
 //
182 178
 // Stretching 'drivers.h' to include LPC/SAMD51 SD options
@@ -187,7 +183,11 @@
187 183
 #define _SDCARD_ID(V) _CAT(_SDCARD_, V)
188 184
 #define SD_CONNECTION_IS(V) (_SDCARD_ID(SDCARD_CONNECTION) == _SDCARD_ID(V))
189 185
 
190
-#define HAS_L64XX (HAS_DRIVER(L6470) || HAS_DRIVER(L6474) || HAS_DRIVER(L6480) || HAS_DRIVER(POWERSTEP01))
191
-#define HAS_L64XX_NOT_L6474 (HAS_L64XX && !HAS_DRIVER(L6474))
186
+#if HAS_DRIVER(L6470) || HAS_DRIVER(L6474) || HAS_DRIVER(L6480) || HAS_DRIVER(POWERSTEP01)
187
+  #define HAS_L64XX 1
188
+#endif
189
+#if HAS_L64XX && !HAS_DRIVER(L6474)
190
+  #define HAS_L64XX_NOT_L6474 1
191
+#endif
192 192
 
193 193
 #define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) ||  AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01))

+ 17
- 11
Marlin/src/core/macros.h Ver arquivo

@@ -177,18 +177,23 @@
177 177
 // Macros to support option testing
178 178
 #define _CAT(a,V...) a##V
179 179
 #define CAT(a,V...) _CAT(a,V)
180
-#define SWITCH_ENABLED_false 0
181
-#define SWITCH_ENABLED_true  1
182
-#define SWITCH_ENABLED_0     0
183
-#define SWITCH_ENABLED_1     1
184
-#define SWITCH_ENABLED_0x0   0
185
-#define SWITCH_ENABLED_0x1   1
186
-#define SWITCH_ENABLED_      1
187
-#define _ENA_1(O)           _CAT(SWITCH_ENABLED_, O)
188
-#define _DIS_1(O)           !_ENA_1(O)
180
+
181
+#define _ISENA_     ~,1
182
+#define _ISENA_1    ~,1
183
+#define _ISENA_0x1  ~,1
184
+#define _ISENA_true ~,1
185
+#define _ISENA(V...)        IS_PROBE(V)
186
+
187
+#define _ENA_1(O)           _ISENA(CAT(_IS,CAT(ENA_, O)))
188
+#define _DIS_1(O)           NOT(_ENA_1(O))
189 189
 #define ENABLED(V...)       DO(ENA,&&,V)
190 190
 #define DISABLED(V...)      DO(DIS,&&,V)
191 191
 
192
+#define TERN(O,A,B)         _TERN(_ENA_1(O),B,A)    // OPTION converted to to '0' or '1'
193
+#define _TERN(E,V...)       __TERN(_CAT(T_,E),V)    // Prepend 'T_' to get 'T_0' or 'T_1'
194
+#define __TERN(T,V...)      ___TERN(_CAT(_NO,T),V)  // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
195
+#define ___TERN(P,V...)     THIRD(P,V)              // If first argument has a comma, A. Else B.
196
+
192 197
 #define ANY(V...)          !DISABLED(V)
193 198
 #define NONE(V...)          DISABLED(V)
194 199
 #define ALL(V...)           ENABLED(V)
@@ -390,8 +395,9 @@
390 395
 //
391 396
 // Primitives supporting precompiler REPEAT
392 397
 //
393
-#define FIRST(a,...)    a
394
-#define SECOND(a,b,...) b
398
+#define FIRST(a,...)     a
399
+#define SECOND(a,b,...)  b
400
+#define THIRD(a,b,c,...) c
395 401
 
396 402
 // Defer expansion
397 403
 #define EMPTY()

+ 25
- 60
Marlin/src/core/utility.cpp Ver arquivo

@@ -57,39 +57,23 @@ void safe_delay(millis_t ms) {
57 57
 
58 58
   void log_machine_info() {
59 59
     SERIAL_ECHOLNPGM("Machine Type: "
60
-      #if ENABLED(DELTA)
61
-        "Delta"
62
-      #elif IS_SCARA
63
-        "SCARA"
64
-      #elif IS_CORE
65
-        "Core"
66
-      #else
67
-        "Cartesian"
68
-      #endif
60
+      TERN(DELTA, "Delta", "")
61
+      TERN(IS_SCARA, "SCARA", "")
62
+      TERN(IS_CORE, "Core", "")
63
+      TERN(IS_CARTESIAN, "Cartesian", "")
69 64
     );
70 65
 
71 66
     SERIAL_ECHOLNPGM("Probe: "
72
-      #if ENABLED(PROBE_MANUALLY)
73
-        "PROBE_MANUALLY"
74
-      #elif ENABLED(NOZZLE_AS_PROBE)
75
-        "NOZZLE_AS_PROBE"
76
-      #elif ENABLED(FIX_MOUNTED_PROBE)
77
-        "FIX_MOUNTED_PROBE"
78
-      #elif ENABLED(BLTOUCH)
79
-        "BLTOUCH"
80
-      #elif HAS_Z_SERVO_PROBE
81
-        "SERVO PROBE"
82
-      #elif ENABLED(TOUCH_MI_PROBE)
83
-        "TOUCH_MI_PROBE"
84
-      #elif ENABLED(Z_PROBE_SLED)
85
-        "Z_PROBE_SLED"
86
-      #elif ENABLED(Z_PROBE_ALLEN_KEY)
87
-        "Z_PROBE_ALLEN_KEY"
88
-      #elif ENABLED(SOLENOID_PROBE)
89
-        "SOLENOID_PROBE"
90
-      #else
91
-        "NONE"
92
-      #endif
67
+      TERN(PROBE_MANUALLY, "PROBE_MANUALLY", "")
68
+      TERN(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE", "")
69
+      TERN(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE", "")
70
+      TERN(BLTOUCH, "BLTOUCH", "")
71
+      TERN(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE"), "")
72
+      TERN(TOUCH_MI_PROBE, "TOUCH_MI_PROBE", "")
73
+      TERN(Z_PROBE_SLED, "Z_PROBE_SLED", "")
74
+      TERN(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY", "")
75
+      TERN(SOLENOID_PROBE, "SOLENOID_PROBE", "")
76
+      TERN(PROBE_SELECTED, "", "NONE")
93 77
     );
94 78
 
95 79
     #if HAS_BED_PROBE
@@ -107,20 +91,10 @@ void safe_delay(millis_t ms) {
107 91
         else
108 92
           SERIAL_ECHOPGM(" (Aligned With");
109 93
 
110
-        if (probe.offset_xy.y > 0) {
111
-          #if IS_SCARA
112
-            SERIAL_ECHOPGM("-Distal");
113
-          #else
114
-            SERIAL_ECHOPGM("-Back");
115
-          #endif
116
-        }
117
-        else if (probe.offset_xy.y < 0) {
118
-          #if IS_SCARA
119
-            SERIAL_ECHOPGM("-Proximal");
120
-          #else
121
-            SERIAL_ECHOPGM("-Front");
122
-          #endif
123
-        }
94
+        if (probe.offset_xy.y > 0)
95
+          serialprintPGM(ENABLED(IS_SCARA) ? PSTR("-Distal") : PSTR("-Back"));
96
+        else if (probe.offset_xy.y < 0)
97
+          serialprintPGM(ENABLED(IS_SCARA) ? PSTR("-Proximal") : PSTR("-Front"));
124 98
         else if (probe.offset_xy.x != 0)
125 99
           SERIAL_ECHOPGM("-Center");
126 100
 
@@ -128,27 +102,18 @@ void safe_delay(millis_t ms) {
128 102
 
129 103
       #endif
130 104
 
131
-      if (probe.offset.z < 0)
132
-        SERIAL_ECHOPGM("Below");
133
-      else if (probe.offset.z > 0)
134
-        SERIAL_ECHOPGM("Above");
135
-      else
136
-        SERIAL_ECHOPGM("Same Z as");
105
+      serialprintPGM(probe.offset.z < 0 ? PSTR("Below") : probe.offset.z > 0 ? PSTR("Above") : PSTR("Same Z as"));
137 106
       SERIAL_ECHOLNPGM(" Nozzle)");
138 107
 
139 108
     #endif
140 109
 
141 110
     #if HAS_ABL_OR_UBL
142
-      SERIAL_ECHOPGM("Auto Bed Leveling: ");
143
-      #if ENABLED(AUTO_BED_LEVELING_LINEAR)
144
-        SERIAL_ECHOLNPGM("LINEAR");
145
-      #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
146
-        SERIAL_ECHOLNPGM("BILINEAR");
147
-      #elif ENABLED(AUTO_BED_LEVELING_3POINT)
148
-        SERIAL_ECHOLNPGM("3POINT");
149
-      #elif ENABLED(AUTO_BED_LEVELING_UBL)
150
-        SERIAL_ECHOLNPGM("UBL");
151
-      #endif
111
+      SERIAL_ECHOPGM("Auto Bed Leveling: "
112
+        TERN(AUTO_BED_LEVELING_LINEAR, "LINEAR", "")
113
+        TERN(AUTO_BED_LEVELING_BILINEAR, "BILINEAR", "")
114
+        TERN(AUTO_BED_LEVELING_3POINT, "3POINT", "")
115
+        TERN(AUTO_BED_LEVELING_UBL, "UBL", "")
116
+      );
152 117
 
153 118
       if (planner.leveling_active) {
154 119
         SERIAL_ECHOLNPGM(" (enabled)");

+ 7
- 15
Marlin/src/feature/Max7219_Debug_LEDs.cpp Ver arquivo

@@ -48,24 +48,16 @@
48 48
 #include "../MarlinCore.h"
49 49
 #include "../HAL/shared/Delay.h"
50 50
 
51
-#define HAS_SIDE_BY_SIDE (ENABLED(MAX7219_SIDE_BY_SIDE) && MAX7219_NUMBER_UNITS > 1)
51
+#if ENABLED(MAX7219_SIDE_BY_SIDE) && MAX7219_NUMBER_UNITS > 1
52
+  #define HAS_SIDE_BY_SIDE 1
53
+#endif
52 54
 
53 55
 #if _ROT == 0 || _ROT == 180
54
-  #if HAS_SIDE_BY_SIDE
55
-    #define MAX7219_X_LEDS  8
56
-    #define MAX7219_Y_LEDS  MAX7219_LINES
57
-  #else
58
-    #define MAX7219_Y_LEDS  8
59
-    #define MAX7219_X_LEDS  MAX7219_LINES
60
-  #endif
56
+  #define MAX7219_X_LEDS TERN(HAS_SIDE_BY_SIDE, 8, MAX7219_LINES)
57
+  #define MAX7219_Y_LEDS TERN(HAS_SIDE_BY_SIDE, MAX7219_LINES, 8)
61 58
 #elif _ROT == 90 || _ROT == 270
62
-  #if HAS_SIDE_BY_SIDE
63
-    #define MAX7219_Y_LEDS  8
64
-    #define MAX7219_X_LEDS  MAX7219_LINES
65
-  #else
66
-    #define MAX7219_X_LEDS  8
67
-    #define MAX7219_Y_LEDS  MAX7219_LINES
68
-  #endif
59
+  #define MAX7219_X_LEDS TERN(HAS_SIDE_BY_SIDE, MAX7219_LINES, 8)
60
+  #define MAX7219_Y_LEDS TERN(HAS_SIDE_BY_SIDE, 8, MAX7219_LINES)
69 61
 #else
70 62
   #error "MAX7219_ROTATE must be a multiple of +/- 90°."
71 63
 #endif

+ 1
- 8
Marlin/src/feature/babystep.cpp Ver arquivo

@@ -55,14 +55,7 @@ void Babystep::add_mm(const AxisEnum axis, const float &mm) {
55 55
 
56 56
 void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
57 57
 
58
-  #if ENABLED(BABYSTEP_WITHOUT_HOMING)
59
-    #define CAN_BABYSTEP(AXIS) true
60
-  #else
61
-    extern uint8_t axis_known_position;
62
-    #define CAN_BABYSTEP(AXIS) TEST(axis_known_position, AXIS)
63
-  #endif
64
-
65
-  if (!CAN_BABYSTEP(axis)) return;
58
+  if (DISABLED(BABYSTEP_WITHOUT_HOMING) && !TEST(axis_known_position, axis)) return;
66 59
 
67 60
   accum += distance; // Count up babysteps for the UI
68 61
   #if ENABLED(BABYSTEP_DISPLAY_TOTAL)

+ 2
- 10
Marlin/src/feature/bltouch.cpp Ver arquivo

@@ -73,20 +73,12 @@ void BLTouch::init(const bool set_voltage/*=false*/) {
73 73
       );
74 74
     }
75 75
 
76
-    const bool should_set = last_written_mode != (false
77
-      #if ENABLED(BLTOUCH_SET_5V_MODE)
78
-        || true
79
-      #endif
80
-    );
76
+    const bool should_set = last_written_mode != ENABLED(BLTOUCH_SET_5V_MODE);
81 77
 
82 78
   #endif
83 79
 
84 80
   if (should_set && set_voltage)
85
-    mode_conv_proc((false
86
-      #if ENABLED(BLTOUCH_SET_5V_MODE)
87
-        || true
88
-      #endif
89
-    ));
81
+    mode_conv_proc(ENABLED(BLTOUCH_SET_5V_MODE));
90 82
 }
91 83
 
92 84
 void BLTouch::clear() {

+ 1
- 5
Marlin/src/feature/power_loss_recovery.h Ver arquivo

@@ -159,11 +159,7 @@ class PrintJobRecovery {
159 159
     static inline void cancel() { purge(); card.autostart_index = 0; }
160 160
 
161 161
     static void load();
162
-    static void save(const bool force=false
163
-      #if ENABLED(SAVE_EACH_CMD_MODE)
164
-        || true
165
-      #endif
166
-    );
162
+    static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE));
167 163
 
168 164
   #if PIN_EXISTS(POWER_LOSS)
169 165
     static inline void outage() {

+ 16
- 42
Marlin/src/gcode/calibrate/G28.cpp Ver arquivo

@@ -62,13 +62,7 @@
62 62
     current_position.set(0.0, 0.0);
63 63
     sync_plan_position();
64 64
 
65
-    const int x_axis_home_dir =
66
-      #if ENABLED(DUAL_X_CARRIAGE)
67
-        x_home_dir(active_extruder)
68
-      #else
69
-        home_dir(X_AXIS)
70
-      #endif
71
-    ;
65
+    const int x_axis_home_dir = x_home_dir(active_extruder);
72 66
 
73 67
     const float mlx = max_length(X_AXIS),
74 68
                 mly = max_length(Y_AXIS),
@@ -310,6 +304,8 @@ void GcodeSuite::G28() {
310 304
 
311 305
   #if ENABLED(DELTA)
312 306
 
307
+    constexpr bool doZ = true; // for NANODLP_Z_SYNC if your DLP is on a DELTA
308
+
313 309
     home_delta();
314 310
 
315 311
     #if ENABLED(IMPROVE_HOMING_RELIABILITY)
@@ -330,12 +326,10 @@ void GcodeSuite::G28() {
330 326
 
331 327
     #endif
332 328
 
333
-    const float z_homing_height = (
334
-      #if ENABLED(UNKNOWN_Z_NO_RAISE)
335
-        !TEST(axis_known_position, Z_AXIS) ? 0 :
336
-      #endif
337
-          (parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT)
338
-    );
329
+    const float z_homing_height =
330
+      (DISABLED(UNKNOWN_Z_NO_RAISE) || TEST(axis_known_position, Z_AXIS))
331
+        ? (parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT)
332
+        : 0;
339 333
 
340 334
     if (z_homing_height && (doX || doY)) {
341 335
       // Raise Z before homing any other axes and z is not already high enough (never lower z)
@@ -355,20 +349,13 @@ void GcodeSuite::G28() {
355 349
     // Home Y (before X)
356 350
     #if ENABLED(HOME_Y_BEFORE_X)
357 351
 
358
-      if (doY
359
-        #if ENABLED(CODEPENDENT_XY_HOMING)
360
-          || doX
361
-        #endif
362
-      ) homeaxis(Y_AXIS);
352
+      if (doY || (doX && ENABLED(CODEPENDENT_XY_HOMING)))
353
+        homeaxis(Y_AXIS);
363 354
 
364 355
     #endif
365 356
 
366 357
     // Home X
367
-    if (doX
368
-      #if ENABLED(CODEPENDENT_XY_HOMING) && DISABLED(HOME_Y_BEFORE_X)
369
-        || doY
370
-      #endif
371
-    ) {
358
+    if (doX || (doY && ENABLED(CODEPENDENT_XY_HOMING) && DISABLED(HOME_Y_BEFORE_X))) {
372 359
 
373 360
       #if ENABLED(DUAL_X_CARRIAGE)
374 361
 
@@ -396,9 +383,8 @@ void GcodeSuite::G28() {
396 383
     }
397 384
 
398 385
     // Home Y (after X)
399
-    #if DISABLED(HOME_Y_BEFORE_X)
400
-      if (doY) homeaxis(Y_AXIS);
401
-    #endif
386
+    if (DISABLED(HOME_Y_BEFORE_X) && doY)
387
+      homeaxis(Y_AXIS);
402 388
 
403 389
     #if ENABLED(IMPROVE_HOMING_RELIABILITY)
404 390
       end_slow_homing(slow_homing);
@@ -487,7 +473,7 @@ void GcodeSuite::G28() {
487 473
     do_blocking_move_to_z(delta_clip_start_height);
488 474
   #endif
489 475
 
490
-  #if HAS_LEVELING && ENABLED(RESTORE_LEVELING_AFTER_G28)
476
+  #if ENABLED(RESTORE_LEVELING_AFTER_G28)
491 477
     set_bed_leveling_enabled(leveling_was_active);
492 478
   #endif
493 479
 
@@ -495,12 +481,7 @@ void GcodeSuite::G28() {
495 481
 
496 482
   // Restore the active tool after homing
497 483
   #if HOTENDS > 1 && (DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE))
498
-    #if EITHER(PARKING_EXTRUDER, DUAL_X_CARRIAGE)
499
-      #define NO_FETCH false // fetch the previous toolhead
500
-    #else
501
-      #define NO_FETCH true
502
-    #endif
503
-    tool_change(old_tool_index, NO_FETCH);
484
+    tool_change(old_tool_index, NONE(PARKING_EXTRUDER, DUAL_X_CARRIAGE));   // Do move if one of these
504 485
   #endif
505 486
 
506 487
   #if HAS_HOMING_CURRENT
@@ -523,15 +504,8 @@ void GcodeSuite::G28() {
523 504
 
524 505
   report_current_position();
525 506
 
526
-  #if ENABLED(NANODLP_Z_SYNC)
527
-    #if ENABLED(NANODLP_ALL_AXIS)
528
-      #define _HOME_SYNC true       // For any axis, output sync text.
529
-    #else
530
-      #define _HOME_SYNC doZ        // Only for Z-axis
531
-    #endif
532
-    if (_HOME_SYNC)
533
-      SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP);
534
-  #endif
507
+  if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS)))
508
+    SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP);
535 509
 
536 510
   if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G28");
537 511
 

+ 6
- 2
Marlin/src/gcode/calibrate/G425.cpp Ver arquivo

@@ -56,8 +56,12 @@
56 56
   #define CALIBRATION_MEASUREMENT_CERTAIN   0.5 // mm
57 57
 #endif
58 58
 
59
-#define HAS_X_CENTER BOTH(CALIBRATION_MEASURE_LEFT, CALIBRATION_MEASURE_RIGHT)
60
-#define HAS_Y_CENTER BOTH(CALIBRATION_MEASURE_FRONT, CALIBRATION_MEASURE_BACK)
59
+#if BOTH(CALIBRATION_MEASURE_LEFT, CALIBRATION_MEASURE_RIGHT)
60
+  #define HAS_X_CENTER 1
61
+#endif
62
+#if BOTH(CALIBRATION_MEASURE_FRONT, CALIBRATION_MEASURE_BACK)
63
+  #define HAS_Y_CENTER 1
64
+#endif
61 65
 
62 66
 enum side_t : uint8_t { TOP, RIGHT, FRONT, LEFT, BACK, NUM_SIDES };
63 67
 

+ 19
- 90
Marlin/src/gcode/host/M115.cpp Ver arquivo

@@ -54,39 +54,19 @@ void GcodeSuite::M115() {
54 54
     #endif
55 55
 
56 56
     // SERIAL_XON_XOFF
57
-    cap_line(PSTR("SERIAL_XON_XOFF")
58
-      #if ENABLED(SERIAL_XON_XOFF)
59
-        , true
60
-      #endif
61
-    );
57
+    cap_line(PSTR("SERIAL_XON_XOFF"), ENABLED(SERIAL_XON_XOFF));
62 58
 
63 59
     // BINARY_FILE_TRANSFER (M28 B1)
64
-    cap_line(PSTR("BINARY_FILE_TRANSFER")
65
-      #if ENABLED(BINARY_FILE_TRANSFER)
66
-        , true
67
-      #endif
68
-    );
60
+    cap_line(PSTR("BINARY_FILE_TRANSFER"), ENABLED(BINARY_FILE_TRANSFER));
69 61
 
70 62
     // EEPROM (M500, M501)
71
-    cap_line(PSTR("EEPROM")
72
-      #if ENABLED(EEPROM_SETTINGS)
73
-        , true
74
-      #endif
75
-    );
63
+    cap_line(PSTR("EEPROM"), ENABLED(EEPROM_SETTINGS));
76 64
 
77 65
     // Volumetric Extrusion (M200)
78
-    cap_line(PSTR("VOLUMETRIC")
79
-      #if DISABLED(NO_VOLUMETRICS)
80
-        , true
81
-      #endif
82
-    );
66
+    cap_line(PSTR("VOLUMETRIC"), DISABLED(NO_VOLUMETRICS));
83 67
 
84 68
     // AUTOREPORT_TEMP (M155)
85
-    cap_line(PSTR("AUTOREPORT_TEMP")
86
-      #if ENABLED(AUTO_REPORT_TEMPERATURES)
87
-        , true
88
-      #endif
89
-    );
69
+    cap_line(PSTR("AUTOREPORT_TEMP"), ENABLED(AUTO_REPORT_TEMPERATURES));
90 70
 
91 71
     // PROGRESS (M530 S L, M531 <file>, M532 X L)
92 72
     cap_line(PSTR("PROGRESS"));
@@ -95,93 +75,42 @@ void GcodeSuite::M115() {
95 75
     cap_line(PSTR("PRINT_JOB"), true);
96 76
 
97 77
     // AUTOLEVEL (G29)
98
-    cap_line(PSTR("AUTOLEVEL")
99
-      #if HAS_AUTOLEVEL
100
-        , true
101
-      #endif
102
-    );
78
+    cap_line(PSTR("AUTOLEVEL"), ENABLED(HAS_AUTOLEVEL));
103 79
 
104 80
     // Z_PROBE (G30)
105
-    cap_line(PSTR("Z_PROBE")
106
-      #if HAS_BED_PROBE
107
-        , true
108
-      #endif
109
-    );
81
+    cap_line(PSTR("Z_PROBE"), ENABLED(HAS_BED_PROBE));
110 82
 
111 83
     // MESH_REPORT (M420 V)
112
-    cap_line(PSTR("LEVELING_DATA")
113
-      #if HAS_LEVELING
114
-        , true
115
-      #endif
116
-    );
84
+    cap_line(PSTR("LEVELING_DATA"), ENABLED(HAS_LEVELING));
117 85
 
118 86
     // BUILD_PERCENT (M73)
119
-    cap_line(PSTR("BUILD_PERCENT")
120
-      #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
121
-        , true
122
-      #endif
123
-    );
87
+    cap_line(PSTR("BUILD_PERCENT"), ENABLED(LCD_SET_PROGRESS_MANUALLY));
124 88
 
125 89
     // SOFTWARE_POWER (M80, M81)
126
-    cap_line(PSTR("SOFTWARE_POWER")
127
-      #if ENABLED(PSU_CONTROL)
128
-        , true
129
-      #endif
130
-    );
90
+    cap_line(PSTR("SOFTWARE_POWER"), ENABLED(PSU_CONTROL));
131 91
 
132 92
     // CASE LIGHTS (M355)
133
-    cap_line(PSTR("TOGGLE_LIGHTS")
134
-      #if HAS_CASE_LIGHT
135
-        , true
136
-      #endif
137
-    );
138
-    cap_line(PSTR("CASE_LIGHT_BRIGHTNESS")
139
-      #if HAS_CASE_LIGHT
140
-        , PWM_PIN(CASE_LIGHT_PIN)
141
-      #endif
142
-    );
93
+    cap_line(PSTR("TOGGLE_LIGHTS"), ENABLED(HAS_CASE_LIGHT));
94
+
95
+    cap_line(PSTR("CASE_LIGHT_BRIGHTNESS"), TERN(HAS_CASE_LIGHT, PWM_PIN(CASE_LIGHT_PIN), 0));
143 96
 
144 97
     // EMERGENCY_PARSER (M108, M112, M410, M876)
145
-    cap_line(PSTR("EMERGENCY_PARSER")
146
-      #if ENABLED(EMERGENCY_PARSER)
147
-        , true
148
-      #endif
149
-    );
98
+    cap_line(PSTR("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER));
150 99
 
151 100
     // PROMPT SUPPORT (M876)
152
-    cap_line(PSTR("PROMPT_SUPPORT")
153
-      #if ENABLED(HOST_PROMPT_SUPPORT)
154
-        , true
155
-      #endif
156
-    );
101
+    cap_line(PSTR("PROMPT_SUPPORT"), ENABLED(HOST_PROMPT_SUPPORT));
157 102
 
158 103
     // AUTOREPORT_SD_STATUS (M27 extension)
159
-    cap_line(PSTR("AUTOREPORT_SD_STATUS")
160
-      #if ENABLED(AUTO_REPORT_SD_STATUS)
161
-        , true
162
-      #endif
163
-    );
104
+    cap_line(PSTR("AUTOREPORT_SD_STATUS"), ENABLED(AUTO_REPORT_SD_STATUS));
164 105
 
165 106
     // THERMAL_PROTECTION
166
-    cap_line(PSTR("THERMAL_PROTECTION")
167
-      #if (ENABLED(THERMAL_PROTECTION_HOTENDS) || !EXTRUDERS) && (ENABLED(THERMAL_PROTECTION_BED) || !HAS_HEATED_BED) && (ENABLED(THERMAL_PROTECTION_CHAMBER) || !HAS_HEATED_CHAMBER)
168
-        , true
169
-      #endif
170
-    );
107
+    cap_line(PSTR("THERMAL_PROTECTION"), ENABLED(THERMALLY_SAFE));
171 108
 
172 109
     // MOTION_MODES (M80-M89)
173
-    cap_line(PSTR("MOTION_MODES")
174
-      #if ENABLED(GCODE_MOTION_MODES)
175
-        , true
176
-      #endif
177
-    );
110
+    cap_line(PSTR("MOTION_MODES"), ENABLED(GCODE_MOTION_MODES));
178 111
 
179 112
     // CHAMBER_TEMPERATURE (M141, M191)
180
-    cap_line(PSTR("CHAMBER_TEMPERATURE")
181
-      #if HAS_HEATED_CHAMBER
182
-        , true
183
-      #endif
184
-    );
113
+    cap_line(PSTR("CHAMBER_TEMPERATURE"), ENABLED(HAS_HEATED_CHAMBER));
185 114
 
186 115
   #endif // EXTENDED_CAPABILITIES_REPORT
187 116
 }

+ 78
- 46
Marlin/src/inc/Conditionals_LCD.h Ver arquivo

@@ -26,6 +26,15 @@
26 26
  * Conditionals that need to be set before Configuration_adv.h or pins.h
27 27
  */
28 28
 
29
+#if ENABLED(MORGAN_SCARA)
30
+  #define IS_SCARA 1
31
+  #define IS_KINEMATIC 1
32
+#elif ENABLED(DELTA)
33
+  #define IS_KINEMATIC 1
34
+#else
35
+  #define IS_CARTESIAN 1
36
+#endif
37
+
29 38
 #if ENABLED(CARTESIO_UI)
30 39
 
31 40
   #define DOGLCD
@@ -193,7 +202,9 @@
193 202
 #endif
194 203
 
195 204
 // 128x64 I2C OLED LCDs - SSD1306/SSD1309/SH1106
196
-#define HAS_SSD1306_OLED_I2C ANY(U8GLIB_SSD1306, U8GLIB_SSD1309, U8GLIB_SH1106)
205
+#if ANY(U8GLIB_SSD1306, U8GLIB_SSD1309, U8GLIB_SH1106)
206
+  #define HAS_SSD1306_OLED_I2C 1
207
+#endif
197 208
 #if HAS_SSD1306_OLED_I2C
198 209
   #define IS_ULTRA_LCD
199 210
   #define DOGLCD
@@ -347,19 +358,34 @@
347 358
 #endif
348 359
 
349 360
 // Extensible UI serial touch screens. (See src/lcd/extensible_ui)
350
-#if ANY(MALYAN_LCD, DGUS_LCD, TOUCH_UI_FTDI_EVE)
361
+#if ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
362
+  #define HAS_DGUS_LCD 1
363
+#endif
364
+
365
+#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE)
351 366
   #define IS_EXTUI
352 367
   #define EXTENSIBLE_UI
353 368
 #endif
354 369
 
355 370
 // Aliases for LCD features
356
-#define HAS_SPI_LCD          ENABLED(ULTRA_LCD)
357
-#define HAS_DISPLAY         (HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI))
358
-#define HAS_GRAPHICAL_LCD    ENABLED(DOGLCD)
359
-#define HAS_CHARACTER_LCD   (HAS_SPI_LCD && !HAS_GRAPHICAL_LCD)
360
-#define HAS_LCD_MENU        (ENABLED(ULTIPANEL) && DISABLED(NO_LCD_MENUS))
361
-#define HAS_ADC_BUTTONS      ENABLED(ADC_KEYPAD)
362
-#define HAS_DGUS_LCD         ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
371
+#if EITHER(ULTRA_LCD, EXTENSIBLE_UI)
372
+  #define HAS_DISPLAY 1
373
+  #if ENABLED(ULTRA_LCD)
374
+    #define HAS_SPI_LCD 1
375
+    #if ENABLED(DOGLCD)
376
+      #define HAS_GRAPHICAL_LCD 1
377
+    #else
378
+      #define HAS_CHARACTER_LCD 1
379
+    #endif
380
+  #endif
381
+#endif
382
+
383
+#if ENABLED(ULTIPANEL) && DISABLED(NO_LCD_MENUS)
384
+  #define HAS_LCD_MENU 1
385
+#endif
386
+#if ENABLED(ADC_KEYPAD)
387
+  #define HAS_ADC_BUTTONS 1
388
+#endif
363 389
 
364 390
 #if HAS_GRAPHICAL_LCD
365 391
   #ifndef LCD_PIXEL_WIDTH
@@ -447,12 +473,17 @@
447 473
 #define ARRAY_BY_HOTENDS(V...) ARRAY_N(HOTENDS, V)
448 474
 #define ARRAY_BY_HOTENDS1(v1) ARRAY_BY_HOTENDS(v1, v1, v1, v1, v1, v1, v1, v1)
449 475
 
450
-#define DO_SWITCH_EXTRUDER (ENABLED(SWITCHING_EXTRUDER) && (DISABLED(SWITCHING_NOZZLE) || SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR))
451
-#define SWITCHING_NOZZLE_TWO_SERVOS defined(SWITCHING_NOZZLE_E1_SERVO_NR)
476
+#if ENABLED(SWITCHING_EXTRUDER) && (DISABLED(SWITCHING_NOZZLE) || SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR)
477
+  #define DO_SWITCH_EXTRUDER 1
478
+#endif
452 479
 
453
-#define HAS_DUPLICATION_MODE EITHER(DUAL_X_CARRIAGE, MULTI_NOZZLE_DUPLICATION)
480
+#ifdef SWITCHING_NOZZLE_E1_SERVO_NR
481
+  #define SWITCHING_NOZZLE_TWO_SERVOS 1
482
+#endif
454 483
 
455
-#define HAS_HOTEND_OFFSET (HOTENDS > 1)
484
+#if HOTENDS > 1
485
+  #define HAS_HOTEND_OFFSET 1
486
+#endif
456 487
 
457 488
 /**
458 489
  * Default hotend offsets, if not defined
@@ -509,6 +540,10 @@
509 540
   #endif
510 541
 #endif
511 542
 
543
+#ifndef NUM_SERVOS
544
+  #define NUM_SERVOS 0
545
+#endif
546
+
512 547
 #ifndef PREHEAT_1_LABEL
513 548
   #define PREHEAT_1_LABEL "PLA"
514 549
 #endif
@@ -520,8 +555,12 @@
520 555
 /**
521 556
  * Set a flag for a servo probe (or BLTouch)
522 557
  */
523
-#define HAS_Z_SERVO_PROBE (defined(Z_PROBE_SERVO_NR) && Z_PROBE_SERVO_NR >= 0)
524
-#define HAS_SERVO_ANGLES (HAS_Z_SERVO_PROBE || EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE))
558
+#if defined(Z_PROBE_SERVO_NR) && Z_PROBE_SERVO_NR >= 0
559
+  #define HAS_Z_SERVO_PROBE 1
560
+#endif
561
+#if HAS_Z_SERVO_PROBE || EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
562
+  #define HAS_SERVO_ANGLES 1
563
+#endif
525 564
 #if !HAS_SERVO_ANGLES
526 565
   #undef EDITABLE_SERVO_ANGLES
527 566
 #endif
@@ -529,20 +568,31 @@
529 568
 /**
530 569
  * Set flags for enabled probes
531 570
  */
532
-#define HAS_BED_PROBE (HAS_Z_SERVO_PROBE || ANY(FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE))
533
-#define PROBE_SELECTED (HAS_BED_PROBE || EITHER(PROBE_MANUALLY, MESH_BED_LEVELING))
571
+#if ANY(HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE)
572
+  #define HAS_BED_PROBE 1
573
+#endif
574
+
575
+#if HAS_BED_PROBE || EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)
576
+  #define PROBE_SELECTED 1
577
+#endif
534 578
 
535 579
 #if HAS_BED_PROBE
536
-  #define HAS_PROBE_XY_OFFSET   DISABLED(NOZZLE_AS_PROBE)
537
-  #define HAS_CUSTOM_PROBE_PIN  DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
538
-  #define HOMING_Z_WITH_PROBE   (Z_HOME_DIR < 0 && !HAS_CUSTOM_PROBE_PIN)
580
+  #if DISABLED(NOZZLE_AS_PROBE)
581
+    #define HAS_PROBE_XY_OFFSET 1
582
+  #endif
583
+  #if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
584
+    #define HAS_CUSTOM_PROBE_PIN 1
585
+  #endif
586
+  #if Z_HOME_DIR < 0 && !HAS_CUSTOM_PROBE_PIN
587
+    #define HOMING_Z_WITH_PROBE 1
588
+  #endif
539 589
   #ifndef Z_PROBE_LOW_POINT
540 590
     #define Z_PROBE_LOW_POINT -5
541 591
   #endif
542 592
   #if ENABLED(Z_PROBE_ALLEN_KEY)
543
-    #define PROBE_TRIGGERED_WHEN_STOWED_TEST // Extra test for Allen Key Probe
593
+    #define PROBE_TRIGGERED_WHEN_STOWED_TEST 1 // Extra test for Allen Key Probe
544 594
   #endif
545
-  #ifdef MULTIPLE_PROBING
595
+  #if MULTIPLE_PROBING > 1
546 596
     #if EXTRA_PROBING
547 597
       #define TOTAL_PROBING (MULTIPLE_PROBING + EXTRA_PROBING)
548 598
     #else
@@ -558,23 +608,6 @@
558 608
   #define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y))
559 609
 #endif
560 610
 
561
-#define HAS_EXTRA_ENDSTOPS           ANY(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS, Z_MULTI_ENDSTOPS)
562
-#define HAS_SOFTWARE_ENDSTOPS        EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
563
-#define HAS_RESUME_CONTINUE          ANY(EXTENSIBLE_UI, NEWPANEL, EMERGENCY_PARSER)
564
-#define HAS_COLOR_LEDS               ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED)
565
-#define HAS_LEDS_OFF_FLAG            (BOTH(PRINTER_EVENT_LEDS, SDSUPPORT) && HAS_RESUME_CONTINUE)
566
-#define HAS_PRINT_PROGRESS           EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
567
-#define HAS_PRINT_PROGRESS_PERMYRIAD (HAS_PRINT_PROGRESS && EITHER(PRINT_PROGRESS_SHOW_DECIMALS, SHOW_REMAINING_TIME))
568
-#define HAS_SERVICE_INTERVALS        (ENABLED(PRINTCOUNTER) && (SERVICE_INTERVAL_1 > 0 || SERVICE_INTERVAL_2 > 0 || SERVICE_INTERVAL_3 > 0))
569
-#define HAS_FILAMENT_SENSOR          ENABLED(FILAMENT_RUNOUT_SENSOR)
570
-
571
-#define HAS_GAMES     ANY(MARLIN_BRICKOUT, MARLIN_INVADERS, MARLIN_SNAKE, MARLIN_MAZE)
572
-#define HAS_GAME_MENU (1 < ENABLED(MARLIN_BRICKOUT) + ENABLED(MARLIN_INVADERS) + ENABLED(MARLIN_SNAKE) + ENABLED(MARLIN_MAZE))
573
-
574
-#define IS_SCARA     ENABLED(MORGAN_SCARA)
575
-#define IS_KINEMATIC (ENABLED(DELTA) || IS_SCARA)
576
-#define IS_CARTESIAN !IS_KINEMATIC
577
-
578 611
 #ifndef INVERT_X_DIR
579 612
   #define INVERT_X_DIR false
580 613
 #endif
@@ -592,16 +625,15 @@
592 625
   #define BOOT_MARLIN_LOGO_SMALL
593 626
 #endif
594 627
 
595
-#define IS_RE_ARM_BOARD MB(RAMPS_14_RE_ARM_EFB, RAMPS_14_RE_ARM_EEB, RAMPS_14_RE_ARM_EFF, RAMPS_14_RE_ARM_EEF, RAMPS_14_RE_ARM_SF)
596
-
597
-// Linear advance uses Jerk since E is an isolated axis
598
-#define HAS_LINEAR_E_JERK  (DISABLED(CLASSIC_JERK) && ENABLED(LIN_ADVANCE))
599
-
600 628
 // This flag indicates some kind of jerk storage is needed
601
-#define HAS_CLASSIC_JERK   (ENABLED(CLASSIC_JERK) || IS_KINEMATIC)
629
+#if ENABLED(CLASSIC_JERK) || IS_KINEMATIC
630
+  #define HAS_CLASSIC_JERK 1
631
+#endif
602 632
 
603 633
 // E jerk exists with JD disabled (of course) but also when Linear Advance is disabled on Delta/SCARA
604
-#define HAS_CLASSIC_E_JERK (ENABLED(CLASSIC_JERK) || (IS_KINEMATIC && DISABLED(LIN_ADVANCE)))
634
+#if ENABLED(CLASSIC_JERK) || (IS_KINEMATIC && DISABLED(LIN_ADVANCE))
635
+  #define HAS_CLASSIC_E_JERK 1
636
+#endif
605 637
 
606 638
 #ifndef SPI_SPEED
607 639
   #define SPI_SPEED SPI_FULL_SPEED

+ 50
- 6
Marlin/src/inc/Conditionals_adv.h Ver arquivo

@@ -56,6 +56,50 @@
56 56
   #undef SHOW_TEMP_ADC_VALUES
57 57
 #endif
58 58
 
59
+#if EITHER(DUAL_X_CARRIAGE, MULTI_NOZZLE_DUPLICATION)
60
+  #define HAS_DUPLICATION_MODE 1
61
+#endif
62
+
63
+#if ENABLED(PRINTCOUNTER) && (SERVICE_INTERVAL_1 > 0 || SERVICE_INTERVAL_2 > 0 || SERVICE_INTERVAL_3 > 0)
64
+  #define HAS_SERVICE_INTERVALS 1
65
+#endif
66
+
67
+#if ENABLED(FILAMENT_RUNOUT_SENSOR)
68
+  #define HAS_FILAMENT_SENSOR 1
69
+#endif
70
+
71
+#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
72
+  #define HAS_PRINT_PROGRESS 1
73
+#endif
74
+
75
+#if HAS_PRINT_PROGRESS && EITHER(PRINT_PROGRESS_SHOW_DECIMALS, SHOW_REMAINING_TIME)
76
+  #define HAS_PRINT_PROGRESS_PERMYRIAD 1
77
+#endif
78
+
79
+#if ANY(MARLIN_BRICKOUT, MARLIN_INVADERS, MARLIN_SNAKE, MARLIN_MAZE)
80
+  #define HAS_GAMES 1
81
+  #if (1 < ENABLED(MARLIN_BRICKOUT) + ENABLED(MARLIN_INVADERS) + ENABLED(MARLIN_SNAKE) + ENABLED(MARLIN_MAZE))
82
+    #define HAS_GAME_MENU 1
83
+  #endif
84
+#endif
85
+
86
+#if ANY(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS, Z_MULTI_ENDSTOPS)
87
+  #define HAS_EXTRA_ENDSTOPS 1
88
+#endif
89
+#if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
90
+  #define HAS_SOFTWARE_ENDSTOPS 1
91
+#endif
92
+#if ANY(EXTENSIBLE_UI, NEWPANEL, EMERGENCY_PARSER)
93
+  #define HAS_RESUME_CONTINUE 1
94
+#endif
95
+
96
+#if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED)
97
+  #define HAS_COLOR_LEDS 1
98
+#endif
99
+#if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT)
100
+  #define HAS_LEDS_OFF_FLAG 1
101
+#endif
102
+
59 103
 #if !NUM_SERIAL
60 104
   #undef BAUD_RATE_GCODE
61 105
 #endif
@@ -65,10 +109,6 @@
65 109
   #define NUM_Z_STEPPER_DRIVERS 1
66 110
 #endif
67 111
 
68
-#ifndef PLR_ENABLED_DEFAULT
69
-  #define PLR_ENABLED_DEFAULT true
70
-#endif
71
-
72 112
 #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
73 113
   #undef Z_STEPPER_ALIGN_AMP
74 114
 #endif
@@ -171,10 +211,14 @@
171 211
 #endif
172 212
 
173 213
 // If platform requires early initialization of watchdog to properly boot
174
-#define EARLY_WATCHDOG (ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM))
214
+#if ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM)
215
+  #define EARLY_WATCHDOG 1
216
+#endif
175 217
 
176 218
 // Extensible UI pin mapping for RepRapDiscount
177
-#define TOUCH_UI_ULTIPANEL ENABLED(TOUCH_UI_FTDI_EVE) && ANY(AO_EXP1_PINMAP, AO_EXP2_PINMAP, CR10_TFT_PINMAP)
219
+#if ENABLED(TOUCH_UI_FTDI_EVE) && ANY(AO_EXP1_PINMAP, AO_EXP2_PINMAP, CR10_TFT_PINMAP)
220
+  #define TOUCH_UI_ULTIPANEL 1
221
+#endif
178 222
 
179 223
 // Poll-based jogging for joystick and other devices
180 224
 #if ENABLED(JOYSTICK)

+ 196
- 109
Marlin/src/inc/Conditionals_post.h Ver arquivo

@@ -30,6 +30,11 @@
30 30
   // Extras for CI testing
31 31
 #endif
32 32
 
33
+// Linear advance uses Jerk since E is an isolated axis
34
+#if DISABLED(CLASSIC_JERK) && ENABLED(LIN_ADVANCE)
35
+  #define HAS_LINEAR_E_JERK 1
36
+#endif
37
+
33 38
 #ifdef TEENSYDUINO
34 39
   #undef max
35 40
   #define max(a,b) ((a)>(b)?(a):(b))
@@ -63,13 +68,8 @@
63 68
 // Define center values for future use
64 69
 #define _X_HALF_BED ((X_BED_SIZE) / 2)
65 70
 #define _Y_HALF_BED ((Y_BED_SIZE) / 2)
66
-#if ENABLED(BED_CENTER_AT_0_0)
67
-  #define X_CENTER 0
68
-  #define Y_CENTER 0
69
-#else
70
-  #define X_CENTER _X_HALF_BED
71
-  #define Y_CENTER _Y_HALF_BED
72
-#endif
71
+#define X_CENTER TERN(BED_CENTER_AT_0_0, 0, _X_HALF_BED)
72
+#define Y_CENTER TERN(BED_CENTER_AT_0_0, 0, _Y_HALF_BED)
73 73
 
74 74
 // Get the linear boundaries of the bed
75 75
 #define X_MIN_BED (X_CENTER - _X_HALF_BED)
@@ -92,10 +92,18 @@
92 92
 /**
93 93
  * CoreXY, CoreXZ, and CoreYZ - and their reverse
94 94
  */
95
-#define CORE_IS_XY EITHER(COREXY, COREYX)
96
-#define CORE_IS_XZ EITHER(COREXZ, COREZX)
97
-#define CORE_IS_YZ EITHER(COREYZ, COREZY)
98
-#define IS_CORE (CORE_IS_XY || CORE_IS_XZ || CORE_IS_YZ)
95
+#if EITHER(COREXY, COREYX)
96
+  #define CORE_IS_XY 1
97
+#endif
98
+#if EITHER(COREXZ, COREZX)
99
+  #define CORE_IS_XZ 1
100
+#endif
101
+#if EITHER(COREYZ, COREZY)
102
+  #define CORE_IS_YZ 1
103
+#endif
104
+#if CORE_IS_XY || CORE_IS_XZ || CORE_IS_YZ
105
+  #define IS_CORE 1
106
+#endif
99 107
 #if IS_CORE
100 108
   #if CORE_IS_XY
101 109
     #define CORE_AXIS_1 A_AXIS
@@ -110,11 +118,7 @@
110 118
     #define CORE_AXIS_1 B_AXIS
111 119
     #define CORE_AXIS_2 C_AXIS
112 120
   #endif
113
-  #if ANY(COREYX, COREZX, COREZY)
114
-    #define CORESIGN(n) (-(n))
115
-  #else
116
-    #define CORESIGN(n) (n)
117
-  #endif
121
+  #define CORESIGN(n) (ANY(COREYX, COREZX, COREZY) ? (-(n)) : (n))
118 122
 #endif
119 123
 
120 124
 /**
@@ -139,33 +143,23 @@
139 143
  */
140 144
 #ifdef MANUAL_X_HOME_POS
141 145
   #define X_HOME_POS MANUAL_X_HOME_POS
142
-#elif ENABLED(BED_CENTER_AT_0_0)
143
-  #if ENABLED(DELTA)
144
-    #define X_HOME_POS 0
145
-  #else
146
-    #define X_HOME_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS)
147
-  #endif
148 146
 #else
149
-  #if ENABLED(DELTA)
150
-    #define X_HOME_POS (X_MIN_POS + (X_BED_SIZE) * 0.5)
147
+  #define X_END_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS)
148
+  #if ENABLED(BED_CENTER_AT_0_0)
149
+    #define X_HOME_POS TERN(DELTA, 0, X_END_POS)
151 150
   #else
152
-    #define X_HOME_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS)
151
+    #define X_HOME_POS TERN(DELTA, X_MIN_POS + (X_BED_SIZE) * 0.5, X_END_POS)
153 152
   #endif
154 153
 #endif
155 154
 
156 155
 #ifdef MANUAL_Y_HOME_POS
157 156
   #define Y_HOME_POS MANUAL_Y_HOME_POS
158
-#elif ENABLED(BED_CENTER_AT_0_0)
159
-  #if ENABLED(DELTA)
160
-    #define Y_HOME_POS 0
161
-  #else
162
-    #define Y_HOME_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS)
163
-  #endif
164 157
 #else
165
-  #if ENABLED(DELTA)
166
-    #define Y_HOME_POS (Y_MIN_POS + (Y_BED_SIZE) * 0.5)
158
+  #define Y_END_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS)
159
+  #if ENABLED(BED_CENTER_AT_0_0)
160
+    #define Y_HOME_POS TERN(DELTA, 0, Y_END_POS)
167 161
   #else
168
-    #define Y_HOME_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS)
162
+    #define Y_HOME_POS TERN(DELTA, Y_MIN_POS + (Y_BED_SIZE) * 0.5, Y_END_POS)
169 163
   #endif
170 164
 #endif
171 165
 
@@ -268,7 +262,10 @@
268 262
   #define _LCD_CONTRAST_INIT  17
269 263
 #endif
270 264
 
271
-#define HAS_LCD_CONTRAST defined(_LCD_CONTRAST_INIT)
265
+#ifdef _LCD_CONTRAST_INIT
266
+  #define HAS_LCD_CONTRAST 1
267
+#endif
268
+
272 269
 #if HAS_LCD_CONTRAST
273 270
   #ifndef LCD_CONTRAST_MIN
274 271
     #ifdef _LCD_CONTRAST_MIN
@@ -1291,20 +1288,40 @@
1291 1288
 
1292 1289
 // Trinamic Stepper Drivers
1293 1290
 #if HAS_TRINAMIC_CONFIG
1294
-  #define STEALTHCHOP_ENABLED ANY(STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_E)
1295
-  #define USE_SENSORLESS EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING)
1291
+  #if ANY(STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_E)
1292
+    #define STEALTHCHOP_ENABLED 1
1293
+  #endif
1294
+  #if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING)
1295
+    #define USE_SENSORLESS 1
1296
+  #endif
1296 1297
   // Disable Z axis sensorless homing if a probe is used to home the Z axis
1297 1298
   #if HOMING_Z_WITH_PROBE
1298 1299
     #undef Z_STALL_SENSITIVITY
1299 1300
   #endif
1300
-  #define X_SENSORLESS  (AXIS_HAS_STALLGUARD(X)  && defined(X_STALL_SENSITIVITY))
1301
-  #define X2_SENSORLESS (AXIS_HAS_STALLGUARD(X2) && defined(X2_STALL_SENSITIVITY))
1302
-  #define Y_SENSORLESS  (AXIS_HAS_STALLGUARD(Y)  && defined(Y_STALL_SENSITIVITY))
1303
-  #define Y2_SENSORLESS (AXIS_HAS_STALLGUARD(Y2) && defined(Y2_STALL_SENSITIVITY))
1304
-  #define Z_SENSORLESS  (AXIS_HAS_STALLGUARD(Z)  && defined(Z_STALL_SENSITIVITY))
1305
-  #define Z2_SENSORLESS (AXIS_HAS_STALLGUARD(Z2) && defined(Z2_STALL_SENSITIVITY))
1306
-  #define Z3_SENSORLESS (AXIS_HAS_STALLGUARD(Z3) && defined(Z3_STALL_SENSITIVITY))
1307
-  #define Z4_SENSORLESS (AXIS_HAS_STALLGUARD(Z4) && defined(Z4_STALL_SENSITIVITY))
1301
+  #if defined(X_STALL_SENSITIVITY)  && AXIS_HAS_STALLGUARD(X)
1302
+    #define X_SENSORLESS 1
1303
+  #endif
1304
+  #if defined(X2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X2)
1305
+    #define X2_SENSORLESS 1
1306
+  #endif
1307
+  #if defined(Y_STALL_SENSITIVITY)  && AXIS_HAS_STALLGUARD(Y)
1308
+    #define Y_SENSORLESS 1
1309
+  #endif
1310
+  #if defined(Y2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y2)
1311
+    #define Y2_SENSORLESS 1
1312
+  #endif
1313
+  #if defined(Z_STALL_SENSITIVITY)  && AXIS_HAS_STALLGUARD(Z)
1314
+    #define Z_SENSORLESS 1
1315
+  #endif
1316
+  #if defined(Z2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z2)
1317
+    #define Z2_SENSORLESS 1
1318
+  #endif
1319
+  #if defined(Z3_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z3)
1320
+    #define Z3_SENSORLESS 1
1321
+  #endif
1322
+  #if defined(Z4_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z4)
1323
+    #define Z4_SENSORLESS 1
1324
+  #endif
1308 1325
   #if ENABLED(SPI_ENDSTOPS)
1309 1326
     #define X_SPI_SENSORLESS X_SENSORLESS
1310 1327
     #define Y_SPI_SENSORLESS Y_SENSORLESS
@@ -1388,23 +1405,48 @@
1388 1405
 #define HAS_HEATER_BED  (PIN_EXISTS(HEATER_BED))
1389 1406
 
1390 1407
 // Shorthand for common combinations
1391
-#define HAS_HEATED_BED (HAS_TEMP_BED && HAS_HEATER_BED)
1392
-#define BED_OR_CHAMBER (HAS_HEATED_BED || HAS_TEMP_CHAMBER)
1393
-#define HAS_TEMP_SENSOR (HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE)
1394
-#define HAS_HEATED_CHAMBER (HAS_TEMP_CHAMBER && PIN_EXISTS(HEATER_CHAMBER))
1408
+#if HAS_TEMP_BED && HAS_HEATER_BED
1409
+  #define HAS_HEATED_BED 1
1410
+#endif
1411
+#if HAS_HEATED_BED || HAS_TEMP_CHAMBER
1412
+  #define BED_OR_CHAMBER 1
1413
+#endif
1414
+#if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE
1415
+  #define HAS_TEMP_SENSOR 1
1416
+#endif
1417
+#if HAS_TEMP_CHAMBER && PIN_EXISTS(HEATER_CHAMBER)
1418
+  #define HAS_HEATED_CHAMBER 1
1419
+#endif
1395 1420
 
1396 1421
 // PID heating
1397 1422
 #if !HAS_HEATED_BED
1398 1423
   #undef PIDTEMPBED
1399 1424
 #endif
1400
-#define HAS_PID_HEATING EITHER(PIDTEMP, PIDTEMPBED)
1401
-#define HAS_PID_FOR_BOTH BOTH(PIDTEMP, PIDTEMPBED)
1425
+#if EITHER(PIDTEMP, PIDTEMPBED)
1426
+  #define HAS_PID_HEATING 1
1427
+#endif
1428
+#if BOTH(PIDTEMP, PIDTEMPBED)
1429
+  #define HAS_PID_FOR_BOTH 1
1430
+#endif
1402 1431
 
1403 1432
 // Thermal protection
1404
-#define HAS_THERMALLY_PROTECTED_BED (HAS_HEATED_BED && ENABLED(THERMAL_PROTECTION_BED))
1405
-#define WATCH_HOTENDS (ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0)
1406
-#define WATCH_BED (HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0)
1407
-#define WATCH_CHAMBER (HAS_HEATED_CHAMBER && ENABLED(THERMAL_PROTECTION_CHAMBER) && WATCH_CHAMBER_TEMP_PERIOD > 0)
1433
+#if HAS_HEATED_BED && ENABLED(THERMAL_PROTECTION_BED)
1434
+  #define HAS_THERMALLY_PROTECTED_BED 1
1435
+#endif
1436
+#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
1437
+  #define WATCH_HOTENDS 1
1438
+#endif
1439
+#if HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0
1440
+  #define WATCH_BED 1
1441
+#endif
1442
+#if HAS_HEATED_CHAMBER && ENABLED(THERMAL_PROTECTION_CHAMBER) && WATCH_CHAMBER_TEMP_PERIOD > 0
1443
+  #define WATCH_CHAMBER 1
1444
+#endif
1445
+#if  (ENABLED(THERMAL_PROTECTION_HOTENDS) || !EXTRUDERS) \
1446
+  && (ENABLED(THERMAL_PROTECTION_BED)     || !HAS_HEATED_BED) \
1447
+  && (ENABLED(THERMAL_PROTECTION_CHAMBER) || !HAS_HEATED_CHAMBER)
1448
+  #define THERMALLY_SAFE 1
1449
+#endif
1408 1450
 
1409 1451
 // Auto fans
1410 1452
 #define HAS_AUTO_FAN_0 (HOTENDS > 0 && PIN_EXISTS(E0_AUTO_FAN))
@@ -1455,22 +1497,48 @@
1455 1497
 #define HAS_FILAMENT_WIDTH_SENSOR (PIN_EXISTS(FILWIDTH))
1456 1498
 
1457 1499
 // User Interface
1458
-#define HAS_HOME        (PIN_EXISTS(HOME))
1459
-#define HAS_KILL        (PIN_EXISTS(KILL))
1460
-#define HAS_SUICIDE     (PIN_EXISTS(SUICIDE))
1461
-#define HAS_PHOTOGRAPH  (PIN_EXISTS(PHOTOGRAPH))
1462
-#define HAS_BUZZER      (PIN_EXISTS(BEEPER) || EITHER(LCD_USE_I2C_BUZZER, PCA9632_BUZZER))
1463
-#define USE_BEEPER      (HAS_BUZZER && DISABLED(LCD_USE_I2C_BUZZER, PCA9632_BUZZER))
1464
-#define HAS_CASE_LIGHT  (PIN_EXISTS(CASE_LIGHT) && ENABLED(CASE_LIGHT_ENABLE))
1500
+#if PIN_EXISTS(HOME)
1501
+  #define HAS_HOME 1
1502
+#endif
1503
+#if PIN_EXISTS(KILL)
1504
+  #define HAS_KILL 1
1505
+#endif
1506
+#if PIN_EXISTS(SUICIDE)
1507
+  #define HAS_SUICIDE 1
1508
+#endif
1509
+#if PIN_EXISTS(PHOTOGRAPH)
1510
+  #define HAS_PHOTOGRAPH 1
1511
+#endif
1512
+#if PIN_EXISTS(BEEPER) || EITHER(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
1513
+  #define HAS_BUZZER 1
1514
+#endif
1515
+#if HAS_BUZZER && DISABLED(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
1516
+  #define USE_BEEPER 1
1517
+#endif
1518
+#if PIN_EXISTS(CASE_LIGHT) && ENABLED(CASE_LIGHT_ENABLE)
1519
+  #define HAS_CASE_LIGHT 1
1520
+#endif
1465 1521
 
1466 1522
 // Digital control
1467
-#define HAS_STEPPER_RESET     (PIN_EXISTS(STEPPER_RESET))
1468
-#define HAS_DIGIPOTSS         (PIN_EXISTS(DIGIPOTSS))
1469
-#define HAS_MOTOR_CURRENT_PWM ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_E)
1523
+#if PIN_EXISTS(STEPPER_RESET)
1524
+  #define HAS_STEPPER_RESET 1
1525
+#endif
1526
+#if PIN_EXISTS(DIGIPOTSS)
1527
+  #define HAS_DIGIPOTSS 1
1528
+#endif
1529
+#if  ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_E)
1530
+  #define HAS_MOTOR_CURRENT_PWM 1
1531
+#endif
1470 1532
 
1471
-#define HAS_SOME_Z_MICROSTEPS (HAS_Z_MICROSTEPS || HAS_Z2_MICROSTEPS || HAS_Z3_MICROSTEPS || HAS_Z4_MICROSTEPS)
1472
-#define HAS_SOME_E_MICROSTEPS (HAS_E0_MICROSTEPS || HAS_E1_MICROSTEPS || HAS_E2_MICROSTEPS || HAS_E3_MICROSTEPS || HAS_E4_MICROSTEPS || HAS_E5_MICROSTEPS || HAS_E6_MICROSTEPS || HAS_E7_MICROSTEPS)
1473
-#define HAS_MICROSTEPS (HAS_X_MICROSTEPS || HAS_X2_MICROSTEPS || HAS_Y_MICROSTEPS || HAS_Y2_MICROSTEPS || HAS_SOME_Z_MICROSTEPS || HAS_SOME_E_MICROSTEPS)
1533
+#if HAS_Z_MICROSTEPS || HAS_Z2_MICROSTEPS || HAS_Z3_MICROSTEPS || HAS_Z4_MICROSTEPS
1534
+  #define HAS_SOME_Z_MICROSTEPS 1
1535
+#endif
1536
+#if HAS_E0_MICROSTEPS || HAS_E1_MICROSTEPS || HAS_E2_MICROSTEPS || HAS_E3_MICROSTEPS || HAS_E4_MICROSTEPS || HAS_E5_MICROSTEPS || HAS_E6_MICROSTEPS || HAS_E7_MICROSTEPS
1537
+  #define HAS_SOME_E_MICROSTEPS 1
1538
+#endif
1539
+#if HAS_X_MICROSTEPS || HAS_X2_MICROSTEPS || HAS_Y_MICROSTEPS || HAS_Y2_MICROSTEPS || HAS_SOME_Z_MICROSTEPS || HAS_SOME_E_MICROSTEPS
1540
+  #define HAS_MICROSTEPS 1
1541
+#endif
1474 1542
 
1475 1543
 #if HAS_MICROSTEPS
1476 1544
 
@@ -1764,21 +1832,48 @@
1764 1832
 /**
1765 1833
  * Set granular options based on the specific type of leveling
1766 1834
  */
1767
-#define UBL_SEGMENTED   BOTH(AUTO_BED_LEVELING_UBL, DELTA)
1768
-#define ABL_PLANAR      EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT)
1769
-#define ABL_GRID        EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)
1770
-#define HAS_ABL_NOT_UBL (ABL_PLANAR || ABL_GRID)
1771
-#define HAS_ABL_OR_UBL  (HAS_ABL_NOT_UBL || ENABLED(AUTO_BED_LEVELING_UBL))
1772
-#define HAS_LEVELING    (HAS_ABL_OR_UBL || ENABLED(MESH_BED_LEVELING))
1773
-#define HAS_AUTOLEVEL   (HAS_ABL_OR_UBL && DISABLED(PROBE_MANUALLY))
1774
-#define HAS_MESH        ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
1775
-#define PLANNER_LEVELING      (HAS_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL))
1776
-#define HAS_PROBING_PROCEDURE (HAS_ABL_OR_UBL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
1777
-#define HAS_POSITION_MODIFIERS (ENABLED(FWRETRACT) || HAS_LEVELING || ENABLED(SKEW_CORRECTION))
1778
-#define NEEDS_THREE_PROBE_POINTS EITHER(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_3POINT)
1779
-
1780 1835
 #if ENABLED(AUTO_BED_LEVELING_UBL)
1781 1836
   #undef LCD_BED_LEVELING
1837
+  #if ENABLED(DELTA)
1838
+    #define UBL_SEGMENTED 1
1839
+  #endif
1840
+#endif
1841
+#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT)
1842
+  #define ABL_PLANAR 1
1843
+#endif
1844
+#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)
1845
+  #define ABL_GRID 1
1846
+#endif
1847
+#if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_3POINT)
1848
+  #define HAS_ABL_NOT_UBL 1
1849
+#endif
1850
+#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
1851
+  #define HAS_MESH 1
1852
+#endif
1853
+#if EITHER(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_3POINT)
1854
+  #define NEEDS_THREE_PROBE_POINTS 1
1855
+#endif
1856
+#if EITHER(HAS_ABL_NOT_UBL, AUTO_BED_LEVELING_UBL)
1857
+  #define HAS_ABL_OR_UBL 1
1858
+  #if DISABLED(PROBE_MANUALLY)
1859
+    #define HAS_AUTOLEVEL 1
1860
+  #endif
1861
+#endif
1862
+#if EITHER(HAS_ABL_OR_UBL, MESH_BED_LEVELING)
1863
+  #define HAS_LEVELING 1
1864
+  #if DISABLED(AUTO_BED_LEVELING_UBL)
1865
+    #define PLANNER_LEVELING 1
1866
+  #endif
1867
+#endif
1868
+#if EITHER(HAS_ABL_OR_UBL, Z_MIN_PROBE_REPEATABILITY_TEST)
1869
+  #define HAS_PROBING_PROCEDURE 1
1870
+#endif
1871
+#if ANY(FWRETRACT, HAS_LEVELING, SKEW_CORRECTION)
1872
+  #define HAS_POSITION_MODIFIERS 1
1873
+#endif
1874
+
1875
+#if !HAS_LEVELING
1876
+  #undef RESTORE_LEVELING_AFTER_G28
1782 1877
 #endif
1783 1878
 
1784 1879
 /**
@@ -1905,8 +2000,8 @@
1905 2000
   #undef MESH_MAX_Y
1906 2001
 #endif
1907 2002
 
1908
-#if (defined(PROBE_PT_1_X) && defined(PROBE_PT_2_X) && defined(PROBE_PT_3_X) && defined(PROBE_PT_1_Y) && defined(PROBE_PT_2_Y) && defined(PROBE_PT_3_Y))
1909
-  #define HAS_FIXED_3POINT
2003
+#if defined(PROBE_PT_1_X) && defined(PROBE_PT_2_X) && defined(PROBE_PT_3_X) && defined(PROBE_PT_1_Y) && defined(PROBE_PT_2_Y) && defined(PROBE_PT_3_Y)
2004
+  #define HAS_FIXED_3POINT 1
1910 2005
 #endif
1911 2006
 
1912 2007
 /**
@@ -1944,10 +2039,10 @@
1944 2039
  * Z_HOMING_HEIGHT / Z_CLEARANCE_BETWEEN_PROBES
1945 2040
  */
1946 2041
 #ifndef Z_HOMING_HEIGHT
1947
-  #ifndef Z_CLEARANCE_BETWEEN_PROBES
1948
-    #define Z_HOMING_HEIGHT 0
1949
-  #else
2042
+  #ifdef Z_CLEARANCE_BETWEEN_PROBES
1950 2043
     #define Z_HOMING_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
2044
+  #else
2045
+    #define Z_HOMING_HEIGHT 0
1951 2046
   #endif
1952 2047
 #endif
1953 2048
 
@@ -1975,15 +2070,16 @@
1975 2070
 #endif
1976 2071
 
1977 2072
 // Updated G92 behavior shifts the workspace
1978
-#define HAS_POSITION_SHIFT DISABLED(NO_WORKSPACE_OFFSETS)
1979
-// The home offset also shifts the coordinate space
1980
-#define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && IS_CARTESIAN)
1981
-// The SCARA home offset applies only on G28
1982
-#define HAS_SCARA_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && IS_SCARA)
1983
-// Cumulative offset to workspace to save some calculation
1984
-#define HAS_WORKSPACE_OFFSET (HAS_POSITION_SHIFT && HAS_HOME_OFFSET)
1985
-// M206 sets the home offset for Cartesian machines
1986
-#define HAS_M206_COMMAND (HAS_HOME_OFFSET && !IS_SCARA)
2073
+#if DISABLED(NO_WORKSPACE_OFFSETS)
2074
+  #define HAS_POSITION_SHIFT 1
2075
+  #if IS_CARTESIAN
2076
+    #define HAS_HOME_OFFSET 1       // The home offset also shifts the coordinate space
2077
+    #define HAS_WORKSPACE_OFFSET 1  // Cumulative offset to workspace to save some calculation
2078
+    #define HAS_M206_COMMAND 1      // M206 sets the home offset for Cartesian machines
2079
+  #elif IS_SCARA
2080
+    #define HAS_SCARA_OFFSET 1      // The SCARA home offset applies only on G28
2081
+  #endif
2082
+#endif
1987 2083
 
1988 2084
 // LCD timeout to status screen default is 15s
1989 2085
 #ifndef LCD_TIMEOUT_TO_STATUS
@@ -2006,11 +2102,7 @@
2006 2102
 #endif
2007 2103
 
2008 2104
 // Number of VFAT entries used. Each entry has 13 UTF-16 characters
2009
-#if ENABLED(SCROLL_LONG_FILENAMES)
2010
-  #define MAX_VFAT_ENTRIES (5)
2011
-#else
2012
-  #define MAX_VFAT_ENTRIES (2)
2013
-#endif
2105
+#define MAX_VFAT_ENTRIES TERN(SCROLL_LONG_FILENAMES, 5, 2)
2014 2106
 
2015 2107
 // Nozzle park for Delta
2016 2108
 #if BOTH(NOZZLE_PARK_FEATURE, DELTA)
@@ -2022,9 +2114,8 @@
2022 2114
 // on boards where SD card and LCD display share the same SPI bus
2023 2115
 // because of a bug in the shared SPI implementation. (See #8122)
2024 2116
 #if defined(TARGET_LPC1768) && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && (SCK_PIN == LCD_PINS_D4)
2025
-  #define SDCARD_SORT_ALPHA         // Keeps one directory level in RAM. Changing
2026
-                                    // directory levels still glitches the screen,
2027
-                                    // but the following LCD update cleans it up.
2117
+  #define SDCARD_SORT_ALPHA         // Keep one directory level in RAM. Changing directory levels
2118
+                                    // may still glitch the screen, but LCD updates clean it up.
2028 2119
   #undef SDSORT_LIMIT
2029 2120
   #undef SDSORT_USES_RAM
2030 2121
   #undef SDSORT_USES_STACK
@@ -2057,19 +2148,15 @@
2057 2148
   #ifndef LCD_WIDTH
2058 2149
     #if HAS_GRAPHICAL_LCD
2059 2150
       #define LCD_WIDTH 21
2060
-    #elif ENABLED(ULTIPANEL)
2061
-      #define LCD_WIDTH 20
2062 2151
     #else
2063
-      #define LCD_WIDTH 16
2152
+      #define LCD_WIDTH TERN(ULTIPANEL, 20, 16)
2064 2153
     #endif
2065 2154
   #endif
2066 2155
   #ifndef LCD_HEIGHT
2067 2156
     #if HAS_GRAPHICAL_LCD
2068 2157
       #define LCD_HEIGHT 5
2069
-    #elif ENABLED(ULTIPANEL)
2070
-      #define LCD_HEIGHT 4
2071 2158
     #else
2072
-      #define LCD_HEIGHT 2
2159
+      #define LCD_HEIGHT TERN(ULTIPANEL, 4, 2)
2073 2160
     #endif
2074 2161
   #endif
2075 2162
 #endif

+ 32
- 1
Marlin/src/inc/SanityCheck.h Ver arquivo

@@ -34,6 +34,37 @@
34 34
   #error "Marlin requires C++11 support (gcc >= 4.7, Arduino IDE >= 1.6.8). Please upgrade your toolchain."
35 35
 #endif
36 36
 
37
+// Make sure macros aren't borked
38
+#define TEST1
39
+#define TEST2 1
40
+#define TEST3 0
41
+#define TEST4 true
42
+#if ENABLED(TEST0)
43
+  #error "ENABLED is borked!"
44
+#endif
45
+#if DISABLED(TEST1)
46
+  #error "DISABLED is borked!"
47
+#endif
48
+#if !ENABLED(TEST2)
49
+  #error "ENABLED is borked!"
50
+#endif
51
+#if ENABLED(TEST3)
52
+  #error "ENABLED is borked!"
53
+#endif
54
+#if DISABLED(TEST4)
55
+  #error "DISABLED is borked!"
56
+#endif
57
+#if !ANY(TEST1, TEST2, TEST3, TEST4) || ANY(TEST0, TEST3)
58
+  #error "ANY is borked!"
59
+#endif
60
+#if DISABLED(TEST0, TEST1, TEST2, TEST4)
61
+  #error "DISABLED is borked!"
62
+#endif
63
+#undef TEST1
64
+#undef TEST2
65
+#undef TEST3
66
+#undef TEST4
67
+
37 68
 /**
38 69
  * We try our best to include sanity checks for all changed configuration
39 70
  * directives because users have a tendency to use outdated config files with
@@ -1237,7 +1268,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
1237 1268
    * Require some kind of probe for bed leveling and probe testing
1238 1269
    */
1239 1270
   #if HAS_ABL_NOT_UBL && !PROBE_SELECTED
1240
-    #error "Auto Bed Leveling requires one of these: PROBE_MANUALLY, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, BLTOUCH, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or a Z Servo."
1271
+    #error "Auto Bed Leveling requires one of these: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or a Z Servo."
1241 1272
   #endif
1242 1273
 
1243 1274
   #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)

+ 12
- 4
Marlin/src/lcd/ultralcd.h Ver arquivo

@@ -27,10 +27,18 @@
27 27
   #include "../libs/buzzer.h"
28 28
 #endif
29 29
 
30
-#define HAS_ENCODER_ACTION (HAS_LCD_MENU || ENABLED(ULTIPANEL_FEEDMULTIPLY))
31
-#define HAS_ENCODER_WHEEL  ((!HAS_ADC_BUTTONS && ENABLED(NEWPANEL)) || BUTTONS_EXIST(EN1, EN2))
32
-#define HAS_DIGITAL_BUTTONS (HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT))
33
-#define HAS_SHIFT_ENCODER   (!HAS_ADC_BUTTONS && (ENABLED(REPRAPWORLD_KEYPAD) || (HAS_SPI_LCD && DISABLED(NEWPANEL))))
30
+#if HAS_LCD_MENU || ENABLED(ULTIPANEL_FEEDMULTIPLY)
31
+  #define HAS_ENCODER_ACTION 1
32
+#endif
33
+#if (!HAS_ADC_BUTTONS && ENABLED(NEWPANEL)) || BUTTONS_EXIST(EN1, EN2)
34
+  #define HAS_ENCODER_WHEEL 1
35
+#endif
36
+#if HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT)
37
+  #define HAS_DIGITAL_BUTTONS 1
38
+#endif
39
+#if !HAS_ADC_BUTTONS && (ENABLED(REPRAPWORLD_KEYPAD) || (HAS_SPI_LCD && DISABLED(NEWPANEL)))
40
+  #define HAS_SHIFT_ENCODER 1
41
+#endif
34 42
 
35 43
 // I2C buttons must be read in the main thread
36 44
 #define HAS_SLOW_BUTTONS EITHER(LCD_I2C_VIKI, LCD_I2C_PANELOLU2)

+ 59
- 133
Marlin/src/module/configuration_store.cpp Ver arquivo

@@ -181,11 +181,8 @@ typedef struct SettingsDataStruct {
181 181
   //
182 182
   float mbl_z_offset;                                   // mbl.z_offset
183 183
   uint8_t mesh_num_x, mesh_num_y;                       // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y
184
-  #if ENABLED(MESH_BED_LEVELING)
185
-    float mbl_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; // mbl.z_values
186
-  #else
187
-    float mbl_z_values[3][3];
188
-  #endif
184
+  float mbl_z_values[TERN(MESH_BED_LEVELING, GRID_MAX_POINTS_X, 3)]   // mbl.z_values
185
+                    [TERN(MESH_BED_LEVELING, GRID_MAX_POINTS_Y, 3)];
189 186
 
190 187
   //
191 188
   // HAS_BED_PROBE
@@ -533,11 +530,10 @@ void MarlinSettings::postprocess() {
533 530
     EEPROM_START();
534 531
 
535 532
     eeprom_error = false;
536
-    #if ENABLED(FLASH_EEPROM_EMULATION)
537
-      EEPROM_SKIP(ver);   // Flash doesn't allow rewriting without erase
538
-    #else
539
-      EEPROM_WRITE(ver);  // invalidate data first
540
-    #endif
533
+
534
+    // Write or Skip version. (Flash doesn't allow rewrite without erase.)
535
+    TERN(FLASH_EEPROM_EMULATION, EEPROM_SKIP, EEPROM_WRITE)(ver);
536
+
541 537
     EEPROM_SKIP(working_crc); // Skip the checksum slot
542 538
 
543 539
     working_crc = 0; // clear before first "real data"
@@ -564,12 +560,10 @@ void MarlinSettings::postprocess() {
564 560
         EEPROM_WRITE(planner_max_jerk);
565 561
       #endif
566 562
 
567
-      #if DISABLED(CLASSIC_JERK)
568
-        EEPROM_WRITE(planner.junction_deviation_mm);
569
-      #else
563
+      #if ENABLED(CLASSIC_JERK)
570 564
         dummyf = 0.02f;
571
-        EEPROM_WRITE(dummyf);
572 565
       #endif
566
+      EEPROM_WRITE(TERN(CLASSIC_JERK, dummyf, planner.junction_deviation_mm));
573 567
     }
574 568
 
575 569
     //
@@ -617,13 +611,7 @@ void MarlinSettings::postprocess() {
617 611
     // Global Leveling
618 612
     //
619 613
     {
620
-      const float zfh = (
621
-        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
622
-          planner.z_fade_height
623
-        #else
624
-          10.0
625
-        #endif
626
-      );
614
+      const float zfh = TERN(ENABLE_LEVELING_FADE_HEIGHT, planner.z_fade_height, 10.0f);
627 615
       EEPROM_WRITE(zfh);
628 616
     }
629 617
 
@@ -632,22 +620,24 @@ void MarlinSettings::postprocess() {
632 620
     //
633 621
     {
634 622
       #if ENABLED(MESH_BED_LEVELING)
635
-        // Compile time test that sizeof(mbl.z_values) is as expected
636 623
         static_assert(
637 624
           sizeof(mbl.z_values) == (GRID_MAX_POINTS) * sizeof(mbl.z_values[0][0]),
638 625
           "MBL Z array is the wrong size."
639 626
         );
640
-        const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
641
-        EEPROM_WRITE(mbl.z_offset);
642
-        EEPROM_WRITE(mesh_num_x);
643
-        EEPROM_WRITE(mesh_num_y);
644
-        EEPROM_WRITE(mbl.z_values);
645
-      #else // For disabled MBL write a default mesh
627
+      #else
646 628
         dummyf = 0;
647
-        const uint8_t mesh_num_x = 3, mesh_num_y = 3;
648
-        EEPROM_WRITE(dummyf); // z_offset
649
-        EEPROM_WRITE(mesh_num_x);
650
-        EEPROM_WRITE(mesh_num_y);
629
+      #endif
630
+
631
+      const uint8_t mesh_num_x = TERN(MESH_BED_LEVELING, GRID_MAX_POINTS_X, 3),
632
+                    mesh_num_y = TERN(MESH_BED_LEVELING, GRID_MAX_POINTS_Y, 3);
633
+
634
+      EEPROM_WRITE(TERN(MESH_BED_LEVELING, mbl.z_offset, dummyf));
635
+      EEPROM_WRITE(mesh_num_x);
636
+      EEPROM_WRITE(mesh_num_y);
637
+
638
+      #if ENABLED(MESH_BED_LEVELING)
639
+        EEPROM_WRITE(mbl.z_values);
640
+      #else
651 641
         for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummyf);
652 642
       #endif
653 643
     }
@@ -682,26 +672,25 @@ void MarlinSettings::postprocess() {
682 672
     //
683 673
     {
684 674
       #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
685
-        // Compile time test that sizeof(z_values) is as expected
686 675
         static_assert(
687 676
           sizeof(z_values) == (GRID_MAX_POINTS) * sizeof(z_values[0][0]),
688 677
           "Bilinear Z array is the wrong size."
689 678
         );
690
-        const uint8_t grid_max_x = GRID_MAX_POINTS_X, grid_max_y = GRID_MAX_POINTS_Y;
691
-        EEPROM_WRITE(grid_max_x);            // 1 byte
692
-        EEPROM_WRITE(grid_max_y);            // 1 byte
693
-        EEPROM_WRITE(bilinear_grid_spacing); // 2 ints
694
-        EEPROM_WRITE(bilinear_start);        // 2 ints
695
-        EEPROM_WRITE(z_values);              // 9-256 floats
696 679
       #else
697
-        // For disabled Bilinear Grid write an empty 3x3 grid
698
-        const uint8_t grid_max_x = 3, grid_max_y = 3;
699 680
         const xy_pos_t bilinear_start{0}, bilinear_grid_spacing{0};
681
+      #endif
682
+
683
+      const uint8_t grid_max_x = TERN(AUTO_BED_LEVELING_BILINEAR, GRID_MAX_POINTS_X, 3),
684
+                    grid_max_y = TERN(AUTO_BED_LEVELING_BILINEAR, GRID_MAX_POINTS_Y, 3);
685
+      EEPROM_WRITE(grid_max_x);
686
+      EEPROM_WRITE(grid_max_y);
687
+      EEPROM_WRITE(bilinear_grid_spacing);
688
+      EEPROM_WRITE(bilinear_start);
689
+
690
+      #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
691
+        EEPROM_WRITE(z_values);              // 9-256 floats
692
+      #else
700 693
         dummyf = 0;
701
-        EEPROM_WRITE(grid_max_x);
702
-        EEPROM_WRITE(grid_max_y);
703
-        EEPROM_WRITE(bilinear_grid_spacing);
704
-        EEPROM_WRITE(bilinear_start);
705 694
         for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummyf);
706 695
       #endif
707 696
     }
@@ -711,16 +700,10 @@ void MarlinSettings::postprocess() {
711 700
     //
712 701
     {
713 702
       _FIELD_TEST(planner_leveling_active);
714
-
715
-      #if ENABLED(AUTO_BED_LEVELING_UBL)
716
-        EEPROM_WRITE(planner.leveling_active);
717
-        EEPROM_WRITE(ubl.storage_slot);
718
-      #else
719
-        const bool ubl_active = false;
720
-        const int8_t storage_slot = -1;
721
-        EEPROM_WRITE(ubl_active);
722
-        EEPROM_WRITE(storage_slot);
723
-      #endif // AUTO_BED_LEVELING_UBL
703
+      const bool ubl_active = TERN(AUTO_BED_LEVELING_UBL, planner.leveling_active, false);
704
+      const int8_t storage_slot = TERN(AUTO_BED_LEVELING_UBL, ubl.storage_slot, -1);
705
+      EEPROM_WRITE(ubl_active);
706
+      EEPROM_WRITE(storage_slot);
724 707
     }
725 708
 
726 709
     //
@@ -728,7 +711,6 @@ void MarlinSettings::postprocess() {
728 711
     //
729 712
     {
730 713
       _FIELD_TEST(servo_angles);
731
-
732 714
       #if !HAS_SERVO_ANGLES
733 715
         uint16_t servo_angles[EEPROM_NUM_SERVOS][2] = { { 0, 0 } };
734 716
       #endif
@@ -753,11 +735,7 @@ void MarlinSettings::postprocess() {
753 735
     //
754 736
     {
755 737
       _FIELD_TEST(bltouch_last_written_mode);
756
-      #if ENABLED(BLTOUCH)
757
-        const bool &bltouch_last_written_mode = bltouch.last_written_mode;
758
-      #else
759
-        constexpr bool bltouch_last_written_mode = false;
760
-      #endif
738
+      const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false);
761 739
       EEPROM_WRITE(bltouch_last_written_mode);
762 740
     }
763 741
 
@@ -782,23 +760,9 @@ void MarlinSettings::postprocess() {
782 760
 
783 761
         // Write dual endstops in X, Y, Z order. Unused = 0.0
784 762
         dummyf = 0;
785
-        #if ENABLED(X_DUAL_ENDSTOPS)
786
-          EEPROM_WRITE(endstops.x2_endstop_adj);   // 1 float
787
-        #else
788
-          EEPROM_WRITE(dummyf);
789
-        #endif
790
-
791
-        #if ENABLED(Y_DUAL_ENDSTOPS)
792
-          EEPROM_WRITE(endstops.y2_endstop_adj);   // 1 float
793
-        #else
794
-          EEPROM_WRITE(dummyf);
795
-        #endif
796
-
797
-        #if ENABLED(Z_MULTI_ENDSTOPS)
798
-          EEPROM_WRITE(endstops.z2_endstop_adj);   // 1 float
799
-        #else
800
-          EEPROM_WRITE(dummyf);
801
-        #endif
763
+        EEPROM_WRITE(TERN(X_DUAL_ENDSTOPS, endstops.x2_endstop_adj, dummyf));   // 1 float
764
+        EEPROM_WRITE(TERN(Y_DUAL_ENDSTOPS, endstops.y2_endstop_adj, dummyf));   // 1 float
765
+        EEPROM_WRITE(TERN(Z_MULTI_ENDSTOPS, endstops.z2_endstop_adj, dummyf));  // 1 float
802 766
 
803 767
         #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3
804 768
           EEPROM_WRITE(endstops.z3_endstop_adj);   // 1 float
@@ -865,12 +829,10 @@ void MarlinSettings::postprocess() {
865 829
       }
866 830
 
867 831
       _FIELD_TEST(lpq_len);
868
-      #if ENABLED(PID_EXTRUSION_SCALING)
869
-        EEPROM_WRITE(thermalManager.lpq_len);
870
-      #else
832
+      #if DISABLED(PID_EXTRUSION_SCALING)
871 833
         const int16_t lpq_len = 20;
872
-        EEPROM_WRITE(lpq_len);
873 834
       #endif
835
+      EEPROM_WRITE(TERN(PID_EXTRUSION_SCALING, thermalManager.lpq_len, lpq_len));
874 836
     }
875 837
 
876 838
     //
@@ -911,8 +873,6 @@ void MarlinSettings::postprocess() {
911 873
       const int16_t lcd_contrast =
912 874
         #if HAS_LCD_CONTRAST
913 875
           ui.contrast
914
-        #elif defined(DEFAULT_LCD_CONTRAST)
915
-          DEFAULT_LCD_CONTRAST
916 876
         #else
917 877
           127
918 878
         #endif
@@ -925,14 +885,7 @@ void MarlinSettings::postprocess() {
925 885
     //
926 886
     {
927 887
       _FIELD_TEST(recovery_enabled);
928
-
929
-      const bool recovery_enabled =
930
-        #if ENABLED(POWER_LOSS_RECOVERY)
931
-          recovery.enabled
932
-        #else
933
-          PLR_ENABLED_DEFAULT
934
-        #endif
935
-      ;
888
+      const bool recovery_enabled = TERN(POWER_LOSS_RECOVERY, recovery.enabled, ENABLED(PLR_ENABLED_DEFAULT));
936 889
       EEPROM_WRITE(recovery_enabled);
937 890
     }
938 891
 
@@ -941,19 +894,15 @@ void MarlinSettings::postprocess() {
941 894
     //
942 895
     {
943 896
       _FIELD_TEST(fwretract_settings);
944
-
945
-      #if ENABLED(FWRETRACT)
946
-        EEPROM_WRITE(fwretract.settings);
947
-      #else
897
+      #if DISABLED(FWRETRACT)
948 898
         const fwretract_settings_t autoretract_defaults = { 3, 45, 0, 0, 0, 13, 0, 8 };
949
-        EEPROM_WRITE(autoretract_defaults);
950 899
       #endif
951
-      #if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT)
952
-        EEPROM_WRITE(fwretract.autoretract_enabled);
953
-      #else
900
+      EEPROM_WRITE(TERN(FWRETRACT, fwretract.settings, autoretract_defaults));
901
+
902
+      #if DISABLED(FWRETRACT_AUTORETRACT)
954 903
         const bool autoretract_enabled = false;
955
-        EEPROM_WRITE(autoretract_enabled);
956 904
       #endif
905
+      EEPROM_WRITE(TERN(FWRETRACT_AUTORETRACT, fwretract.autoretract_enabled, autoretract_enabled));
957 906
     }
958 907
 
959 908
     //
@@ -1270,12 +1219,10 @@ void MarlinSettings::postprocess() {
1270 1219
 
1271 1220
     _FIELD_TEST(coordinate_system);
1272 1221
 
1273
-    #if ENABLED(CNC_COORDINATE_SYSTEMS)
1274
-      EEPROM_WRITE(gcode.coordinate_system);
1275
-    #else
1222
+    #if DISABLED(CNC_COORDINATE_SYSTEMS)
1276 1223
       const xyz_pos_t coordinate_system[MAX_COORDINATE_SYSTEMS] = { { 0 } };
1277
-      EEPROM_WRITE(coordinate_system);
1278 1224
     #endif
1225
+    EEPROM_WRITE(TERN(CNC_COORDINATE_SYSTEMS, gcode.coordinate_system, coordinate_system));
1279 1226
 
1280 1227
     //
1281 1228
     // Skew correction factors
@@ -1448,11 +1395,7 @@ void MarlinSettings::postprocess() {
1448 1395
           for (uint8_t q = 4; q--;) EEPROM_READ(dummyf);
1449 1396
         #endif
1450 1397
 
1451
-        #if DISABLED(CLASSIC_JERK)
1452
-          EEPROM_READ(planner.junction_deviation_mm);
1453
-        #else
1454
-          EEPROM_READ(dummyf);
1455
-        #endif
1398
+        EEPROM_READ(TERN(CLASSIC_JERK, dummyf, planner.junction_deviation_mm));
1456 1399
       }
1457 1400
 
1458 1401
       //
@@ -1504,13 +1447,7 @@ void MarlinSettings::postprocess() {
1504 1447
       //
1505 1448
       // Global Leveling
1506 1449
       //
1507
-      {
1508
-        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1509
-          EEPROM_READ(new_z_fade_height);
1510
-        #else
1511
-          EEPROM_READ(dummyf);
1512
-        #endif
1513
-      }
1450
+      EEPROM_READ(TERN(ENABLE_LEVELING_FADE_HEIGHT, new_z_fade_height, dummyf));
1514 1451
 
1515 1452
       //
1516 1453
       // Mesh (Manual) Bed Leveling
@@ -1662,21 +1599,10 @@ void MarlinSettings::postprocess() {
1662 1599
 
1663 1600
           _FIELD_TEST(x2_endstop_adj);
1664 1601
 
1665
-          #if ENABLED(X_DUAL_ENDSTOPS)
1666
-            EEPROM_READ(endstops.x2_endstop_adj);  // 1 float
1667
-          #else
1668
-            EEPROM_READ(dummyf);
1669
-          #endif
1670
-          #if ENABLED(Y_DUAL_ENDSTOPS)
1671
-            EEPROM_READ(endstops.y2_endstop_adj);  // 1 float
1672
-          #else
1673
-            EEPROM_READ(dummyf);
1674
-          #endif
1675
-          #if ENABLED(Z_MULTI_ENDSTOPS)
1676
-            EEPROM_READ(endstops.z2_endstop_adj); // 1 float
1677
-          #else
1678
-            EEPROM_READ(dummyf);
1679
-          #endif
1602
+          EEPROM_READ(TERN(X_DUAL_ENDSTOPS, endstops.x2_endstop_adj, dummyf));  // 1 float
1603
+          EEPROM_READ(TERN(Y_DUAL_ENDSTOPS, endstops.y2_endstop_adj, dummyf));  // 1 float
1604
+          EEPROM_READ(TERN(Z_MULTI_ENDSTOPS, endstops.z2_endstop_adj, dummyf)); // 1 float
1605
+
1680 1606
           #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3
1681 1607
             EEPROM_READ(endstops.z3_endstop_adj); // 1 float
1682 1608
           #else
@@ -2667,7 +2593,7 @@ void MarlinSettings::reset() {
2667 2593
   //
2668 2594
 
2669 2595
   #if ENABLED(POWER_LOSS_RECOVERY)
2670
-    recovery.enable(PLR_ENABLED_DEFAULT);
2596
+    recovery.enable(ENABLED(PLR_ENABLED_DEFAULT));
2671 2597
   #endif
2672 2598
 
2673 2599
   //

+ 6
- 18
Marlin/src/module/motion.cpp Ver arquivo

@@ -1208,15 +1208,9 @@ feedRate_t get_homing_bump_feedrate(const AxisEnum axis) {
1208 1208
 
1209 1209
     #if ENABLED(SPI_ENDSTOPS)
1210 1210
       switch (axis) {
1211
-        #if X_SPI_SENSORLESS
1212
-          case X_AXIS: endstops.tmc_spi_homing.x = true; break;
1213
-        #endif
1214
-        #if Y_SPI_SENSORLESS
1215
-          case Y_AXIS: endstops.tmc_spi_homing.y = true; break;
1216
-        #endif
1217
-        #if Z_SPI_SENSORLESS
1218
-          case Z_AXIS: endstops.tmc_spi_homing.z = true; break;
1219
-        #endif
1211
+        case X_AXIS: if (ENABLED(X_SPI_SENSORLESS)) endstops.tmc_spi_homing.x = true; break;
1212
+        case Y_AXIS: if (ENABLED(Y_SPI_SENSORLESS)) endstops.tmc_spi_homing.y = true; break;
1213
+        case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = true; break;
1220 1214
         default: break;
1221 1215
       }
1222 1216
     #endif
@@ -1280,15 +1274,9 @@ feedRate_t get_homing_bump_feedrate(const AxisEnum axis) {
1280 1274
 
1281 1275
     #if ENABLED(SPI_ENDSTOPS)
1282 1276
       switch (axis) {
1283
-        #if X_SPI_SENSORLESS
1284
-          case X_AXIS: endstops.tmc_spi_homing.x = false; break;
1285
-        #endif
1286
-        #if Y_SPI_SENSORLESS
1287
-          case Y_AXIS: endstops.tmc_spi_homing.y = false; break;
1288
-        #endif
1289
-        #if Z_SPI_SENSORLESS
1290
-          case Z_AXIS: endstops.tmc_spi_homing.z = false; break;
1291
-        #endif
1277
+        case X_AXIS: if (ENABLED(X_SPI_SENSORLESS)) endstops.tmc_spi_homing.x = false; break;
1278
+        case Y_AXIS: if (ENABLED(Y_SPI_SENSORLESS)) endstops.tmc_spi_homing.y = false; break;
1279
+        case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = false; break;
1292 1280
         default: break;
1293 1281
       }
1294 1282
     #endif

+ 6
- 4
Marlin/src/module/motion.h Ver arquivo

@@ -375,11 +375,13 @@ void homeaxis(const AxisEnum axis);
375 375
 
376 376
   FORCE_INLINE int x_home_dir(const uint8_t extruder) { return extruder ? X2_HOME_DIR : X_HOME_DIR; }
377 377
 
378
-#elif ENABLED(MULTI_NOZZLE_DUPLICATION)
378
+#else
379 379
 
380
-  enum DualXMode : char {
381
-    DXC_DUPLICATION_MODE = 2
382
-  };
380
+  #if ENABLED(MULTI_NOZZLE_DUPLICATION)
381
+    enum DualXMode : char { DXC_DUPLICATION_MODE = 2 };
382
+  #endif
383
+
384
+  FORCE_INLINE int x_home_dir(const uint8_t) { return home_dir(X_AXIS); }
383 385
 
384 386
 #endif
385 387
 

+ 1
- 1
Marlin/src/module/probe.h Ver arquivo

@@ -177,7 +177,7 @@ public:
177 177
       // Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
178 178
       template <typename T>
179 179
       static inline void get_three_points(T points[3]) {
180
-        #if ENABLED(HAS_FIXED_3POINT)
180
+        #if HAS_FIXED_3POINT
181 181
           points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
182 182
           points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
183 183
           points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);

+ 1
- 5
Marlin/src/sd/cardreader.h Ver arquivo

@@ -276,11 +276,7 @@ private:
276 276
 #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
277 277
   #define IS_SD_INSERTED() Sd2Card::isInserted()
278 278
 #elif PIN_EXISTS(SD_DETECT)
279
-  #if ENABLED(SD_DETECT_INVERTED)
280
-    #define IS_SD_INSERTED()  READ(SD_DETECT_PIN)
281
-  #else
282
-    #define IS_SD_INSERTED() !READ(SD_DETECT_PIN)
283
-  #endif
279
+  #define IS_SD_INSERTED() (READ(SD_DETECT_PIN) != ENABLED(SD_DETECT_INVERTED))
284 280
 #else
285 281
   // No card detect line? Assume the card is inserted.
286 282
   #define IS_SD_INSERTED() true

Carregando…
Cancelar
Salvar