fix(color): UI freeze when setting up 'Set' special function with no timers configured (#6377)
This commit is contained in:
@@ -267,9 +267,15 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
}
|
||||
#endif // GVARS
|
||||
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, isTimerSourceAvailable);
|
||||
if (timersSetupCount()> 0) {
|
||||
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, isTimerSourceAvailable);
|
||||
} else {
|
||||
lcdDrawText(lcdNextPos + FW, y, STR_NO_TIMERS, 0);
|
||||
if (attr)
|
||||
repeatLastCursorHorMove(event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
@@ -317,8 +323,12 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
}
|
||||
#endif
|
||||
else if (func == FUNC_SET_TIMER) {
|
||||
getMixSrcRange(MIXSRC_FIRST_TIMER, val_min, val_max);
|
||||
drawTimer(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT, attr);
|
||||
if (timersSetupCount() > 0) {
|
||||
getMixSrcRange(MIXSRC_FIRST_TIMER, val_min, val_max);
|
||||
drawTimer(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT, attr);
|
||||
} else if (attr) {
|
||||
repeatLastCursorHorMove(event);
|
||||
}
|
||||
}
|
||||
#if defined(AUDIO)
|
||||
else if (func == FUNC_PLAY_SOUND) {
|
||||
|
||||
@@ -256,9 +256,15 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
}
|
||||
#endif
|
||||
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, isTimerSourceAvailable);
|
||||
if (timersSetupCount()> 0) {
|
||||
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, isTimerSourceAvailable);
|
||||
} else {
|
||||
lcdDrawText(lcdNextPos + FW, y, STR_NO_TIMERS, 0);
|
||||
if (attr)
|
||||
repeatLastCursorHorMove(event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (attr) {
|
||||
@@ -300,8 +306,12 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
}
|
||||
#endif
|
||||
else if (func == FUNC_SET_TIMER) {
|
||||
getMixSrcRange(MIXSRC_FIRST_TIMER, val_min, val_max);
|
||||
drawTimer(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT|TIMEHOUR, attr);
|
||||
if (timersSetupCount() > 0) {
|
||||
getMixSrcRange(MIXSRC_FIRST_TIMER, val_min, val_max);
|
||||
drawTimer(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT|TIMEHOUR, attr);
|
||||
} else if (attr) {
|
||||
repeatLastCursorHorMove(event);
|
||||
}
|
||||
}
|
||||
else if (func == FUNC_PLAY_SOUND) {
|
||||
val_max = AU_SPECIAL_SOUND_LAST-AU_SPECIAL_SOUND_FIRST-1;
|
||||
|
||||
@@ -200,9 +200,13 @@ void FunctionLineButton::refresh()
|
||||
break;
|
||||
|
||||
case FUNC_SET_TIMER:
|
||||
sprintf(s + strlen(s), "%s%d = %s", STR_SRC_TIMER,
|
||||
CFN_TIMER_INDEX(cfn) + 1,
|
||||
getTimerString(CFN_PARAM(cfn), {.options = SHOW_TIME}));
|
||||
if (isTimerSourceAvailable(CFN_TIMER_INDEX(cfn))) {
|
||||
sprintf(s + strlen(s), "%s%d = %s", STR_SRC_TIMER,
|
||||
CFN_TIMER_INDEX(cfn) + 1,
|
||||
getTimerString(CFN_PARAM(cfn), {.options = SHOW_TIME}));
|
||||
} else {
|
||||
sprintf(s + strlen(s), "---");
|
||||
}
|
||||
break;
|
||||
|
||||
case FUNC_SET_FAILSAFE:
|
||||
@@ -464,18 +468,22 @@ void FunctionEditPage::updateSpecialFunctionOneWindow()
|
||||
|
||||
case FUNC_SET_TIMER: {
|
||||
new StaticText(line, rect_t{}, STR_TIMER);
|
||||
auto timerchoice = new Choice(line, rect_t{}, 0, TIMERS - 1,
|
||||
GET_SET_DEFAULT(CFN_TIMER_INDEX(cfn)));
|
||||
timerchoice->setTextHandler([](int32_t value) {
|
||||
return std::string(STR_TIMER) + std::to_string(value + 1);
|
||||
});
|
||||
timerchoice->setAvailableHandler(
|
||||
[=](int value) { return isTimerSourceAvailable(value); });
|
||||
if (timersSetupCount() > 0) {
|
||||
auto timerchoice = new Choice(line, rect_t{}, 0, TIMERS - 1,
|
||||
GET_SET_DEFAULT(CFN_TIMER_INDEX(cfn)));
|
||||
timerchoice->setTextHandler([](int32_t value) {
|
||||
return std::string(STR_TIMER) + std::to_string(value + 1);
|
||||
});
|
||||
timerchoice->setAvailableHandler(
|
||||
[=](int value) { return isTimerSourceAvailable(value); });
|
||||
|
||||
line = specialFunctionOneWindow->newLine(grid);
|
||||
new StaticText(line, rect_t{}, STR_VALUE);
|
||||
new TimeEdit(line, rect_t{}, 0, 9 * 60 * 60 - 1,
|
||||
GET_SET_DEFAULT(CFN_PARAM(cfn)));
|
||||
line = specialFunctionOneWindow->newLine(grid);
|
||||
new StaticText(line, rect_t{}, STR_VALUE);
|
||||
new TimeEdit(line, rect_t{}, 0, 9 * 60 * 60 - 1,
|
||||
GET_SET_DEFAULT(CFN_PARAM(cfn)));
|
||||
} else {
|
||||
new StaticText(line, rect_t{}, STR_NO_TIMERS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -693,6 +693,15 @@ bool isAssignableFunctionAvailable(int function)
|
||||
}
|
||||
#endif
|
||||
|
||||
int timersSetupCount()
|
||||
{
|
||||
int tc = 0;
|
||||
for (int i = 0; i < MAX_TIMERS; i += 1)
|
||||
if (isTimerSourceAvailable(i))
|
||||
tc += 1;
|
||||
return tc;
|
||||
}
|
||||
|
||||
bool isTimerSourceAvailable(int index)
|
||||
{
|
||||
TimerData *timer = &g_model.timers[index];
|
||||
|
||||
@@ -61,6 +61,7 @@ bool isThrottleSourceAvailable(int source);
|
||||
bool isLogicalSwitchAvailable(int index);
|
||||
bool isAssignableFunctionAvailable(int function);
|
||||
bool isSourceAvailable(int source);
|
||||
int timersSetupCount();
|
||||
bool isTimerSourceAvailable(int source);
|
||||
bool isSourceAvailableInGlobalFunctions(int source);
|
||||
bool isSourceAvailableInCustomSwitches(int source);
|
||||
|
||||
Reference in New Issue
Block a user