diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 9706cfbb..83e587d9 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -496,5 +496,5 @@ void proc_commands(); void M600_load_filament(); void M600_load_filament_movements(); void M600_wait_for_user(float HotendTempBckp); -void M600_check_state(); +void M600_check_state(float nozzle_temp); void load_filament_final_feed(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 52e1e356..5b04d749 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3055,12 +3055,12 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float manage_response(false, false); } } - mmu_M600_load_filament(automatic); + mmu_M600_load_filament(automatic, HotendTempBckp); } else M600_load_filament(); - if (!automatic) M600_check_state(); + if (!automatic) M600_check_state(HotendTempBckp); lcd_update_enable(true); @@ -9109,38 +9109,41 @@ void load_filament_final_feed() plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EFEED_FINAL, active_extruder); } -void M600_check_state() +//! @brief Wait for user to check the state +//! @par nozzle_temp nozzle temperature to load filament +void M600_check_state(float nozzle_temp) { - //Wait for user to check the state - lcd_change_fil_state = 0; - while (lcd_change_fil_state != 1){ - lcd_change_fil_state = 0; - KEEPALIVE_STATE(PAUSED_FOR_USER); - lcd_alright(); - KEEPALIVE_STATE(IN_HANDLER); - switch(lcd_change_fil_state){ - // Filament failed to load so load it again - case 2: - if (mmu_enabled) - mmu_M600_load_filament(false); //nonautomatic load; change to "wrong filament loaded" option? - else - M600_load_filament_movements(); - break; + lcd_change_fil_state = 0; + while (lcd_change_fil_state != 1) + { + lcd_change_fil_state = 0; + KEEPALIVE_STATE(PAUSED_FOR_USER); + lcd_alright(); + KEEPALIVE_STATE(IN_HANDLER); + switch(lcd_change_fil_state) + { + // Filament failed to load so load it again + case 2: + if (mmu_enabled) + mmu_M600_load_filament(false, nozzle_temp); //nonautomatic load; change to "wrong filament loaded" option? + else + M600_load_filament_movements(); + break; - // Filament loaded properly but color is not clear - case 3: - st_synchronize(); - load_filament_final_feed(); - lcd_loading_color(); - st_synchronize(); - break; - - // Everything good - default: - lcd_change_success(); - break; - } - } + // Filament loaded properly but color is not clear + case 3: + st_synchronize(); + load_filament_final_feed(); + lcd_loading_color(); + st_synchronize(); + break; + + // Everything good + default: + lcd_change_success(); + break; + } + } } //! @brief Wait for user action diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 449efabd..45a3c421 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -830,37 +830,43 @@ void mmu_M600_wait_and_beep() { WRITE(BEEPER, LOW); } -void mmu_M600_load_filament(bool automatic) +//! @brief load filament for mmu v2 +//! @par nozzle_temp nozzle temperature to load filament +void mmu_M600_load_filament(bool automatic, float nozzle_temp) { - //load filament for mmu v2 - tmp_extruder = mmu_extruder; - if (!automatic) { -#ifdef MMU_M600_SWITCH_EXTRUDER - bool yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false); - if(yes) tmp_extruder = choose_extruder_menu(); -#endif //MMU_M600_SWITCH_EXTRUDER - } - else { - tmp_extruder = ad_getAlternative(tmp_extruder); - } - lcd_update_enable(false); - lcd_clear(); - lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); - lcd_print(" "); - lcd_print(tmp_extruder + 1); - snmm_filaments_used |= (1 << tmp_extruder); //for stop print + tmp_extruder = mmu_extruder; + if (!automatic) + { + #ifdef MMU_M600_SWITCH_EXTRUDER + bool yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false); + if(yes) tmp_extruder = choose_extruder_menu(); + #endif //MMU_M600_SWITCH_EXTRUDER + } + else + { + tmp_extruder = ad_getAlternative(tmp_extruder); + } + lcd_update_enable(false); + lcd_clear(); + lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); + lcd_print(" "); + lcd_print(tmp_extruder + 1); + snmm_filaments_used |= (1 << tmp_extruder); //for stop print -// printf_P(PSTR("T code: %d \n"), tmp_extruder); -// mmu_printf_P(PSTR("T%d\n"), tmp_extruder); - mmu_command(MmuCmd::T0 + tmp_extruder); + //printf_P(PSTR("T code: %d \n"), tmp_extruder); + //mmu_printf_P(PSTR("T%d\n"), tmp_extruder); + setTargetHotend(nozzle_temp,active_extruder); + mmu_wait_for_heater_blocking(); - manage_response(false, true, MMU_LOAD_MOVE); - mmu_continue_loading(); - mmu_extruder = tmp_extruder; //filament change is finished - - mmu_load_to_nozzle(); - load_filament_final_feed(); - st_synchronize(); + mmu_command(MmuCmd::T0 + tmp_extruder); + + manage_response(false, true, MMU_LOAD_MOVE); + mmu_continue_loading(); + mmu_extruder = tmp_extruder; //filament change is finished + + mmu_load_to_nozzle(); + load_filament_final_feed(); + st_synchronize(); } diff --git a/Firmware/mmu.h b/Firmware/mmu.h index b498a374..c2e8b713 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -97,7 +97,7 @@ extern void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move = extern void mmu_load_to_nozzle(); -extern void mmu_M600_load_filament(bool automatic); +extern void mmu_M600_load_filament(bool automatic, float nozzle_temp); extern void mmu_M600_wait_and_beep(); extern void extr_mov(float shift, float feed_rate);