TEST(getSwitch, OldTypeStickyCSW) { MODEL_RESET(); MIXER_RESET(); g_model.logicalSw[0] = { SWSRC_SA0, 0, 0, LS_FUNC_AND }; g_model.logicalSw[1] = { SWSRC_SW1, SWSRC_SW2, 0, LS_FUNC_OR }; evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(SWSRC_SW2), false); // now trigger SA0, both switches should become true simuSetSwitch(0, -1); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), true); EXPECT_EQ(getSwitch(SWSRC_SW2), true); // now release SA0 and SW2 should stay true simuSetSwitch(0, 0); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(SWSRC_SW2), true); // now reset logical switches logicalSwitchesReset(); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(SWSRC_SW2), false); }
TEST(getSwitch, OldTypeStickyCSW) { RADIO_RESET(); MODEL_RESET(); MIXER_RESET(); SET_LOGICAL_SWITCH(0, LS_FUNC_AND, SWSRC_SA0, SWSRC_NONE); SET_LOGICAL_SWITCH(1, LS_FUNC_OR, SWSRC_SW1, SWSRC_SW2); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(SWSRC_SW2), false); // now trigger SA0, both switches should become true simuSetSwitch(0, -1); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), true); EXPECT_EQ(getSwitch(SWSRC_SW2), true); // now release SA0 and SW2 should stay true simuSetSwitch(0, 0); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(SWSRC_SW2), true); // now reset logical switches logicalSwitchesReset(); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(SWSRC_SW2), false); }
TEST(getSwitch, recursiveSW) { MODEL_RESET(); MIXER_RESET(); g_model.logicalSw[0] = { SWSRC_RUD, -SWSRC_SW2, LS_FUNC_OR }; g_model.logicalSw[1] = { SWSRC_ELE, -SWSRC_SW1, LS_FUNC_OR }; evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(SWSRC_SW2), true); LS_RECURSIVE_EVALUATION_RESET(); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(SWSRC_SW2), true); simuSetSwitch(1, 1); LS_RECURSIVE_EVALUATION_RESET(); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), true); EXPECT_EQ(getSwitch(SWSRC_SW2), true); LS_RECURSIVE_EVALUATION_RESET(); evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), true); EXPECT_EQ(getSwitch(SWSRC_SW2), false); }
TEST(Trims, greaterTrimLink) { MODEL_RESET(); setTrimValue(1, RUD_STICK, TRIM_EXTENDED_MAX+3); // link to FP3 trim setTrimValue(3, RUD_STICK, 32); EXPECT_EQ(getRawTrimValue(getTrimFlightPhase(1, RUD_STICK), RUD_STICK), 32); }
TEST(Mixer, RecursiveAddChannelAfterInactivePhase) { MODEL_RESET(); MIXER_RESET(); g_model.flightModeData[1].swtch = SWSRC_ID1; g_model.mixData[0].destCh = 0; g_model.mixData[0].mltpx = MLTPX_ADD; g_model.mixData[0].srcRaw = MIXSRC_CH2; g_model.mixData[0].flightModes = 0b11110; g_model.mixData[0].weight = 50; g_model.mixData[1].destCh = 0; g_model.mixData[1].mltpx = MLTPX_ADD; g_model.mixData[1].srcRaw = MIXSRC_MAX; g_model.mixData[1].flightModes = 0b11101; g_model.mixData[1].weight = 50; g_model.mixData[2].destCh = 1; g_model.mixData[2].srcRaw = MIXSRC_MAX; g_model.mixData[2].weight = 100; simuSetSwitch(3, -1); #if defined(CPUARM) doMixerCalculations(); #else perMain(); #endif EXPECT_EQ(chans[0], CHANNEL_MAX/2); EXPECT_EQ(chans[1], CHANNEL_MAX); simuSetSwitch(3, 0); #if defined(CPUARM) doMixerCalculations(); #else perMain(); #endif EXPECT_EQ(chans[0], CHANNEL_MAX/2); EXPECT_EQ(chans[1], CHANNEL_MAX); }
TEST(Mixer, R2029Comment) { MODEL_RESET(); MIXER_RESET(); g_model.mixData[0].destCh = 0; g_model.mixData[0].srcRaw = MIXSRC_CH2; g_model.mixData[0].swtch = -SWSRC_THR; g_model.mixData[0].weight = 100; g_model.mixData[1].destCh = 1; g_model.mixData[1].srcRaw = MIXSRC_Thr; g_model.mixData[1].swtch = SWSRC_THR; g_model.mixData[1].weight = 100; anaInValues[THR_STICK] = 1024; simuSetSwitch(0, 1); evalFlightModeMixes(e_perout_mode_normal, 0); EXPECT_EQ(chans[0], 0); EXPECT_EQ(chans[1], CHANNEL_MAX); simuSetSwitch(0, 0); evalFlightModeMixes(e_perout_mode_normal, 0); EXPECT_EQ(chans[0], 0); EXPECT_EQ(chans[1], 0); simuSetSwitch(0, 1); evalFlightModeMixes(e_perout_mode_normal, 0); EXPECT_EQ(chans[0], 0); EXPECT_EQ(chans[1], CHANNEL_MAX); }
TEST(FrSkySPORT, frskyVfas) { uint8_t packet[FRSKY_SPORT_PACKET_SIZE]; MODEL_RESET(); TELEMETRY_RESET(); // tests for Vfas generateSportFasVoltagePacket(packet, 5000); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 5000); EXPECT_EQ(telemetryItems[0].valueMin, 5000); EXPECT_EQ(telemetryItems[0].valueMax, 5000); generateSportFasVoltagePacket(packet, 6524); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 6524); EXPECT_EQ(telemetryItems[0].valueMin, 6524); // the batt was changed (val > old max) EXPECT_EQ(telemetryItems[0].valueMax, 6524); generateSportFasVoltagePacket(packet, 1248); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 1248); EXPECT_EQ(telemetryItems[0].valueMin, 1248); EXPECT_EQ(telemetryItems[0].valueMax, 6524); generateSportFasVoltagePacket(packet, 2248); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 2248); EXPECT_EQ(telemetryItems[0].valueMin, 1248); EXPECT_EQ(telemetryItems[0].valueMax, 6524); }
TEST(Mixer, SlowOnSwitchAndPhase) { MODEL_RESET(); MIXER_RESET(); g_model.flightModeData[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 = TR(SWSRC_THR, SWSRC_SA0); #if defined(CPUARM) g_model.mixData[0].flightModes = 0x2 + 0x4 + 0x8 + 0x10 + 0x20 + 0x40 + 0x80 + 0x100 /*only enabled in phase 0*/; #else g_model.mixData[0].flightModes = 0x2 + 0x4 + 0x8 + 0x10 /*only enabled in phase 0*/; #endif g_model.mixData[0].speedUp = SLOW_STEP*5; g_model.mixData[0].speedDown = SLOW_STEP*5; s_mixer_first_run_done = true; evalFlightModeMixes(e_perout_mode_normal, 0); EXPECT_EQ(chans[0], 0); simuSetSwitch(0, 1); mixerCurrentFlightMode = 0; CHECK_SLOW_MOVEMENT(0, +1, 250); simuSetSwitch(0, -1); mixerCurrentFlightMode = 1; CHECK_SLOW_MOVEMENT(0, -1, 250); }
TEST(Mixer, SlowAndDelayOnReplace3POSSource) { MODEL_RESET(); MIXER_RESET(); g_model.mixData[0].destCh = 0; g_model.mixData[0].mltpx = MLTPX_REP; g_model.mixData[0].srcRaw = MIXSRC_3POS; g_model.mixData[0].weight = 100; g_model.mixData[0].delayUp = 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); simuSetSwitch(3, 0); CHECK_DELAY(0, 500); CHECK_SLOW_MOVEMENT(0, +1, 250/*half course*/); EXPECT_EQ(chans[0], 0); simuSetSwitch(3, 1); CHECK_DELAY(0, 500); CHECK_SLOW_MOVEMENT(0, +1, 250); }
TEST(Mixer, DelayOnSwitch) { 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].swtch = TR(SWSRC_THR, SWSRC_SA2); g_model.mixData[0].delayUp = DELAY_STEP*5; g_model.mixData[0].delayDown = DELAY_STEP*5; evalFlightModeMixes(e_perout_mode_normal, 0); EXPECT_EQ(chans[0], 0); simuSetSwitch(0, 1); CHECK_DELAY(0, 500); evalFlightModeMixes(e_perout_mode_normal, 1); EXPECT_EQ(chans[0], CHANNEL_MAX); simuSetSwitch(0, 0); CHECK_DELAY(0, 500); evalFlightModeMixes(e_perout_mode_normal, 1); EXPECT_EQ(chans[0], 0); }
TEST(Mixer, SlowOnSwitchReplace) { 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 = 50; g_model.mixData[1].destCh = 0; g_model.mixData[1].mltpx = MLTPX_REP; 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 = SLOW_STEP*5; simuSetSwitch(0, 0); evalFlightModeMixes(e_perout_mode_normal, 1); EXPECT_EQ(chans[0], CHANNEL_MAX/2); simuSetSwitch(0, 1); evalFlightModeMixes(e_perout_mode_normal, 1); // slow is not applied, but it's better than the first mix not applied at all! EXPECT_EQ(chans[0], CHANNEL_MAX); simuSetSwitch(0, 0); evalFlightModeMixes(e_perout_mode_normal, 1); // slow is not applied, but it's better than the first mix not applied at all! EXPECT_EQ(chans[0], CHANNEL_MAX/2); }
TEST(Mixer, SlowUpOnSwitch) { 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].swtch = SWSRC_THR; g_model.mixData[0].speedUp = SLOW_STEP*5; g_model.mixData[0].speedDown = 0; simuSetSwitch(0, 0); evalFlightModeMixes(e_perout_mode_normal, 0); s_mixer_first_run_done = true; EXPECT_EQ(chans[0], 0); simuSetSwitch(0, 1); CHECK_SLOW_MOVEMENT(0, +1, 250); simuSetSwitch(0, 0); evalFlightModeMixes(e_perout_mode_normal, 1); EXPECT_EQ(chans[0], 0); lastAct = 0; simuSetSwitch(0, 1); CHECK_SLOW_MOVEMENT(0, +1, 100); }
TEST(Trims, invertedThrottlePlusThrottleTrim) { MODEL_RESET(); modelDefault(0); g_model.throttleReversed = 1; g_model.thrTrim = 1; // stick max + trim max anaInValues[THR_STICK] = +1024; setTrimValue(0, THR_STICK, TRIM_MAX); evalMixes(1); EXPECT_EQ(channelOutputs[2], -1024); // stick max + trim mid anaInValues[THR_STICK] = +1024; setTrimValue(0, THR_STICK, 0); evalMixes(1); EXPECT_EQ(channelOutputs[2], -1024+250); // stick max + trim min anaInValues[THR_STICK] = +1024; setTrimValue(0, THR_STICK, TRIM_MIN); evalMixes(1); EXPECT_EQ(channelOutputs[2], -1024+500); // stick min + trim max anaInValues[THR_STICK] = -1024; setTrimValue(0, THR_STICK, TRIM_MAX); evalMixes(1); EXPECT_EQ(channelOutputs[2], +1024); // stick min + trim min anaInValues[THR_STICK] = -1024; setTrimValue(0, THR_STICK, TRIM_MIN); evalMixes(1); EXPECT_EQ(channelOutputs[2], +1024); // now the same tests with extended Trims g_model.extendedTrims = 1; // stick max + trim max anaInValues[THR_STICK] = +1024; setTrimValue(0, THR_STICK, TRIM_EXTENDED_MAX); evalMixes(1); EXPECT_EQ(channelOutputs[2], -1024); // stick max + trim mid anaInValues[THR_STICK] = +1024; setTrimValue(0, THR_STICK, 0); evalMixes(1); EXPECT_EQ(channelOutputs[2], -1024+1000); // stick max + trim min anaInValues[THR_STICK] = +1024; setTrimValue(0, THR_STICK, TRIM_EXTENDED_MIN); evalMixes(1); EXPECT_EQ(channelOutputs[2], -1024+2000); // stick min + trim max anaInValues[THR_STICK] = -1024; setTrimValue(0, THR_STICK, TRIM_EXTENDED_MAX); evalMixes(1); EXPECT_EQ(channelOutputs[2], +1024); // stick min + trim min anaInValues[THR_STICK] = -1024; setTrimValue(0, THR_STICK, TRIM_EXTENDED_MIN); evalMixes(1); EXPECT_EQ(channelOutputs[2], +1024); }
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 = 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, -1); CHECK_NO_MOVEMENT(0, CHANNEL_MAX, 250); simuSetSwitch(0, 1); CHECK_NO_MOVEMENT(0, CHANNEL_MAX, 250); }
TEST(Heli, Mode2Test) { MODEL_RESET(); g_eeGeneral.templateSetup = 2; applyDefaultTemplate(); g_model.swashR.collectiveSource = MIXSRC_Thr; g_model.swashR.elevatorSource = MIXSRC_Ele; g_model.swashR.aileronSource = MIXSRC_Ail; g_model.swashR.collectiveWeight = 100; g_model.swashR.elevatorWeight = 100; g_model.swashR.aileronWeight = 100; g_model.swashR.type = SWASH_TYPE_120; g_model.mixData[0].destCh = 0; g_model.mixData[0].mltpx = MLTPX_ADD; g_model.mixData[0].srcRaw = MIXSRC_CYC1; g_model.mixData[0].weight = 100; g_model.mixData[1].destCh = 1; g_model.mixData[1].mltpx = MLTPX_ADD; g_model.mixData[1].srcRaw = MIXSRC_CYC2; g_model.mixData[1].weight = 100; g_model.mixData[2].destCh = 2; g_model.mixData[2].mltpx = MLTPX_ADD; g_model.mixData[2].srcRaw = MIXSRC_CYC3; g_model.mixData[2].weight = 100; anaInValues[ELE_STICK] = 1024; evalFlightModeMixes(e_perout_mode_normal, 0); EXPECT_EQ(chans[0], -CHANNEL_MAX); EXPECT_EQ(chans[1], CHANNEL_MAX/2); EXPECT_EQ(chans[2], CHANNEL_MAX/2); }
TEST(Trims, InstantTrim) { MODEL_RESET(); modelDefault(0); anaInValues[AIL_STICK] = 50; instantTrim(); EXPECT_EQ(25, getTrimValue(0, AIL_STICK)); }
TEST(Trims, chainedTrims) { MODEL_RESET(); setTrimValue(0, RUD_STICK, 32); setTrimValue(1, RUD_STICK, TRIM_EXTENDED_MAX+1); // link to FP0 trim setTrimValue(2, RUD_STICK, TRIM_EXTENDED_MAX+2); // link to FP1 trim EXPECT_EQ(getRawTrimValue(getTrimFlightPhase(0, RUD_STICK), RUD_STICK), 32); }
TEST(Trims, CopySticksToOffset) { MODEL_RESET(); modelDefault(0); anaInValues[ELE_STICK] = -100; perMain(); copySticksToOffset(1); EXPECT_EQ(g_model.limitData[1].offset, -97); }
TEST(Trims, infiniteChainedTrims) { MODEL_RESET(); setTrimValue(0, 0, 32); setTrimValue(1, 0, TRIM_EXTENDED_MAX+3); // link to FP3 trim setTrimValue(2, 0, TRIM_EXTENDED_MAX+2); // link to FP1 trim setTrimValue(3, 0, TRIM_EXTENDED_MAX+3); // link to FP2 trim EXPECT_EQ(getRawTrimValue(getTrimFlightPhase(0, 2), 0), 32); }
TEST(FlightModes, nullFadeOut_posFadeIn) { MODEL_RESET(); g_model.flightModeData[1].swtch = SWSRC_ID1; g_model.flightModeData[1].fadeIn = 15; perMain(); simuSetSwitch(3, 0); perMain(); }
TEST(FrSky, HubAltNegative) { MODEL_RESET(); TELEMETRY_RESET(); EXPECT_EQ(telemetryItems[0].value, 0); // altimeter auto offset processHubPacket(BARO_ALT_BP_ID, 0); processHubPacket(BARO_ALT_AP_ID, 0); EXPECT_EQ(telemetryItems[0].value, 0); // low precision altimeter, bp always less than 10 processHubPacket(BARO_ALT_BP_ID, 12); // set value of 12.3m processHubPacket(BARO_ALT_AP_ID, 3); EXPECT_EQ(telemetryItems[0].value, 123); // altitude stored has resolution of 0.1m processHubPacket(BARO_ALT_BP_ID, -12); // set value of -12.3m processHubPacket(BARO_ALT_AP_ID, 3); EXPECT_EQ(telemetryItems[0].value, -123); // hi precision altimeter, bp can be two decimals MODEL_RESET(); TELEMETRY_RESET(); // altimeter auto offset processHubPacket(BARO_ALT_BP_ID, 0); processHubPacket(BARO_ALT_AP_ID, 0); EXPECT_EQ(telemetryItems[0].value, 0); // first trigger hi precision, by setting AP above 9 processHubPacket(BARO_ALT_BP_ID, -1); // set value of -1.35m processHubPacket(BARO_ALT_AP_ID, 35); EXPECT_EQ(telemetryItems[0].value, -13); processHubPacket(BARO_ALT_BP_ID, 12); // set value of 12.35m processHubPacket(BARO_ALT_AP_ID, 35); EXPECT_EQ(telemetryItems[0].value, 123); // now test with the AP less than 10 to check if hiprecision is still active processHubPacket(BARO_ALT_BP_ID, 12); // set value of 12.05m processHubPacket(BARO_ALT_AP_ID, 05); EXPECT_EQ(telemetryItems[0].value, 120); }
TEST(Heli, SimpleTest) { MODEL_RESET(); applyTemplate(TMPL_HELI_SETUP); anaInValues[ELE_STICK] = 1024; evalFlightModeMixes(e_perout_mode_normal, 0); EXPECT_EQ(chans[0], -CHANNEL_MAX); EXPECT_EQ(chans[1], CHANNEL_MAX/2); EXPECT_EQ(chans[1], CHANNEL_MAX/2); }
TEST(Mixer, BlockingChannel) { MODEL_RESET(); MIXER_RESET(); g_model.mixData[0].destCh = 0; g_model.mixData[0].srcRaw = MIXSRC_CH1; g_model.mixData[0].weight = 100; evalFlightModeMixes(e_perout_mode_normal, 0); EXPECT_EQ(chans[0], 0); }
TEST(FrSkySPORT, frskyCurrent) { uint8_t packet[FRSKY_SPORT_PACKET_SIZE]; MODEL_RESET(); TELEMETRY_RESET(); // tests for Curr generateSportFasCurrentPacket(packet, 0); processSportPacket(packet); g_model.telemetrySensors[0].custom.offset = -5; /* unit: 1/10 amps */ generateSportFasCurrentPacket(packet, 0); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 0); EXPECT_EQ(telemetryItems[0].valueMin, 0); EXPECT_EQ(telemetryItems[0].valueMax, 0); // measured current less then offset - value should be zero generateSportFasCurrentPacket(packet, 4); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 0); EXPECT_EQ(telemetryItems[0].valueMin, 0); EXPECT_EQ(telemetryItems[0].valueMax, 0); generateSportFasCurrentPacket(packet, 10); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 5); EXPECT_EQ(telemetryItems[0].valueMin, 0); EXPECT_EQ(telemetryItems[0].valueMax, 5); generateSportFasCurrentPacket(packet, 500); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 495); EXPECT_EQ(telemetryItems[0].valueMin, 0); EXPECT_EQ(telemetryItems[0].valueMax, 495); generateSportFasCurrentPacket(packet, 200); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 195); EXPECT_EQ(telemetryItems[0].valueMin, 0); EXPECT_EQ(telemetryItems[0].valueMax, 495); // test with positive offset TELEMETRY_RESET(); g_model.telemetrySensors[0].custom.offset = +5; /* unit: 1/10 amps */ generateSportFasCurrentPacket(packet, 0); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 5); EXPECT_EQ(telemetryItems[0].valueMin, 5); EXPECT_EQ(telemetryItems[0].valueMax, 5); generateSportFasCurrentPacket(packet, 500); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 505); EXPECT_EQ(telemetryItems[0].valueMin, 5); EXPECT_EQ(telemetryItems[0].valueMax, 505); generateSportFasCurrentPacket(packet, 200); processSportPacket(packet); EXPECT_EQ(telemetryItems[0].value, 205); EXPECT_EQ(telemetryItems[0].valueMin, 5); EXPECT_EQ(telemetryItems[0].valueMax, 505); }
TEST(Curves, LinearIntpol) { MODEL_RESET(); for (int8_t i=-2; i<=2; i++) { g_model.points[2+i] = 50*i; } EXPECT_EQ(applyCustomCurve(-1024, 0), -1024); EXPECT_EQ(applyCustomCurve(0, 0), 0); EXPECT_EQ(applyCustomCurve(1024, 0), 1024); EXPECT_EQ(applyCustomCurve(-192, 0), -192); }
TEST(FrSkySPORT, StrangeCellsBug) { MODEL_RESET(); TELEMETRY_RESET(); uint8_t pkt[] = { 0x7E, 0x48, 0x10, 0x00, 0x03, 0x30, 0x15, 0x50, 0x81, 0xD5 }; EXPECT_EQ(checkSportPacket(pkt+1), true); processSportPacket(pkt+1); EXPECT_EQ(telemetryItems[0].cells.count, 3); EXPECT_EQ(telemetryItems[0].cells.values[0].value, 0); // now we ignore such low values EXPECT_EQ(telemetryItems[0].cells.values[1].value, 413); }
TEST(getSwitch, circularCSW) { MODEL_RESET(); MIXER_RESET(); g_model.logicalSw[0] = { SWSRC_SW1, SWSRC_SW1, LS_FUNC_OR }; g_model.logicalSw[1] = { SWSRC_SW1, SWSRC_SW1, LS_FUNC_AND }; evalLogicalSwitches(); EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(-SWSRC_SW1), true); EXPECT_EQ(getSwitch(SWSRC_SW2), false); EXPECT_EQ(getSwitch(-SWSRC_SW2), true); }
TEST(Trims, CopySticksToOffset) { MODEL_RESET(); modelDefault(0); anaInValues[ELE_STICK] = -100; #if defined(CPUARM) doMixerCalculations(); #else perMain(); #endif copySticksToOffset(1); EXPECT_EQ(g_model.limitData[1].offset, -97); }
TEST(Trainer, UnpluggedTest) { MODEL_RESET(); MIXER_RESET(); g_model.mixData[0].destCh = 0; g_model.mixData[0].mltpx = MLTPX_ADD; g_model.mixData[0].srcRaw = MIXSRC_FIRST_TRAINER; g_model.mixData[0].weight = 100; g_model.mixData[0].delayUp = DELAY_STEP*5; g_model.mixData[0].delayDown = DELAY_STEP*5; ppmInputValidityTimer = 0; ppmInput[0] = 1024; CHECK_DELAY(0, 5000); }
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; evalFlightModeMixes(e_perout_mode_normal, 0); EXPECT_EQ(chans[0], CHANNEL_MAX); }