diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 045d9deff..972fc5cd1 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -301,7 +301,7 @@ bool MMU2::VerifyFilamentEnteredPTFE() { uint8_t dpixel1 = 0; uint8_t dpixel0 = 0; for (uint8_t move = 0; move < 2; move++) { - MoveE(move == 0 ? delta_mm : -delta_mm, MMU2_VERIFY_LOAD_TO_NOZZLE_FEED_RATE); + extruder_move(move == 0 ? delta_mm : -delta_mm, MMU2_VERIFY_LOAD_TO_NOZZLE_FEED_RATE); while (planner_any_moves()) { // Wait for move to finish and monitor the fsensor the entire time // A single 0 reading will set the bit. @@ -355,8 +355,6 @@ bool MMU2::ToolChangeCommonOnce(uint8_t slot) { // but honestly - if the MMU restarts during every toolchange, // something else is seriously broken and stopping a print is probably our best option. } - // reset current position to whatever the planner thinks it is - planner_set_current_position_E(planner_get_current_position_E()); if (VerifyFilamentEnteredPTFE()) { return true; // success } else { // Prepare a retry attempt @@ -654,7 +652,7 @@ void MMU2::SaveAndPark(bool move_axes) { resume_position = planner_current_position(); // save current pos // lift Z - MoveRaiseZ(MMU_ERR_Z_PAUSE_LIFT); + move_raise_z(MMU_ERR_Z_PAUSE_LIFT); // move XY aside if (all_axes_homed()) { @@ -930,7 +928,7 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) { const E_Step *step = sequence; for (uint8_t i = steps; i ; --i) { - MoveE(pgm_read_float(&(step->extrude)), pgm_read_float(&(step->feedRate))); + extruder_move(pgm_read_float(&(step->extrude)), pgm_read_float(&(step->feedRate))); step++; } planner_synchronize(); // it looks like it's better to sync the moves at the end - smoother move (if the sequence is not too long). @@ -1058,7 +1056,7 @@ void MMU2::OnMMUProgressMsgChanged(ProgressCode pc) { } void __attribute__((noinline)) MMU2::HelpUnloadToFinda() { - MoveE(-MMU2_RETRY_UNLOAD_TO_FINDA_LENGTH, MMU2_RETRY_UNLOAD_TO_FINDA_FEED_RATE); + extruder_move(-MMU2_RETRY_UNLOAD_TO_FINDA_LENGTH, MMU2_RETRY_UNLOAD_TO_FINDA_FEED_RATE); } void MMU2::OnMMUProgressMsgSame(ProgressCode pc) { @@ -1089,7 +1087,7 @@ void MMU2::OnMMUProgressMsgSame(ProgressCode pc) { // After the MMU knows the FSENSOR is triggered it will: // 1. Push the filament by additional 30mm (see fsensorToNozzle) // 2. Disengage the idler and push another 2mm. - MoveE(logic.ExtraLoadDistance() + 2, logic.PulleySlowFeedRate()); + extruder_move(logic.ExtraLoadDistance() + 2, logic.PulleySlowFeedRate()); break; case FilamentState::NOT_PRESENT: // fsensor not triggered, continue moving extruder @@ -1099,7 +1097,7 @@ void MMU2::OnMMUProgressMsgSame(ProgressCode pc) { // than 450mm because the firmware will ignore too long extrusions // for safety reasons. See PREVENT_LENGTHY_EXTRUDE. // Use 350mm to be safely away from the prevention threshold - MoveE(350.0f, logic.PulleySlowFeedRate()); + extruder_move(350.0f, logic.PulleySlowFeedRate()); } break; default: diff --git a/Firmware/mmu2_marlin.h b/Firmware/mmu2_marlin.h index 0877a60f8..0990fdbc2 100644 --- a/Firmware/mmu2_marlin.h +++ b/Firmware/mmu2_marlin.h @@ -14,27 +14,25 @@ struct pos3d { pos3d() = default; inline constexpr pos3d(float x, float y, float z) : xyz { x, y, z } {} - pos3d operator=(const float *newP){ - for(uint8_t i = 0; i < 3; ++i){ + pos3d operator=(const float *newP) { + for (uint8_t i = 0; i < 3; ++i) { xyz[i] = newP[i]; } return *this; } }; -void MoveE(float delta, float feedRate); +void extruder_move(float distance, float feed_rate); +void extruder_schedule_turning(float feed_rate); -float MoveRaiseZ(float delta); +float move_raise_z(float delta); void planner_abort_queued_moves(); void planner_synchronize(); bool planner_any_moves(); -float planner_get_machine_position_E_mm(); float stepper_get_machine_position_E_mm(); float planner_get_current_position_E(); void planner_set_current_position_E(float e); -void planner_line_to_current_position(float feedRate_mm_s); -void planner_line_to_current_position_sync(float feedRate_mm_s); pos3d planner_current_position(); void motion_do_blocking_move_to_xy(float rx, float ry, float feedRate_mm_s); @@ -61,6 +59,4 @@ bool all_axes_homed(); void gcode_reset_stepper_timeout(); -bool cutter_enabled(); - } // namespace MMU2 diff --git a/Firmware/mmu2_marlin1.cpp b/Firmware/mmu2_marlin1.cpp index 58ce99171..05a9bf05e 100644 --- a/Firmware/mmu2_marlin1.cpp +++ b/Firmware/mmu2_marlin1.cpp @@ -9,12 +9,21 @@ namespace MMU2 { -void MoveE(float delta, float feedRate) { +static void planner_line_to_current_position(float feedRate_mm_s){ + plan_buffer_line_curposXYZE(feedRate_mm_s); +} + +static void planner_line_to_current_position_sync(float feedRate_mm_s){ + planner_line_to_current_position(feedRate_mm_s); + planner_synchronize(); +} + +void extruder_move(float delta, float feedRate) { current_position[E_AXIS] += delta; planner_line_to_current_position(feedRate); } -float MoveRaiseZ(float delta) { +float move_raise_z(float delta) { return raise_z(delta); } @@ -53,15 +62,6 @@ void planner_set_current_position_E(float e){ current_position[E_AXIS] = e; } -void planner_line_to_current_position(float feedRate_mm_s){ - plan_buffer_line_curposXYZE(feedRate_mm_s); -} - -void planner_line_to_current_position_sync(float feedRate_mm_s){ - planner_line_to_current_position(feedRate_mm_s); - planner_synchronize(); -} - pos3d planner_current_position(){ return pos3d(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]); } @@ -132,8 +132,4 @@ bool all_axes_homed(){ return axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]; } -bool cutter_enabled(){ - return eeprom_read_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED) == EEPROM_MMU_CUTTER_ENABLED_enabled; -} - } // namespace MMU2 diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index f2b0fab45..ddef50c61 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -332,6 +332,10 @@ void IncrementMMUFails(){ eeprom_increment_word((uint16_t *)EEPROM_MMU_FAIL_TOT); } +bool cutter_enabled(){ + return eeprom_read_byte((uint8_t*)EEPROM_MMU_CUTTER_ENABLED) == EEPROM_MMU_CUTTER_ENABLED_enabled; +} + void MakeSound(SoundType s){ Sound_MakeSound( (eSOUND_TYPE)s); } diff --git a/Firmware/mmu2_reporting.h b/Firmware/mmu2_reporting.h index 89a2765bd..e26a11ea0 100644 --- a/Firmware/mmu2_reporting.h +++ b/Firmware/mmu2_reporting.h @@ -74,6 +74,9 @@ void IncrementLoadFails(); /// Increments EEPROM cell - number of MMU errors void IncrementMMUFails(); +/// @returns true when Cutter is enabled in the menus +bool cutter_enabled(); + // Beware: enum values intentionally chosen to match the 8bit FW to save code size enum SoundType { Prompt = 2,