diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index a5481bb985..4f74fa0067 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -869,6 +869,24 @@ #define HAS_ENCODER_ACTION 1 #endif +#if ENABLED(ENCODER_RATE_MULTIPLIER) + #ifndef ENCODER_5X_STEPS_PER_SEC + #define ENCODER_5X_STEPS_PER_SEC 0 + #endif + #ifndef ENCODER_10X_STEPS_PER_SEC + #define ENCODER_10X_STEPS_PER_SEC 0 + #endif + #ifndef ENCODER_100X_STEPS_PER_SEC + #define ENCODER_100X_STEPS_PER_SEC 0 + #endif + #if !((HAS_MARLINUI_MENU || HAS_DWIN_E3V2) && (ENCODER_5X_STEPS_PER_SEC || ENCODER_10X_STEPS_PER_SEC || ENCODER_100X_STEPS_PER_SEC)) + #undef ENCODER_RATE_MULTIPLIER + #undef ENCODER_5X_STEPS_PER_SEC + #undef ENCODER_10X_STEPS_PER_SEC + #undef ENCODER_100X_STEPS_PER_SEC + #endif +#endif + #if STATUS_MESSAGE_TIMEOUT_SEC > 0 #define HAS_STATUS_MESSAGE_TIMEOUT 1 #endif diff --git a/Marlin/src/lcd/e3v2/common/encoder.cpp b/Marlin/src/lcd/e3v2/common/encoder.cpp index c406cc47d9..5825fb0f77 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.cpp +++ b/Marlin/src/lcd/e3v2/common/encoder.cpp @@ -137,11 +137,12 @@ EncoderState encoderReceiveAnalyze() { // Note that the rate is always calculated between two passes through the // loop and that the abs of the temp_diff value is tracked. const float encoderStepRate = encoderMovementSteps / float(ms - encoderRate.lastEncoderTime) * 1000; - if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoder_multiplier = 100; - else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoder_multiplier = 10; - #if ENCODER_5X_STEPS_PER_SEC - else if (encoderStepRate >= ENCODER_5X_STEPS_PER_SEC) encoder_multiplier = 5; - #endif + if (ENCODER_100X_STEPS_PER_SEC > 0 && encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) + encoder_multiplier = 100; + else if (ENCODER_10X_STEPS_PER_SEC > 0 && encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) + encoder_multiplier = 10; + else if (ENCODER_5X_STEPS_PER_SEC > 0 && encoderStepRate >= ENCODER_5X_STEPS_PER_SEC) + encoder_multiplier = 5; } encoderRate.lastEncoderTime = ms; } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 9a8152ba99..f66b680bc1 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1055,18 +1055,23 @@ void MarlinUI::init() { const float encoderStepRate = ((float(abs_diff) / float(epps)) * 1000.0f) / float(ms - encoder_mult_prev_ms); encoder_mult_prev_ms = ms; - if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoder_multiplier = 100; - else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoder_multiplier = 10; + if (ENCODER_100X_STEPS_PER_SEC > 0 && encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) + encoder_multiplier = 100; + else if (ENCODER_10X_STEPS_PER_SEC > 0 && encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) + encoder_multiplier = 10; + else if (ENCODER_5X_STEPS_PER_SEC > 0 && encoderStepRate >= ENCODER_5X_STEPS_PER_SEC) + encoder_multiplier = 5; // Enable to output the encoder steps per second value //#define ENCODER_RATE_MULTIPLIER_DEBUG #if ENABLED(ENCODER_RATE_MULTIPLIER_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOPGM("Enc Step Rate: ", encoderStepRate); - SERIAL_ECHOPGM(" Multiplier: ", encoder_multiplier); - SERIAL_ECHOPGM(" ENCODER_10X_STEPS_PER_SEC: ", ENCODER_10X_STEPS_PER_SEC); - SERIAL_ECHOPGM(" ENCODER_100X_STEPS_PER_SEC: ", ENCODER_100X_STEPS_PER_SEC); - SERIAL_EOL(); + SERIAL_ECHO_MSG( + "Enc Step Rate: ", encoderStepRate, + " Mult: ", encoder_multiplier, + " 5X Steps: ", ENCODER_5X_STEPS_PER_SEC, + " 10X Steps: ", ENCODER_10X_STEPS_PER_SEC, + " 100X Steps: ", ENCODER_100X_STEPS_PER_SEC + ); #endif }