feat(bw): add 'Set Screen' special function to B&W radios (#5589)

This commit is contained in:
philmoz
2024-10-17 15:58:34 +10:00
committed by GitHub
parent 200518cc9a
commit e8224b8f08
46 changed files with 183 additions and 43 deletions
+19 -6
View File
@@ -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();
@@ -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);
@@ -550,14 +553,24 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
else if (func == FuncSetScreen) {
if (modified)
if (modified) {
cfn.param = (uint8_t)fswtchParam[i]->value();
cfn.repeatParam = fswtchRepeat[i]->currentData().toInt();
}
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setMinimum(1);
if(model)
fswtchParam[i]->setMaximum(model->getCustomScreensCount());
else
fswtchParam[i]->setMaximum(1);
if (Boards::getCapability(firmware->getBoard(), Board::HasColorLcd)) {
fswtchParam[i]->setMinimum(1);
if(model)
fswtchParam[i]->setMaximum(model->getCustomScreensCount());
else
fswtchParam[i]->setMaximum(1);
} else {
fswtchParam[i]->setMinimum(0);
fswtchParam[i]->setMaximum(4);
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatSetScreenId));
fswtchRepeat[i]->setCurrentIndex(fswtchRepeat[i]->findData(cfn.repeatParam));
}
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setValue(cfn.param);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;