Browse Source

Add alternative TERN macros

Scott Lahteine 4 years ago
parent
commit
06bf3ccfb7

+ 1
- 1
Marlin/src/MarlinCore.cpp View File

@@ -248,7 +248,7 @@ bool wait_for_heatup = true;
248 248
   bool wait_for_user; // = false;
249 249
 
250 250
   void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) {
251
-    TERN(ADVANCED_PAUSE_FEATURE,,UNUSED(no_sleep));
251
+    UNUSED(no_sleep);
252 252
     KEEPALIVE_STATE(PAUSED_FOR_USER);
253 253
     wait_for_user = true;
254 254
     if (ms) ms += millis(); // expire time

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

@@ -196,6 +196,9 @@
196 196
 #define __TERN(T,V...)      ___TERN(_CAT(_NO,T),V)  // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
197 197
 #define ___TERN(P,V...)     THIRD(P,V)              // If first argument has a comma, A. Else B.
198 198
 
199
+#define IF_ENABLED          TERN_
200
+#define IF_DISABLED(O,A)    TERN(O,,A)
201
+
199 202
 #define ANY(V...)          !DISABLED(V)
200 203
 #define NONE(V...)          DISABLED(V)
201 204
 #define ALL(V...)           ENABLED(V)

+ 2
- 2
Marlin/src/feature/backlash.h View File

@@ -54,17 +54,17 @@ public:
54 54
   #endif
55 55
 
56 56
   static inline float get_measurement(const AxisEnum a) {
57
+    UNUSED(a);
57 58
     // Return the measurement averaged over all readings
58 59
     return TERN(MEASURE_BACKLASH_WHEN_PROBING
59 60
       , measured_count[a] > 0 ? measured_mm[a] / measured_count[a] : 0
60 61
       , 0
61 62
     );
62
-    TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a));
63 63
   }
64 64
 
65 65
   static inline bool has_measurement(const AxisEnum a) {
66
+    UNUSED(a);
66 67
     return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0);
67
-    TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a));
68 68
   }
69 69
 
70 70
   static inline bool has_any_measurement() {

+ 1
- 1
Marlin/src/feature/leds/neopixel.h View File

@@ -110,7 +110,7 @@ public:
110 110
       #if CONJOINED_NEOPIXEL
111 111
         adaneo2.show();
112 112
       #else
113
-        TERN(NEOPIXEL2_SEPARATE,,adaneo1.setPin(NEOPIXEL2_PIN));
113
+        IF_DISABLED(NEOPIXEL2_SEPARATE, adaneo1.setPin(NEOPIXEL2_PIN));
114 114
         adaneo1.show();
115 115
         adaneo1.setPin(NEOPIXEL_PIN);
116 116
       #endif

+ 1
- 1
Marlin/src/lcd/dogm/marlinui_DOGM.cpp View File

@@ -123,7 +123,7 @@ bool MarlinUI::detected() { return true; }
123 123
           custom_start_bmp
124 124
         #endif
125 125
       ;
126
-      TERN(CUSTOM_BOOTSCREEN_ANIMATED,,UNUSED(frame));
126
+      UNUSED(frame);
127 127
 
128 128
       u8g.drawBitmapP(left, top, CUSTOM_BOOTSCREEN_BMP_BYTEWIDTH, CUSTOM_BOOTSCREEN_BMPHEIGHT, bmp);
129 129
 

+ 3
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h View File

@@ -253,6 +253,9 @@
253 253
   #define __TERN(T,V...)      ___TERN(_CAT(_NO,T),V)  // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
254 254
   #define ___TERN(P,V...)     THIRD(P,V)              // If first argument has a comma, A. Else B.
255 255
 
256
+  #define IF_ENABLED          TERN_
257
+  #define IF_DISABLED(O,A)    _TERN(_ENA_1(O),,A)
258
+
256 259
   #define ANY(V...)          !DISABLED(V)
257 260
   #define NONE(V...)          DISABLED(V)
258 261
   #define ALL(V...)           ENABLED(V)

+ 1
- 1
Marlin/src/lcd/menu/menu.cpp View File

@@ -81,7 +81,7 @@ void MarlinUI::save_previous_screen() {
81 81
 }
82 82
 
83 83
 void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
84
-  TERN(TURBO_BACK_MENU_ITEM,,constexpr bool is_back = false);
84
+  IF_DISABLED(TURBO_BACK_MENU_ITEM, constexpr bool is_back = false);
85 85
   TERN_(HAS_TOUCH_XPT2046, on_edit_screen = false);
86 86
   if (screen_history_depth > 0) {
87 87
     menuPosition &sh = screen_history[--screen_history_depth];

+ 2
- 2
Marlin/src/lcd/menu/menu_advanced.cpp View File

@@ -202,12 +202,12 @@ void menu_backlash();
202 202
   // Helpers for editing PID Ki & Kd values
203 203
   // grab the PID value out of the temp variable; scale it; then update the PID driver
204 204
   void copy_and_scalePID_i(int16_t e) {
205
-    TERN(PID_PARAMS_PER_HOTEND,,UNUSED(e));
205
+    UNUSED(e);
206 206
     PID_PARAM(Ki, e) = scalePID_i(raw_Ki);
207 207
     thermalManager.updatePID();
208 208
   }
209 209
   void copy_and_scalePID_d(int16_t e) {
210
-    TERN(PID_PARAMS_PER_HOTEND,,UNUSED(e));
210
+    UNUSED(e);
211 211
     PID_PARAM(Kd, e) = scalePID_d(raw_Kd);
212 212
     thermalManager.updatePID();
213 213
   }

+ 1
- 1
Marlin/src/lcd/menu/menu_filament.cpp View File

@@ -219,7 +219,7 @@ static PGM_P pause_header() {
219 219
 #define HOTEND_STATUS_ITEM() do { \
220 220
   if (_menuLineNr == _thisItemNr) { \
221 221
     if (ui.should_draw()) { \
222
-      TERN(HAS_GRAPHICAL_TFT,, MenuItem_static::draw(_lcdLineNr, GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT)); \
222
+      IF_DISABLED(HAS_GRAPHICAL_TFT, MenuItem_static::draw(_lcdLineNr, GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT)); \
223 223
       ui.draw_hotend_status(_lcdLineNr, hotend_status_extruder); \
224 224
     } \
225 225
     if (_skipStatic && encoderLine <= _thisItemNr) { \

+ 1
- 1
Marlin/src/lcd/menu/menu_ubl.cpp View File

@@ -64,7 +64,7 @@ static void _lcd_mesh_fine_tune(PGM_P const msg) {
64 64
       ubl.encoder_diff > 0 ? 0.005f : -0.005f
65 65
     );
66 66
     ubl.encoder_diff = 0;
67
-    TERN(IS_TFTGLCD_PANEL,,ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
67
+    IF_DISABLED(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
68 68
   }
69 69
   TERN_(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
70 70
 

+ 3
- 3
Marlin/src/module/settings.cpp View File

@@ -1497,7 +1497,7 @@ void MarlinSettings::postprocess() {
1497 1497
       }
1498 1498
       DEBUG_ECHO_START();
1499 1499
       DEBUG_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")");
1500
-      TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_version());
1500
+      IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version());
1501 1501
       eeprom_error = true;
1502 1502
     }
1503 1503
     else {
@@ -2325,13 +2325,13 @@ void MarlinSettings::postprocess() {
2325 2325
       if (eeprom_error) {
2326 2326
         DEBUG_ECHO_START();
2327 2327
         DEBUG_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize());
2328
-        TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_index());
2328
+        IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_index());
2329 2329
       }
2330 2330
       else if (working_crc != stored_crc) {
2331 2331
         eeprom_error = true;
2332 2332
         DEBUG_ERROR_START();
2333 2333
         DEBUG_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!");
2334
-        TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_crc());
2334
+        IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_crc());
2335 2335
       }
2336 2336
       else if (!validating) {
2337 2337
         DEBUG_ECHO_START();

+ 1
- 1
Marlin/src/module/stepper.cpp View File

@@ -180,7 +180,7 @@ bool Stepper::abort_current_block;
180 180
 uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
181 181
 uint8_t Stepper::steps_per_isr;
182 182
 
183
-TERN(ADAPTIVE_STEP_SMOOTHING,,constexpr) uint8_t Stepper::oversampling_factor;
183
+IF_DISABLED(ADAPTIVE_STEP_SMOOTHING, constexpr) uint8_t Stepper::oversampling_factor;
184 184
 
185 185
 xyze_long_t Stepper::delta_error{0};
186 186
 

+ 1
- 1
Marlin/src/module/temperature.cpp View File

@@ -268,7 +268,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
268 268
     int16_t Temperature::maxtemp_raw_BED = HEATER_BED_RAW_HI_TEMP;
269 269
   #endif
270 270
   TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 }
271
-  TERN(PIDTEMPBED,, millis_t Temperature::next_bed_check_ms);
271
+  IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms);
272 272
 #endif // HAS_HEATED_BED
273 273
 
274 274
 #if HAS_TEMP_CHAMBER

+ 1
- 1
Marlin/src/module/temperature.h View File

@@ -392,7 +392,7 @@ class Temperature {
392 392
 
393 393
     #if HAS_HEATED_BED
394 394
       TERN_(WATCH_BED, static bed_watch_t watch_bed);
395
-      TERN(PIDTEMPBED,,static millis_t next_bed_check_ms);
395
+      IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms);
396 396
       #ifdef BED_MINTEMP
397 397
         static int16_t mintemp_raw_BED;
398 398
       #endif

+ 4
- 4
Marlin/src/module/tool_change.cpp View File

@@ -799,8 +799,8 @@ void tool_change_prime() {
799 799
     // Park
800 800
     #if ENABLED(TOOLCHANGE_PARK)
801 801
       if (ok) {
802
-        TERN(TOOLCHANGE_PARK_Y_ONLY,,current_position.x = toolchange_settings.change_point.x);
803
-        TERN(TOOLCHANGE_PARK_X_ONLY,,current_position.y = toolchange_settings.change_point.y);
802
+        IF_DISABLED(TOOLCHANGE_PARK_Y_ONLY, current_position.x = toolchange_settings.change_point.x);
803
+        IF_DISABLED(TOOLCHANGE_PARK_X_ONLY, current_position.y = toolchange_settings.change_point.y);
804 804
         planner.buffer_line(current_position, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE), active_extruder);
805 805
         planner.synchronize();
806 806
       }
@@ -998,8 +998,8 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
998 998
       // Toolchange park
999 999
       #if ENABLED(TOOLCHANGE_PARK) && DISABLED(SWITCHING_NOZZLE)
1000 1000
         if (can_move_away && toolchange_settings.enable_park) {
1001
-          TERN(TOOLCHANGE_PARK_Y_ONLY,,current_position.x = toolchange_settings.change_point.x);
1002
-          TERN(TOOLCHANGE_PARK_X_ONLY,,current_position.y = toolchange_settings.change_point.y);
1001
+          IF_DISABLED(TOOLCHANGE_PARK_Y_ONLY, current_position.x = toolchange_settings.change_point.x);
1002
+          IF_DISABLED(TOOLCHANGE_PARK_X_ONLY, current_position.y = toolchange_settings.change_point.y);
1003 1003
           planner.buffer_line(current_position, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE), old_tool);
1004 1004
           planner.synchronize();
1005 1005
         }

Loading…
Cancel
Save