1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 00:05:17 +03:00
This commit is contained in:
bsongis 2014-12-16 20:33:17 +01:00
parent e647c8623b
commit 62b64862d8
5 changed files with 58 additions and 31 deletions

View file

@ -285,6 +285,14 @@ void menuModelSetup(uint8_t event)
switch (m_posHorz) {
case 0:
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;
case 1:
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);

View file

@ -104,6 +104,34 @@ uint8_t switchToMix(uint8_t source)
#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;
#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 (i_flags & INCDEC_SWITCH) {
if (s_editMode>0) {
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
}
}
newval = checkIncDecMovedSwitch(newval);
}
#endif

View file

@ -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);
#endif
int8_t checkIncDecMovedSwitch(int8_t val);
#if defined(CPUM64)
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);

View file

@ -721,12 +721,14 @@ int switchConfig(int idx);
#define SWITCH_DEFAULT_CONFIG(x) (SWITCH_3POS)
#define IS_2x2POS(x) (false)
#define ONE_2x2POS_DEFINED() (false)
#define SWITCH_EXISTS(x) (switchConfig(x) != SWITCH_NONE)
#define SWITCH_WARNING_ALLOWED(x) (!IS_TOGGLE(x))
#else
#define SWITCH_DEFAULT_CONFIG(x) ((x)==5 ? SWITCH_2POS : ((x)==7 ? SWITCH_TOGGLE : SWITCH_3POS))
#define IS_2x2POS(x) (switchConfig(x) == SWITCH_2x2POS)
#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
inline int getSwitchWarningsAllowed()
{

View file

@ -587,7 +587,8 @@ int8_t getMovedSwitch()
int8_t result = 0;
#if defined(PCBTARANIS)
for (uint8_t i=0; i<NUM_SWITCHES; i++) {
for (int i=0; i<NUM_SWITCHES; i++) {
if (SWITCH_EXISTS(i)) {
swarnstate_t mask = (0x03 << (i*2));
uint8_t prev = (switches_states & mask) >> (i*2);
uint8_t next = (1024+getValue(MIXSRC_SA+i)) / 1024;
@ -603,6 +604,7 @@ int8_t getMovedSwitch()
result = 1+(3*5)+2+3+(next!=0);
}
}
}
#else
// return delivers 1 to 3 for ID1 to ID3
// 4..8 for all other switches if changed to true