From 62810c5a7cf44a2aac076f8a3a1c3a38cc6c8886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 19 Nov 2022 21:19:36 +0000 Subject: [PATCH] optimisation: lcdui_print_extruder Simplify the rendering to cover more scenarios: "[nr.]>?" "?>?" Both of these indicate there is a bug in the firmware. Currently these are not handled and result in the status screen being corrupted. This is because we are trying to write a 3 digit number where there is not space on the LCD for it. Change in memory: Flash: -52 bytes SRAM: 0 bytes --- Firmware/ultralcd.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 52dade610..7c7bf24e6 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -441,24 +441,27 @@ void lcdui_print_percent_done(void) // Scenario 3: "?>[nr.]" // [nr.] ranges from 1 to 5. // There is no filament currently loaded, but [nr.] is currently being loaded via tool change -// Scenario 4: "[nr1.] > [nr2.]" +// Scenario 4: "[nr.]>?" +// [nr.] ranges from 1 to 5. +// This scenario indicates a bug in the firmware if ? is on the right side +// Scenario 5: "[nr1.]>[nr2.]" // [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 +// Scenario 6: "?>?" +// This scenario should not be possible and indicates a bug in the firmware uint8_t lcdui_print_extruder(void) { - uint8_t chars = 0; + uint8_t chars = 1; + lcd_space(1); if (MMU2::mmu2.get_current_tool() == MMU2::mmu2.get_tool_change_tool()) { - if (MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN) { - chars = lcd_printf_P(_N(" F?")); - } else { - chars = lcd_printf_P(_N(" F%u"), MMU2::mmu2.get_current_tool() + 1); - } + lcd_putc('F'); + lcd_putc(MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? '?' : MMU2::mmu2.get_current_tool() + 1); + chars += 2; } else { - if (MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN) { - chars = lcd_printf_P(_N(" ?>%u"), MMU2::mmu2.get_tool_change_tool() + 1); - } else { - chars = lcd_printf_P(_N(" %u>%u"), MMU2::mmu2.get_current_tool() + 1, MMU2::mmu2.get_tool_change_tool() + 1); - } + lcd_putc(MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? '?' : MMU2::mmu2.get_current_tool() + 1); + lcd_putc('>'); + lcd_putc(MMU2::mmu2.get_tool_change_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? '?' : MMU2::mmu2.get_tool_change_tool() + 1); + chars += 3; } return chars; }