diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index b6b2b4c46..8638a14bf 100755 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -524,7 +524,7 @@ uint8_t s_current_mixer_flight_mode; void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms) { evalInputs(mode); - evalLogicalSwitches(mode); + evalLogicalSwitches(); #if defined(MODULE_ALWAYS_SEND_PULSES) checkStartupWarnings(); @@ -918,6 +918,7 @@ int32_t sum_chans512[NUM_CHNOUT] = {0}; #define MAX_ACT 0xffff +uint8_t s_last_phase = 255; // TODO reinit everything here when the model changes, no??? void evalMixes(uint8_t tick10ms) { @@ -928,7 +929,6 @@ void evalMixes(uint8_t tick10ms) static uint16_t fp_act[MAX_FLIGHT_MODES] = {0}; static uint16_t delta = 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??? uint8_t phase = getFlightPhase(); @@ -951,7 +951,7 @@ void evalMixes(uint8_t tick10ms) fp_act[s_last_phase] = 0; fp_act[phase] = MAX_ACT; } - logicalSwitchesCopyState(s_last_phase, phase); //push last logical switches state from old to new phase + logicalSwitchesCopyState(); //push last logical switches state from old to new phase } s_last_phase = phase; } diff --git a/radio/src/opentx.h b/radio/src/opentx.h index d69411a71..13e5c681b 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -671,6 +671,7 @@ enum StartupWarningStates { #endif extern uint8_t s_current_mixer_flight_mode; +extern uint8_t s_last_phase; #if defined(CPUARM) #define bitfield_channels_t uint32_t @@ -695,8 +696,8 @@ getvalue_t getValue(uint8_t i); bool getSwitch(int8_t swtch); void logicalSwitchesTimerTick(); void logicalSwitchesReset(); -void evalLogicalSwitches(uint8_t mode); -void logicalSwitchesCopyState(uint8_t oldPhase, uint8_t newPhase); +void evalLogicalSwitches(); +void logicalSwitchesCopyState(); #if defined(PCBTARANIS) void getSwitchesPosition(bool startup); diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index 7a64e42a1..63006b232 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -51,7 +51,7 @@ PACK(typedef struct { lsw_struct ls[NUM_LOGICAL_SWITCH]; }) lsw_array; -lsw_array lswFm[MAX_FLIGHT_MODES]; +lsw_array lswFm[2]; #if defined(PCBTARANIS) tmr10ms_t switchesMidposStart[6] = { 0 }; @@ -218,7 +218,7 @@ bool getSwitch(int8_t swtch) #endif else { cs_idx -= SWSRC_FIRST_LOGICAL_SWITCH; - result = lswFm[s_current_mixer_flight_mode].ls[cs_idx].state; + result = lswFm[(s_last_phase == s_current_mixer_flight_mode)?0:1].ls[cs_idx].state; } return swtch > 0 ? result : !result; @@ -227,14 +227,14 @@ bool getSwitch(int8_t swtch) /** @brief Calculates new state of logical switches for s_current_mixer_flight_mode */ -void evalLogicalSwitches(uint8_t mode) +void evalLogicalSwitches() { for(unsigned int cs_idx=0; cs_idxandsw; @@ -406,10 +406,10 @@ void evalLogicalSwitches(uint8_t mode) #endif if (result) { - if (!lsd->state && mode == e_perout_mode_normal) PLAY_LOGICAL_SWITCH_ON(cs_idx); + if (!lsd->state && s_last_phase == s_current_mixer_flight_mode) PLAY_LOGICAL_SWITCH_ON(cs_idx); } else { - if (lsd->state && mode == e_perout_mode_normal) PLAY_LOGICAL_SWITCH_OFF(cs_idx); + if (lsd->state && s_last_phase == s_current_mixer_flight_mode) PLAY_LOGICAL_SWITCH_OFF(cs_idx); } lsd->state = result; } @@ -606,7 +606,7 @@ void checkSwitches() } void logicalSwitchesTimerTick() { - for (uint8_t fm=0; fmls[i].lastValue = CS_LAST_VALUE_INIT; - //todo other values - lsa->ls[i].state = false; } } } @@ -732,8 +730,6 @@ getvalue_t convertLswTelemValue(LogicalSwitchData * ls) return val; } -void logicalSwitchesCopyState(uint8_t oldPhase, uint8_t newPhase) { - for (uint8_t i=0; i