Issue 41 fixed
RSSI alarms thresholds now 45 and 42 instead of 50
This commit is contained in:
+147
-18
@@ -38,6 +38,8 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "opentx.h"
|
||||
|
||||
#define CHANNEL_MAX (1024*256)
|
||||
|
||||
void doMixerCalculations();
|
||||
|
||||
#define MODEL_RESET() memset(&g_model, 0, sizeof(g_model))
|
||||
@@ -329,7 +331,7 @@ TEST(Mixer, R2029Comment)
|
||||
simuSetSwitch(0, 1);
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
EXPECT_EQ(chans[1], 1024*256);
|
||||
EXPECT_EQ(chans[1], CHANNEL_MAX);
|
||||
simuSetSwitch(0, 0);
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
@@ -337,7 +339,7 @@ TEST(Mixer, R2029Comment)
|
||||
simuSetSwitch(0, 1);
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
EXPECT_EQ(chans[1], 1024*256);
|
||||
EXPECT_EQ(chans[1], CHANNEL_MAX);
|
||||
}
|
||||
|
||||
TEST(Mixer, Cascaded3Channels)
|
||||
@@ -355,9 +357,9 @@ TEST(Mixer, Cascaded3Channels)
|
||||
g_model.mixData[2].weight = 100;
|
||||
simuSetSwitch(0, 1);
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 1024*256);
|
||||
EXPECT_EQ(chans[1], 1024*256);
|
||||
EXPECT_EQ(chans[2], 1024*256);
|
||||
EXPECT_EQ(chans[0], CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[1], CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[2], CHANNEL_MAX);
|
||||
}
|
||||
|
||||
TEST(Mixer, CascadedOrderedChannels)
|
||||
@@ -372,8 +374,8 @@ TEST(Mixer, CascadedOrderedChannels)
|
||||
g_model.mixData[1].weight = 100;
|
||||
simuSetSwitch(0, 1);
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 1024*256);
|
||||
EXPECT_EQ(chans[1], 1024*256);
|
||||
EXPECT_EQ(chans[0], CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[1], CHANNEL_MAX);
|
||||
}
|
||||
|
||||
TEST(Mixer, Cascaded5Channels)
|
||||
@@ -398,18 +400,18 @@ TEST(Mixer, Cascaded5Channels)
|
||||
for (uint8_t i=0; i<10; i++) {
|
||||
simuSetSwitch(0, 1);
|
||||
doMixerCalculations();
|
||||
EXPECT_EQ(chans[0], 1024*256);
|
||||
EXPECT_EQ(chans[1], 1024*256);
|
||||
EXPECT_EQ(chans[2], 1024*256);
|
||||
EXPECT_EQ(chans[3], 1024*256);
|
||||
EXPECT_EQ(chans[4], 1024*256);
|
||||
EXPECT_EQ(chans[0], CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[1], CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[2], CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[3], CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[4], CHANNEL_MAX);
|
||||
simuSetSwitch(0, 0);
|
||||
doMixerCalculations();
|
||||
EXPECT_EQ(chans[0], -1024*256);
|
||||
EXPECT_EQ(chans[1], -1024*256);
|
||||
EXPECT_EQ(chans[2], -1024*256);
|
||||
EXPECT_EQ(chans[3], -1024*256);
|
||||
EXPECT_EQ(chans[4], -1024*256);
|
||||
EXPECT_EQ(chans[0], -CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[1], -CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[2], -CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[3], -CHANNEL_MAX);
|
||||
EXPECT_EQ(chans[4], -CHANNEL_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,10 +461,137 @@ TEST(Mixer, RecursiveAddChannel)
|
||||
g_model.mixData[2].srcRaw = MIXSRC_Rud;
|
||||
g_model.mixData[2].weight = 100;
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 1024*256/2);
|
||||
EXPECT_EQ(chans[0], CHANNEL_MAX/2);
|
||||
EXPECT_EQ(chans[1], 0);
|
||||
}
|
||||
|
||||
TEST(Mixer, SlowOnSwitch)
|
||||
{
|
||||
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 = 10;
|
||||
g_model.mixData[0].speedDown = 10;
|
||||
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
|
||||
simuSetSwitch(0, 1);
|
||||
int32_t lastAct = 0;
|
||||
for (int i=1; i<=250; i++) {
|
||||
perOut(e_perout_mode_normal, 1);
|
||||
lastAct = lastAct + (1<<19)/500; /* 100 on ARM */
|
||||
EXPECT_EQ(chans[0], 256 * (lastAct >> 8));
|
||||
}
|
||||
|
||||
simuSetSwitch(0, 0);
|
||||
for (int i=1; i<=250; i++) {
|
||||
perOut(e_perout_mode_normal, 1);
|
||||
lastAct = lastAct - (1<<19)/500; /* 100 on ARM */
|
||||
EXPECT_EQ(chans[0], 256 * (lastAct >> 8));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Mixer, SlowOnPhase)
|
||||
{
|
||||
MODEL_RESET();
|
||||
MIXER_RESET();
|
||||
g_model.phaseData[1].swtch = SWSRC_THR;
|
||||
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;
|
||||
|
||||
s_perout_flight_phase = 0;
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
|
||||
int32_t lastAct = 0;
|
||||
for (int i=1; i<=250; i++) {
|
||||
perOut(e_perout_mode_normal, 1);
|
||||
lastAct = lastAct+(1<<19)/500; /* 100 on ARM */
|
||||
EXPECT_EQ(chans[0], 256 * (lastAct >> 8));
|
||||
}
|
||||
|
||||
s_perout_flight_phase = 1;
|
||||
for (int i=1; i<=250; i++) {
|
||||
perOut(e_perout_mode_normal, 1);
|
||||
lastAct = lastAct - (1<<19)/500; /* 100 on ARM */
|
||||
EXPECT_EQ(chans[0], 256 * (lastAct >> 8));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Mixer, SlowOnSwitchAndPhase)
|
||||
{
|
||||
MODEL_RESET();
|
||||
MIXER_RESET();
|
||||
g_model.phaseData[1].swtch = SWSRC_THR;
|
||||
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].phases = 0x2 + 0x4 + 0x8 + 0x10 /*only enabled in phase 0*/;
|
||||
g_model.mixData[0].speedUp = 10;
|
||||
g_model.mixData[0].speedDown = 10;
|
||||
|
||||
perOut(e_perout_mode_normal, 0);
|
||||
EXPECT_EQ(chans[0], 0);
|
||||
|
||||
simuSetSwitch(0, 1);
|
||||
s_perout_flight_phase = 0;
|
||||
int32_t lastAct = 0;
|
||||
for (int i=1; i<=250; i++) {
|
||||
perOut(e_perout_mode_normal, 1);
|
||||
lastAct = lastAct+(1<<19)/500; /* 100 on ARM */
|
||||
EXPECT_EQ(chans[0], 256 * (lastAct >> 8));
|
||||
}
|
||||
|
||||
simuSetSwitch(0, 0);
|
||||
s_perout_flight_phase = 1;
|
||||
for (int i=1; i<=250; i++) {
|
||||
perOut(e_perout_mode_normal, 1);
|
||||
lastAct = lastAct - (1<<19)/500; /* 100 on ARM */
|
||||
EXPECT_EQ(chans[0], 256 * (lastAct >> 8));
|
||||
}
|
||||
}
|
||||
|
||||
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].weight = 100;
|
||||
g_model.mixData[0].speedUp = 10;
|
||||
g_model.mixData[0].speedDown = 10;
|
||||
|
||||
simuSetSwitch(0, 0);
|
||||
int32_t lastAct = 0;
|
||||
for (int i=1; i<=250; i++) {
|
||||
perOut(e_perout_mode_normal, 1);
|
||||
lastAct = lastAct - (1<<19)/500; /* 100 on ARM */
|
||||
EXPECT_EQ(chans[0], 256 * (lastAct >> 8));
|
||||
}
|
||||
|
||||
EXPECT_EQ(chans[0], -CHANNEL_MAX);
|
||||
|
||||
simuSetSwitch(0, 1);
|
||||
for (int i=1; i<=500; i++) {
|
||||
perOut(e_perout_mode_normal, 1);
|
||||
lastAct = lastAct + (1<<19)/500; /* 100 on ARM */
|
||||
EXPECT_EQ(chans[0], 256 * (lastAct >> 8));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Curves, LinearIntpol)
|
||||
{
|
||||
MODEL_RESET();
|
||||
|
||||
@@ -144,7 +144,7 @@ void displayGpsCoord(uint8_t y, char direction, int16_t bp, int16_t ap)
|
||||
|
||||
NOINLINE uint8_t getRssiAlarmValue(uint8_t alarm)
|
||||
{
|
||||
return (50 + g_model.frsky.rssiAlarms[alarm].value);
|
||||
return (45 - 3*alarm + g_model.frsky.rssiAlarms[alarm].value);
|
||||
}
|
||||
|
||||
void displayVoltageScreenLine(uint8_t y, uint8_t index)
|
||||
|
||||
+21
-17
@@ -2881,15 +2881,14 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
|
||||
if (!(dirtyChannels & ((bitfield_channels_t)1 << md->destCh))) continue;
|
||||
|
||||
if (md->phases & (1 << s_perout_flight_phase)) continue;
|
||||
|
||||
//========== SWITCH ===============
|
||||
bool sw = getSwitch(md->swtch, 1);
|
||||
//========== PHASE && SWITCH =====
|
||||
bool mixCondition = (md->phases != 0 || md->swtch);
|
||||
bool mixEnabled = !(md->phases & (1 << s_perout_flight_phase)) && getSwitch(md->swtch, 1);
|
||||
|
||||
//========== VALUE ===============
|
||||
getvalue_t v = 0;
|
||||
if (mode != e_perout_mode_normal) {
|
||||
if (!sw || k >= NUM_STICKS || (k == THR_STICK && g_model.thrTrim)) {
|
||||
if (!mixEnabled || k >= NUM_STICKS || (k == THR_STICK && g_model.thrTrim)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
@@ -2897,13 +2896,14 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (k < NUM_STICKS)
|
||||
if (k < NUM_STICKS) {
|
||||
v = md->noExpo ? rawAnas[k] : anas[k]; //Switch is on. MAX=FULL=512 or value.
|
||||
}
|
||||
#if defined(PCBTARANIS)
|
||||
else {
|
||||
v = getValue(k);
|
||||
if ((k == MIXSRC_SF-1) || (k >= MIXSRC_SH-1 && k <= MIXSRC_LAST_CSW-1)) {
|
||||
if (v < 0 && !md->swtch) sw = false;
|
||||
if (v < 0 && !mixCondition) mixEnabled = false;
|
||||
}
|
||||
if (k>=MIXSRC_CH1-1 && k<=MIXSRC_LAST_CH-1 && md->destCh != k-MIXSRC_CH1+1) {
|
||||
if (dirtyChannels & ((bitfield_channels_t)1 << (k-MIXSRC_CH1+1)) & (passDirtyChannels|~(((bitfield_channels_t) 1 << md->destCh)-1)))
|
||||
@@ -2916,7 +2916,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
else {
|
||||
v = getValue(k);
|
||||
if (k >= MIXSRC_THR-1 && k <= MIXSRC_LAST_CSW-1) {
|
||||
if (v < 0 && !md->swtch) sw = false;
|
||||
if (v < 0 && !mixCondition) mixEnabled = false;
|
||||
}
|
||||
else if (k>=MIXSRC_CH1-1 && k<=MIXSRC_LAST_CH-1 && md->destCh != k-MIXSRC_CH1+1) {
|
||||
if (dirtyChannels & ((bitfield_channels_t)1 << (k-MIXSRC_CH1+1)) & (passDirtyChannels|~(((bitfield_channels_t) 1 << md->destCh)-1)))
|
||||
@@ -2932,7 +2932,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
|
||||
//========== DELAYS ===============
|
||||
uint8_t swTog;
|
||||
if (sw) { // switch on? (if no switch selected => on)
|
||||
if (mixEnabled) { // switch on? (if no switch selected => on)
|
||||
swTog = !swOn[i];
|
||||
if (mode == e_perout_mode_normal) {
|
||||
swOn[i] = true;
|
||||
@@ -2942,7 +2942,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
}
|
||||
if (sDelay[i] > 0) { // perform delay
|
||||
sDelay[i] = max<int16_t>(0, (int16_t)sDelay[i] - tick10ms);
|
||||
if (!md->swtch) {
|
||||
if (!mixCondition) {
|
||||
v = -1024;
|
||||
}
|
||||
else {
|
||||
@@ -2966,10 +2966,10 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
}
|
||||
if (delay > 0) { // perform delay
|
||||
delay = max<int16_t>(0, (int16_t)delay - tick10ms);
|
||||
if (!md->swtch) v = +1024;
|
||||
if (!mixCondition) v = +1024;
|
||||
has_delay = true;
|
||||
}
|
||||
else if (!md->swtch) {
|
||||
else if (!mixCondition) {
|
||||
v = -1024;
|
||||
}
|
||||
sDelay[i] = delay;
|
||||
@@ -2977,12 +2977,12 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
if (!has_delay) {
|
||||
if (md->speedDown) {
|
||||
if (md->mltpx == MLTPX_REP) continue;
|
||||
if (md->swtch) {
|
||||
if (mixCondition) {
|
||||
v = 0;
|
||||
apply_offset_and_curve = false;
|
||||
}
|
||||
}
|
||||
else if (md->swtch) {
|
||||
else if (mixCondition) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -3012,7 +3012,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
|
||||
// saves 12 bytes code if done here and not together with weight; unknown reason
|
||||
int16_t weight = GET_GVAR(MD_WEIGHT(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_phase);
|
||||
weight=calc100to256_16Bits(weight);
|
||||
weight = calc100to256_16Bits(weight);
|
||||
|
||||
//========== SPEED ===============
|
||||
// now its on input side, but without weight compensation. More like other remote controls
|
||||
@@ -3037,14 +3037,14 @@ void perOut(uint8_t mode, uint8_t tick10ms)
|
||||
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
|
||||
if (newValue<currentValue) currentValue = newValue; // Endposition; prevent toggling around the destination
|
||||
}
|
||||
}
|
||||
else { // if is <0 because ==0 is not possible
|
||||
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
|
||||
if (newValue>currentValue) currentValue = newValue; // Endposition; prevent toggling around the destination
|
||||
}
|
||||
} //endif diff>0
|
||||
act[i] = tact = currentValue;
|
||||
@@ -4284,6 +4284,10 @@ void menusTask(void * pdata)
|
||||
lcd_clear();
|
||||
displayPopup(STR_SHUTDOWN);
|
||||
|
||||
#if defined(FRSKY)
|
||||
FRSKY_End();
|
||||
#endif
|
||||
|
||||
#if defined(SDCARD)
|
||||
closeLogs();
|
||||
#endif
|
||||
|
||||
@@ -203,6 +203,8 @@ extern uint8_t frskyTxBuffer[FRSKY_TX_PACKET_SIZE];
|
||||
extern uint8_t frskyTxBufferCount;
|
||||
|
||||
void FRSKY_Init(void);
|
||||
#define FRSKY_End()
|
||||
|
||||
void telemetryWakeup(void);
|
||||
void telemetryInterrupt10ms(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user