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
This commit is contained in:
Guðni Már Gilbert 2022-11-19 21:19:36 +00:00 committed by DRracer
parent 439fb4ad4a
commit 62810c5a7c
1 changed files with 15 additions and 12 deletions

View File

@ -441,24 +441,27 @@ void lcdui_print_percent_done(void)
// Scenario 3: "?>[nr.]" // Scenario 3: "?>[nr.]"
// [nr.] ranges from 1 to 5. // [nr.] ranges from 1 to 5.
// There is no filament currently loaded, but [nr.] is currently being loaded via tool change // 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. // [nr1.] ranges from 1 to 5.
// [nr2.] ranges from 1 to 5. // [nr2.] ranges from 1 to 5.
// Filament [nr1.] was loaded, but [nr2.] is currently being loaded via tool change // 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 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() == MMU2::mmu2.get_tool_change_tool()) {
if (MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN) { lcd_putc('F');
chars = lcd_printf_P(_N(" F?")); lcd_putc(MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? '?' : MMU2::mmu2.get_current_tool() + 1);
} else { chars += 2;
chars = lcd_printf_P(_N(" F%u"), MMU2::mmu2.get_current_tool() + 1);
}
} else { } else {
if (MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN) { lcd_putc(MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? '?' : MMU2::mmu2.get_current_tool() + 1);
chars = lcd_printf_P(_N(" ?>%u"), MMU2::mmu2.get_tool_change_tool() + 1); lcd_putc('>');
} else { lcd_putc(MMU2::mmu2.get_tool_change_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? '?' : MMU2::mmu2.get_tool_change_tool() + 1);
chars = lcd_printf_P(_N(" %u>%u"), MMU2::mmu2.get_current_tool() + 1, MMU2::mmu2.get_tool_change_tool() + 1); chars += 3;
}
} }
return chars; return chars;
} }