fix(simu): rotencDt must be updated as well (#2676)
The acceleration calculation is relying on it to compute dx/dt.
This commit is contained in:
@@ -466,6 +466,8 @@ void OpenTxSim::updateKeysAndSwitches(bool start)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern volatile uint32_t rotencDt;
|
||||||
|
|
||||||
long OpenTxSim::onTimeout(FXObject*, FXSelector, void*)
|
long OpenTxSim::onTimeout(FXObject*, FXSelector, void*)
|
||||||
{
|
{
|
||||||
if (hasFocus()) {
|
if (hasFocus()) {
|
||||||
@@ -485,6 +487,14 @@ long OpenTxSim::onTimeout(FXObject*, FXSelector, void*)
|
|||||||
else {
|
else {
|
||||||
rotencAction = false;
|
rotencAction = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t last_tick = 0;
|
||||||
|
if (rotencAction) {
|
||||||
|
uint32_t now = RTOS_GET_MS();
|
||||||
|
uint32_t dt = now - last_tick;
|
||||||
|
rotencDt += dt;
|
||||||
|
last_tick = now;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,12 +273,21 @@ void OpenTxSimulator::setInputValue(int type, uint8_t index, int16_t value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern volatile uint32_t rotencDt;
|
||||||
|
|
||||||
void OpenTxSimulator::rotaryEncoderEvent(int steps)
|
void OpenTxSimulator::rotaryEncoderEvent(int steps)
|
||||||
{
|
{
|
||||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||||
(g_eeGeneral.rotEncMode >= ROTARY_ENCODER_MODE_INVERT_BOTH ? steps *= -1
|
static uint32_t last_tick = 0;
|
||||||
: steps);
|
if (steps != 0) {
|
||||||
ROTARY_ENCODER_NAVIGATION_VALUE += steps * ROTARY_ENCODER_GRANULARITY;
|
if (g_eeGeneral.rotEncMode >= ROTARY_ENCODER_MODE_INVERT_BOTH) steps *= -1;
|
||||||
|
ROTARY_ENCODER_NAVIGATION_VALUE += steps * ROTARY_ENCODER_GRANULARITY;
|
||||||
|
// TODO: set rotencDt
|
||||||
|
uint32_t now = RTOS_GET_MS();
|
||||||
|
uint32_t dt = now - last_tick;
|
||||||
|
rotencDt += dt;
|
||||||
|
last_tick = now;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// TODO : this should probably be handled in the GUI
|
// TODO : this should probably be handled in the GUI
|
||||||
int key;
|
int key;
|
||||||
|
|||||||
Reference in New Issue
Block a user