Browse Source

Add alternative TERN macros

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
06bf3ccfb7
  1. 2
      Marlin/src/MarlinCore.cpp
  2. 3
      Marlin/src/core/macros.h
  3. 4
      Marlin/src/feature/backlash.h
  4. 2
      Marlin/src/feature/leds/neopixel.h
  5. 2
      Marlin/src/lcd/dogm/marlinui_DOGM.cpp
  6. 3
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h
  7. 2
      Marlin/src/lcd/menu/menu.cpp
  8. 4
      Marlin/src/lcd/menu/menu_advanced.cpp
  9. 2
      Marlin/src/lcd/menu/menu_filament.cpp
  10. 2
      Marlin/src/lcd/menu/menu_ubl.cpp
  11. 6
      Marlin/src/module/settings.cpp
  12. 2
      Marlin/src/module/stepper.cpp
  13. 2
      Marlin/src/module/temperature.cpp
  14. 2
      Marlin/src/module/temperature.h
  15. 8
      Marlin/src/module/tool_change.cpp

2
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

3
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)

4
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() {

2
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

2
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);

3
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)

2
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];

4
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();
}

2
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) { \

2
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));

6
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();

2
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};

2
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

2
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

8
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();
}

Loading…
Cancel
Save