Allow load filament retry after button push unlimited times in case mmu_continue_loading() is in blocking mode.
This commit is contained in:
parent
84cabd3836
commit
c7d403733a
2 changed files with 92 additions and 57 deletions
147
Firmware/mmu.cpp
147
Firmware/mmu.cpp
|
@ -1466,74 +1466,109 @@ static void load_more()
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void increment_load_fail()
|
||||||
|
{
|
||||||
|
uint8_t mmu_load_fail = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL);
|
||||||
|
uint16_t mmu_load_fail_tot = eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT);
|
||||||
|
if(mmu_load_fail < 255) eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, mmu_load_fail + 1);
|
||||||
|
if(mmu_load_fail_tot < 65535) eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, mmu_load_fail_tot + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! @brief continue loading filament
|
||||||
//! @par blocking
|
//! @par blocking
|
||||||
//! * true blocking
|
//! * true blocking - do not return until successful load
|
||||||
//! * false non-blocking
|
//! * false non-blocking - pause print and return on load failure
|
||||||
|
//!
|
||||||
|
//! @startuml
|
||||||
|
//! [*] --> [*] : !ir_sensor_detected /\n send MmuCmd::C0
|
||||||
|
//! [*] --> LoadMore
|
||||||
|
//! LoadMore --> [*] : filament \ndetected
|
||||||
|
//! LoadMore --> Retry : !filament detected /\n increment load fail
|
||||||
|
//! Retry --> [*] : filament \ndetected
|
||||||
|
//! Retry --> Unload : !filament \ndetected
|
||||||
|
//! Unload --> [*] : non-blocking
|
||||||
|
//! Unload --> Retry : button \nclicked
|
||||||
|
//!
|
||||||
|
//! Retry : Cut filament if enabled
|
||||||
|
//! Retry : repeat last T-code
|
||||||
|
//! Unload : unload filament
|
||||||
|
//! Unload : pause print
|
||||||
|
//! Unload : show error message
|
||||||
|
//!
|
||||||
|
//! @enduml
|
||||||
void mmu_continue_loading(bool blocking)
|
void mmu_continue_loading(bool blocking)
|
||||||
{
|
{
|
||||||
if (ir_sensor_detected)
|
if (!ir_sensor_detected)
|
||||||
{
|
{
|
||||||
load_more();
|
mmu_command(MmuCmd::C0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (PIN_GET(IR_SENSOR_PIN) != 0) {
|
load_more();
|
||||||
uint8_t mmu_load_fail = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL);
|
|
||||||
uint16_t mmu_load_fail_tot = eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT);
|
|
||||||
if(mmu_load_fail < 255) eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, mmu_load_fail + 1);
|
|
||||||
if(mmu_load_fail_tot < 65535) eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, mmu_load_fail_tot + 1);
|
|
||||||
|
|
||||||
|
enum class Ls : uint_least8_t
|
||||||
|
{
|
||||||
|
enter,
|
||||||
|
retry,
|
||||||
|
unload,
|
||||||
|
};
|
||||||
|
Ls state = Ls::enter;
|
||||||
|
|
||||||
|
while (PIN_GET(IR_SENSOR_PIN) != 0)
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case Ls::enter:
|
||||||
|
increment_load_fail();
|
||||||
|
// no break
|
||||||
|
case Ls::retry:
|
||||||
#ifdef MMU_HAS_CUTTER
|
#ifdef MMU_HAS_CUTTER
|
||||||
if (1 == eeprom_read_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED))
|
if (1 == eeprom_read_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED))
|
||||||
{
|
{
|
||||||
mmu_command(MmuCmd::K0 + tmp_extruder);
|
mmu_command(MmuCmd::K0 + tmp_extruder);
|
||||||
manage_response(true, true, MMU_UNLOAD_MOVE);
|
manage_response(true, true, MMU_UNLOAD_MOVE);
|
||||||
}
|
}
|
||||||
#endif //MMU_HAS_CUTTER
|
#endif //MMU_HAS_CUTTER
|
||||||
|
|
||||||
mmu_command(MmuCmd::T0 + tmp_extruder);
|
mmu_command(MmuCmd::T0 + tmp_extruder);
|
||||||
manage_response(true, true, MMU_TCODE_MOVE);
|
manage_response(true, true, MMU_TCODE_MOVE);
|
||||||
load_more();
|
load_more();
|
||||||
|
state = Ls::unload;
|
||||||
|
break;
|
||||||
|
case Ls::unload:
|
||||||
|
stop_and_save_print_to_ram(0, 0);
|
||||||
|
|
||||||
if (PIN_GET(IR_SENSOR_PIN) != 0)
|
//lift z
|
||||||
|
current_position[Z_AXIS] += Z_PAUSE_LIFT;
|
||||||
|
if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
|
||||||
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
|
||||||
|
st_synchronize();
|
||||||
|
|
||||||
|
//Move XY to side
|
||||||
|
current_position[X_AXIS] = X_PAUSE_POS;
|
||||||
|
current_position[Y_AXIS] = Y_PAUSE_POS;
|
||||||
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
|
||||||
|
st_synchronize();
|
||||||
|
|
||||||
|
mmu_command(MmuCmd::U0);
|
||||||
|
manage_response(false, true, MMU_UNLOAD_MOVE);
|
||||||
|
|
||||||
|
setAllTargetHotends(0);
|
||||||
|
lcd_setstatuspgm(_i("MMU load failed "));////c=20 r=1
|
||||||
|
|
||||||
|
if (blocking)
|
||||||
{
|
{
|
||||||
//pause print, show error message and then repeat last T-code
|
marlin_wait_for_click();
|
||||||
stop_and_save_print_to_ram(0, 0);
|
restore_print_from_ram_and_continue(0);
|
||||||
|
state = Ls::retry;
|
||||||
//lift z
|
|
||||||
current_position[Z_AXIS] += Z_PAUSE_LIFT;
|
|
||||||
if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
|
|
||||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
|
|
||||||
st_synchronize();
|
|
||||||
|
|
||||||
//Move XY to side
|
|
||||||
current_position[X_AXIS] = X_PAUSE_POS;
|
|
||||||
current_position[Y_AXIS] = Y_PAUSE_POS;
|
|
||||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
|
|
||||||
st_synchronize();
|
|
||||||
|
|
||||||
mmu_command(MmuCmd::U0);
|
|
||||||
manage_response(false, true, MMU_UNLOAD_MOVE);
|
|
||||||
|
|
||||||
setAllTargetHotends(0);
|
|
||||||
lcd_setstatuspgm(_i("MMU load failed "));////MSG_RECOVERING_PRINT c=20 r=1
|
|
||||||
|
|
||||||
if (blocking)
|
|
||||||
{
|
|
||||||
marlin_wait_for_click();
|
|
||||||
restore_print_from_ram_and_continue(0);
|
|
||||||
mmu_command(MmuCmd::T0 + tmp_extruder);
|
|
||||||
manage_response(true, true, MMU_TCODE_MOVE);
|
|
||||||
load_more();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mmu_fil_loaded = false; //so we can retry same T-code again
|
|
||||||
isPrintPaused = true;
|
|
||||||
mmu_command(MmuCmd::W0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
else { //mmu_ir_sensor_detected == false
|
mmu_fil_loaded = false; //so we can retry same T-code again
|
||||||
mmu_command(MmuCmd::C0);
|
isPrintPaused = true;
|
||||||
}
|
mmu_command(MmuCmd::W0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ enum class MmuCmd : uint_least8_t
|
||||||
K4,
|
K4,
|
||||||
R0,
|
R0,
|
||||||
S3,
|
S3,
|
||||||
W0,
|
W0, //!< Wait and signal load error
|
||||||
};
|
};
|
||||||
|
|
||||||
inline MmuCmd operator+ (MmuCmd cmd, uint8_t filament)
|
inline MmuCmd operator+ (MmuCmd cmd, uint8_t filament)
|
||||||
|
|
Loading…
Add table
Reference in a new issue