Don't enable lcd update inside mmu_eject_filament().

This commit is contained in:
Marek Bel 2018-09-17 17:05:11 +02:00
parent f496076508
commit a687b8e64a
2 changed files with 31 additions and 7 deletions

View file

@ -150,6 +150,29 @@ extern void lcd_update_enable(uint8_t enabled);
extern void lcd_buttons_update(void);
//! @brief Helper class to temporarily disable LCD updates
//!
//! When constructed (on stack), original state state of lcd_update_enabled is stored
//! and LCD updates are disabled.
//! When destroyed (gone out of scope), original state of LCD update is restored.
//! It has zero overhead compared to storing bool saved = lcd_update_enabled
//! and calling lcd_update_enable(false) and lcd_update_enable(saved).
class LcdUpdateDisabler
{
public:
LcdUpdateDisabler(): m_updateEnabled(lcd_update_enabled)
{
lcd_update_enable(false);
}
~LcdUpdateDisabler()
{
lcd_update_enable(m_updateEnabled);
}
private:
bool m_updateEnabled;
};

View file

@ -1012,14 +1012,15 @@ void mmu_eject_filament(uint8_t filament, bool recover)
if (degHotend0() > EXTRUDE_MINTEMP)
{
st_synchronize();
lcd_update_enable(false);
lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_i("Ejecting filament"));
current_position[E_AXIS] -= 80;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
st_synchronize();
lcd_update_enable(true);
{
LcdUpdateDisabler disableLcdUpdate;
lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_i("Ejecting filament"));
current_position[E_AXIS] -= 80;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
st_synchronize();
}
mmu_command(MMU_CMD_E0 + filament);
manage_response(false, false);