fix(radio): YAML timer handling (#3949)

* fix: YAML timer handling

* chore: improve YAML set timer handling

* chore: improve timer handling

* feat: only offer defined timer for set and reset functions

* feat: only offer defined timer for set and reset functions (bw)

* chore: cosmetics
This commit is contained in:
3djc
2023-08-28 20:02:03 +10:00
committed by GitHub
parent e56cffafa9
commit 78aa381464
19 changed files with 61 additions and 82 deletions
@@ -247,7 +247,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
else if (func == FUNC_SET_TIMER) {
maxParam = MAX_TIMERS - 1;
lcdDrawTextAtIndex(lcdNextPos, y, STR_VFSWRESET, CFN_TIMER_INDEX(cfn), 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, isTimerSourceAvailable);
break;
}
else if (attr) {
+1 -1
View File
@@ -714,7 +714,7 @@ void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
lcdDrawSizedText(x, y, g_model.timers[idx].name, LEN_TIMER_NAME, att);
}
else {
drawStringWithIndex(x, y, STR_SRC_TIMER, idx, att);
drawStringWithIndex(x, y, STR_SRC_TIMER, idx + 1, att);
}
}
else {
@@ -239,7 +239,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
else if (func == FUNC_SET_TIMER) {
maxParam = TIMERS-1;
drawStringWithIndex(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, isTimerSourceAvailable);
break;
}
else if (attr) {
+5 -2
View File
@@ -207,8 +207,11 @@ class SpecialFunctionEditPage : public Page
timerchoice->setTextHandler([](int32_t value) {
return std::string(STR_TIMER) + std::to_string(value + 1);
});
line = specialFunctionOneWindow->newLine(&grid);
timerchoice->setAvailableHandler([=](int value) {
return isTimerSourceAvailable(value);
});
line = specialFunctionOneWindow->newLine(&grid);
new StaticText(line, rect_t{}, STR_VALUE, 0, COLOR_THEME_PRIMARY1);
new TimeEdit(line, rect_t{}, 0,
9 * 60 * 60 - 1, GET_SET_DEFAULT(CFN_PARAM(cfn)));
@@ -619,7 +622,7 @@ class SpecialFunctionButton : public Button
break;
case FUNC_SET_TIMER:
sprintf(s+strlen(s), "%s%d = %s", STR_TIMER, CFN_TIMER_INDEX(cfn) + 1, getTimerString(CFN_PARAM(cfn), {.options = SHOW_TIME}));
sprintf(s+strlen(s), "%s%d = %s", STR_SRC_TIMER, CFN_TIMER_INDEX(cfn) + 1, getTimerString(CFN_PARAM(cfn), {.options = SHOW_TIME}));
break;
case FUNC_SET_FAILSAFE:
+13 -9
View File
@@ -608,6 +608,12 @@ bool isAssignableFunctionAvailable(int function)
}
#endif
bool isTimerSourceAvailable(int index)
{
TimerData *timer = &g_model.timers[index];
return timer->mode != 0;
}
bool isSourceAvailableInGlobalResetSpecialFunction(int index)
{
if (index >= FUNC_RESET_PARAM_FIRST_TELEM)
@@ -622,16 +628,14 @@ bool isSourceAvailableInResetSpecialFunction(int index)
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;
else if (index <= FUNC_RESET_TIMER3) {
if (index > (TIMERS - 1))
return false;
else {
TimerData *timer = &g_model.timers[index];
return timer->mode != 0;
}
}
#endif
#if TIMERS < 2
else if (index == FUNC_RESET_TIMER2) {
return false;
}
#endif
else {
return true;
}
+1
View File
@@ -78,6 +78,7 @@ bool isLogicalSwitchFunctionAvailable(int function);
bool isLogicalSwitchAvailable(int index);
bool isAssignableFunctionAvailable(int function);
bool isSourceAvailable(int source);
bool isTimerSourceAvailable(int source);
bool isSourceAvailableInGlobalFunctions(int source);
bool isSourceAvailableInCustomSwitches(int source);
bool isSourceAvailableInResetSpecialFunction(int index);