Skip to content

Commit

Permalink
Limit range for repeat value for 'Set Screen' function.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Oct 4, 2024
1 parent b43d0a1 commit ce9505a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
13 changes: 13 additions & 0 deletions companion/src/firmwares/customfunctiondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,19 @@ AbstractStaticItemModel * CustomFunctionData::repeatLuaItemModel()
return mdl;
}

// static
AbstractStaticItemModel * CustomFunctionData::repeatSetScreenItemModel()
{
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
mdl->setName("customfunctiondata.repeatSetScreen");

mdl->appendToItemList(repeatToString(-1, false), -1);
mdl->appendToItemList(repeatToString(0, false), 0);

mdl->loadItemList();
return mdl;
}

// static
AbstractStaticItemModel * CustomFunctionData::playSoundItemModel()
{
Expand Down
1 change: 1 addition & 0 deletions companion/src/firmwares/customfunctiondata.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class CustomFunctionData {
static QString gvarAdjustModeToString(const int value);
static AbstractStaticItemModel * repeatItemModel();
static AbstractStaticItemModel * repeatLuaItemModel();
static AbstractStaticItemModel * repeatSetScreenItemModel();
static AbstractStaticItemModel * playSoundItemModel();
static AbstractStaticItemModel * harpicItemModel();
static AbstractStaticItemModel * gvarAdjustModeItemModel();
Expand Down
5 changes: 5 additions & 0 deletions companion/src/modeledit/customfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
harpicId = tabModelFactory->registerItemModel(CustomFunctionData::harpicItemModel());
repeatId = tabModelFactory->registerItemModel(CustomFunctionData::repeatItemModel());
repeatLuaId = tabModelFactory->registerItemModel(CustomFunctionData::repeatLuaItemModel());
repeatSetScreenId = tabModelFactory->registerItemModel(CustomFunctionData::repeatSetScreenItemModel());
gvarAdjustModeId = tabModelFactory->registerItemModel(CustomFunctionData::gvarAdjustModeItemModel());

tabFilterFactory = new FilteredItemModelFactory();
Expand Down Expand Up @@ -209,6 +210,8 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
fswtchRepeat[i]->setProperty("index", i);
if (functions[i].func == FuncPlayScript || functions[i].func == FuncRGBLed)
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatLuaId));
else if (functions[i].func == FuncSetScreen && !Boards::getCapability(firmware->getBoard(), Board::HasColorLcd))
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatSetScreenId));
else
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatId));
fswtchRepeat[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
Expand Down Expand Up @@ -356,6 +359,8 @@ void CustomFunctionsPanel::functionEdited()
functions[index].enabled = true;
if (functions[index].func == FuncPlayScript || functions[index].func == FuncRGBLed)
fswtchRepeat[index]->setModel(tabModelFactory->getItemModel(repeatLuaId));
else if (functions[index].func == FuncSetScreen && !Boards::getCapability(firmware->getBoard(), Board::HasColorLcd))
fswtchRepeat[index]->setModel(tabModelFactory->getItemModel(repeatSetScreenId));
else
fswtchRepeat[index]->setModel(tabModelFactory->getItemModel(repeatId));
if (functions[index].func == FuncLogs)
Expand Down
1 change: 1 addition & 0 deletions companion/src/modeledit/customfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class CustomFunctionsPanel : public GenericPanel
int harpicId;
int repeatId;
int repeatLuaId;
int repeatSetScreenId;
int gvarAdjustModeId;

QSet<QString> tracksSet;
Expand Down
6 changes: 5 additions & 1 deletion radio/src/gui/128x64/model_special_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,11 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
else {
lcdDrawNumber(MODEL_SPECIAL_FUNC_4TH_COLUMN+2+FW, y, CFN_PLAY_REPEAT(cfn)*CFN_PLAY_REPEAT_MUL, RIGHT | attr);
}
if (active) CFN_PLAY_REPEAT(cfn) = checkIncDec(event, CFN_PLAY_REPEAT(cfn)==CFN_PLAY_REPEAT_NOSTART?-1:CFN_PLAY_REPEAT(cfn), -1, 60/CFN_PLAY_REPEAT_MUL, eeFlags);
if (active)
CFN_PLAY_REPEAT(cfn) = checkIncDec(event, CFN_PLAY_REPEAT(cfn)==CFN_PLAY_REPEAT_NOSTART?-1:CFN_PLAY_REPEAT(cfn),
-1,
(func == FUNC_SET_SCREEN ? 0 : 60/CFN_PLAY_REPEAT_MUL),
eeFlags);
}
}
else if (attr) {
Expand Down
6 changes: 5 additions & 1 deletion radio/src/gui/212x64/model_special_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,11 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
lcdDrawNumber(MODEL_SPECIAL_FUNC_4TH_COLUMN+2+FW, y, CFN_PLAY_REPEAT(cfn)*CFN_PLAY_REPEAT_MUL, attr|RIGHT);
lcdDrawChar(MODEL_SPECIAL_FUNC_4TH_COLUMN+2+FW, y, 's', attr);
}
if (active) CFN_PLAY_REPEAT(cfn) = checkIncDec(event, CFN_PLAY_REPEAT(cfn)==CFN_PLAY_REPEAT_NOSTART?-1:CFN_PLAY_REPEAT(cfn), -1, 60/CFN_PLAY_REPEAT_MUL, eeFlags);
if (active)
CFN_PLAY_REPEAT(cfn) = checkIncDec(event, CFN_PLAY_REPEAT(cfn)==CFN_PLAY_REPEAT_NOSTART?-1:CFN_PLAY_REPEAT(cfn),
-1,
(func == FUNC_SET_SCREEN ? 0 : 60/CFN_PLAY_REPEAT_MUL),
eeFlags);
}
}
else if (attr) {
Expand Down

0 comments on commit ce9505a

Please sign in to comment.