fix: Throttle invert and gimbal dead zone (#3864)

This commit is contained in:
Raphael Coeffic
2023-07-30 21:37:21 +10:00
committed by GitHub
parent 032d581821
commit 1912697616
2 changed files with 26 additions and 2 deletions
+2 -2
View File
@@ -526,7 +526,7 @@ void evalInputs(uint8_t mode)
#if defined(STICK_DEAD_ZONE)
// dead zone invented by FlySky in my opinion it should goes into ADC
// float calculations are not efficient
if (g_eeGeneral.stickDeadZone && ch != inputMappingConvertMode(inputMappingGetThrottle())) {
if (g_eeGeneral.stickDeadZone && ch != inputMappingGetThrottle()) {
if (v > P_OFFSET) {
// y=ax+b
v = (int)((aParam * (float)v) - bParam);
@@ -539,7 +539,7 @@ void evalInputs(uint8_t mode)
}
#endif
if (g_model.throttleReversed && ch==inputMappingConvertMode(inputMappingGetThrottle())) {
if (g_model.throttleReversed && ch == inputMappingGetThrottle()) {
v = -v;
}
+24
View File
@@ -75,6 +75,30 @@ class MixerTest : public OpenTxTest {};
#define MIXSRC_CYC2 (MIXSRC_FIRST_HELI + 1)
#define MIXSRC_CYC3 (MIXSRC_FIRST_HELI + 2)
TEST_F(MixerTest, throttleInvert)
{
// Mode 1 / reversed
g_eeGeneral.stickMode = 0;
g_model.throttleReversed = 1;
anaSetFiltered(inputMappingConvertMode(THR_STICK), -1024);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], +1024);
// Mode 2 / reversed
g_eeGeneral.stickMode = 1;
g_model.throttleReversed = 1;
anaSetFiltered(inputMappingConvertMode(THR_STICK), -1024);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], +1024);
// Mode 2 / normal
g_eeGeneral.stickMode = 1;
g_model.throttleReversed = 0;
anaSetFiltered(inputMappingConvertMode(THR_STICK), -1024);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024);
}
TEST_F(TrimsTest, throttleTrim)
{
g_model.thrTrim = 1;