void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) { unsigned int widgetsMask = 0; if (modified) { model.funcSw[i].swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt()); model.funcSw[i].func = (AssignFunc)fswtchFunc[i]->currentIndex(); model.funcSw[i].enabled = fswtchEnable[i]->isChecked(); model.funcSw[i].adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex(); } int index = fswtchFunc[i]->currentIndex(); if (index>=FuncOverrideCH1 && index<=FuncOverrideCH32) { int channelsMax = model.getChannelsMax(true); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setMinimum(-channelsMax); fswtchParam[i]->setMaximum(channelsMax); if (modified) { model.funcSw[i].param = fswtchParam[i]->value(); } fswtchParam[i]->setValue(model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (index==FuncLogs) { fswtchParam[i]->setDecimals(1); fswtchParam[i]->setMinimum(0); fswtchParam[i]->setMaximum(25.5); fswtchParam[i]->setSingleStep(0.1); if (modified) model.funcSw[i].param = fswtchParam[i]->value()*10.0; fswtchParam[i]->setValue(model.funcSw[i].param/10.0); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; } else if (index>=FuncAdjustGV1 && index<=FuncAdjustGVLast) { if (modified) model.funcSw[i].adjustMode = fswtchGVmode[i]->currentIndex(); widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE; if (model.funcSw[i].adjustMode==0) { if (modified) model.funcSw[i].param = fswtchParam[i]->value(); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); if (IS_ARM(GetEepromInterface()->getBoard())) { fswtchParam[i]->setMinimum(-500); fswtchParam[i]->setMaximum(500); } else { fswtchParam[i]->setMinimum(-125); fswtchParam[i]->setMaximum(125); } fswtchParam[i]->setValue(model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; } else { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param, model.funcSw[i].adjustMode); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } } else if (index==FuncReset) { if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; } else if (index>=FuncSetTimer1 && index<=FuncSetTimer2) { if (modified) model.funcSw[i].param = QTimeS(fswtchParamTime[i]->time()).seconds(); fswtchParamTime[i]->setMinimumTime(QTime(0, 0, 0)); fswtchParamTime[i]->setMaximumTime(QTime(0, 59, 59)); fswtchParamTime[i]->setTime(QTimeS(model.funcSw[i].param)); widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (index==FuncVolume) { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { if (index != FuncBackgroundMusic) { widgetsMask |= CUSTOM_FUNCTION_REPEAT; fswtchRepeat[i]->update(); } if (index==FuncPlayValue) { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT; } else if (index==FuncPlayPrompt || index==FuncPlayBoth) { if (firmware->getCapability(VoicesAsNumbers)) { fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setMinimum(0); if (index==FuncPlayPrompt) { widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT + CUSTOM_FUNCTION_GV_TOOGLE; } else { widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT; fswtchParamGV[i]->setChecked(false); } fswtchParam[i]->setMaximum(index==FuncPlayBoth ? 254 : 255); if (modified) { if (fswtchParamGV[i]->isChecked()) { fswtchParam[i]->setMinimum(1); model.funcSw[i].param = std::min(fswtchParam[i]->value(),5.0)+(fswtchParamGV[i]->isChecked() ? 250 : 0); } else { model.funcSw[i].param = fswtchParam[i]->value(); } } if (model.funcSw[i].param>250 && (index!=FuncPlayBoth)) { fswtchParamGV[i]->setChecked(true); fswtchParam[i]->setValue(model.funcSw[i].param-250); fswtchParam[i]->setMaximum(5); } else { fswtchParamGV[i]->setChecked(false); fswtchParam[i]->setValue(model.funcSw[i].param); } if (model.funcSw[i].param < 251) widgetsMask |= CUSTOM_FUNCTION_PLAY; } else { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); int vml = firmware->getCapability(VoicesMaxLength); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(), vml); j++) { model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); } } } populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, tracksSet); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; } } } else if (index==FuncBackgroundMusic) { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); int vml=firmware->getCapability(VoicesMaxLength); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(),vml); j++) { model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); } } } populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, tracksSet); } else if (index==FuncPlaySound) { if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } else if (index==FuncPlayHaptic) { if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } } else if (index==FuncPlayScript) { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); int vml = 8/*TODO*/; if (fswtchParamArmT[i]->currentText() != "----") { for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(), vml); j++) { model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); } } } populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, scriptsSet); } else if (index==FuncBacklight && IS_TARANIS_PLUS(GetEepromInterface()->getBoard())) { if (modified) model.funcSw[i].param = (uint8_t)fswtchBLcolor[i]->value(); fswtchBLcolor[i]->setValue(model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_BL_COLOR; } else { if (modified) model.funcSw[i].param = fswtchParam[i]->value(); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setValue(model.funcSw[i].param); if (index <= FuncInstantTrim) { widgetsMask |= CUSTOM_FUNCTION_ENABLE; } } fswtchParam[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_NUMERIC_PARAM); fswtchParamTime[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_TIME_PARAM); fswtchParamGV[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_TOOGLE); fswtchParamT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SOURCE_PARAM); fswtchParamArmT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_FILE_PARAM); fswtchEnable[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_ENABLE); if (widgetsMask & CUSTOM_FUNCTION_ENABLE) fswtchEnable[i]->setChecked(model.funcSw[i].enabled); else fswtchEnable[i]->setChecked(false); fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT); fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE); fswtchBLcolor[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_BL_COLOR); #ifdef PHONON playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY); #endif }
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) { CustomFunctionData & cfn = functions[i]; AssignFunc func = (AssignFunc)fswtchFunc[i]->itemData(fswtchFunc[i]->currentIndex()).toInt(); unsigned int widgetsMask = 0; if (modified) { cfn.swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt()); cfn.func = func; cfn.enabled = fswtchEnable[i]->isChecked(); cfn.adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex(); } if (func>=FuncOverrideCH1 && func<=FuncOverrideCH32) { if (model) { int channelsMax = model->getChannelsMax(true); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setMinimum(-channelsMax); fswtchParam[i]->setMaximum(channelsMax); if (modified) { cfn.param = fswtchParam[i]->value(); } fswtchParam[i]->setValue(cfn.param); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE; } } else if (func==FuncLogs) { fswtchParam[i]->setDecimals(1); fswtchParam[i]->setMinimum(0); fswtchParam[i]->setMaximum(25.5); fswtchParam[i]->setSingleStep(0.1); if (modified) cfn.param = fswtchParam[i]->value()*10.0; fswtchParam[i]->setValue(cfn.param/10.0); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; } else if (func>=FuncAdjustGV1 && func<=FuncAdjustGVLast) { if (modified) cfn.adjustMode = fswtchGVmode[i]->currentIndex(); widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE; if (cfn.adjustMode==0) { if (modified) cfn.param = fswtchParam[i]->value(); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); if (IS_ARM(GetEepromInterface()->getBoard())) { fswtchParam[i]->setMinimum(-500); fswtchParam[i]->setMaximum(500); } else { fswtchParam[i]->setMinimum(-125); fswtchParam[i]->setMaximum(125); } fswtchParam[i]->setValue(cfn.param); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; } else { if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], func, cfn.param, cfn.adjustMode); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } } else if (func==FuncReset) { if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; } else if (func>=FuncSetTimer1 && func<=FuncSetTimer3) { if (modified) cfn.param = QTimeS(fswtchParamTime[i]->time()).seconds(); fswtchParamTime[i]->setMinimumTime(QTime(0, 0, 0)); fswtchParamTime[i]->setMaximumTime(firmware->getMaxTimerStart()); fswtchParamTime[i]->setTime(QTimeS(cfn.param)); widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (func>=FuncSetFailsafeInternalModule && func<=FuncBindExternalModule) { widgetsMask |= CUSTOM_FUNCTION_ENABLE; } else if (func==FuncVolume) { if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (func==FuncPlaySound || func==FuncPlayHaptic || func==FuncPlayValue || func==FuncPlayPrompt || func==FuncPlayBoth || func==FuncBackgroundMusic) { if (func != FuncBackgroundMusic) { widgetsMask |= CUSTOM_FUNCTION_REPEAT; fswtchRepeat[i]->update(); } if (func==FuncPlayValue) { if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT; } else if (func==FuncPlayPrompt || func==FuncPlayBoth) { if (firmware->getCapability(VoicesAsNumbers)) { fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setMinimum(0); if (func==FuncPlayPrompt) { widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT + CUSTOM_FUNCTION_GV_TOOGLE; } else { widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT; fswtchParamGV[i]->setChecked(false); } fswtchParam[i]->setMaximum(func==FuncPlayBoth ? 254 : 255); if (modified) { if (fswtchParamGV[i]->isChecked()) { fswtchParam[i]->setMinimum(1); cfn.param = std::min(fswtchParam[i]->value(),5.0)+(fswtchParamGV[i]->isChecked() ? 250 : 0); } else { cfn.param = fswtchParam[i]->value(); } } if (cfn.param>250 && (func!=FuncPlayBoth)) { fswtchParamGV[i]->setChecked(true); fswtchParam[i]->setValue(cfn.param-250); fswtchParam[i]->setMaximum(5); } else { fswtchParamGV[i]->setChecked(false); fswtchParam[i]->setValue(cfn.param); } if (cfn.param < 251) widgetsMask |= CUSTOM_FUNCTION_PLAY; } else { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength)); } populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; } } } else if (func==FuncBackgroundMusic) { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength)); } populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; } } else if (func==FuncPlaySound) { if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } else if (func==FuncPlayHaptic) { if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } } else if (func==FuncPlayScript) { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, 8); } populateFileComboBox(fswtchParamArmT[i], scriptsSet, cfn.paramarm); } else if (func==FuncBacklight && IS_TARANIS_PLUS(GetEepromInterface()->getBoard())) { if (modified) cfn.param = (uint8_t)fswtchBLcolor[i]->value(); fswtchBLcolor[i]->setValue(cfn.param); widgetsMask |= CUSTOM_FUNCTION_BL_COLOR; } else { if (modified) cfn.param = fswtchParam[i]->value(); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setValue(cfn.param); if (func <= FuncInstantTrim) { widgetsMask |= CUSTOM_FUNCTION_ENABLE; } } fswtchParam[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_NUMERIC_PARAM); fswtchParamTime[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_TIME_PARAM); fswtchParamGV[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_TOOGLE); fswtchParamT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SOURCE_PARAM); fswtchParamArmT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_FILE_PARAM); fswtchEnable[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_ENABLE); if (widgetsMask & CUSTOM_FUNCTION_ENABLE) fswtchEnable[i]->setChecked(cfn.enabled); else fswtchEnable[i]->setChecked(false); fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT); fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE); fswtchBLcolor[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_BL_COLOR); #ifdef PHONON playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY); #endif }