wizard: Rewrite the wizard handling loop
Simplify status tracking: - S::Restore to continue to the next logical wizard item - S::Finish for a successful failure - S::Failed to exit while showing a failure
This commit is contained in:
parent
8a43aa0024
commit
d478aa5c5e
|
|
@ -758,9 +758,10 @@ static void factory_reset(char level)
|
||||||
case 3: // Level 3: Preparation after being serviced
|
case 3: // Level 3: Preparation after being serviced
|
||||||
// Force language selection at the next boot up.
|
// Force language selection at the next boot up.
|
||||||
lang_reset();
|
lang_reset();
|
||||||
// Force the "Follow calibration flow" message at the next boot up.
|
|
||||||
calibration_status_store(CALIBRATION_STATUS_Z_CALIBRATION);
|
// Force the wizard in "Follow calibration flow" mode at the next boot up
|
||||||
eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 2); //run wizard
|
calibration_status_clear(CALIBRATION_FORCE_PREP);
|
||||||
|
eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 2);
|
||||||
farm_disable();
|
farm_disable();
|
||||||
|
|
||||||
#ifdef FILAMENT_SENSOR
|
#ifdef FILAMENT_SENSOR
|
||||||
|
|
|
||||||
|
|
@ -952,10 +952,8 @@ void lcd_commands()
|
||||||
lcd_setstatuspgm(MSG_WELCOME);
|
lcd_setstatuspgm(MSG_WELCOME);
|
||||||
lcd_commands_step = 0;
|
lcd_commands_step = 0;
|
||||||
lcd_commands_type = LcdCommands::Idle;
|
lcd_commands_type = LcdCommands::Idle;
|
||||||
if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1)
|
if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE))
|
||||||
{
|
|
||||||
lcd_wizard(WizState::RepeatLay1Cal);
|
lcd_wizard(WizState::RepeatLay1Cal);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3976,14 +3974,13 @@ void lcd_v2_calibration()
|
||||||
|
|
||||||
void lcd_wizard() {
|
void lcd_wizard() {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
if (calibration_status() != CALIBRATION_STATUS_ASSEMBLED) {
|
if (calibration_status_get(CALIBRATION_WIZARD_STEPS)) {
|
||||||
result = lcd_show_multiscreen_message_yes_no_and_wait_P(_i("Running Wizard will delete current calibration results and start from the beginning. Continue?"), false, false);////MSG_WIZARD_RERUN c=20 r=7
|
// calibration already performed: ask before clearing the previous status
|
||||||
|
result = !lcd_show_multiscreen_message_yes_no_and_wait_P(_i("Running Wizard will delete current calibration results and start from the beginning. Continue?"), false);////MSG_WIZARD_RERUN c=20 r=7
|
||||||
}
|
}
|
||||||
if (result) {
|
if (result) {
|
||||||
calibration_status_store(CALIBRATION_STATUS_ASSEMBLED);
|
|
||||||
lcd_wizard(WizState::Run);
|
lcd_wizard(WizState::Run);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
lcd_return_to_status();
|
lcd_return_to_status();
|
||||||
lcd_update_enable(true);
|
lcd_update_enable(true);
|
||||||
lcd_update(2);
|
lcd_update(2);
|
||||||
|
|
@ -4134,52 +4131,56 @@ void lcd_wizard(WizState state)
|
||||||
saved_printing = false;
|
saved_printing = false;
|
||||||
|
|
||||||
if( eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)==2){
|
if( eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)==2){
|
||||||
|
// printer pre-assembled: finish remaining steps
|
||||||
lcd_show_fullscreen_message_and_wait_P(_T(MSG_WIZARD_WELCOME_SHIPPING));
|
lcd_show_fullscreen_message_and_wait_P(_T(MSG_WIZARD_WELCOME_SHIPPING));
|
||||||
state = S::Restore;
|
state = S::Restore;
|
||||||
} else {
|
} else {
|
||||||
wizard_event = lcd_show_multiscreen_message_yes_no_and_wait_P(_T(MSG_WIZARD_WELCOME), false, true);
|
// new printer, factory reset or manual invocation
|
||||||
if (wizard_event) {
|
wizard_event = lcd_show_multiscreen_message_yes_no_and_wait_P(_T(MSG_WIZARD_WELCOME), false, LCD_LEFT_BUTTON_CHOICE);
|
||||||
|
if (wizard_event == LCD_LEFT_BUTTON_CHOICE) {
|
||||||
state = S::Restore;
|
state = S::Restore;
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1);
|
eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1);
|
||||||
|
calibration_status_clear(CALIBRATION_WIZARD_STEPS);
|
||||||
} else {
|
} else {
|
||||||
|
// user interrupted
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 0);
|
eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 0);
|
||||||
end = true;
|
end = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case S::Restore:
|
case S::Restore:
|
||||||
switch (calibration_status()) {
|
// clear any previous error for make _new_ errors visible
|
||||||
case CALIBRATION_STATUS_ASSEMBLED: state = S::Selftest; break; //run selftest
|
lcd_reset_alert_level();
|
||||||
case CALIBRATION_STATUS_XYZ_CALIBRATION: state = S::Xyz; break; //run xyz cal.
|
|
||||||
case CALIBRATION_STATUS_Z_CALIBRATION: state = S::Z; break; //run z cal.
|
// determine the next step in the required order
|
||||||
|
if (!calibration_status_get(CALIBRATION_STATUS_SELFTEST)) {
|
||||||
|
state = S::Selftest;
|
||||||
|
} else if (!calibration_status_get(CALIBRATION_STATUS_XYZ)) {
|
||||||
|
// S::Xyz *includes* S::Z so it needs to come before
|
||||||
|
// to avoid repeating Z alignment
|
||||||
|
state = S::Xyz;
|
||||||
|
} else if (!calibration_status_get(CALIBRATION_STATUS_Z)) {
|
||||||
|
state = S::Z;
|
||||||
#ifdef TEMP_MODEL
|
#ifdef TEMP_MODEL
|
||||||
case CALIBRATION_STATUS_TEMP_MODEL_CALIBRATION: state = S::TempModel; break; //run temp model cal.
|
} else if (!calibration_status_get(CALIBRATION_STATUS_TEMP_MODEL)) {
|
||||||
|
state = S::TempModel;
|
||||||
#endif //TEMP_MODEL
|
#endif //TEMP_MODEL
|
||||||
case CALIBRATION_STATUS_LIVE_ADJUST: state = S::IsFil; break; //run live adjust
|
} else if (!calibration_status_get(CALIBRATION_STATUS_LIVE_ADJUST)) {
|
||||||
case CALIBRATION_STATUS_CALIBRATED: end = true; eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 0); break;
|
state = S::IsFil;
|
||||||
default: state = S::Selftest; break; //if calibration status is unknown, run wizard from the beginning
|
} else {
|
||||||
|
// all required steps completed, finish successfully
|
||||||
|
state = S::Finish;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case S::Selftest:
|
case S::Selftest:
|
||||||
lcd_show_fullscreen_message_and_wait_P(_i("First, I will run the selftest to check most common assembly problems."));////MSG_WIZARD_SELFTEST c=20 r=8
|
lcd_show_fullscreen_message_and_wait_P(_i("First, I will run the selftest to check most common assembly problems."));////MSG_WIZARD_SELFTEST c=20 r=8
|
||||||
wizard_event = lcd_selftest();
|
wizard_event = lcd_selftest();
|
||||||
if (wizard_event) {
|
state = (wizard_event ? S::Restore : S::Failed);
|
||||||
calibration_status_store(CALIBRATION_STATUS_XYZ_CALIBRATION);
|
|
||||||
state = S::Xyz;
|
|
||||||
}
|
|
||||||
else end = true;
|
|
||||||
break;
|
break;
|
||||||
case S::Xyz:
|
case S::Xyz:
|
||||||
lcd_show_fullscreen_message_and_wait_P(_i("I will run xyz calibration now. It will take up to 24 mins."));////MSG_WIZARD_XYZ_CAL c=20 r=8
|
lcd_show_fullscreen_message_and_wait_P(_i("I will run xyz calibration now. It will take up to 24 mins."));////MSG_WIZARD_XYZ_CAL c=20 r=8
|
||||||
wizard_event = gcode_M45(false, 0);
|
wizard_event = gcode_M45(false, 0);
|
||||||
if (wizard_event) {
|
state = (wizard_event ? S::Restore : S::Failed);
|
||||||
#ifdef TEMP_MODEL
|
|
||||||
lcd_reset_alert_level();
|
|
||||||
state = S::TempModel;
|
|
||||||
#else
|
|
||||||
state = S::IsFil;
|
|
||||||
#endif //TEMP_MODEL
|
|
||||||
} else end = true;
|
|
||||||
break;
|
break;
|
||||||
case S::Z:
|
case S::Z:
|
||||||
lcd_show_fullscreen_message_and_wait_P(_i("Please remove shipping helpers first."));////MSG_REMOVE_SHIPPING_HELPERS c=20 r=3
|
lcd_show_fullscreen_message_and_wait_P(_i("Please remove shipping helpers first."));////MSG_REMOVE_SHIPPING_HELPERS c=20 r=3
|
||||||
|
|
@ -4188,7 +4189,10 @@ void lcd_wizard(WizState state)
|
||||||
wizard_event = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_STEEL_SHEET_CHECK), false, false);
|
wizard_event = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_STEEL_SHEET_CHECK), false, false);
|
||||||
if (!wizard_event) lcd_show_fullscreen_message_and_wait_P(_T(MSG_PLACE_STEEL_SHEET));
|
if (!wizard_event) lcd_show_fullscreen_message_and_wait_P(_T(MSG_PLACE_STEEL_SHEET));
|
||||||
wizard_event = gcode_M45(true, 0);
|
wizard_event = gcode_M45(true, 0);
|
||||||
if (wizard_event) {
|
if (!wizard_event) {
|
||||||
|
state = S::Failed;
|
||||||
|
} else {
|
||||||
|
raise_z_above(MIN_Z_FOR_SWAP);
|
||||||
//current filament needs to be unloaded and then new filament should be loaded
|
//current filament needs to be unloaded and then new filament should be loaded
|
||||||
//start to preheat nozzle for unloading remaining PLA filament
|
//start to preheat nozzle for unloading remaining PLA filament
|
||||||
setTargetHotend(PLA_PREHEAT_HOTEND_TEMP, 0);
|
setTargetHotend(PLA_PREHEAT_HOTEND_TEMP, 0);
|
||||||
|
|
@ -4199,9 +4203,8 @@ void lcd_wizard(WizState state)
|
||||||
//load filament
|
//load filament
|
||||||
lcd_wizard_load();
|
lcd_wizard_load();
|
||||||
setTargetHotend(0, 0); //we are finished, cooldown nozzle
|
setTargetHotend(0, 0); //we are finished, cooldown nozzle
|
||||||
state = S::Finish; //shipped, no need to set first layer, go to final message directly
|
state = S::Restore;
|
||||||
}
|
}
|
||||||
else end = true;
|
|
||||||
break;
|
break;
|
||||||
#ifdef TEMP_MODEL
|
#ifdef TEMP_MODEL
|
||||||
case S::TempModel:
|
case S::TempModel:
|
||||||
|
|
@ -4261,16 +4264,15 @@ void lcd_wizard(WizState state)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lcd_show_fullscreen_message_and_wait_P(_i("If you have additional steel sheets, calibrate their presets in Settings - HW Setup - Steel sheets."));////MSG_ADDITIONAL_SHEETS c=20 r=9
|
lcd_show_fullscreen_message_and_wait_P(_i("If you have additional steel sheets, calibrate their presets in Settings - HW Setup - Steel sheets."));////MSG_ADDITIONAL_SHEETS c=20 r=9
|
||||||
state = S::Finish;
|
state = S::Restore;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case S::Finish:
|
case S::Finish:
|
||||||
|
case S::Failed:
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 0);
|
eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 0);
|
||||||
end = true;
|
end = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4278,30 +4280,27 @@ void lcd_wizard(WizState state)
|
||||||
|
|
||||||
const char *msg = NULL;
|
const char *msg = NULL;
|
||||||
printf_P(_N("Wizard end state: %d\n"), (uint8_t)state);
|
printf_P(_N("Wizard end state: %d\n"), (uint8_t)state);
|
||||||
switch (state) { //final message
|
switch (state) {
|
||||||
case S::Restore: //printer was already calibrated
|
case S::Run:
|
||||||
msg = _T(MSG_WIZARD_DONE);
|
// user interrupted
|
||||||
|
msg = _T(MSG_WIZARD_QUIT);
|
||||||
break;
|
break;
|
||||||
case S::Selftest: //selftest
|
|
||||||
case S::Xyz: //xyz cal.
|
case S::Finish:
|
||||||
case S::Z: //z cal.
|
// we are successfully finished
|
||||||
msg = _T(MSG_WIZARD_CALIBRATION_FAILED);
|
|
||||||
break;
|
|
||||||
case S::Finish: //we are finished
|
|
||||||
msg = _T(MSG_WIZARD_DONE);
|
msg = _T(MSG_WIZARD_DONE);
|
||||||
lcd_reset_alert_level();
|
lcd_reset_alert_level();
|
||||||
lcd_setstatuspgm(MSG_WELCOME);
|
lcd_setstatuspgm(MSG_WELCOME);
|
||||||
lcd_return_to_status();
|
lcd_return_to_status();
|
||||||
break;
|
break;
|
||||||
case S::Preheat:
|
|
||||||
case S::Lay1CalCold:
|
case S::Failed:
|
||||||
case S::Lay1CalHot:
|
// aborted due to failure
|
||||||
#ifdef TEMP_MODEL
|
msg = _T(MSG_WIZARD_CALIBRATION_FAILED);
|
||||||
case S::TempModel: // exiting for calibration
|
break;
|
||||||
#endif //TEMP_MODEL
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
msg = _T(MSG_WIZARD_QUIT);
|
// exiting for later re-entry
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (msg) {
|
if (msg) {
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,8 @@ enum class WizState : uint8_t
|
||||||
Lay1CalCold, //!< First layer calibration, temperature not selected yet
|
Lay1CalCold, //!< First layer calibration, temperature not selected yet
|
||||||
Lay1CalHot, //!< First layer calibration, temperature already selected
|
Lay1CalHot, //!< First layer calibration, temperature already selected
|
||||||
RepeatLay1Cal, //!< Repeat first layer calibration?
|
RepeatLay1Cal, //!< Repeat first layer calibration?
|
||||||
Finish, //!< Deactivate wizard
|
Finish, //!< Deactivate wizard (success)
|
||||||
|
Failed, //!< Deactivate wizard (failure)
|
||||||
};
|
};
|
||||||
|
|
||||||
void lcd_wizard(WizState state);
|
void lcd_wizard(WizState state);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue