5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
23 class TrimsTest
: public OpenTxTest
{};
24 class MixerTest
: public OpenTxTest
{};
26 #define CHECK_NO_MOVEMENT(channel, value, duration) \
27 for (int i=1; i<=(duration); i++) { \
28 evalFlightModeMixes(e_perout_mode_normal, 1); \
29 GTEST_ASSERT_EQ((value), chans[(channel)]); \
32 #define CHECK_SLOW_MOVEMENT(channel, sign, duration) \
34 for (int i=1; i<=(duration); i++) { \
35 evalFlightModeMixes(e_perout_mode_normal, 1); \
36 lastAct = lastAct + (sign) * (1<<19)/500; /* 100 on ARM */ \
37 GTEST_ASSERT_EQ(256 * (lastAct >> 8), chans[(channel)]); \
41 #define CHECK_DELAY(channel, duration) \
43 int32_t value = chans[(channel)]; \
44 for (int i=1; i<=(duration); i++) { \
45 evalFlightModeMixes(e_perout_mode_normal, 1); \
46 GTEST_ASSERT_EQ(chans[(channel)], value); \
50 TEST_F(TrimsTest
, throttleTrim
)
53 // stick max + trim max
54 anaInValues
[THR_STICK
] = +1024;
55 setTrimValue(0, THR_STICK
, TRIM_MAX
);
57 EXPECT_EQ(channelOutputs
[2], 1024);
58 // stick max + trim min
59 anaInValues
[THR_STICK
] = +1024;
60 setTrimValue(0, THR_STICK
, TRIM_MIN
);
62 EXPECT_EQ(channelOutputs
[2], 1024);
63 // stick min + trim max
64 anaInValues
[THR_STICK
] = -1024;
65 setTrimValue(0, THR_STICK
, TRIM_MAX
);
67 EXPECT_EQ(channelOutputs
[2], -1024+500);
68 // stick min + trim mid
69 anaInValues
[THR_STICK
] = -1024;
70 setTrimValue(0, THR_STICK
, 0);
72 EXPECT_EQ(channelOutputs
[2], -1024+250);
73 // stick min + trim min
74 anaInValues
[THR_STICK
] = -1024;
75 setTrimValue(0, THR_STICK
, TRIM_MIN
);
77 EXPECT_EQ(channelOutputs
[2], -1024);
79 // now the same tests with extended Trims
80 g_model
.extendedTrims
= 1;
81 // stick max + trim max
82 anaInValues
[THR_STICK
] = +1024;
83 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MAX
);
85 EXPECT_EQ(channelOutputs
[2], 1024);
86 // stick max + trim min
87 anaInValues
[THR_STICK
] = +1024;
88 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MIN
);
90 EXPECT_EQ(channelOutputs
[2], 1024);
91 // stick min + trim max
92 anaInValues
[THR_STICK
] = -1024;
93 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MAX
);
95 EXPECT_EQ(channelOutputs
[2], -1024+2000);
96 // stick min + trim mid
97 anaInValues
[THR_STICK
] = -1024;
98 setTrimValue(0, THR_STICK
, 0);
100 EXPECT_EQ(channelOutputs
[2], -1024+1000);
101 // stick min + trim min
102 anaInValues
[THR_STICK
] = -1024;
103 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MIN
);
105 EXPECT_EQ(channelOutputs
[2], -1024);
109 TEST_F(TrimsTest
, invertedThrottlePlusThrottleTrim
)
111 g_model
.throttleReversed
= 1;
113 // stick max + trim max
114 anaInValues
[THR_STICK
] = +1024;
115 setTrimValue(0, THR_STICK
, TRIM_MAX
);
117 EXPECT_EQ(channelOutputs
[2], -1024);
118 // stick max + trim mid
119 anaInValues
[THR_STICK
] = +1024;
120 setTrimValue(0, THR_STICK
, 0);
122 EXPECT_EQ(channelOutputs
[2], -1024+250);
123 // stick max + trim min
124 anaInValues
[THR_STICK
] = +1024;
125 setTrimValue(0, THR_STICK
, TRIM_MIN
);
127 EXPECT_EQ(channelOutputs
[2], -1024+500);
128 // stick min + trim max
129 anaInValues
[THR_STICK
] = -1024;
130 setTrimValue(0, THR_STICK
, TRIM_MAX
);
132 EXPECT_EQ(channelOutputs
[2], +1024);
133 // stick min + trim min
134 anaInValues
[THR_STICK
] = -1024;
135 setTrimValue(0, THR_STICK
, TRIM_MIN
);
137 EXPECT_EQ(channelOutputs
[2], +1024);
139 // now the same tests with extended Trims
140 g_model
.extendedTrims
= 1;
141 // stick max + trim max
142 anaInValues
[THR_STICK
] = +1024;
143 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MAX
);
145 EXPECT_EQ(channelOutputs
[2], -1024);
146 // stick max + trim mid
147 anaInValues
[THR_STICK
] = +1024;
148 setTrimValue(0, THR_STICK
, 0);
150 EXPECT_EQ(channelOutputs
[2], -1024+1000);
151 // stick max + trim min
152 anaInValues
[THR_STICK
] = +1024;
153 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MIN
);
155 EXPECT_EQ(channelOutputs
[2], -1024+2000);
156 // stick min + trim max
157 anaInValues
[THR_STICK
] = -1024;
158 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MAX
);
160 EXPECT_EQ(channelOutputs
[2], +1024);
161 // stick min + trim min
162 anaInValues
[THR_STICK
] = -1024;
163 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MIN
);
165 EXPECT_EQ(channelOutputs
[2], +1024);
168 TEST_F(TrimsTest
, throttleTrimWithZeroWeightOnThrottle
)
171 // the input already exists
172 ExpoData
*expo
= expoAddress(THR_STICK
);
174 // stick max + trim max
175 anaInValues
[THR_STICK
] = +1024;
176 setTrimValue(0, THR_STICK
, TRIM_MAX
);
178 EXPECT_EQ(channelOutputs
[2], 250);
179 // stick max + trim mid
180 anaInValues
[THR_STICK
] = +1024;
181 setTrimValue(0, THR_STICK
, 0);
183 EXPECT_LE(abs(channelOutputs
[2] - 125), 1); //can't use precise comparison here because of lower precision math on 9X
184 // stick max + trim min
185 anaInValues
[THR_STICK
] = +1024;
186 setTrimValue(0, THR_STICK
, TRIM_MIN
);
188 EXPECT_EQ(channelOutputs
[2], 0);
189 // stick min + trim max
190 anaInValues
[THR_STICK
] = -1024;
191 setTrimValue(0, THR_STICK
, TRIM_MAX
);
193 EXPECT_EQ(channelOutputs
[2], 250);
194 // stick min + trim mid
195 anaInValues
[THR_STICK
] = -1024;
196 setTrimValue(0, THR_STICK
, 0);
198 EXPECT_LE(abs(channelOutputs
[2] - 125), 1);
199 // stick min + trim min
200 anaInValues
[THR_STICK
] = -1024;
201 setTrimValue(0, THR_STICK
, TRIM_MIN
);
203 EXPECT_EQ(channelOutputs
[2], 0);
205 // now some tests with extended Trims
206 g_model
.extendedTrims
= 1;
207 // trim min + various stick positions = should always be same value
208 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MIN
);
209 anaInValues
[THR_STICK
] = -1024;
211 EXPECT_EQ(channelOutputs
[2], 0);
212 anaInValues
[THR_STICK
] = -300;
214 EXPECT_EQ(channelOutputs
[2], 0);
215 anaInValues
[THR_STICK
] = +300;
217 EXPECT_EQ(channelOutputs
[2], 0);
218 anaInValues
[THR_STICK
] = +1024;
220 EXPECT_EQ(channelOutputs
[2], 0);
222 // trim max + various stick positions = should always be same value
223 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MAX
);
224 anaInValues
[THR_STICK
] = -1024;
226 EXPECT_EQ(channelOutputs
[2], 1000);
227 anaInValues
[THR_STICK
] = -300;
229 EXPECT_EQ(channelOutputs
[2], 1000);
230 anaInValues
[THR_STICK
] = +300;
232 EXPECT_EQ(channelOutputs
[2], 1000);
233 anaInValues
[THR_STICK
] = +1024;
235 EXPECT_EQ(channelOutputs
[2], 1000);
238 TEST_F(TrimsTest
, invertedThrottlePlusthrottleTrimWithZeroWeightOnThrottle
)
240 g_model
.throttleReversed
= 1;
242 // the input already exists
243 ExpoData
*expo
= expoAddress(THR_STICK
);
245 // stick max + trim max
246 anaInValues
[THR_STICK
] = +1024;
247 setTrimValue(0, THR_STICK
, TRIM_MAX
);
249 EXPECT_EQ(channelOutputs
[2], 0);
250 // stick max + trim mid
251 anaInValues
[THR_STICK
] = +1024;
252 setTrimValue(0, THR_STICK
, 0);
254 EXPECT_LE(abs(channelOutputs
[2] - 125), 1);
255 // stick max + trim min
256 anaInValues
[THR_STICK
] = +1024;
257 setTrimValue(0, THR_STICK
, TRIM_MIN
);
259 EXPECT_EQ(channelOutputs
[2], 250);
260 // stick min + trim max
261 anaInValues
[THR_STICK
] = -1024;
262 setTrimValue(0, THR_STICK
, TRIM_MAX
);
264 EXPECT_EQ(channelOutputs
[2], 0);
265 // stick min + trim mid
266 anaInValues
[THR_STICK
] = -1024;
267 setTrimValue(0, THR_STICK
, 0);
269 EXPECT_LE(abs(channelOutputs
[2] - 125), 1);
270 // stick min + trim min
271 anaInValues
[THR_STICK
] = -1024;
272 setTrimValue(0, THR_STICK
, TRIM_MIN
);
274 EXPECT_EQ(channelOutputs
[2], 250);
276 // now some tests with extended Trims
277 g_model
.extendedTrims
= 1;
278 // trim min + various stick positions = should always be same value
279 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MIN
);
280 anaInValues
[THR_STICK
] = -1024;
282 EXPECT_EQ(channelOutputs
[2], 1000);
283 anaInValues
[THR_STICK
] = -300;
285 EXPECT_EQ(channelOutputs
[2], 1000);
286 anaInValues
[THR_STICK
] = +300;
288 EXPECT_EQ(channelOutputs
[2], 1000);
289 anaInValues
[THR_STICK
] = +1024;
291 EXPECT_EQ(channelOutputs
[2], 1000);
293 // trim max + various stick positions = should always be same value
294 setTrimValue(0, THR_STICK
, TRIM_EXTENDED_MAX
);
295 anaInValues
[THR_STICK
] = -1024;
297 EXPECT_EQ(channelOutputs
[2], 0);
298 anaInValues
[THR_STICK
] = -300;
300 EXPECT_EQ(channelOutputs
[2], 0);
301 anaInValues
[THR_STICK
] = +300;
303 EXPECT_EQ(channelOutputs
[2], 0);
304 anaInValues
[THR_STICK
] = +1024;
306 EXPECT_EQ(channelOutputs
[2], 0);
309 TEST_F(TrimsTest
, CopyTrimsToOffset
)
311 setTrimValue(0, ELE_STICK
, -100); // -100 on elevator
312 evalFunctions(g_model
.customFn
, modelFunctionsContext
); // it disables all safety channels
313 copyTrimsToOffset(1);
314 EXPECT_EQ(getTrimValue(0, ELE_STICK
), -100); // unchanged
315 EXPECT_EQ(g_model
.limitData
[1].offset
, -195);
318 TEST_F(TrimsTest
, CopySticksToOffset
)
320 anaInValues
[ELE_STICK
] = -100;
322 copySticksToOffset(1);
323 EXPECT_EQ(g_model
.limitData
[1].offset
, -97);
326 TEST_F(TrimsTest
, InstantTrim
)
328 anaInValues
[AIL_STICK
] = 50;
330 EXPECT_EQ(25, getTrimValue(0, AIL_STICK
));
333 TEST_F(TrimsTest
, InstantTrimNegativeCurve
)
335 ExpoData
*expo
= expoAddress(AIL_STICK
);
336 expo
->curve
.type
= CURVE_REF_CUSTOM
;
337 expo
->curve
.value
= 1;
338 g_model
.points
[0] = -100;
339 g_model
.points
[1] = -75;
340 g_model
.points
[2] = -50;
341 g_model
.points
[3] = -25;
342 g_model
.points
[4] = 0;
343 anaInValues
[AIL_STICK
] = 512;
345 EXPECT_EQ(128, getTrimValue(0, AIL_STICK
));
348 TEST(Curves
, LinearIntpol
)
354 for (int8_t i
=-2; i
<=2; i
++) {
355 g_model
.points
[2+i
] = 50*i
;
357 EXPECT_EQ(applyCustomCurve(-1024, 0), -1024);
358 EXPECT_EQ(applyCustomCurve(0, 0), 0);
359 EXPECT_EQ(applyCustomCurve(1024, 0), 1024);
360 EXPECT_EQ(applyCustomCurve(-192, 0), -192);
365 TEST_F(MixerTest
, InfiniteRecursiveChannels
)
367 g_model
.mixData
[0].destCh
= 0;
368 g_model
.mixData
[0].srcRaw
= MIXSRC_CH2
;
369 g_model
.mixData
[0].weight
= 100;
370 g_model
.mixData
[1].destCh
= 1;
371 g_model
.mixData
[1].srcRaw
= MIXSRC_CH3
;
372 g_model
.mixData
[1].weight
= 100;
373 g_model
.mixData
[2].destCh
= 2;
374 g_model
.mixData
[2].srcRaw
= MIXSRC_CH1
;
375 g_model
.mixData
[2].weight
= 100;
376 evalFlightModeMixes(e_perout_mode_normal
, 0);
377 EXPECT_EQ(chans
[2], 0);
378 EXPECT_EQ(chans
[1], 0);
379 EXPECT_EQ(chans
[0], 0);
382 TEST_F(MixerTest
, BlockingChannel
)
384 g_model
.mixData
[0].destCh
= 0;
385 g_model
.mixData
[0].srcRaw
= MIXSRC_CH1
;
386 g_model
.mixData
[0].weight
= 100;
387 evalFlightModeMixes(e_perout_mode_normal
, 0);
388 EXPECT_EQ(chans
[0], 0);
391 TEST_F(MixerTest
, RecursiveAddChannel
)
393 g_model
.mixData
[0].destCh
= 0;
394 g_model
.mixData
[0].mltpx
= MLTPX_ADD
;
395 g_model
.mixData
[0].srcRaw
= MIXSRC_MAX
;
396 g_model
.mixData
[0].weight
= 50;
397 g_model
.mixData
[1].destCh
= 0;
398 g_model
.mixData
[1].mltpx
= MLTPX_ADD
;
399 g_model
.mixData
[1].srcRaw
= MIXSRC_CH2
;
400 g_model
.mixData
[1].weight
= 100;
401 g_model
.mixData
[2].destCh
= 1;
402 g_model
.mixData
[2].srcRaw
= MIXSRC_Rud
;
403 g_model
.mixData
[2].weight
= 100;
404 evalFlightModeMixes(e_perout_mode_normal
, 0);
405 EXPECT_EQ(chans
[0], CHANNEL_MAX
/2);
406 EXPECT_EQ(chans
[1], 0);
409 TEST_F(MixerTest
, RecursiveAddChannelAfterInactivePhase
)
411 g_model
.flightModeData
[1].swtch
= SWSRC_ID1
;
412 g_model
.mixData
[0].destCh
= 0;
413 g_model
.mixData
[0].mltpx
= MLTPX_ADD
;
414 g_model
.mixData
[0].srcRaw
= MIXSRC_CH2
;
415 g_model
.mixData
[0].flightModes
= 0b11110;
416 g_model
.mixData
[0].weight
= 50;
417 g_model
.mixData
[1].destCh
= 0;
418 g_model
.mixData
[1].mltpx
= MLTPX_ADD
;
419 g_model
.mixData
[1].srcRaw
= MIXSRC_MAX
;
420 g_model
.mixData
[1].flightModes
= 0b11101;
421 g_model
.mixData
[1].weight
= 50;
422 g_model
.mixData
[2].destCh
= 1;
423 g_model
.mixData
[2].srcRaw
= MIXSRC_MAX
;
424 g_model
.mixData
[2].weight
= 100;
425 simuSetSwitch(3, -1);
427 EXPECT_EQ(chans
[0], CHANNEL_MAX
/2);
428 EXPECT_EQ(chans
[1], CHANNEL_MAX
);
431 EXPECT_EQ(chans
[0], CHANNEL_MAX
/2);
432 EXPECT_EQ(chans
[1], CHANNEL_MAX
);
436 TEST_F(MixerTest
, SlowOnPhase
)
438 g_model
.flightModeData
[1].swtch
= TR(SWSRC_THR
, SWSRC_SA0
);
439 g_model
.mixData
[0].destCh
= 0;
440 g_model
.mixData
[0].mltpx
= MLTPX_ADD
;
441 g_model
.mixData
[0].srcRaw
= MIXSRC_MAX
;
442 g_model
.mixData
[0].weight
= 100;
443 g_model
.mixData
[0].flightModes
= 0x2 + 0x4 + 0x8 + 0x10 /*only enabled in phase 0*/;
444 g_model
.mixData
[0].speedUp
= 50;
445 g_model
.mixData
[0].speedDown
= 50;
447 s_mixer_first_run_done
= true;
448 mixerCurrentFlightMode
= 0;
449 evalFlightModeMixes(e_perout_mode_normal
, 0);
450 EXPECT_EQ(chans
[0], 0);
452 CHECK_SLOW_MOVEMENT(0, +1, 250);
454 mixerCurrentFlightMode
= 1;
455 CHECK_SLOW_MOVEMENT(0, -1, 250);
458 TEST_F(MixerTest
, SlowOnSwitchSource
)
460 g_model
.mixData
[0].destCh
= 0;
461 g_model
.mixData
[0].mltpx
= MLTPX_ADD
;
462 #if defined(PCBSKY9X)
463 g_model
.mixData
[0].srcRaw
= MIXSRC_THR
;
466 g_eeGeneral
.switchConfig
= 0x03;
467 g_model
.mixData
[0].srcRaw
= MIXSRC_SA
;
470 g_model
.mixData
[0].weight
= 100;
471 g_model
.mixData
[0].speedUp
= 50;
472 g_model
.mixData
[0].speedDown
= 50;
474 s_mixer_first_run_done
= true;
476 simuSetSwitch(switchIndex
, -1);
477 CHECK_SLOW_MOVEMENT(0, -1, 250);
478 EXPECT_EQ(chans
[0], -CHANNEL_MAX
);
480 simuSetSwitch(switchIndex
, 1);
481 CHECK_SLOW_MOVEMENT(0, +1, 500);
484 TEST_F(MixerTest
, SlowDisabledOnStartup
)
486 g_model
.mixData
[0].destCh
= 0;
487 g_model
.mixData
[0].mltpx
= MLTPX_ADD
;
488 g_model
.mixData
[0].srcRaw
= MIXSRC_MAX
;
489 g_model
.mixData
[0].weight
= 100;
490 g_model
.mixData
[0].speedUp
= 50;
491 g_model
.mixData
[0].speedDown
= 50;
493 evalFlightModeMixes(e_perout_mode_normal
, 0);
494 EXPECT_EQ(chans
[0], CHANNEL_MAX
);
497 TEST_F(MixerTest
, DelayOnSwitch
)
499 g_model
.mixData
[0].destCh
= 0;
500 g_model
.mixData
[0].mltpx
= MLTPX_ADD
;
501 g_model
.mixData
[0].srcRaw
= MIXSRC_MAX
;
502 g_model
.mixData
[0].weight
= 100;
503 #if defined(PCBTARANIS) || defined(PCBHORUS)
504 g_model
.mixData
[0].swtch
= SWSRC_SA2
;
505 int switch_index
= 0;
507 g_model
.mixData
[0].swtch
= SWSRC_THR
;
508 int switch_index
= 1;
510 g_model
.mixData
[0].delayUp
= 50;
511 g_model
.mixData
[0].delayDown
= 50;
513 evalFlightModeMixes(e_perout_mode_normal
, 0);
514 EXPECT_EQ(chans
[0], 0);
516 simuSetSwitch(switch_index
, 1);
519 evalFlightModeMixes(e_perout_mode_normal
, 1);
520 EXPECT_EQ(chans
[0], CHANNEL_MAX
);
522 simuSetSwitch(switch_index
, 0);
525 evalFlightModeMixes(e_perout_mode_normal
, 1);
526 EXPECT_EQ(chans
[0], 0);
529 TEST_F(MixerTest
, SlowOnMultiply
)
531 g_model
.mixData
[0].destCh
= 0;
532 g_model
.mixData
[0].mltpx
= MLTPX_ADD
;
533 g_model
.mixData
[0].srcRaw
= MIXSRC_MAX
;
534 g_model
.mixData
[0].weight
= 100;
535 g_model
.mixData
[1].destCh
= 0;
536 g_model
.mixData
[1].mltpx
= MLTPX_MUL
;
537 g_model
.mixData
[1].srcRaw
= MIXSRC_MAX
;
538 g_model
.mixData
[1].weight
= 100;
539 g_model
.mixData
[1].swtch
= TR(SWSRC_THR
, SWSRC_SA0
);
540 g_model
.mixData
[1].speedUp
= 50;
541 g_model
.mixData
[1].speedDown
= 50;
543 s_mixer_first_run_done
= true;
546 CHECK_SLOW_MOVEMENT(0, 1, 250);
548 simuSetSwitch(0, -1);
549 CHECK_NO_MOVEMENT(0, CHANNEL_MAX
, 250);
552 CHECK_NO_MOVEMENT(0, CHANNEL_MAX
, 250);
555 TEST_F(TrimsTest
, throttleTrimEle
) {
560 g_eeGeneral
.templateSetup
= 17;
561 applyDefaultTemplate();
563 // checks ELE sticks are not affected by throttleTrim
564 // stick max + trim min
565 anaInValues
[ELE_STICK
] = +1024;
566 setTrimValue(0, ELE_STICK
, TRIM_MIN
);
568 EXPECT_EQ(channelOutputs
[2], 1024 - 250);
573 g_eeGeneral
.templateSetup
= 0;
574 applyDefaultTemplate();
578 TEST(Heli
, BasicTest
)
584 g_model
.swashR
.collectiveSource
= MIXSRC_Thr
;
585 g_model
.swashR
.elevatorSource
= MIXSRC_Ele
;
586 g_model
.swashR
.aileronSource
= MIXSRC_Ail
;
587 g_model
.swashR
.collectiveWeight
= 100;
588 g_model
.swashR
.elevatorWeight
= 100;
589 g_model
.swashR
.aileronWeight
= 100;
590 g_model
.swashR
.type
= SWASH_TYPE_120
;
591 g_model
.mixData
[0].destCh
= 0;
592 g_model
.mixData
[0].mltpx
= MLTPX_ADD
;
593 g_model
.mixData
[0].srcRaw
= MIXSRC_CYC1
;
594 g_model
.mixData
[0].weight
= 100;
595 g_model
.mixData
[1].destCh
= 1;
596 g_model
.mixData
[1].mltpx
= MLTPX_ADD
;
597 g_model
.mixData
[1].srcRaw
= MIXSRC_CYC2
;
598 g_model
.mixData
[1].weight
= 100;
599 g_model
.mixData
[2].destCh
= 2;
600 g_model
.mixData
[2].mltpx
= MLTPX_ADD
;
601 g_model
.mixData
[2].srcRaw
= MIXSRC_CYC3
;
602 g_model
.mixData
[2].weight
= 100;
603 anaInValues
[ELE_STICK
] = 1024;
604 evalFlightModeMixes(e_perout_mode_normal
, 0);
605 EXPECT_EQ(chans
[0], -CHANNEL_MAX
);
606 EXPECT_EQ(chans
[1], CHANNEL_MAX
/2);
607 EXPECT_EQ(chans
[2], CHANNEL_MAX
/2);
610 TEST(Heli
, Mode2Test
)
616 g_eeGeneral
.templateSetup
= 2;
617 applyDefaultTemplate();
618 g_model
.swashR
.collectiveSource
= MIXSRC_Thr
;
619 g_model
.swashR
.elevatorSource
= MIXSRC_Ele
;
620 g_model
.swashR
.aileronSource
= MIXSRC_Ail
;
621 g_model
.swashR
.collectiveWeight
= 100;
622 g_model
.swashR
.elevatorWeight
= 100;
623 g_model
.swashR
.aileronWeight
= 100;
624 g_model
.swashR
.type
= SWASH_TYPE_120
;
625 g_model
.mixData
[0].destCh
= 0;
626 g_model
.mixData
[0].mltpx
= MLTPX_ADD
;
627 g_model
.mixData
[0].srcRaw
= MIXSRC_CYC1
;
628 g_model
.mixData
[0].weight
= 100;
629 g_model
.mixData
[1].destCh
= 1;
630 g_model
.mixData
[1].mltpx
= MLTPX_ADD
;
631 g_model
.mixData
[1].srcRaw
= MIXSRC_CYC2
;
632 g_model
.mixData
[1].weight
= 100;
633 g_model
.mixData
[2].destCh
= 2;
634 g_model
.mixData
[2].mltpx
= MLTPX_ADD
;
635 g_model
.mixData
[2].srcRaw
= MIXSRC_CYC3
;
636 g_model
.mixData
[2].weight
= 100;
637 anaInValues
[ELE_STICK
] = 1024;
638 evalFlightModeMixes(e_perout_mode_normal
, 0);
639 EXPECT_EQ(chans
[0], -CHANNEL_MAX
);
640 EXPECT_EQ(chans
[1], CHANNEL_MAX
/2);
641 EXPECT_EQ(chans
[2], CHANNEL_MAX
/2);
646 TEST(Trainer
, UnpluggedTest
)
652 g_model
.mixData
[0].destCh
= 0;
653 g_model
.mixData
[0].mltpx
= MLTPX_ADD
;
654 g_model
.mixData
[0].srcRaw
= MIXSRC_FIRST_TRAINER
;
655 g_model
.mixData
[0].weight
= 100;
656 g_model
.mixData
[0].delayUp
= 50;
657 g_model
.mixData
[0].delayDown
= 50;
658 ppmInputValidityTimer
= 0;
660 CHECK_DELAY(0, 5000);