From d2f3835b2c2eca6a18f8bdcc1cba74d8f9391510 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Mon, 30 Jan 2023 08:10:23 +0100 Subject: [PATCH] Fixup after review --- Firmware/mmu2.cpp | 24 ++---------------------- Firmware/mmu2.h | 16 +--------------- Firmware/mmu2/variants/config_MMU2S.h | 2 +- Firmware/mmu2_error_converter.cpp | 2 +- Firmware/mmu2_log.h | 4 ++++ Firmware/mmu2_marlin.h | 1 + Firmware/mmu2_marlin1.cpp | 23 ++++++++++++----------- 7 files changed, 22 insertions(+), 50 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 9bd7fc777..75465334c 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -836,9 +836,9 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) { const E_Step *step = sequence; for (uint8_t i = 0; i < steps; i++) { const float es = pgm_read_float(&(step->extrude)); - const feedRate_t fr_mm_m = pgm_read_float(&(step->feedRate)); + const feedRate_t fr_mm_s = pgm_read_float(&(step->feedRate)); planner_set_current_position_E(planner_get_current_position_E() + es); - planner_line_to_current_position(MMM_TO_MMS(fr_mm_m)); + planner_line_to_current_position(fr_mm_s); step++; } @@ -1012,24 +1012,4 @@ void MMU2::OnMMUProgressMsgSame(ProgressCode pc) { } } -//void MMU2::LogErrorEvent(const char *msg) { -// MMU2_ERROR_MSG(msg); -// SERIAL_ECHOLN(); -//} - -void MMU2::LogErrorEvent_P(const char *msg_P) { - MMU2_ERROR_MSGRPGM(msg_P); - SERIAL_ECHOLN(); -} - -//void MMU2::LogEchoEvent(const char *msg) { -// MMU2_ECHO_MSG(msg); -// SERIAL_ECHOLN(); -//} - -void MMU2::LogEchoEvent_P(const char *msg_P) { - MMU2_ECHO_MSGRPGM(msg_P); - SERIAL_ECHOLN(); -} - } // namespace MMU2 diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index 9260989c8..cc6f043b5 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -175,7 +175,7 @@ public: bool is_mmu_error_monitor_active; /// Method to read-only mmu_print_saved - bool MMU_PRINT_SAVED() const { return mmu_print_saved != SavedState::None; } + inline bool MMU_PRINT_SAVED() const { return mmu_print_saved != SavedState::None; } /// Automagically "press" a Retry button if we have any retry attempts left /// @param ec ErrorCode enum value @@ -243,20 +243,6 @@ private: /// Repeated calls when progress code remains the same void OnMMUProgressMsgSame(ProgressCode pc); - /// Report the msg into the general logging subsystem (through Marlin's SERIAL_ECHO stuff) - // void LogErrorEvent(const char *msg); - /// Report the msg into the general logging subsystem. - /// On the AVR platform this variant reads the input string from PROGMEM. - /// On the ARM platform it calls LogErrorEvent directly (silently expecting the compiler to optimize it away) - void LogErrorEvent_P(const char *msg_P); - - /// Report the msg into the general logging subsystem (through Marlin's SERIAL_ECHO stuff) - // void LogEchoEvent(const char *msg); - /// Report the msg into the general logging subsystem. - /// On the AVR platform this variant reads the input string from PROGMEM. - /// On the ARM platform it calls LogEchoEvent directly (silently expecting the compiler to optimize it away) - void LogEchoEvent_P(const char *msg_P); - /// @brief Save hotend temperature and set flag to cooldown hotend after 60 minutes /// @param turn_off_nozzle if true, the hotend temperature will be set to 0degC after 60 minutes void SaveHotendTemp(bool turn_off_nozzle); diff --git a/Firmware/mmu2/variants/config_MMU2S.h b/Firmware/mmu2/variants/config_MMU2S.h index 13e1552c3..2559cf318 100644 --- a/Firmware/mmu2/variants/config_MMU2S.h +++ b/Firmware/mmu2/variants/config_MMU2S.h @@ -43,7 +43,7 @@ static constexpr uint8_t MMU2_NO_TOOL = 99; static constexpr uint32_t MMU_BAUD = 115200; struct E_Step { - float extrude; ///< extrude distance in mm + float extrude; ///< extrude distance in mm float feedRate; ///< feed rate in mm/s }; diff --git a/Firmware/mmu2_error_converter.cpp b/Firmware/mmu2_error_converter.cpp index 207e47767..592f1cb74 100644 --- a/Firmware/mmu2_error_converter.cpp +++ b/Firmware/mmu2_error_converter.cpp @@ -19,7 +19,7 @@ constexpr InputIt find_if_cx(InputIt first, InputIt last, UnaryPredicate p) { return last; } -// Making a constexpr FindError should instruct the compiler to optimize the ConvertMMUErrorCode +// Making a constexpr FindError should instruct the compiler to optimize the PrusaErrorCodeIndex // in such a way that no searching will ever be done at runtime. // A call to FindError then compiles to a single instruction even on the AVR. static constexpr uint8_t FindErrorIndex(uint16_t pec) { diff --git a/Firmware/mmu2_log.h b/Firmware/mmu2_log.h index a008655d6..10d9d897f 100644 --- a/Firmware/mmu2_log.h +++ b/Firmware/mmu2_log.h @@ -12,10 +12,14 @@ namespace MMU2 { /// Report the msg into the general logging subsystem (through Marlin's SERIAL_ECHO stuff) /// @param msg pointer to a string in PROGMEM +/// On the AVR platform this variant reads the input string from PROGMEM. +/// On the ARM platform it calls LogErrorEvent directly (silently expecting the compiler to optimize it away) void LogErrorEvent_P(const char *msg); /// Report the msg into the general logging subsystem (through Marlin's SERIAL_ECHO stuff) /// @param msg pointer to a string in PROGMEM +/// On the AVR platform this variant reads the input string from PROGMEM. +/// On the ARM platform it calls LogErrorEvent directly (silently expecting the compiler to optimize it away) void LogEchoEvent_P(const char *msg); } // namespace diff --git a/Firmware/mmu2_marlin.h b/Firmware/mmu2_marlin.h index ba3982656..89ab2753f 100644 --- a/Firmware/mmu2_marlin.h +++ b/Firmware/mmu2_marlin.h @@ -32,6 +32,7 @@ float planner_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); diff --git a/Firmware/mmu2_marlin1.cpp b/Firmware/mmu2_marlin1.cpp index f31b74464..b4123588f 100644 --- a/Firmware/mmu2_marlin1.cpp +++ b/Firmware/mmu2_marlin1.cpp @@ -11,7 +11,7 @@ namespace MMU2 { void MoveE(float delta, float feedRate) { current_position[E_AXIS] += delta; - plan_buffer_line_curposXYZE(feedRate); + planner_line_to_current_position(feedRate); } float MoveRaiseZ(float delta) { @@ -40,7 +40,11 @@ void planner_set_current_position_E(float e){ void planner_line_to_current_position(float feedRate_mm_s){ plan_buffer_line_curposXYZE(feedRate_mm_s); - st_synchronize(); +} + +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(){ @@ -48,23 +52,20 @@ pos3d planner_current_position(){ } void motion_do_blocking_move_to_xy(float rx, float ry, float feedRate_mm_s){ - current_position[X_AXIS] = rx; - current_position[Y_AXIS] = ry; - plan_buffer_line_curposXYZE(feedRate_mm_s); - st_synchronize(); + current_position[X_AXIS] = rx; + current_position[Y_AXIS] = ry; + planner_line_to_current_position_sync(feedRate_mm_s); } void motion_do_blocking_move_to_z(float z, float feedRate_mm_s){ - current_position[Z_AXIS] = z; - plan_buffer_line_curposXYZE(feedRate_mm_s); - st_synchronize(); + current_position[Z_AXIS] = z; + planner_line_to_current_position_sync(feedRate_mm_s); } void nozzle_park() { current_position[X_AXIS] = MMU_ERR_X_PAUSE_POS; current_position[Y_AXIS] = MMU_ERR_Y_PAUSE_POS; - planner_line_to_current_position(NOZZLE_PARK_XY_FEEDRATE); - st_synchronize(); + planner_line_to_current_position_sync(NOZZLE_PARK_XY_FEEDRATE); } bool marlin_printingIsActive() {