feat(bw): add 'Set Screen' special function to B&W radios (#5589)
This commit is contained in:
@@ -261,7 +261,6 @@ bool CustomFunctionData::isFuncAvailable(const int index, const ModelData * mode
|
||||
((index >= FuncRangeCheckInternalModule && index <= FuncBindExternalModule) && !fw->getCapability(DangerousFunctions)) ||
|
||||
((index >= FuncAdjustGV1 && index <= FuncAdjustGVLast) && !fw->getCapability(Gvars)) ||
|
||||
((index == FuncDisableTouch) && !IS_HORUS_OR_TARANIS(fw->getBoard())) ||
|
||||
((index == FuncSetScreen && !Boards::getCapability(fw->getBoard(), Board::HasColorLcd))) ||
|
||||
((index == FuncDisableAudioAmp && !Boards::getCapability(fw->getBoard(), Board::HasAudioMuteGPIO))) ||
|
||||
((index == FuncRGBLed && !Boards::getCapability(fw->getBoard(), Board::HasLedStripGPIO))) ||
|
||||
((index == FuncLCDtoVideo && !IS_FATFISH_F16(fw->getBoard()))) ||
|
||||
@@ -424,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()
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -89,6 +89,7 @@ class CustomFunctionsPanel : public GenericPanel
|
||||
int harpicId;
|
||||
int repeatId;
|
||||
int repeatLuaId;
|
||||
int repeatSetScreenId;
|
||||
int gvarAdjustModeId;
|
||||
|
||||
QSet<QString> tracksSet;
|
||||
|
||||
Reference in New Issue
Block a user