1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-26 01:35:21 +03:00

[all] Mixer bug when a MULTIPLY mix used with a slow

This commit is contained in:
bsongis 2013-10-02 18:00:32 +00:00
parent bc8d6ef9c0
commit defb936d33
4 changed files with 42 additions and 8 deletions

View file

@ -533,6 +533,12 @@ TEST(Mixer, RecursiveAddChannelAfterInactivePhase)
EXPECT_EQ(chans[1], CHANNEL_MAX);
}
#define CHECK_NO_MOVEMENT(channel, value, duration) \
for (int i=1; i<=(duration); i++) { \
perOut(e_perout_mode_normal, 1); \
EXPECT_EQ(chans[(channel)], (value)); \
}
#define CHECK_SLOW_MOVEMENT(channel, sign, duration) \
do { \
for (int i=1; i<=(duration); i++) { \
@ -723,6 +729,32 @@ TEST(Mixer, NoTrimOnInactiveMix)
simuSetSwitch(0, 0);
CHECK_SLOW_MOVEMENT(0, -1, 100);
}
TEST(Mixer, SlowOnMultiply)
{
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[1].destCh = 0;
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;
simuSetSwitch(0, 1);
CHECK_SLOW_MOVEMENT(0, 1, 250);
simuSetSwitch(0, 0);
CHECK_NO_MOVEMENT(0, CHANNEL_MAX, 250);
simuSetSwitch(0, 1);
CHECK_NO_MOVEMENT(0, CHANNEL_MAX, 250);
}
#endif
TEST(Curves, LinearIntpol)

View file

@ -1008,8 +1008,10 @@ PACK(typedef struct t_PhaseData {
enum SwitchSources {
SWSRC_NONE = 0,
SWSRC_FIRST_SWITCH,
#if defined(PCBTARANIS)
SWSRC_SA0,
SWSRC_SA0 = SWSRC_FIRST_SWITCH,
SWSRC_SA1,
SWSRC_SA2,
SWSRC_SB0,
@ -1032,7 +1034,7 @@ enum SwitchSources {
SWSRC_SH0,
SWSRC_SH2,
#else
SWSRC_ID0,
SWSRC_ID0 = SWSRC_FIRST_SWITCH,
SWSRC_ID1,
SWSRC_ID2,
#if defined(EXTRA_3POS)
@ -1040,7 +1042,6 @@ enum SwitchSources {
SWSRC_ID4,
SWSRC_ID5,
#endif
SWSRC_THR,
SWSRC_RUD,
SWSRC_ELE,

View file

@ -2964,7 +2964,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
else if (!mixEnabled) {
if (md->speedDown && md->mltpx!=MLTPX_REP) {
if (mixCondition) {
v = 0;
v = (md->mltpx == MLTPX_ADD ? 0 : RESX);
apply_offset_and_curve = false;
}
}
@ -3020,16 +3020,16 @@ void perOut(uint8_t mode, uint8_t tick10ms)
int32_t rate = (int32_t) tick10ms << (DEL_MULT_SHIFT+11); // = DEL_MULT*2048*tick10ms
// rate equals a full range for one second; if less time is passed rate is accordingly smaller
// if one second passed, rate would be 2048 (full motion)*256(recalculated weight)*100(100 ticks needed for one second)
int32_t currentValue=((int32_t) v<<DEL_MULT_SHIFT);
if (diff>0) {
if (md->speedUp>0) {
int32_t currentValue = ((int32_t) v<<DEL_MULT_SHIFT);
if (diff > 0) {
if (md->speedUp > 0) {
// if a speed upwards is defined recalculate the new value according configured speed; the higher the speed the smaller the add value is
int32_t newValue = tact+rate/((int16_t)(100/SLOW_STEP)*md->speedUp);
if (newValue<currentValue) currentValue = newValue; // Endposition; prevent toggling around the destination
}
}
else { // if is <0 because ==0 is not possible
if (md->speedDown>0) {
if (md->speedDown > 0) {
// see explanation in speedUp
int32_t newValue = tact-rate/((int16_t)(100/SLOW_STEP)*md->speedDown);
if (newValue>currentValue) currentValue = newValue; // Endposition; prevent toggling around the destination

View file

@ -178,6 +178,7 @@ void simuSetTrim(uint8_t trim, bool state)
}
}
// TODO use a better numbering to allow google tests to work on Taranis
void simuSetSwitch(uint8_t swtch, int8_t state)
{
// printf("swtch=%d state=%d\n", swtch, state); fflush(stdout);