From aee04a43e202fdcb5a7d4c558c581a0d9a553e17 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 28 Apr 2021 17:13:46 +0200 Subject: [PATCH] Redraw "Preheating to load" in full when modified by other actions Check for lcd_draw_update to see if the lcd has been altered outside the function and redraw the screen if full. This fixes scenarios such as #3129 where the "Card removed" message or the SD menu is entered from outside the function's control. This requires checking/resetting bFilamentWaitingFlag carefully to avoid re-entering this function _twice_ (raise_z_above will run the main loop until complete). --- Firmware/ultralcd.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index b0ba7d34e..ac8426ae8 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2201,14 +2201,21 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed) } else { - if (!bFilamentWaitingFlag) + if (!bFilamentWaitingFlag || lcd_draw_update) { - // First run after the filament preheat selection: - // setup the fixed LCD parts and raise Z as we wait + // First entry from another menu OR first run after the filament preheat selection. Use + // bFilamentWaitingFlag to distinguish: this flag is reset exactly once when entering + // the menu and is used to raise the carriage *once*. In other cases, the LCD has been + // modified elsewhere and needs to be redrawn in full. + + // reset bFilamentWaitingFlag immediately to avoid re-entry from raise_z_above()! + bool once = !bFilamentWaitingFlag; bFilamentWaitingFlag = true; - lcd_clear(); + // also force-enable lcd_draw_update (might be 0 when called from outside a menu) lcd_draw_update = 1; + + lcd_clear(); lcd_puts_at_P(0, 3, _i(">Cancel")); ////MSG_ c=20 r=1 lcd_set_cursor(0, 1); @@ -2218,12 +2225,12 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed) case FilamentAction::AutoLoad: case FilamentAction::MmuLoad: lcd_puts_P(_i("Preheating to load")); ////MSG_ c=20 - raise_z_above(MIN_Z_FOR_LOAD); + if (once) raise_z_above(MIN_Z_FOR_LOAD); break; case FilamentAction::UnLoad: case FilamentAction::MmuUnLoad: lcd_puts_P(_i("Preheating to unload")); ////MSG_ c=20 - raise_z_above(MIN_Z_FOR_UNLOAD); + if (once) raise_z_above(MIN_Z_FOR_UNLOAD); break; case FilamentAction::MmuEject: lcd_puts_P(_i("Preheating to eject")); ////MSG_ c=20