Restore the previous model state when performing a nozzle change

Do not force-enable the model if it was previously disabled.

Fix cherry-pick issue lcd_show_fullscreen_message_yes_no_and_wait_P
This commit is contained in:
Yuri D'Elia 2022-12-12 20:15:59 +01:00 committed by 3d-gussner
parent f194bb1242
commit f81b2a00c1
3 changed files with 13 additions and 6 deletions

View File

@ -2509,6 +2509,11 @@ static void temp_model_reset_enabled(bool enabled)
temp_model::data.flag_bits.uninitialized = true; temp_model::data.flag_bits.uninitialized = true;
} }
bool temp_model_enabled()
{
return temp_model::enabled;
}
void temp_model_set_enabled(bool enabled) void temp_model_set_enabled(bool enabled)
{ {
// set the enabled flag // set the enabled flag

View File

@ -217,6 +217,7 @@ FORCE_INLINE void autotempShutdown(){
void PID_autotune(float temp, int extruder, int ncycles); void PID_autotune(float temp, int extruder, int ncycles);
#ifdef TEMP_MODEL #ifdef TEMP_MODEL
bool temp_model_enabled(); // return temperature model state
void temp_model_set_enabled(bool enabled); void temp_model_set_enabled(bool enabled);
void temp_model_set_warn_beep(bool enabled); void temp_model_set_warn_beep(bool enabled);
void temp_model_set_params(float C = NAN, float P = NAN, float Ta_corr = NAN, float warn = NAN, float err = NAN); void temp_model_set_params(float C = NAN, float P = NAN, float Ta_corr = NAN, float warn = NAN, float err = NAN);

View File

@ -1085,6 +1085,9 @@ void lcd_commands()
{ {
if (!blocks_queued() && cmd_buffer_empty() && !saved_printing) if (!blocks_queued() && cmd_buffer_empty() && !saved_printing)
{ {
#ifdef TEMP_MODEL
static bool was_enabled;
#endif //TEMP_MODEL
switch(lcd_commands_step) switch(lcd_commands_step)
{ {
case 0: case 0:
@ -1099,7 +1102,7 @@ void lcd_commands()
enquecommand_P(PSTR("G1 X125 Y10 Z150 F1000")); enquecommand_P(PSTR("G1 X125 Y10 Z150 F1000"));
enquecommand_P(PSTR("M109 S280")); enquecommand_P(PSTR("M109 S280"));
#ifdef TEMP_MODEL #ifdef TEMP_MODEL
//enquecommand_P(PSTR("M310 S0")); was_enabled = temp_model_enabled();
temp_model_set_enabled(false); temp_model_set_enabled(false);
#endif //TEMP_MODEL #endif //TEMP_MODEL
lcd_commands_step = 2; lcd_commands_step = 2;
@ -1113,13 +1116,11 @@ void lcd_commands()
enquecommand_P(PSTR("M84 XY")); enquecommand_P(PSTR("M84 XY"));
lcd_update_enabled = false; //hack to avoid lcd_update recursion. lcd_update_enabled = false; //hack to avoid lcd_update recursion.
if (lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_NOZZLE_CNG_CHANGED), false, true)) { if (lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_NOZZLE_CNG_CHANGED), false, true)) {
setAllTargetHotends(0);
#ifdef TEMP_MODEL #ifdef TEMP_MODEL
//enquecommand_P(PSTR("M310 S1")); temp_model_set_enabled(was_enabled);
temp_model_set_enabled(true);
#endif //TEMP_MODEL #endif //TEMP_MODEL
//enquecommand_P(PSTR("M104 S0")); lcd_commands_step = 1;
setTargetHotendSafe(0,0);
lcd_commands_step = 1;
} }
lcd_update_enabled = true; lcd_update_enabled = true;
break; break;