Skip to content

Commit bcd5732

Browse files
authored
Merge pull request #942 from Paciente8159/min-rpm-enc-factor
added configurable min encoder RPM
2 parents b4da04f + b219c64 commit bcd5732

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

uCNC/src/modules/encoder.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222

2323
#if ENCODERS > 0
2424

25+
#ifndef MIN_ENC_RPM
26+
#define MIN_ENC_RPM 1
27+
#endif
28+
29+
#define MIN_ENC_RPM_FACTOR (60000000UL / MIN_ENC_RPM)
30+
2531
static int32_t encoders_pos[ENCODERS];
2632
static uint32_t encoders_tstamp[ENCODERS][2];
2733

@@ -451,7 +457,7 @@ uint16_t encoder_get_rpm(uint8_t i)
451457
}
452458

453459
uint32_t delta = (t0 - t1);
454-
uint32_t max_elapsed = 60000000UL/g_settings.encoders_resolution[i];
460+
uint32_t max_elapsed = MIN_ENC_RPM_FACTOR/g_settings.encoders_resolution[i];
455461

456462
if (!delta || (t_now - t0) > max_elapsed)
457463
{

0 commit comments

Comments
 (0)