From 9b6fca92144b372fdf79db0a3f8981f5635fb0c2 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 28 Mar 2021 16:39:02 +0200 Subject: [PATCH] Introduce lcd_show_yes_no_and_wait for future use Split off yes/no lcd handling from lcd_show_fullscreen_message_yes_no_and_wait_P into a separate function in order to allow generic requests where the text prompt can change. --- Firmware/ultralcd.cpp | 22 ++++++++++++++++------ Firmware/ultralcd.h | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index a3ee0c452..e7841712c 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3579,18 +3579,14 @@ int8_t lcd_show_multiscreen_message_two_choices_and_wait_P(const char *msg, bool } } -//! @brief Show single screen message with yes and no possible choices and wait with possible timeout -//! @param msg Message to show +//! @brief Display and wait for a Yes/No choice using the last two lines of the LCD //! @param allow_timeouting if true, allows time outing of the screen //! @param default_yes if true, yes choice is selected by default, otherwise no choice is preselected //! @retval 1 yes choice selected by user //! @retval 0 no choice selected by user //! @retval -1 screen timed out -int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting, bool default_yes) +int8_t lcd_show_yes_no_and_wait(bool allow_timeouting, bool default_yes) { - - lcd_display_message_fullscreen_P(msg); - if (default_yes) { lcd_putc_at(0, 2, '>'); lcd_puts_P(_T(MSG_YES)); @@ -3643,6 +3639,20 @@ int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow return retval; } +//! @brief Show single screen message with yes and no possible choices and wait with possible timeout +//! @param msg Message to show +//! @param allow_timeouting if true, allows time outing of the screen +//! @param default_yes if true, yes choice is selected by default, otherwise no choice is preselected +//! @retval 1 yes choice selected by user +//! @retval 0 no choice selected by user +//! @retval -1 screen timed out +//! @relates lcd_show_yes_no_and_wait +int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting, bool default_yes) +{ + lcd_display_message_fullscreen_P(msg); + return lcd_show_yes_no_and_wait(allow_timeouting, default_yes); +} + void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, uint8_t point_too_far_mask) { const char *msg = NULL; diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 36fcad573..d8ea9b479 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -72,6 +72,8 @@ extern void lcd_wait_for_click(); extern bool lcd_wait_for_click_delay(uint16_t nDelay); extern void lcd_show_fullscreen_message_and_wait_P(const char *msg); // 0: no, 1: yes, -1: timeouted +extern int8_t lcd_show_yes_no_and_wait(bool allow_timeouting = true, bool default_yes = false); +// 0: no, 1: yes, -1: timeouted extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false); extern int8_t lcd_show_multiscreen_message_two_choices_and_wait_P(const char *msg, bool allow_timeouting, bool default_yes, const char *first_choice, const char *second_choice);