From f94c2cba460c2fd85a3447ea91a7e38d51fad887 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Wed, 22 Jun 2022 07:22:08 +0200 Subject: [PATCH] Fix rendering temp. + toolchange on MMU error screen --- Firmware/mmu2_reporting.cpp | 24 ++++++++---------------- Firmware/ultralcd.cpp | 21 +++++++++++---------- Firmware/ultralcd.h | 2 ++ 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index 84b2ff5a6..5290ec966 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -27,26 +27,18 @@ void EndReport(CommandInProgress cip, uint16_t ec) { * @brief Renders any characters that will be updated live on the MMU error screen. *Currently, this is FINDA and Filament Sensor status and Extruder temperature. */ -extern void ReportErrorHookDynamicRender(void) -{ - lcd_set_cursor(3, 2); - lcd_printf_P(PSTR("%d"), mmu2.FindaDetectsFilament()); +extern void ReportErrorHookDynamicRender(void){ + // beware - this optimization abuses the fact, that FindaDetectsFilament returns 0 or 1 and '0' is followed by '1' in the ASCII table + lcd_putc_at(3, 2, mmu2.FindaDetectsFilament() + '0'); + lcd_putc_at(8, 2, fsensor.getFilamentPresent() + '0'); - 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/changing filament slot + lcd_set_cursor(10, 2); + lcdui_print_extruder(); // Print active extruder temperature lcd_set_cursor(16, 2); - lcd_printf_P(PSTR("%d"), (int)(degHotend(0) + 0.5)); + lcd_printf_P(PSTR("%3d"), (int)(degHotend(0) + 0.5)); } /** diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 4ccf41bcc..dae03e8f7 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -463,7 +463,7 @@ void lcdui_print_percent_done(void) // [nr1.] ranges from 1 to 5. // [nr2.] ranges from 1 to 5. // Filament [nr1.] was loaded, but [nr2.] is currently being loaded via tool change -void lcdui_print_extruder(void) { +uint8_t lcdui_print_extruder(void) { uint8_t chars = 0; if (MMU2::mmu2.get_current_tool() == MMU2::mmu2.get_tool_change_tool()) { if (MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN) { @@ -478,7 +478,7 @@ void lcdui_print_extruder(void) { chars = lcd_printf_P(_N(" %u>%u"), MMU2::mmu2.get_current_tool() + 1, MMU2::mmu2.get_tool_change_tool() + 1); } } - lcd_space(5 - chars); + return chars; } // Print farm number (5 chars total) @@ -737,14 +737,15 @@ void lcdui_print_status_screen(void) //Print SD status (7 chars) lcdui_print_percent_done(); - if (MMU2::mmu2.Enabled()) - //Print extruder status (5 chars) - lcdui_print_extruder(); - else if (farm_mode) - //Print farm number (5 chars) - lcdui_print_farm(); - else - lcd_space(5); //5 spaces + if (MMU2::mmu2.Enabled()) { + // Print extruder status (5 chars) + lcd_space(5 - lcdui_print_extruder()); + } else if (farm_mode) { + // Print farm number (5 chars) + lcdui_print_farm(); + } else { + lcd_space(5); // 5 spaces + } #ifdef CMD_DIAGNOSTICS //Print cmd queue diagnostics (8chars) diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 8d5fbfb45..5441198a3 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -242,6 +242,8 @@ void lcd_wizard(WizState state); extern void lcd_experimental_toggle(); extern void lcd_experimental_menu(); +uint8_t lcdui_print_extruder(void); + #ifdef PINDA_TEMP_COMP extern void lcd_pinda_temp_compensation_toggle(); #endif //PINDA_TEMP_COMP