Add alternative TERN macros

This commit is contained in:
Scott Lahteine
2020-11-07 18:28:29 -06:00
parent 5bf82b34c6
commit 367e717aeb
15 changed files with 26 additions and 20 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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