mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 08:15:17 +03:00
Fixes #1918
This commit is contained in:
parent
e647c8623b
commit
62b64862d8
5 changed files with 58 additions and 31 deletions
|
@ -285,6 +285,14 @@ void menuModelSetup(uint8_t event)
|
||||||
switch (m_posHorz) {
|
switch (m_posHorz) {
|
||||||
case 0:
|
case 0:
|
||||||
CHECK_INCDEC_MODELVAR_CHECK(event, timer->mode, SWSRC_FIRST, TMRMODE_COUNT+SWSRC_LAST-1/*SWSRC_None removed*/, isSwitchAvailableInTimers);
|
CHECK_INCDEC_MODELVAR_CHECK(event, timer->mode, SWSRC_FIRST, TMRMODE_COUNT+SWSRC_LAST-1/*SWSRC_None removed*/, isSwitchAvailableInTimers);
|
||||||
|
if (s_editMode>0) {
|
||||||
|
int8_t val = timer->mode - (TMRMODE_COUNT-1);
|
||||||
|
int8_t switchVal = checkIncDecMovedSwitch(val);
|
||||||
|
if (val != switchVal) {
|
||||||
|
timer->mode = switchVal + (TMRMODE_COUNT-1);
|
||||||
|
eeDirty(EE_MODEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);
|
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);
|
||||||
|
|
|
@ -104,6 +104,34 @@ uint8_t switchToMix(uint8_t source)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(AUTOSWITCH)
|
||||||
|
int8_t checkIncDecMovedSwitch(int8_t val)
|
||||||
|
{
|
||||||
|
if (s_editMode>0) {
|
||||||
|
int8_t swtch = getMovedSwitch();
|
||||||
|
if (swtch) {
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
div_t info = switchInfo(swtch);
|
||||||
|
if (IS_TOGGLE(info.quot)) {
|
||||||
|
if (info.rem != 0) {
|
||||||
|
val = (val == swtch ? swtch+2 : swtch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val = swtch;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (IS_MOMENTARY(val) && swtch==val)
|
||||||
|
val = -val;
|
||||||
|
else
|
||||||
|
val = swtch;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int8_t checkIncDec_Ret;
|
int8_t checkIncDec_Ret;
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
|
@ -217,22 +245,7 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
|
||||||
|
|
||||||
#if defined(AUTOSWITCH)
|
#if defined(AUTOSWITCH)
|
||||||
if (i_flags & INCDEC_SWITCH) {
|
if (i_flags & INCDEC_SWITCH) {
|
||||||
if (s_editMode>0) {
|
newval = checkIncDecMovedSwitch(newval);
|
||||||
int8_t swtch = getMovedSwitch();
|
|
||||||
if (swtch) {
|
|
||||||
#if defined(PCBTARANIS)
|
|
||||||
if(swtch == SWSRC_SH2)
|
|
||||||
newval = (newval == SWSRC_SH2 ? SWSRC_SH0 : SWSRC_SH2);
|
|
||||||
else if(swtch != SWSRC_SH0)
|
|
||||||
newval = swtch;
|
|
||||||
#else
|
|
||||||
if (IS_MOMENTARY(newval) && IS_MOMENTARY(swtch))
|
|
||||||
newval = -newval;
|
|
||||||
else
|
|
||||||
newval = swtch;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,8 @@ int checkIncDec(uint8_t event, int val, int i_min, int i_max, uint8_t i_flags=0,
|
||||||
int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, uint8_t i_flags=0);
|
int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, uint8_t i_flags=0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int8_t checkIncDecMovedSwitch(int8_t val);
|
||||||
|
|
||||||
#if defined(CPUM64)
|
#if defined(CPUM64)
|
||||||
int8_t checkIncDecModel(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
|
int8_t checkIncDecModel(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
|
||||||
int8_t checkIncDecModelZero(uint8_t event, int8_t i_val, int8_t i_max);
|
int8_t checkIncDecModelZero(uint8_t event, int8_t i_val, int8_t i_max);
|
||||||
|
|
|
@ -721,12 +721,14 @@ int switchConfig(int idx);
|
||||||
#define SWITCH_DEFAULT_CONFIG(x) (SWITCH_3POS)
|
#define SWITCH_DEFAULT_CONFIG(x) (SWITCH_3POS)
|
||||||
#define IS_2x2POS(x) (false)
|
#define IS_2x2POS(x) (false)
|
||||||
#define ONE_2x2POS_DEFINED() (false)
|
#define ONE_2x2POS_DEFINED() (false)
|
||||||
|
#define SWITCH_EXISTS(x) (switchConfig(x) != SWITCH_NONE)
|
||||||
#define SWITCH_WARNING_ALLOWED(x) (!IS_TOGGLE(x))
|
#define SWITCH_WARNING_ALLOWED(x) (!IS_TOGGLE(x))
|
||||||
#else
|
#else
|
||||||
#define SWITCH_DEFAULT_CONFIG(x) ((x)==5 ? SWITCH_2POS : ((x)==7 ? SWITCH_TOGGLE : SWITCH_3POS))
|
#define SWITCH_DEFAULT_CONFIG(x) ((x)==5 ? SWITCH_2POS : ((x)==7 ? SWITCH_TOGGLE : SWITCH_3POS))
|
||||||
#define IS_2x2POS(x) (switchConfig(x) == SWITCH_2x2POS)
|
#define IS_2x2POS(x) (switchConfig(x) == SWITCH_2x2POS)
|
||||||
#define ONE_2x2POS_DEFINED() (g_eeGeneral.switchConfig & 0x44444444)
|
#define ONE_2x2POS_DEFINED() (g_eeGeneral.switchConfig & 0x44444444)
|
||||||
#define SWITCH_WARNING_ALLOWED(x) (x<8 ? !IS_TOGGLE(x) : IS_2x2POS(x-8))
|
#define SWITCH_EXISTS(x) ((x)<8 ? (switchConfig(x) != SWITCH_NONE) : (IS_2x2POS(x-8)))
|
||||||
|
#define SWITCH_WARNING_ALLOWED(x) ((x)<8 ? !IS_TOGGLE(x) : IS_2x2POS(x-8))
|
||||||
#endif
|
#endif
|
||||||
inline int getSwitchWarningsAllowed()
|
inline int getSwitchWarningsAllowed()
|
||||||
{
|
{
|
||||||
|
|
|
@ -587,20 +587,22 @@ int8_t getMovedSwitch()
|
||||||
int8_t result = 0;
|
int8_t result = 0;
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
for (uint8_t i=0; i<NUM_SWITCHES; i++) {
|
for (int i=0; i<NUM_SWITCHES; i++) {
|
||||||
swarnstate_t mask = (0x03 << (i*2));
|
if (SWITCH_EXISTS(i)) {
|
||||||
uint8_t prev = (switches_states & mask) >> (i*2);
|
swarnstate_t mask = (0x03 << (i*2));
|
||||||
uint8_t next = (1024+getValue(MIXSRC_SA+i)) / 1024;
|
uint8_t prev = (switches_states & mask) >> (i*2);
|
||||||
if (prev != next) {
|
uint8_t next = (1024+getValue(MIXSRC_SA+i)) / 1024;
|
||||||
switches_states = (switches_states & (~mask)) | (next << (i*2));
|
if (prev != next) {
|
||||||
if (i<5)
|
switches_states = (switches_states & (~mask)) | (next << (i*2));
|
||||||
result = 1+(3*i)+next;
|
if (i<5)
|
||||||
else if (i==5)
|
result = 1+(3*i)+next;
|
||||||
result = 1+(3*5)+(next!=0);
|
else if (i==5)
|
||||||
else if (i==6)
|
result = 1+(3*5)+(next!=0);
|
||||||
result = 1+(3*5)+2+next;
|
else if (i==6)
|
||||||
else
|
result = 1+(3*5)+2+next;
|
||||||
result = 1+(3*5)+2+3+(next!=0);
|
else
|
||||||
|
result = 1+(3*5)+2+3+(next!=0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue