Fix print not recovered when filament sensor is disabled during filament change initiated by filament run out.

This commit is contained in:
Marek Bel 2018-09-19 14:22:08 +02:00
parent a5a7b1f1d6
commit 9868dd766e

View file

@ -42,8 +42,6 @@ bool fsensor_enabled = true;
bool fsensor_watch_runout = true; bool fsensor_watch_runout = true;
//not responding - is set if any communication error occured durring initialization or readout //not responding - is set if any communication error occured durring initialization or readout
bool fsensor_not_responding = false; bool fsensor_not_responding = false;
//printing saved
bool fsensor_printing_saved = false;
//number of errors, updated in ISR //number of errors, updated in ISR
uint8_t fsensor_err_cnt = 0; uint8_t fsensor_err_cnt = 0;
@ -105,6 +103,8 @@ void fsensor_stop_and_save_print(void)
void fsensor_restore_print_and_continue(void) void fsensor_restore_print_and_continue(void)
{ {
printf_P(PSTR("fsensor_restore_print_and_continue\n")); printf_P(PSTR("fsensor_restore_print_and_continue\n"));
fsensor_watch_runout = true;
fsensor_err_cnt = 0;
restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change
} }
@ -428,22 +428,12 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
void fsensor_update(void) void fsensor_update(void)
{ {
if (fsensor_enabled) if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX))
{
if (fsensor_printing_saved)
{
fsensor_restore_print_and_continue();
fsensor_printing_saved = false;
fsensor_watch_runout = true;
fsensor_err_cnt = 0;
}
else if (fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX))
{ {
bool autoload_enabled_tmp = fsensor_autoload_enabled; bool autoload_enabled_tmp = fsensor_autoload_enabled;
fsensor_autoload_enabled = false; fsensor_autoload_enabled = false;
fsensor_stop_and_save_print(); fsensor_stop_and_save_print();
fsensor_printing_saved = true;
fsensor_err_cnt = 0; fsensor_err_cnt = 0;
fsensor_oq_meassure_start(0); fsensor_oq_meassure_start(0);
@ -480,20 +470,19 @@ void fsensor_update(void)
{ {
printf_P(PSTR("fsensor_err_cnt = 0\n")); printf_P(PSTR("fsensor_err_cnt = 0\n"));
fsensor_restore_print_and_continue(); fsensor_restore_print_and_continue();
fsensor_printing_saved = false;
} }
else else
{ {
printf_P(PSTR("fsensor_update - M600\n")); printf_P(PSTR("fsensor_update - M600\n"));
eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1); eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1); eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
enquecommand_front_P(PSTR("FSENSOR_RECOVER"));
enquecommand_front_P((PSTR("M600"))); enquecommand_front_P((PSTR("M600")));
fsensor_watch_runout = false; fsensor_watch_runout = false;
} }
fsensor_autoload_enabled = autoload_enabled_tmp; fsensor_autoload_enabled = autoload_enabled_tmp;
} }
} }
}
void fsensor_setup_interrupt(void) void fsensor_setup_interrupt(void)
{ {