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:
Raphael Coeffic
2022-11-05 19:39:45 +10:00
committed by GitHub
parent 062564cc41
commit 4071eacc92
2 changed files with 22 additions and 3 deletions
+10
View File
@@ -466,6 +466,8 @@ void OpenTxSim::updateKeysAndSwitches(bool start)
#endif
}
extern volatile uint32_t rotencDt;
long OpenTxSim::onTimeout(FXObject*, FXSelector, void*)
{
if (hasFocus()) {
@@ -485,6 +487,14 @@ long OpenTxSim::onTimeout(FXObject*, FXSelector, void*)
else {
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
}
+12 -3
View File
@@ -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)
{
#if defined(ROTARY_ENCODER_NAVIGATION)
(g_eeGeneral.rotEncMode >= ROTARY_ENCODER_MODE_INVERT_BOTH ? steps *= -1
: steps);
ROTARY_ENCODER_NAVIGATION_VALUE += steps * ROTARY_ENCODER_GRANULARITY;
static uint32_t last_tick = 0;
if (steps != 0) {
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
// TODO : this should probably be handled in the GUI
int key;