wizard: Rework the thermal model calibration logic

- Correctly sequence the enqueued commands in order to check for the
  real calibration result.
- Perform autocalibration with self-check enabled.
- Only save/continue the wizard if autocalibration succeeds.
This commit is contained in:
Yuri D'Elia 2022-12-12 17:50:24 +01:00 committed by 3d-gussner
parent 6d83a494d6
commit 4ce808c98b

View file

@ -1041,27 +1041,35 @@ void lcd_commands()
lcd_commands_type = LcdCommands::Idle; lcd_commands_type = LcdCommands::Idle;
} }
} }
#ifdef TEMP_MODEL #ifdef TEMP_MODEL
if (lcd_commands_type == LcdCommands::TempModel) { if (lcd_commands_type == LcdCommands::TempModel && cmd_buffer_empty())
if (lcd_commands_step == 0) { {
switch (lcd_commands_step)
{
case 0:
lcd_commands_step = 3; lcd_commands_step = 3;
} [[fallthrough]];
if (lcd_commands_step == 3) {
enquecommand_P(PSTR("M310 A F0")); case 3:
enquecommand_P(PSTR("M310 A F1"));
lcd_commands_step = 2; lcd_commands_step = 2;
} break;
if (lcd_commands_step ==2 && temp_model_valid()) {
enquecommand_P(PSTR("M310 S1")); case 2:
if (temp_model_autotune_result())
enquecommand_P(PSTR("M500"));
lcd_commands_step = 1; lcd_commands_step = 1;
} break;
//if (lcd_commands_step == 1 && calibrated()) {
if (lcd_commands_step == 1 && temp_model_valid()) { case 1:
lcd_commands_step = 0; lcd_commands_step = 0;
lcd_commands_type = LcdCommands::Idle; lcd_commands_type = LcdCommands::Idle;
enquecommand_P(PSTR("M500")); if ((eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) && temp_model_autotune_result()) {
if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) { // calibration successful, resume the wizard
lcd_wizard(WizState::IsFil); lcd_wizard(WizState::IsFil);
} }
break;
} }
} }
#endif //TEMP_MODEL #endif //TEMP_MODEL
@ -4271,10 +4279,6 @@ void lcd_wizard(WizState state)
case S::Z: //z cal. case S::Z: //z cal.
msg = _T(MSG_WIZARD_CALIBRATION_FAILED); msg = _T(MSG_WIZARD_CALIBRATION_FAILED);
break; break;
#ifdef TEMP_MODEL
case S::TempModel: //Temp model calibration
break;
#endif //TEMP_MODEL
case S::Finish: //we are finished case S::Finish: //we are finished
msg = _T(MSG_WIZARD_DONE); msg = _T(MSG_WIZARD_DONE);
lcd_reset_alert_level(); lcd_reset_alert_level();
@ -4284,6 +4288,9 @@ void lcd_wizard(WizState state)
case S::Preheat: case S::Preheat:
case S::Lay1CalCold: case S::Lay1CalCold:
case S::Lay1CalHot: case S::Lay1CalHot:
#ifdef TEMP_MODEL
case S::TempModel: // exiting for calibration
#endif //TEMP_MODEL
break; break;
default: default:
msg = _T(MSG_WIZARD_QUIT); msg = _T(MSG_WIZARD_QUIT);