1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 01:05:10 +03:00

Re #3724: added smoothing filter for rotary encoder speed/acceleration calculation (#3726)

This commit is contained in:
Damjan Adamic 2016-08-28 18:00:54 +02:00 committed by Andre Bernet
parent 446ed3db59
commit 89e0fd1e1d
2 changed files with 15 additions and 13 deletions

View file

@ -142,9 +142,11 @@ void per10ms()
putEvent(scrollRE < 0 ? EVT_ROTARY_LEFT : EVT_ROTARY_RIGHT);
}
#if defined(CPUARM)
// rotary encoder navigation speed (acceleration) detection/calculation
if (scrollRE) {
static uint32_t lastTick = 0;
uint32_t delay = get_tmr10ms() - lastTick;
static uint32_t delay = 0;
delay = (((get_tmr10ms() - lastTick) << 3) + delay) >> 1; // Modified moving average filter used for smoother change of speed
lastTick = get_tmr10ms();
if (delay < ROTENC_DELAY_HIGHSPEED)
rotencSpeed = ROTENC_HIGHSPEED;

View file

@ -541,8 +541,8 @@ extern uint8_t rotencSpeed;
#define ROTENC_LOWSPEED 1
#define ROTENC_MIDSPEED 5
#define ROTENC_HIGHSPEED 50
#define ROTENC_DELAY_MIDSPEED 4
#define ROTENC_DELAY_HIGHSPEED 2
#define ROTENC_DELAY_MIDSPEED 32
#define ROTENC_DELAY_HIGHSPEED 16
#endif
#define HEART_TIMER_10MS 1