🚸 Optional encoder multipliers
This commit is contained in:
parent
1e8fbb7bbb
commit
76b5688304
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue