Issue #773 fixed (+ non regression tests added)
This commit is contained in:
+68
-29
@@ -42,7 +42,10 @@
|
||||
|
||||
void doMixerCalculations();
|
||||
|
||||
#define MODEL_RESET() memset(&g_model, 0, sizeof(g_model))
|
||||
#define MODEL_RESET() \
|
||||
memset(&g_model, 0, sizeof(g_model)); \
|
||||
extern bool s_mixer_first_run_done; \
|
||||
s_mixer_first_run_done = false;
|
||||
|
||||
#define MIXER_RESET() \
|
||||
memset(channelOutputs, 0, sizeof(channelOutputs)); \
|
||||
@@ -62,6 +65,7 @@ uint16_t anaIn(uint8_t chan)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(PCBTARANIS)
|
||||
TEST(Trims, greaterTrimLink)
|
||||
{
|
||||
MODEL_RESET();
|
||||
@@ -88,6 +92,7 @@ TEST(Trims, infiniteChainedTrims)
|
||||
setTrimValue(3, 0, TRIM_EXTENDED_MAX+3); // link to FP2 trim
|
||||
EXPECT_EQ(getRawTrimValue(getTrimFlightPhase(0, 2), 0), 32);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(outdezNAtt, test_unsigned)
|
||||
{
|
||||
@@ -565,16 +570,18 @@ TEST(Mixer, SlowOnSwitch)
|
||||
g_model.mixData[0].srcRaw = MIXSRC_MAX;
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[0].swtch = SWSRC_THR;
|
||||
g_model.mixData[0].speedUp = 10;
|
||||
g_model.mixData[0].speedDown = 10;
|
||||
g_model.mixData[0].speedUp = SLOW_STEP*5;
|
||||
g_model.mixData[0].speedDown = SLOW_STEP*5;
|
||||
|
||||
s_mixer_first_run_done = true;
|
||||
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
|
||||
simuSetSwitch(0, 1);
|
||||
CHECK_SLOW_MOVEMENT(0, +1, 250);
|
||||
|
||||
simuSetSwitch(0, 0);
|
||||
simuSetSwitch(0, -1);
|
||||
CHECK_SLOW_MOVEMENT(0, -1, 250);
|
||||
}
|
||||
|
||||
@@ -587,11 +594,12 @@ TEST(Mixer, SlowUpOnSwitch)
|
||||
g_model.mixData[0].srcRaw = MIXSRC_MAX;
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[0].swtch = SWSRC_THR;
|
||||
g_model.mixData[0].speedUp = 10;
|
||||
g_model.mixData[0].speedUp = SLOW_STEP*5;
|
||||
g_model.mixData[0].speedDown = 0;
|
||||
|
||||
simuSetSwitch(0, 0);
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
s_mixer_first_run_done = true;
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
|
||||
simuSetSwitch(0, 1);
|
||||
@@ -605,20 +613,22 @@ TEST(Mixer, SlowUpOnSwitch)
|
||||
simuSetSwitch(0, 1);
|
||||
CHECK_SLOW_MOVEMENT(0, +1, 100);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(Mixer, SlowOnPhase)
|
||||
{
|
||||
MODEL_RESET();
|
||||
MIXER_RESET();
|
||||
g_model.phaseData[1].swtch = SWSRC_THR;
|
||||
g_model.phaseData[1].swtch = TR(SWSRC_THR, SWSRC_SA0);
|
||||
g_model.mixData[0].destCh = 0;
|
||||
g_model.mixData[0].mltpx = MLTPX_ADD;
|
||||
g_model.mixData[0].srcRaw = MIXSRC_MAX;
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[0].phases = 0x2 + 0x4 + 0x8 + 0x10 /*only enabled in phase 0*/;
|
||||
g_model.mixData[0].speedUp = 10;
|
||||
g_model.mixData[0].speedDown = 10;
|
||||
g_model.mixData[0].speedUp = SLOW_STEP*5;
|
||||
g_model.mixData[0].speedDown = SLOW_STEP*5;
|
||||
|
||||
s_mixer_first_run_done = true;
|
||||
s_perout_flight_phase = 0;
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
@@ -629,20 +639,26 @@ TEST(Mixer, SlowOnPhase)
|
||||
CHECK_SLOW_MOVEMENT(0, -1, 250);
|
||||
}
|
||||
|
||||
#if !defined(CPUARM)
|
||||
TEST(Mixer, SlowOnSwitchAndPhase)
|
||||
{
|
||||
MODEL_RESET();
|
||||
MIXER_RESET();
|
||||
g_model.phaseData[1].swtch = SWSRC_THR;
|
||||
g_model.phaseData[1].swtch = TR(SWSRC_THR, SWSRC_SA0);
|
||||
g_model.mixData[0].destCh = 0;
|
||||
g_model.mixData[0].mltpx = MLTPX_ADD;
|
||||
g_model.mixData[0].srcRaw = MIXSRC_MAX;
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[0].swtch = SWSRC_THR;
|
||||
g_model.mixData[0].swtch = TR(SWSRC_THR, SWSRC_SA0);
|
||||
#if defined(CPUARM)
|
||||
g_model.mixData[0].phases = 0x2 + 0x4 + 0x8 + 0x10 + 0x20 + 0x40 + 0x80 + 0x100 /*only enabled in phase 0*/;
|
||||
#else
|
||||
g_model.mixData[0].phases = 0x2 + 0x4 + 0x8 + 0x10 /*only enabled in phase 0*/;
|
||||
g_model.mixData[0].speedUp = 10;
|
||||
g_model.mixData[0].speedDown = 10;
|
||||
#endif
|
||||
g_model.mixData[0].speedUp = SLOW_STEP*5;
|
||||
g_model.mixData[0].speedDown = SLOW_STEP*5;
|
||||
|
||||
s_mixer_first_run_done = true;
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
|
||||
@@ -650,25 +666,26 @@ TEST(Mixer, SlowOnSwitchAndPhase)
|
||||
s_perout_flight_phase = 0;
|
||||
CHECK_SLOW_MOVEMENT(0, +1, 250);
|
||||
|
||||
simuSetSwitch(0, 0);
|
||||
simuSetSwitch(0, -1);
|
||||
s_perout_flight_phase = 1;
|
||||
CHECK_SLOW_MOVEMENT(0, -1, 250);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(PCBTARANIS)
|
||||
TEST(Mixer, SlowOnSwitchSource)
|
||||
{
|
||||
MODEL_RESET();
|
||||
MIXER_RESET();
|
||||
g_model.mixData[0].destCh = 0;
|
||||
g_model.mixData[0].mltpx = MLTPX_ADD;
|
||||
g_model.mixData[0].srcRaw = MIXSRC_THR;
|
||||
g_model.mixData[0].srcRaw = TR(MIXSRC_THR, MIXSRC_SA);
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[0].speedUp = 10;
|
||||
g_model.mixData[0].speedDown = 10;
|
||||
g_model.mixData[0].speedUp = SLOW_STEP*5;
|
||||
g_model.mixData[0].speedDown = SLOW_STEP*5;
|
||||
|
||||
simuSetSwitch(0, 0);
|
||||
s_mixer_first_run_done = true;
|
||||
|
||||
simuSetSwitch(0, -1);
|
||||
CHECK_SLOW_MOVEMENT(0, -1, 250);
|
||||
EXPECT_EQ(chans[0], -CHANNEL_MAX);
|
||||
|
||||
@@ -676,6 +693,22 @@ TEST(Mixer, SlowOnSwitchSource)
|
||||
CHECK_SLOW_MOVEMENT(0, +1, 500);
|
||||
}
|
||||
|
||||
TEST(Mixer, SlowDisabledOnStartup)
|
||||
{
|
||||
MODEL_RESET();
|
||||
MIXER_RESET();
|
||||
g_model.mixData[0].destCh = 0;
|
||||
g_model.mixData[0].mltpx = MLTPX_ADD;
|
||||
g_model.mixData[0].srcRaw = MIXSRC_MAX;
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[0].speedUp = SLOW_STEP*5;
|
||||
g_model.mixData[0].speedDown = SLOW_STEP*5;
|
||||
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], CHANNEL_MAX);
|
||||
}
|
||||
|
||||
#if !defined(PCBTARANIS)
|
||||
TEST(Mixer, SlowAndDelayOnReplace3POSSource)
|
||||
{
|
||||
MODEL_RESET();
|
||||
@@ -685,9 +718,11 @@ TEST(Mixer, SlowAndDelayOnReplace3POSSource)
|
||||
g_model.mixData[0].srcRaw = MIXSRC_3POS;
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[0].delayUp = 10;
|
||||
g_model.mixData[0].speedUp = 10;
|
||||
g_model.mixData[0].speedDown = 10;
|
||||
g_model.mixData[0].speedUp = SLOW_STEP*5;
|
||||
g_model.mixData[0].speedDown = SLOW_STEP*5;
|
||||
|
||||
s_mixer_first_run_done = true;
|
||||
|
||||
simuSetSwitch(3, -1);
|
||||
CHECK_SLOW_MOVEMENT(0, -1, 250);
|
||||
EXPECT_EQ(chans[0], -CHANNEL_MAX);
|
||||
@@ -717,7 +752,7 @@ TEST(Mixer, SlowOnSwitchReplace)
|
||||
g_model.mixData[1].srcRaw = MIXSRC_MAX;
|
||||
g_model.mixData[1].weight = 100;
|
||||
g_model.mixData[1].swtch = SWSRC_THR;
|
||||
g_model.mixData[1].speedDown = 10;
|
||||
g_model.mixData[1].speedDown = SLOW_STEP*5;
|
||||
|
||||
simuSetSwitch(0, 0);
|
||||
perOut(e_perout_mode_normal, 1);
|
||||
@@ -745,16 +780,19 @@ TEST(Mixer, NoTrimOnInactiveMix)
|
||||
g_model.mixData[0].srcRaw = MIXSRC_Thr;
|
||||
g_model.mixData[0].weight = 100;
|
||||
g_model.mixData[0].swtch = SWSRC_THR;
|
||||
g_model.mixData[0].speedUp = 10;
|
||||
g_model.mixData[0].speedDown = 10;
|
||||
g_model.mixData[0].speedUp = SLOW_STEP*5;
|
||||
g_model.mixData[0].speedDown = SLOW_STEP*5;
|
||||
setTrimValue(0, 2, 256);
|
||||
|
||||
s_mixer_first_run_done = true;
|
||||
|
||||
simuSetSwitch(0, 1);
|
||||
CHECK_SLOW_MOVEMENT(0, 1, 100);
|
||||
|
||||
simuSetSwitch(0, 0);
|
||||
simuSetSwitch(0, -1);
|
||||
CHECK_SLOW_MOVEMENT(0, -1, 100);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(Mixer, SlowOnMultiply)
|
||||
{
|
||||
@@ -768,20 +806,21 @@ TEST(Mixer, SlowOnMultiply)
|
||||
g_model.mixData[1].mltpx = MLTPX_MUL;
|
||||
g_model.mixData[1].srcRaw = MIXSRC_MAX;
|
||||
g_model.mixData[1].weight = 100;
|
||||
g_model.mixData[1].swtch = SWSRC_THR;
|
||||
g_model.mixData[1].speedUp = 10;
|
||||
g_model.mixData[1].speedDown = 10;
|
||||
g_model.mixData[1].swtch = TR(SWSRC_THR, SWSRC_SA0);
|
||||
g_model.mixData[1].speedUp = SLOW_STEP*5;
|
||||
g_model.mixData[1].speedDown = SLOW_STEP*5;
|
||||
|
||||
s_mixer_first_run_done = true;
|
||||
|
||||
simuSetSwitch(0, 1);
|
||||
CHECK_SLOW_MOVEMENT(0, 1, 250);
|
||||
|
||||
simuSetSwitch(0, 0);
|
||||
simuSetSwitch(0, -1);
|
||||
CHECK_NO_MOVEMENT(0, CHANNEL_MAX, 250);
|
||||
|
||||
simuSetSwitch(0, 1);
|
||||
CHECK_NO_MOVEMENT(0, CHANNEL_MAX, 250);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(Curves, LinearIntpol)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user