Apply TERN to compact code (#17619)

This commit is contained in:
Scott Lahteine
2020-04-22 16:35:03 -05:00
committed by GitHub
parent 88bdd26c99
commit 6d90d1e1f5
162 changed files with 1493 additions and 3530 deletions

View File

@@ -141,9 +141,7 @@ void MenuItem_gcode::action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pg
* MenuItem_int3::draw(encoderLine == _thisItemNr, _lcdLineNr, plabel, &feedrate_percentage, 10, 999)
*/
void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) {
#if ENABLED(TOUCH_BUTTONS)
ui.repeat_delay = BUTTON_DELAY_EDIT;
#endif
TERN_(TOUCH_BUTTONS, ui.repeat_delay = BUTTON_DELAY_EDIT);
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
if (ui.should_draw())
@@ -222,13 +220,9 @@ bool printer_busy() {
void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) {
if (currentScreen != screen) {
#if ENABLED(TOUCH_BUTTONS)
repeat_delay = BUTTON_DELAY_MENU;
#endif
TERN_(TOUCH_BUTTONS, repeat_delay = BUTTON_DELAY_MENU);
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
progress_reset();
#endif
TERN_(LCD_SET_PROGRESS_MANUALLY, progress_reset());
#if BOTH(DOUBLECLICK_FOR_Z_BABYSTEPPING, BABYSTEPPING)
static millis_t doubleclick_expire_ms = 0;
@@ -275,9 +269,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
screen_items = items;
if (screen == status_screen) {
defer_status_screen(false);
#if ENABLED(AUTO_BED_LEVELING_UBL)
ubl.lcd_map_control = false;
#endif
TERN_(AUTO_BED_LEVELING_UBL, ubl.lcd_map_control = false);
screen_history_depth = 0;
}
@@ -294,13 +286,9 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
refresh(LCDVIEW_CALL_REDRAW_NEXT);
screen_changed = true;
#if HAS_GRAPHICAL_LCD
drawing_screen = false;
#endif
TERN_(HAS_GRAPHICAL_LCD, drawing_screen = false);
#if HAS_LCD_MENU
encoder_direction_normal();
#endif
TERN_(HAS_LCD_MENU, encoder_direction_normal());
set_selection(false);
}
@@ -400,10 +388,10 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
babystep.add_steps(Z_AXIS, babystep_increment);
if (do_probe) probe.offset.z = new_offs;
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
else hotend_offset[active_extruder].z = new_offs;
#endif
if (do_probe)
probe.offset.z = new_offs;
else
TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP);
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
}
@@ -415,9 +403,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
#endif
if (do_probe) {
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), BABYSTEP_TO_STR(probe.offset.z));
#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
_lcd_zoffset_overlay_gfx(probe.offset.z);
#endif
TERN_(BABYSTEP_ZPROBE_GFX_OVERLAY, _lcd_zoffset_overlay_gfx(probe.offset.z));
}
}
}
@@ -427,16 +413,12 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
#if ENABLED(EEPROM_SETTINGS)
void lcd_store_settings() {
const bool saved = settings.save();
#if HAS_BUZZER
ui.completion_feedback(saved);
#endif
TERN_(HAS_BUZZER, ui.completion_feedback(saved));
UNUSED(saved);
}
void lcd_load_settings() {
const bool loaded = settings.load();
#if HAS_BUZZER
ui.completion_feedback(loaded);
#endif
TERN_(HAS_BUZZER, ui.completion_feedback(loaded));
UNUSED(loaded);
}
#endif