1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-22 07:45:14 +03:00
This commit is contained in:
Bertrand Songis 2015-09-01 18:55:44 +02:00
parent c907c20705
commit a985d021b6
3 changed files with 12 additions and 19 deletions

View file

@ -284,10 +284,10 @@ void evalFunctions()
#endif #endif
for (uint8_t i=0; i<NUM_CFN; i++) { for (uint8_t i=0; i<NUM_CFN; i++) {
const CustomFunctionData *cfn = &functions[i]; const CustomFunctionData * cfn = &functions[i];
int8_t swtch = CFN_SWITCH(cfn); int8_t swtch = CFN_SWITCH(cfn);
if (swtch) { if (swtch) {
MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i); MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i);
#if defined(CPUARM) #if defined(CPUARM)
bool active = getSwitch(swtch, IS_PLAY_FUNC(CFN_FUNC(cfn)) ? GETSWITCH_MIDPOS_DELAY : 0); bool active = getSwitch(swtch, IS_PLAY_FUNC(CFN_FUNC(cfn)) ? GETSWITCH_MIDPOS_DELAY : 0);

View file

@ -530,7 +530,7 @@ typedef struct {
MASK_CFN_TYPE activeSwitches; MASK_CFN_TYPE activeSwitches;
tmr10ms_t lastFunctionTime[NUM_CFN]; tmr10ms_t lastFunctionTime[NUM_CFN];
inline bool isFuunctionActive(uint8_t func) inline bool isFunctionActive(uint8_t func)
{ {
return activeFunctions & ((MASK_FUNC_TYPE)1 << func); return activeFunctions & ((MASK_FUNC_TYPE)1 << func);
} }
@ -1333,7 +1333,7 @@ extern CustomFunctionsContext modelFunctionsContext;
extern CustomFunctionsContext globalFunctionsContext; extern CustomFunctionsContext globalFunctionsContext;
inline bool isFunctionActive(uint8_t func) inline bool isFunctionActive(uint8_t func)
{ {
return globalFunctionsContext.isFuunctionActive(func) || modelFunctionsContext.isFuunctionActive(func); return globalFunctionsContext.isFunctionActive(func) || modelFunctionsContext.isFunctionActive(func);
} }
void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext & functionsContext); void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext & functionsContext);
inline void customFunctionsReset() inline void customFunctionsReset()
@ -1343,7 +1343,7 @@ inline void customFunctionsReset()
} }
#else #else
extern CustomFunctionsContext modelFunctionsContext; extern CustomFunctionsContext modelFunctionsContext;
#define isFunctionActive(func) modelFunctionsContext.isFuunctionActive(func) #define isFunctionActive(func) modelFunctionsContext.isFunctionActive(func)
void evalFunctions(); void evalFunctions();
#define customFunctionsReset() modelFunctionsContext.reset() #define customFunctionsReset() modelFunctionsContext.reset()
#endif #endif

View file

@ -92,7 +92,7 @@ uint64_t check2PosSwitchPosition(EnumKeys sw)
else else
index = sw - SW_SA0 + 2; index = sw - SW_SA0 + 2;
result = ((int64_t)1 << index); result = ((uint64_t)1 << index);
if (!(switchesPos & result)) { if (!(switchesPos & result)) {
PLAY_SWITCH_MOVED(index); PLAY_SWITCH_MOVED(index);
@ -101,9 +101,9 @@ uint64_t check2PosSwitchPosition(EnumKeys sw)
return result; return result;
} }
uint32_t check3PosSwitchPosition(uint8_t idx, EnumKeys sw, bool startup) uint64_t check3PosSwitchPosition(uint8_t idx, EnumKeys sw, bool startup)
{ {
uint32_t result; uint64_t result;
uint32_t index; uint32_t index;
if (switchState(sw)) { if (switchState(sw)) {
@ -178,6 +178,7 @@ void getSwitchesPosition(bool startup)
} }
} }
} }
#define SWITCH_POSITION(sw) (switchesPos & (1<<(sw))) #define SWITCH_POSITION(sw) (switchesPos & (1<<(sw)))
#define POT_POSITION(sw) ((potsPos[(sw)/XPOTS_MULTIPOS_COUNT] & 0x0f) == ((sw) % XPOTS_MULTIPOS_COUNT)) #define POT_POSITION(sw) ((potsPos[(sw)/XPOTS_MULTIPOS_COUNT] & 0x0f) == ((sw) % XPOTS_MULTIPOS_COUNT))
@ -444,18 +445,10 @@ bool getSwitch(int8_t swtch)
} }
else if (cs_idx <= SWSRC_LAST_SWITCH) { else if (cs_idx <= SWSRC_LAST_SWITCH) {
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
if (flags & GETSWITCH_MIDPOS_DELAY) { if (flags & GETSWITCH_MIDPOS_DELAY)
div_t swinfo = switchInfo(cs_idx); result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH);
if (IS_3POS(swinfo.quot)) { else
result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH);
}
else {
result = switchState((EnumKeys)(SW_BASE+cs_idx-SWSRC_FIRST_SWITCH));
}
}
else {
result = switchState((EnumKeys)(SW_BASE+cs_idx-SWSRC_FIRST_SWITCH)); result = switchState((EnumKeys)(SW_BASE+cs_idx-SWSRC_FIRST_SWITCH));
}
#else #else
result = switchState((EnumKeys)(SW_BASE+cs_idx-SWSRC_FIRST_SWITCH)); result = switchState((EnumKeys)(SW_BASE+cs_idx-SWSRC_FIRST_SWITCH));
#endif #endif