From 55e519a06f47e8c29687ebf2b58cc8117be0afdf Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 14 Jul 2020 21:26:09 -0500 Subject: [PATCH] General cleanup --- Marlin/src/lcd/menu/menu_motion.cpp | 4 +--- Marlin/src/module/stepper.cpp | 26 ++++++++++++-------------- Marlin/src/module/stepper.h | 3 +-- Marlin/src/module/temperature.cpp | 5 ++++- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index bc1e101816..1821161cb1 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -139,9 +139,7 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); } ui.encoderPosition = 0; } if (ui.should_draw()) { - #if MULTI_MANUAL - MenuItemBase::init(eindex); - #endif + TERN_(MULTI_MANUAL, MenuItemBase::init(eindex)); MenuEditItemBase::draw_edit_screen( GET_TEXT(TERN(MULTI_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)), ftostr41sign(current_position.e diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 6b957bad89..16ff134923 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -168,22 +168,19 @@ bool Stepper::abort_current_block; #if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN) bool Stepper::locked_Z_motor = false, Stepper::locked_Z2_motor = false - #if NUM_Z_STEPPER_DRIVERS >= 3 - , Stepper::locked_Z3_motor = false - #if NUM_Z_STEPPER_DRIVERS >= 4 - , Stepper::locked_Z4_motor = false - #endif - #endif - ; + #if NUM_Z_STEPPER_DRIVERS >= 3 + , Stepper::locked_Z3_motor = false + #if NUM_Z_STEPPER_DRIVERS >= 4 + , Stepper::locked_Z4_motor = false + #endif + #endif + ; #endif uint32_t Stepper::acceleration_time, Stepper::deceleration_time; uint8_t Stepper::steps_per_isr; -#if DISABLED(ADAPTIVE_STEP_SMOOTHING) - constexpr -#endif - uint8_t Stepper::oversampling_factor; +TERN(ADAPTIVE_STEP_SMOOTHING,,constexpr) uint8_t Stepper::oversampling_factor; xyze_long_t Stepper::delta_error{0}; @@ -2099,17 +2096,18 @@ uint32_t Stepper::block_phase_isr() { // No acceleration / deceleration time elapsed so far acceleration_time = deceleration_time = 0; - uint8_t oversampling = 0; // Assume no axis smoothing (via oversampling) - #if ENABLED(ADAPTIVE_STEP_SMOOTHING) + uint8_t oversampling = 0; // Assume no axis smoothing (via oversampling) // Decide if axis smoothing is possible - uint32_t max_rate = current_block->nominal_rate; // Get the maximum rate (maximum event speed) + uint32_t max_rate = current_block->nominal_rate; // Get the maximum rate (maximum event speed) while (max_rate < MIN_STEP_ISR_FREQUENCY) { // As long as more ISRs are possible... max_rate <<= 1; // Try to double the rate if (max_rate >= MAX_STEP_ISR_FREQUENCY_1X) break; // Don't exceed the estimated ISR limit ++oversampling; // Increase the oversampling (used for left-shift) } oversampling_factor = oversampling; // For all timer interval calculations + #else + constexpr uint8_t oversampling = 0; #endif // Based on the oversampling factor, do the calculations diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 90ca092ace..6ae5076cd2 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -191,7 +191,6 @@ #error "Expected at least one of MINIMUM_STEPPER_PULSE or MAXIMUM_STEPPER_RATE to be defined" #endif - // But the user could be enforcing a minimum time, so the loop time is #define ISR_LOOP_CYCLES (ISR_LOOP_BASE_CYCLES + _MAX(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LOOP_CYCLES)) @@ -558,7 +557,7 @@ class Stepper { // In case of high-performance processor, it is able to calculate in real-time timer = uint32_t(STEPPER_TIMER_RATE) / step_rate; #else - constexpr uint32_t min_step_rate = F_CPU / 500000U; + constexpr uint32_t min_step_rate = (F_CPU) / 500000U; NOLESS(step_rate, min_step_rate); step_rate -= min_step_rate; // Correct for minimal speed if (step_rate >= (8 * 256)) { // higher step rate diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 7c10beceeb..e62754a301 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -907,7 +907,10 @@ void Temperature::min_temp_error(const heater_ind_t heater) { SERIAL_ECHOPAIR(STR_PID_DEBUG, ee, STR_PID_DEBUG_INPUT, temp_hotend[ee].celsius, STR_PID_DEBUG_OUTPUT, pid_output); #if DISABLED(PID_OPENLOOP) { - SERIAL_ECHOPAIR( STR_PID_DEBUG_PTERM, work_pid[ee].Kp, STR_PID_DEBUG_ITERM, work_pid[ee].Ki, STR_PID_DEBUG_DTERM, work_pid[ee].Kd + SERIAL_ECHOPAIR( + STR_PID_DEBUG_PTERM, work_pid[ee].Kp, + STR_PID_DEBUG_ITERM, work_pid[ee].Ki, + STR_PID_DEBUG_DTERM, work_pid[ee].Kd #if ENABLED(PID_EXTRUSION_SCALING) , STR_PID_DEBUG_CTERM, work_pid[ee].Kc #endif