diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index e395bdccb..be3dcdd10 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -248,7 +248,7 @@ bool wait_for_heatup = true; bool wait_for_user; // = false; void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) { - TERN(ADVANCED_PAUSE_FEATURE,,UNUSED(no_sleep)); + UNUSED(no_sleep); KEEPALIVE_STATE(PAUSED_FOR_USER); wait_for_user = true; if (ms) ms += millis(); // expire time diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 7948e8ce8..798570617 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -196,6 +196,9 @@ #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' #define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. +#define IF_ENABLED TERN_ +#define IF_DISABLED(O,A) TERN(O,,A) + #define ANY(V...) !DISABLED(V) #define NONE(V...) DISABLED(V) #define ALL(V...) ENABLED(V) diff --git a/Marlin/src/feature/backlash.h b/Marlin/src/feature/backlash.h index 8d00570f9..49857f1f9 100644 --- a/Marlin/src/feature/backlash.h +++ b/Marlin/src/feature/backlash.h @@ -54,17 +54,17 @@ public: #endif static inline float get_measurement(const AxisEnum a) { + UNUSED(a); // Return the measurement averaged over all readings return TERN(MEASURE_BACKLASH_WHEN_PROBING , measured_count[a] > 0 ? measured_mm[a] / measured_count[a] : 0 , 0 ); - TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a)); } static inline bool has_measurement(const AxisEnum a) { + UNUSED(a); return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0); - TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a)); } static inline bool has_any_measurement() { diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 42046fa56..d7354207f 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -110,7 +110,7 @@ public: #if CONJOINED_NEOPIXEL adaneo2.show(); #else - TERN(NEOPIXEL2_SEPARATE,,adaneo1.setPin(NEOPIXEL2_PIN)); + IF_DISABLED(NEOPIXEL2_SEPARATE, adaneo1.setPin(NEOPIXEL2_PIN)); adaneo1.show(); adaneo1.setPin(NEOPIXEL_PIN); #endif diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 0aba49d56..480721e56 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -123,7 +123,7 @@ bool MarlinUI::detected() { return true; } custom_start_bmp #endif ; - TERN(CUSTOM_BOOTSCREEN_ANIMATED,,UNUSED(frame)); + UNUSED(frame); u8g.drawBitmapP(left, top, CUSTOM_BOOTSCREEN_BMP_BYTEWIDTH, CUSTOM_BOOTSCREEN_BMPHEIGHT, bmp); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h index cd41a5fe0..0f4bbbdb9 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h @@ -253,6 +253,9 @@ #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' #define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. + #define IF_ENABLED TERN_ + #define IF_DISABLED(O,A) _TERN(_ENA_1(O),,A) + #define ANY(V...) !DISABLED(V) #define NONE(V...) DISABLED(V) #define ALL(V...) ENABLED(V) diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index cd9492704..35c736c56 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -81,7 +81,7 @@ void MarlinUI::save_previous_screen() { } void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) { - TERN(TURBO_BACK_MENU_ITEM,,constexpr bool is_back = false); + IF_DISABLED(TURBO_BACK_MENU_ITEM, constexpr bool is_back = false); TERN_(HAS_TOUCH_XPT2046, on_edit_screen = false); if (screen_history_depth > 0) { menuPosition &sh = screen_history[--screen_history_depth]; diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 0e207ffc5..fdddf1781 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -202,12 +202,12 @@ void menu_backlash(); // Helpers for editing PID Ki & Kd values // grab the PID value out of the temp variable; scale it; then update the PID driver void copy_and_scalePID_i(int16_t e) { - TERN(PID_PARAMS_PER_HOTEND,,UNUSED(e)); + UNUSED(e); PID_PARAM(Ki, e) = scalePID_i(raw_Ki); thermalManager.updatePID(); } void copy_and_scalePID_d(int16_t e) { - TERN(PID_PARAMS_PER_HOTEND,,UNUSED(e)); + UNUSED(e); PID_PARAM(Kd, e) = scalePID_d(raw_Kd); thermalManager.updatePID(); } diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index d116a6a39..5f0afa476 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -219,7 +219,7 @@ static PGM_P pause_header() { #define HOTEND_STATUS_ITEM() do { \ if (_menuLineNr == _thisItemNr) { \ if (ui.should_draw()) { \ - TERN(HAS_GRAPHICAL_TFT,, MenuItem_static::draw(_lcdLineNr, GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT)); \ + IF_DISABLED(HAS_GRAPHICAL_TFT, MenuItem_static::draw(_lcdLineNr, GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT)); \ ui.draw_hotend_status(_lcdLineNr, hotend_status_extruder); \ } \ if (_skipStatic && encoderLine <= _thisItemNr) { \ diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index f0f5c21be..5dce47eec 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -64,7 +64,7 @@ static void _lcd_mesh_fine_tune(PGM_P const msg) { ubl.encoder_diff > 0 ? 0.005f : -0.005f ); ubl.encoder_diff = 0; - TERN(IS_TFTGLCD_PANEL,,ui.refresh(LCDVIEW_CALL_REDRAW_NEXT)); + IF_DISABLED(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT)); } TERN_(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT)); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index fc432b7e9..b1b9bb6e0 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1497,7 +1497,7 @@ void MarlinSettings::postprocess() { } DEBUG_ECHO_START(); DEBUG_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); - TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_version()); + IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version()); eeprom_error = true; } else { @@ -2325,13 +2325,13 @@ void MarlinSettings::postprocess() { if (eeprom_error) { DEBUG_ECHO_START(); DEBUG_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize()); - TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_index()); + IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_index()); } else if (working_crc != stored_crc) { eeprom_error = true; DEBUG_ERROR_START(); DEBUG_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); - TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_crc()); + IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_crc()); } else if (!validating) { DEBUG_ECHO_START(); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 0a83a90ba..627ecf9eb 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -180,7 +180,7 @@ bool Stepper::abort_current_block; uint32_t Stepper::acceleration_time, Stepper::deceleration_time; uint8_t Stepper::steps_per_isr; -TERN(ADAPTIVE_STEP_SMOOTHING,,constexpr) uint8_t Stepper::oversampling_factor; +IF_DISABLED(ADAPTIVE_STEP_SMOOTHING, constexpr) uint8_t Stepper::oversampling_factor; xyze_long_t Stepper::delta_error{0}; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 40f8624ef..4eb721651 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -268,7 +268,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, int16_t Temperature::maxtemp_raw_BED = HEATER_BED_RAW_HI_TEMP; #endif TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 } - TERN(PIDTEMPBED,, millis_t Temperature::next_bed_check_ms); + IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms); #endif // HAS_HEATED_BED #if HAS_TEMP_CHAMBER diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 4b27fff19..c3c3ce2d8 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -392,7 +392,7 @@ class Temperature { #if HAS_HEATED_BED TERN_(WATCH_BED, static bed_watch_t watch_bed); - TERN(PIDTEMPBED,,static millis_t next_bed_check_ms); + IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms); #ifdef BED_MINTEMP static int16_t mintemp_raw_BED; #endif diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 1cdafe019..0d0ef4605 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -799,8 +799,8 @@ void tool_change_prime() { // Park #if ENABLED(TOOLCHANGE_PARK) if (ok) { - TERN(TOOLCHANGE_PARK_Y_ONLY,,current_position.x = toolchange_settings.change_point.x); - TERN(TOOLCHANGE_PARK_X_ONLY,,current_position.y = toolchange_settings.change_point.y); + IF_DISABLED(TOOLCHANGE_PARK_Y_ONLY, current_position.x = toolchange_settings.change_point.x); + IF_DISABLED(TOOLCHANGE_PARK_X_ONLY, current_position.y = toolchange_settings.change_point.y); planner.buffer_line(current_position, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE), active_extruder); planner.synchronize(); } @@ -998,8 +998,8 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { // Toolchange park #if ENABLED(TOOLCHANGE_PARK) && DISABLED(SWITCHING_NOZZLE) if (can_move_away && toolchange_settings.enable_park) { - TERN(TOOLCHANGE_PARK_Y_ONLY,,current_position.x = toolchange_settings.change_point.x); - TERN(TOOLCHANGE_PARK_X_ONLY,,current_position.y = toolchange_settings.change_point.y); + IF_DISABLED(TOOLCHANGE_PARK_Y_ONLY, current_position.x = toolchange_settings.change_point.x); + IF_DISABLED(TOOLCHANGE_PARK_X_ONLY, current_position.y = toolchange_settings.change_point.y); planner.buffer_line(current_position, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE), old_tool); planner.synchronize(); }