From 1c26875e0e729ce6bc339f1e746c0a9f767e2096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Thu, 26 May 2022 09:42:25 +0000 Subject: [PATCH] PFW-1318 Implement callback to render status line To render the thermometer and degree symbols the CGRAM table will instead swap out the feedrate and clock symbol when lcd_set_custom_characters_nextpage() is called. --- Firmware/lcd.h | 4 ++-- Firmware/mmu2/errors_list.h | 2 +- Firmware/mmu2_reporting.cpp | 37 +++++++++++++++++++++++++++++++++++-- Firmware/ultralcd.cpp | 10 +++++++++- Firmware/ultralcd.h | 3 ++- 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/Firmware/lcd.h b/Firmware/lcd.h index 7331131ad..8ac643f58 100644 --- a/Firmware/lcd.h +++ b/Firmware/lcd.h @@ -165,14 +165,14 @@ extern void lcd_buttons_update(void); //Custom characters defined in the first 8 characters of the LCD #define LCD_STR_BEDTEMP "\x00" #define LCD_STR_DEGREE "\x01" -#define LCD_STR_ARROW_2_DOWN "\x01" #define LCD_STR_THERMOMETER "\x02" -#define LCD_STR_CONFIRM "\x02" #define LCD_STR_UPLEVEL "\x03" #define LCD_STR_REFRESH "\x04" #define LCD_STR_FOLDER "\x05" #define LCD_STR_FEEDRATE "\x06" +#define LCD_STR_ARROW_2_DOWN "\x06" #define LCD_STR_CLOCK "\x07" +#define LCD_STR_CONFIRM "\x07" #define LCD_STR_ARROW_RIGHT "\x7E" //from the default character set #define LCD_STR_SOLID_BLOCK "\xFF" //from the default character set diff --git a/Firmware/mmu2/errors_list.h b/Firmware/mmu2/errors_list.h index 2580f347f..1b4f32074 100644 --- a/Firmware/mmu2/errors_list.h +++ b/Firmware/mmu2/errors_list.h @@ -274,7 +274,7 @@ static const char btnRestartMMU[] PROGMEM_I1 = ISTR("RstMMU"); static const char btnUnload[] PROGMEM_I1 = ISTR("Unload"); static const char btnStop[] PROGMEM_I1 = ISTR("Stop"); static const char btnDisableMMU[] PROGMEM_I1 = ISTR("Disable"); -static const char btnMore[] PROGMEM_I1 = ISTR("More\x01"); +static const char btnMore[] PROGMEM_I1 = ISTR("More\x06"); // Used to parse the buttons from Btns(). static const char * const btnOperation[] PROGMEM = { diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index ff2d01b3f..3b9ca0637 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -1,8 +1,10 @@ +#include "mmu2.h" #include "mmu2_reporting.h" #include "mmu2_error_converter.h" #include "mmu2/error_codes.h" #include "mmu2/buttons.h" #include "ultralcd.h" +#include "Filament_sensor.h" #include "language.h" namespace MMU2 { @@ -19,13 +21,39 @@ void EndReport(CommandInProgress cip, uint16_t ec) { custom_message_type = CustomMsg::Status; } +// Callback which is called while the printer is +// waiting for the user to click a button option +static void ReportErrorHook_cb(void) +{ + //TODO: MK3S needs to request an update for the FINDA value + // if we want it to be updated live on the menu screen + lcd_set_cursor(3, 2); + lcd_printf_P(PSTR("%d"), mmu2.FindaDetectsFilament()); + + lcd_set_cursor(8, 2); + lcd_printf_P(PSTR("%d"), fsensor.getFilamentPresent()); + + lcd_set_cursor(11, 2); + lcd_print("?>?"); // This is temporary until below TODO is resolved + + // TODO, see lcdui_print_extruder(void) + //if (MMU2::mmu2.get_current_tool() == MMU2::FILAMENT_UNKNOWN) + // lcd_printf_P(_N(" ?>%u"), tmp_extruder + 1); + //else + // lcd_printf_P(_N(" %u>%u"), MMU2::mmu2.get_current_tool() + 1, tmp_extruder + 1); + + // Print active extruder temperature + lcd_set_cursor(16, 2); + lcd_printf_P(PSTR("%d"), (int)(degHotend(0) + 0.5)); +} + void ReportErrorHook(CommandInProgress cip, uint16_t ec) { //! Show an error screen //! When an MMU error occurs, the LCD content will look like this: //! |01234567890123456789| //! |MMU FW update needed| <- title/header of the error: max 20 characters //! |prusa3d.com/ERR04504| <- URL 20 characters - //! | | <- empty line + //! |FI:1 FS:1 5>3 t201°| <- status line, t is thermometer symbol //! |>Retry >Done >MoreW| <- buttons const uint8_t ei = PrusaErrorCodeIndex(ec); uint8_t choice_selected = 0; @@ -51,6 +79,10 @@ back_to_choices: // Print title and header lcd_printf_P(PSTR("%.20S\nprusa3d.com/ERR04%hu"), _T(PrusaErrorTitle(ei)), PrusaErrorCode(ei) ); + // Render static characters in third line + lcd_set_cursor(0, 2); + lcd_printf_P(PSTR("FI: FS: > %c %c"), LCD_STR_THERMOMETER[0], LCD_STR_DEGREE[0]); + // Render the choices and store selection in 'choice_selected' choice_selected = lcd_show_multiscreen_message_with_choices_and_wait_P( NULL, // NULL, since title screen is not in PROGMEM @@ -61,7 +93,8 @@ back_to_choices: two_choices ? nullptr : _T(PrusaErrorButtonMore()), two_choices ? 10 // If two choices, allow the first choice to have more characters - : 7 + : 7, + ReportErrorHook_cb ); if ((two_choices && choice_selected == MIDDLE_BUTTON_CHOICE) // Two choices and middle button selected diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 72db24ebe..7d2e6f035 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3220,12 +3220,14 @@ void lcd_show_choices_prompt_P(uint8_t selected, const char *first_choice, const //! @param second_choice text caption of second possible choice. Must be in PROGMEM //! @param third_choice text caption of second possible choice. Must be in PROGMEM. When not set to nullptr first_choice and second_choice may not be more than 5 characters long. //! @param second_col column on LCD where second_choice starts +//! @param multiscreen_cb an optional call back that will be called periodically when the printer is paused for user //! @retval 0 first choice selected by user //! @retval 1 first choice selected by user //! @retval 2 third choice selected by user //! @retval -1 screen timed out (only possible if allow_timeouting is true) int8_t lcd_show_multiscreen_message_with_choices_and_wait_P(const char * const msg, bool allow_timeouting, uint8_t default_selection, - const char * const first_choice, const char * const second_choice, const char * const third_choice, uint8_t second_col) + const char * const first_choice, const char * const second_choice, const char * const third_choice, uint8_t second_col, + void (*multiscreen_cb)(void)) { const char *msg_next = msg ? lcd_display_message_fullscreen_P(msg) : NULL; bool multi_screen = msg_next != NULL; @@ -3251,6 +3253,12 @@ int8_t lcd_show_multiscreen_message_with_choices_and_wait_P(const char * const m manage_heater(); manage_inactivity(true); + if (multiscreen_cb) + { + multiscreen_cb(); + } + + if (abs(enc_dif - lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP) { if (msg_next == NULL) { if (third_choice) diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 717e9950c..d097165c5 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -82,7 +82,8 @@ extern int8_t lcd_show_yes_no_and_wait(bool allow_timeouting = true, uint8_t def // 1: no, 0: yes, -1: timeouted extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, uint8_t default_selection = MIDDLE_BUTTON_CHOICE); extern int8_t lcd_show_multiscreen_message_with_choices_and_wait_P(const char * const msg, bool allow_timeouting, uint8_t default_selection, - const char * const first_choice, const char * const second_choice, const char * const third_choice = nullptr, uint8_t second_col = 7); + const char * const first_choice, const char * const second_choice, const char * const third_choice = nullptr, uint8_t second_col = 7, + void (*multiscreen_cb)(void) = nullptr); extern int8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, uint8_t default_selection = MIDDLE_BUTTON_CHOICE); // Ask the user to move the Z axis up to the end stoppers and let // the user confirm that it has been done.