1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-25 01:05:08 +03:00

It was possible to reset Timer3 in custom functions even if Timer3

unavailable
This commit is contained in:
bsongis 2015-07-09 22:17:55 +02:00
parent d0bee7d666
commit ef21053b3d
5 changed files with 24 additions and 11 deletions

View file

@ -343,6 +343,27 @@ bool isAssignableFunctionAvailable(int function)
} }
} }
bool isAvailableInResetSpecialFunction(int index)
{
if (index >= FUNC_RESET_PARAM_FIRST_TELEM) {
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index-FUNC_RESET_PARAM_FIRST_TELEM];
return telemetrySensor.isAvailable();
}
#if TIMERS < 3
else if (index == FUNC_RESET_TIMER3) {
return false;
}
#endif
#if TIMERS < 2
else if (index == FUNC_RESET_TIMER2) {
return false;
}
#endif
else {
return true;
}
}
bool isModuleAvailable(int module) bool isModuleAvailable(int module)
{ {
return true; return true;

View file

@ -192,7 +192,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
} }
#endif #endif
else if (func == FUNC_SET_TIMER) { else if (func == FUNC_SET_TIMER) {
maxParam = MAX_TIMERS-1; maxParam = TIMERS-1;
putsStrIdx(lcdNextPos, y, STR_TIMER, CFN_TIMER_INDEX(cfn)+1, attr); putsStrIdx(lcdNextPos, y, STR_TIMER, CFN_TIMER_INDEX(cfn)+1, attr);
if (active) CFN_TIMER_INDEX(cfn) = checkIncDec(event, CFN_TIMER_INDEX(cfn), 0, maxParam, eeFlags); if (active) CFN_TIMER_INDEX(cfn) = checkIncDec(event, CFN_TIMER_INDEX(cfn), 0, maxParam, eeFlags);
break; break;
@ -217,12 +217,10 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, param, attr); lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, param, attr);
} }
else { else {
if (param > FUNC_RESET_PARAM_FIRST_TELEM) {
INCDEC_ENABLE_CHECK(isSensorAvailableInResetSpecialFunction);
}
TelemetrySensor * sensor = & g_model.telemetrySensors[param-FUNC_RESET_PARAM_FIRST_TELEM]; TelemetrySensor * sensor = & g_model.telemetrySensors[param-FUNC_RESET_PARAM_FIRST_TELEM];
lcd_putsnAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, sensor->label, TELEM_LABEL_LEN, attr|ZCHAR); lcd_putsnAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, sensor->label, TELEM_LABEL_LEN, attr|ZCHAR);
} }
INCDEC_ENABLE_CHECK(isAvailableInResetSpecialFunction);
} }
#if defined(OVERRIDE_CHANNEL_FUNCTION) #if defined(OVERRIDE_CHANNEL_FUNCTION)
else if (func == FUNC_OVERRIDE_CHANNEL) { else if (func == FUNC_OVERRIDE_CHANNEL) {

View file

@ -196,6 +196,7 @@ int8_t checkIncDecMovedSwitch(int8_t val);
bool isThrottleSourceAvailable(int source); bool isThrottleSourceAvailable(int source);
bool isLogicalSwitchFunctionAvailable(int function); bool isLogicalSwitchFunctionAvailable(int function);
bool isAssignableFunctionAvailable(int function); bool isAssignableFunctionAvailable(int function);
bool isAvailableInResetSpecialFunction(int index);
bool isLogicalSwitchAvailable(int index); bool isLogicalSwitchAvailable(int index);
bool isSwitchAvailableInLogicalSwitches(int swtch); bool isSwitchAvailableInLogicalSwitches(int swtch);
bool isSwitchAvailableInCustomFunctions(int swtch); bool isSwitchAvailableInCustomFunctions(int swtch);

View file

@ -480,12 +480,6 @@ int lastUsedTelemetryIndex()
return -1; return -1;
} }
bool isSensorAvailableInResetSpecialFunction(int index)
{
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index-FUNC_RESET_PARAM_FIRST_TELEM];
return telemetrySensor.isAvailable();
}
void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t instance, int32_t value, uint32_t unit, uint32_t prec) void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t instance, int32_t value, uint32_t unit, uint32_t prec)
{ {
for (int index=0; index<MAX_SENSORS; index++) { for (int index=0; index<MAX_SENSORS; index++) {

View file

@ -186,7 +186,6 @@ void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t instance
void delTelemetryIndex(uint8_t index); void delTelemetryIndex(uint8_t index);
int availableTelemetryIndex(); int availableTelemetryIndex();
int lastUsedTelemetryIndex(); int lastUsedTelemetryIndex();
bool isSensorAvailableInResetSpecialFunction(int index);
int32_t getTelemetryValue(uint8_t index, uint8_t & prec); int32_t getTelemetryValue(uint8_t index, uint8_t & prec);
int32_t convertTelemetryValue(int32_t value, uint8_t unit, uint8_t prec, uint8_t destUnit, uint8_t destPrec); int32_t convertTelemetryValue(int32_t value, uint8_t unit, uint8_t prec, uint8_t destUnit, uint8_t destPrec);