Fixes #1039:
* order of logical switches calculaton now predicable: always from L1 to L64 * each flight mode has its own logical switches context (RAM usage multiplied by number of flight modes) * resolved problem of non-reentrancy of getSwitch() function
This commit is contained in:
@@ -445,6 +445,7 @@ tmr10ms_t timeAutomaticPromptsSilence = 0;
|
|||||||
void playModelEvent(uint8_t category, uint8_t index, uint8_t event)
|
void playModelEvent(uint8_t category, uint8_t index, uint8_t event)
|
||||||
{
|
{
|
||||||
char filename[AUDIO_FILENAME_MAXLEN+1];
|
char filename[AUDIO_FILENAME_MAXLEN+1];
|
||||||
|
TRACE("playModelEvent(): cat: %u, idx: %u, evt:%u", (uint32_t)category, (uint32_t)index, (uint32_t)event);
|
||||||
if (IS_SILENCE_PERIOD_ELAPSED() && isAudioFileReferenced((category << 24) + (index << 16) + event, filename)) {
|
if (IS_SILENCE_PERIOD_ELAPSED() && isAudioFileReferenced((category << 24) + (index << 16) + event, filename)) {
|
||||||
audioQueue.playFile(filename);
|
audioQueue.playFile(filename);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ void doMixerCalculations();
|
|||||||
memset(act, 0, sizeof(act)); \
|
memset(act, 0, sizeof(act)); \
|
||||||
memset(swOn, 0, sizeof(swOn)); \
|
memset(swOn, 0, sizeof(swOn)); \
|
||||||
int32_t lastAct = 0; lastAct = lastAct; /* to avoid a warning */ \
|
int32_t lastAct = 0; lastAct = lastAct; /* to avoid a warning */ \
|
||||||
s_last_switch_used = 0; \
|
lswReset();
|
||||||
s_last_switch_value = 0;
|
|
||||||
|
|
||||||
uint16_t anaInValues[NUM_STICKS+NUM_POTS] = { 0 };
|
uint16_t anaInValues[NUM_STICKS+NUM_POTS] = { 0 };
|
||||||
uint16_t anaIn(uint8_t chan)
|
uint16_t anaIn(uint8_t chan)
|
||||||
@@ -330,19 +329,20 @@ TEST(getSwitch, recursiveSW)
|
|||||||
g_model.logicalSw[0] = { SWSRC_RUD, -SWSRC_SW2, LS_FUNC_OR };
|
g_model.logicalSw[0] = { SWSRC_RUD, -SWSRC_SW2, LS_FUNC_OR };
|
||||||
g_model.logicalSw[1] = { SWSRC_ELE, -SWSRC_SW1, LS_FUNC_OR };
|
g_model.logicalSw[1] = { SWSRC_ELE, -SWSRC_SW1, LS_FUNC_OR };
|
||||||
|
|
||||||
|
evalLogicalSwitches(e_perout_mode_normal);
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
|
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
|
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
|
||||||
|
|
||||||
s_last_switch_used = 0;
|
evalLogicalSwitches(e_perout_mode_normal);
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
|
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
|
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
|
||||||
|
|
||||||
simuSetSwitch(1, 1);
|
simuSetSwitch(1, 1);
|
||||||
s_last_switch_used = 0;
|
evalLogicalSwitches(e_perout_mode_normal);
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
|
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
|
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
|
||||||
|
|
||||||
s_last_switch_used = 0;
|
evalLogicalSwitches(e_perout_mode_normal);
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
|
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
|
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -524,6 +524,7 @@ uint8_t s_current_mixer_flight_mode;
|
|||||||
void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
|
||||||
{
|
{
|
||||||
evalInputs(mode);
|
evalInputs(mode);
|
||||||
|
evalLogicalSwitches(mode);
|
||||||
|
|
||||||
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
#if defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
checkStartupWarnings();
|
checkStartupWarnings();
|
||||||
@@ -929,8 +930,6 @@ void evalMixes(uint8_t tick10ms)
|
|||||||
static ACTIVE_PHASES_TYPE s_fade_flight_phases = 0;
|
static ACTIVE_PHASES_TYPE s_fade_flight_phases = 0;
|
||||||
static uint8_t s_last_phase = 255; // TODO reinit everything here when the model changes, no???
|
static uint8_t s_last_phase = 255; // TODO reinit everything here when the model changes, no???
|
||||||
|
|
||||||
s_last_switch_used = 0;
|
|
||||||
|
|
||||||
uint8_t phase = getFlightPhase();
|
uint8_t phase = getFlightPhase();
|
||||||
|
|
||||||
if (s_last_phase != phase) {
|
if (s_last_phase != phase) {
|
||||||
@@ -953,6 +952,7 @@ void evalMixes(uint8_t tick10ms)
|
|||||||
fp_act[phase] = MAX_ACT;
|
fp_act[phase] = MAX_ACT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
copyLswState(s_last_phase, phase); //push last logical switches state from old to new phase
|
||||||
s_last_phase = phase;
|
s_last_phase = phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -960,7 +960,6 @@ void evalMixes(uint8_t tick10ms)
|
|||||||
if (s_fade_flight_phases) {
|
if (s_fade_flight_phases) {
|
||||||
memclear(sum_chans512, sizeof(sum_chans512));
|
memclear(sum_chans512, sizeof(sum_chans512));
|
||||||
for (uint8_t p=0; p<MAX_FLIGHT_MODES; p++) {
|
for (uint8_t p=0; p<MAX_FLIGHT_MODES; p++) {
|
||||||
s_last_switch_used = 0;
|
|
||||||
if (s_fade_flight_phases & ((ACTIVE_PHASES_TYPE)1 << p)) {
|
if (s_fade_flight_phases & ((ACTIVE_PHASES_TYPE)1 << p)) {
|
||||||
s_current_mixer_flight_mode = p;
|
s_current_mixer_flight_mode = p;
|
||||||
evalFlightModeMixes(p==phase ? e_perout_mode_normal : e_perout_mode_inactive_phase, p==phase ? tick10ms : 0);
|
evalFlightModeMixes(p==phase ? e_perout_mode_normal : e_perout_mode_inactive_phase, p==phase ? tick10ms : 0);
|
||||||
@@ -968,7 +967,6 @@ void evalMixes(uint8_t tick10ms)
|
|||||||
sum_chans512[i] += (chans[i] >> 4) * fp_act[p];
|
sum_chans512[i] += (chans[i] >> 4) * fp_act[p];
|
||||||
weight += fp_act[p];
|
weight += fp_act[p];
|
||||||
}
|
}
|
||||||
s_last_switch_used = 0;
|
|
||||||
}
|
}
|
||||||
assert(weight);
|
assert(weight);
|
||||||
s_current_mixer_flight_mode = phase;
|
s_current_mixer_flight_mode = phase;
|
||||||
|
|||||||
@@ -1521,7 +1521,6 @@ void flightReset()
|
|||||||
#endif
|
#endif
|
||||||
lswReset();
|
lswReset();
|
||||||
|
|
||||||
s_last_switch_value = 0;
|
|
||||||
s_mixer_first_run_done = false;
|
s_mixer_first_run_done = false;
|
||||||
|
|
||||||
START_SILENCE_PERIOD();
|
START_SILENCE_PERIOD();
|
||||||
|
|||||||
+2
-9
@@ -695,6 +695,8 @@ getvalue_t getValue(uint8_t i);
|
|||||||
bool getSwitch(int8_t swtch);
|
bool getSwitch(int8_t swtch);
|
||||||
void lswTimerTick();
|
void lswTimerTick();
|
||||||
void lswReset();
|
void lswReset();
|
||||||
|
void evalLogicalSwitches(uint8_t mode);
|
||||||
|
void copyLswState(uint8_t oldPhase, uint8_t newPhase);
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
void getSwitchesPosition(bool startup);
|
void getSwitchesPosition(bool startup);
|
||||||
@@ -817,15 +819,6 @@ extern int8_t safetyCh[NUM_CHNOUT];
|
|||||||
|
|
||||||
extern uint8_t trimsCheckTimer;
|
extern uint8_t trimsCheckTimer;
|
||||||
|
|
||||||
#if defined(CPUARM)
|
|
||||||
#define GETSWITCH_RECURSIVE_TYPE uint32_t
|
|
||||||
#else
|
|
||||||
#define GETSWITCH_RECURSIVE_TYPE uint16_t
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_used;
|
|
||||||
extern volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_value;
|
|
||||||
|
|
||||||
#define TMR_OFF 0
|
#define TMR_OFF 0
|
||||||
#define TMR_RUNNING 1
|
#define TMR_RUNNING 1
|
||||||
#define TMR_NEGATIVE 2
|
#define TMR_NEGATIVE 2
|
||||||
|
|||||||
+734
-717
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user