Update do_select_screen for general use (#13800)

This commit is contained in:
Scott Lahteine
2019-04-24 10:13:44 -05:00
committed by GitHub
parent 63f6ad3fd2
commit 5051909c3c
16 changed files with 144 additions and 123 deletions

View File

@ -268,6 +268,8 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
#if HAS_GRAPHICAL_LCD
drawing_screen = false;
#endif
set_ui_selection(false);
}
}
@ -436,12 +438,21 @@ void _lcd_draw_homing() {
void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(!planner.leveling_active); }
#endif
void do_select_screen(PGM_P const yes, PGM_P const no, bool &yesno, PGM_P const pref, const char * const string, PGM_P const suff) {
//
// Selection screen presents a prompt and two options
//
bool ui_selection; // = false
void set_ui_selection(const bool sel) { ui_selection = sel; }
void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string/*=NULL*/, PGM_P const suff/*=NULL*/) {
if (ui.encoderPosition) {
yesno = int16_t(ui.encoderPosition) > 0;
ui_selection = int16_t(ui.encoderPosition) > 0;
ui.encoderPosition = 0;
}
draw_select_screen(yes, no, yesno, pref, string, suff);
const bool got_click = ui.use_click();
if (got_click || ui.should_draw()) {
draw_select_screen(yes, no, ui_selection, pref, string, suff);
if (got_click) { ui_selection ? yesFunc() : noFunc(); }
}
}
#endif // HAS_LCD_MENU