diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index f4c31af6d..2d5c03e38 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -23,8 +23,6 @@ static_assert(EXTRUDERS==1); namespace MMU2 { -void execute_extruder_sequence(const E_Step *sequence, int steps); - template void waitForHotendTargetTemp(uint16_t delay, F f){ while (((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5)) { @@ -357,7 +355,7 @@ bool MMU2::tool_change(char code, uint8_t slot) { case 'c': { waitForHotendTargetTemp(100, []{}); - execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); + execute_load_to_nozzle_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); } break; } @@ -508,7 +506,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t slot) { ToolChangeCommon(slot); // Finish loading to the nozzle with finely tuned steps. - execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); + execute_load_to_nozzle_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); Sound_MakeSound(e_SOUND_TYPE_StandardConfirm); } lcd_update_enable(true); @@ -839,6 +837,13 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) { } } +void MMU2::execute_load_to_nozzle_sequence(const E_Step *sequence, uint8_t steps) { + st_synchronize(); + // Compensate for configurable Extra Loading Distance + current_position[E_AXIS] -= logic.ExtraLoadDistance(); + execute_extruder_sequence(sequence, steps); +} + void MMU2::ReportError(ErrorCode ec, ErrorSource res) { // Due to a potential lossy error reporting layers linked to this hook // we'd better report everything to make sure especially the error states diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index a38b7f235..30a7f4fc7 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -239,6 +239,7 @@ private: void filament_ramming(); void execute_extruder_sequence(const E_Step *sequence, uint8_t steps); + void execute_load_to_nozzle_sequence(const E_Step *sequence, uint8_t steps); /// Reports an error into attached ExtUIs /// @param ec error code, see ErrorCode diff --git a/Firmware/mmu2/variants/config_MMU2.h b/Firmware/mmu2/variants/config_MMU2.h index f7a4a2b65..6942df889 100644 --- a/Firmware/mmu2/variants/config_MMU2.h +++ b/Firmware/mmu2/variants/config_MMU2.h @@ -64,7 +64,7 @@ static constexpr E_Step ramming_sequence[] PROGMEM = { { -35.0F, 2000.0F / 60.F}, }; -static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { - { 10.0F, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast until filament reach end of nozzle - { 25.0F, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament is out of the nozzle +static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { + { MMU2_EXTRUDER_PTFE_LENGTH, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast while not at heatbreak + { MMU2_EXTRUDER_HEATBREAK_LENGTH, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament reaches heatbreak }; diff --git a/Firmware/mmu2/variants/config_MMU2S.h b/Firmware/mmu2/variants/config_MMU2S.h index eea700c53..fdd7972bf 100644 --- a/Firmware/mmu2/variants/config_MMU2S.h +++ b/Firmware/mmu2/variants/config_MMU2S.h @@ -64,7 +64,7 @@ static constexpr E_Step ramming_sequence[] PROGMEM = { { -35.0F, 2000.0F / 60.F}, }; -static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { - { 10.0F, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast until filament reach end of nozzle - { 25.0F, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament is out of the nozzle +static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { + { MMU2_EXTRUDER_PTFE_LENGTH, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast while not at heatbreak + { MMU2_EXTRUDER_HEATBREAK_LENGTH, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament reaches heatbreak };