diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 318a65524..375b4e7ff 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -109,6 +109,8 @@ add_custom_command( DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/ersky9x/ersky9xsimulator.cpp ) +add_subdirectory(modeledit) + SET( companion9x_SRCS eeprominterface.cpp hexinterface.cpp @@ -137,15 +139,11 @@ SET( companion9x_SRCS firmwares/ersky9x/ersky9xeeprom.cpp firmwares/ersky9x/ersky9xinterface.cpp ${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp - node.cpp - edge.cpp helpers.cpp mdichild.cpp generaledit.cpp - modeledit.cpp modelslist.cpp mountlist.cpp - mixerslist.cpp avroutputdialog.cpp preferencesdialog.cpp burnconfigdialog.cpp @@ -155,8 +153,6 @@ SET( companion9x_SRCS burndialog.cpp printdialog.cpp fusesdialog.cpp - expodialog.cpp - mixerdialog.cpp logsdialog.cpp downloaddialog.cpp simulatordialog.cpp @@ -175,9 +171,7 @@ SET( companion9x_MOC_HDRS comparedialog.h printdialog.h fusesdialog.h - mixerdialog.h logsdialog.h - expodialog.h contributorsdialog.h customizesplashdialog.h splashlibrary.h @@ -191,9 +185,7 @@ SET( companion9x_MOC_HDRS xmenuwidget.h xsimulatordialog.h generaledit.h - modeledit.h modelslist.h - mixerslist.h mdichild.h mainwindow.h myslider.h @@ -206,16 +198,13 @@ SET( companion9x_UIS avroutputdialog.ui comparedialog.ui fusesdialog.ui - expodialog.ui logsdialog.ui - mixerdialog.ui preferencesdialog.ui simulatordialog.ui xsimulatordialog.ui burnconfigdialog.ui downloaddialog.ui generaledit.ui - modeledit.ui printdialog.ui contributorsdialog.ui customizesplashdialog.ui @@ -314,7 +303,7 @@ ELSE( ) ADD_EXECUTABLE( ${PROJECT_NAME} WIN32 ${companion9x_SRCS} ${companion9x_QM} ) ENDIF( ) -TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${XERCESC_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS} ) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} modeledit ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${XERCESC_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS} ) IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin ) diff --git a/companion/src/comparedialog.cpp b/companion/src/comparedialog.cpp index ded52c41c..f5dd1216a 100644 --- a/companion/src/comparedialog.cpp +++ b/companion/src/comparedialog.cpp @@ -21,7 +21,7 @@ public: } bool general_settings; uint8_t models_count; - uint8_t models[C9XMAX_MODELS]; + uint8_t models[C9X_MAX_MODELS]; }; compareDialog::compareDialog(QWidget *parent, GeneralSettings *gg) : @@ -342,7 +342,7 @@ void compareDialog::printPhases() gvars=1; } if (gvars==1) { - gvarnum=GetEepromInterface()->getCapability(GvarsNum); + gvarnum=GetEepromInterface()->getCapability(Gvars); } if ((gvars==1 && GetEepromInterface()->getCapability(GvarsFlightPhases)) || GetEepromInterface()->getCapability(RotaryEncoders)) { str.append("
"); @@ -564,7 +564,7 @@ void compareDialog::printGvars() int gvarnum=0; if ((GetCurrentFirmwareVariant() & GVARS_VARIANT ) || (!GetEepromInterface()->getCapability(HasVariants) && GetEepromInterface()->getCapability(Gvars))) { gvars=1; - gvarnum=GetEepromInterface()->getCapability(GvarsNum); + gvarnum=GetEepromInterface()->getCapability(Gvars); } if (!GetEepromInterface()->getCapability(GvarsFlightPhases) && (gvars==1 && GetEepromInterface()->getCapability(Gvars))) { diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 497149ca2..909a0e5e5 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -534,6 +534,18 @@ ModelData::ModelData() clear(); } +void ModelData::clearInputs() +{ + for (int i=0; i template setup, Second 3,1,2,4 , 3,1,4,2 , 3,2,1,4 , 3,2,4,1 , 3,4,1,2 , 3,4,2,1, 4,1,2,3 , 4,1,3,2 , 4,2,1,3 , 4,2,3,1 , 4,3,1,2 , 4,3,2,1 }; // TODO delete it? +// Beep center bits +#define BC_BIT_RUD (0x01) +#define BC_BIT_ELE (0x02) +#define BC_BIT_THR (0x04) +#define BC_BIT_AIL (0x08) +#define BC_BIT_P1 (0x10) +#define BC_BIT_P2 (0x20) +#define BC_BIT_P3 (0x40) +#define BC_BIT_P4 (0x80) +#define BC_BIT_REA (0x80) +#define BC_BIT_REB (0x100) + // TODO remove this enum! enum EnumKeys { KEY_MENU, @@ -477,7 +490,7 @@ class CurveData { CurveData() { clear(5); } bool custom; // 0=end, 1=pos, 2=neg, 3=both uint8_t count; - CurvePoint points[MAX_POINTS]; + CurvePoint points[C9X_MAX_POINTS]; char name[6+1]; void clear(int count) { memset(this, 0, sizeof(CurveData)); this->count = count; } }; @@ -828,6 +841,9 @@ class ModelData { ModelData removeGlobalVars(); + void clearMixes(); + void clearInputs(); + protected: void removeGlobalVar(int & var); }; @@ -835,13 +851,14 @@ class ModelData { class RadioData { public: GeneralSettings generalSettings; - ModelData models[C9XMAX_MODELS]; + ModelData models[C9X_MAX_MODELS]; }; +// TODO rename FlightPhase to FlightMode enum Capability { OwnerName, FlightPhases, - FlightPhasesAreNamed, + FlightModesName, FlightPhasesHaveFades, SimulatorType, Mixes, @@ -867,6 +884,7 @@ enum Capability { CustomSwitchesExt, RotaryEncoders, Outputs, + ChannelsName, ExtraChannels, ExtraInputs, ExtraTrims, @@ -931,7 +949,7 @@ enum Capability { GvarsHaveSources, GvarsAsSources, GvarsAsWeight, - GvarsNum, + GvarsName, GvarsOfsNum, NoTelemetryProtocol, TelemetryCSFields, diff --git a/companion/src/firmwares/er9x/er9xinterface.cpp b/companion/src/firmwares/er9x/er9xinterface.cpp index 4895e31e6..f7e6762a8 100644 --- a/companion/src/firmwares/er9x/er9xinterface.cpp +++ b/companion/src/firmwares/er9x/er9xinterface.cpp @@ -286,8 +286,6 @@ int Er9xInterface::getCapability(const Capability capability) return 12; case CustomAndSwitches: return 5; - case GvarsNum: - return 7; case GvarsOfsNum: return 5; case CSFunc: @@ -332,7 +330,9 @@ int Er9xInterface::getCapability(const Capability capability) case DiffMixers: case HasNegCurves: case HasFixOffset: + return 1; case Gvars: + return 7; case GvarsHaveSources: case GvarsAsSources: case GvarsAsWeight: diff --git a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp index 412d13520..5190ce0e8 100644 --- a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp @@ -306,7 +306,7 @@ int Ersky9xInterface::getCapability(const Capability capability) return 2; case Pots: return 3; - case GvarsNum: + case Gvars: return 7; case GvarsOfsNum: return 5; @@ -350,7 +350,6 @@ int Ersky9xInterface::getCapability(const Capability capability) return 125; case MaxVolume: return 23; - case Gvars: case GvarsHaveSources: case GvarsAsSources: case GvarsAsWeight: diff --git a/companion/src/firmwares/opentx/open9xinterface.cpp b/companion/src/firmwares/opentx/open9xinterface.cpp index f5e9ce787..0ffe6b85e 100644 --- a/companion/src/firmwares/opentx/open9xinterface.cpp +++ b/companion/src/firmwares/opentx/open9xinterface.cpp @@ -562,9 +562,13 @@ int Open9xInterface::getCapability(const Capability capability) return 6; else return 5; - case FlightPhasesAreNamed: case FlightPhasesHaveFades: + return 1; case Gvars: + return 5; + case FlightModesName: + case GvarsName: + return (IS_TARANIS(board) ? 10 : 6); case GvarsInCS: case GvarsAsWeight: case ExpoIsCurve: @@ -692,8 +696,8 @@ int Open9xInterface::getCapability(const Capability capability) return (IS_ARM(board) ? (IS_TARANIS(board) ? 8 : 6) : false); case HasExpoNames: return (IS_ARM(board) ? (IS_TARANIS(board) ? 8 : 6) : false); - case HasChNames: - return (IS_TARANIS(board) ? 1 : 0); + case ChannelsName: + return (IS_TARANIS(board) ? 6 : 0); case HasCvNames: return (IS_TARANIS(board) ? 1 : 0); case NoTimerDirs: @@ -777,7 +781,6 @@ int Open9xInterface::getCapability(const Capability capability) return (IS_ARM(board) ? 250 : 15); case CSFunc: return 18; - case GvarsNum: case GvarsOfsNum: return 5; case HasSDLogs: diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 30f2a9c6f..fc4346a23 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -560,12 +560,9 @@ void populateTrimUseCB(QComboBox *b, unsigned int phase) void populateGvarUseCB(QComboBox *b, unsigned int phase) { b->addItem(QObject::tr("Own value")); - unsigned int num_phases = GetEepromInterface()->getCapability(FlightPhases); - if (num_phases>0) { - for (unsigned int i = 0; i < num_phases; i++) { - if (i != phase) { - b->addItem(QObject::tr("Flight mode %1 value").arg(i)); - } + for (int i=0; igetCapability(FlightPhases); i++) { + if (i != (int)phase) { + b->addItem(QObject::tr("Flight mode %1 value").arg(i)); } } } @@ -983,7 +980,7 @@ void populateSourceCB(QComboBox *b, const RawSource &source, unsigned int flags) } if (flags & POPULATE_GVARS) { - for (int i=0; igetCapability(GvarsNum); i++) { + for (int i=0; igetCapability(Gvars); i++) { item = RawSource(SOURCE_TYPE_GVAR, i); b->addItem(item.toString(), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); diff --git a/companion/src/helpers.h b/companion/src/helpers.h index d37b8f8bd..0cd545016 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -6,10 +6,10 @@ #define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(CustomSwitches)-1) -//convert from mode 1 to mode g_eeGeneral.stickMode +//convert from mode 1 to mode generalSettings.stickMode //NOTICE! => 1..4 -> 1..4 -#define CONVERT_MODE(x) (((x)<=4) ? modn12x3[g_eeGeneral.stickMode][((x)-1)] : (x)) -#define CHANNEL_ORDER(x) (chout_ar[g_eeGeneral.templateSetup*4 + (x)-1]) +#define CONVERT_MODE(x) (((x)<=4) ? modn12x3[generalSettings.stickMode][((x)-1)] : (x)) +#define CHANNEL_ORDER(x) (chout_ar[generalSettings.templateSetup*4 + (x)-1]) #define CURVE_BASE 7 #define CH(x) (SRC_CH1+(x)-1-(SRC_SWC-SRC_3POS)) diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 6fbd16afa..f1654a530 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -44,7 +44,7 @@ #include "xmlinterface.h" #include "hexinterface.h" #include "mainwindow.h" -#include "modeledit.h" +#include "modeledit/modeledit.h" #include "generaledit.h" #include "avroutputdialog.h" #include "burnconfigdialog.h" @@ -192,9 +192,9 @@ void MdiChild::OpenEditWindow(bool wizard=false) } } ModelEdit *t = new ModelEdit(radioData, (row - 1), wizard, this); - if (isNew && !wizard) t->applyBaseTemplate(); + // TODO if (isNew && !wizard) t->applyBaseTemplate(); t->setWindowTitle(tr("Editing model %1: ").arg(row) + model.name); - connect(t, SIGNAL(modelValuesChanged()), this, SLOT(setModified())); + connect(t, SIGNAL(modified()), this, SLOT(setModified())); //t->exec(); t->show(); } diff --git a/companion/src/modelconfigdialog.cpp b/companion/src/modelconfigdialog.cpp index d9e245107..49c4a8df0 100644 --- a/companion/src/modelconfigdialog.cpp +++ b/companion/src/modelconfigdialog.cpp @@ -9,7 +9,7 @@ modelConfigDialog::modelConfigDialog(RadioData &radioData, uint64_t * result, QW ui(new Ui::modelConfigDialog), radioData(radioData), result(result), - g_eeGeneral(radioData.generalSettings) + generalSettings(radioData.generalSettings) { ui->setupUi(this); rxLock=false; @@ -930,4 +930,4 @@ void modelConfigDialog::asUpdate() ui->asspo2_CB->hide(); } rxLock=false; -} \ No newline at end of file +} diff --git a/companion/src/modelconfigdialog.h b/companion/src/modelconfigdialog.h index e5418a8a5..f8f508c71 100644 --- a/companion/src/modelconfigdialog.h +++ b/companion/src/modelconfigdialog.h @@ -23,7 +23,7 @@ private: int ModelType; RadioData &radioData; uint64_t * result; - GeneralSettings g_eeGeneral; + GeneralSettings generalSettings; QStringList ruddercolor; QStringList aileroncolor; QStringList elevatorcolor; diff --git a/companion/src/modeledit.cpp b/companion/src/modeledit.cpp deleted file mode 100644 index b6b5aade1..000000000 --- a/companion/src/modeledit.cpp +++ /dev/null @@ -1,7433 +0,0 @@ -#include "modeledit.h" -#include "ui_modeledit.h" -#include "helpers.h" -#include "edge.h" -#include "node.h" -#include "expodialog.h" -#include "mixerdialog.h" -#include "simulatordialog.h" -#include "xsimulatordialog.h" -#include "modelconfigdialog.h" -#include -#include -#include - -#define BC_BIT_RUD (0x01) -#define BC_BIT_ELE (0x02) -#define BC_BIT_THR (0x04) -#define BC_BIT_AIL (0x08) -#define BC_BIT_P1 (0x10) -#define BC_BIT_P2 (0x20) -#define BC_BIT_P3 (0x40) -#define BC_BIT_P4 (0x80) -#define BC_BIT_REA (0x80) -#define BC_BIT_REB (0x100) - -#define RUD (1) -#define ELE (2) -#define THR (3) -#define AIL (4) - -#define GFX_MARGIN 16 - -ModelEdit::ModelEdit(RadioData &radioData, uint8_t id, bool openWizard, bool isNew, QWidget *parent) : - QDialog(parent), - redrawCurve(true), - openWizard(openWizard), - isNew(isNew), - ui(new Ui::ModelEdit), - radioData(radioData), - id_model(id), - g_model(radioData.models[id]), - g_eeGeneral(radioData.generalSettings) -{ - ui->setupUi(this); - - setupMixerListWidget(); - setupExposListWidget(); - - QSettings settings("companion9x", "companion9x"); - ui->tabWidget->setCurrentIndex(settings.value("modelEditTab", 0).toInt()); - - QRegExp rx(CHAR_FOR_NAMES_REGEX); - ui->modelNameLE->setValidator(new QRegExpValidator(rx, this)); - ui->phase0Name->setValidator(new QRegExpValidator(rx, this)); - ui->phase1Name->setValidator(new QRegExpValidator(rx, this)); - ui->phase2Name->setValidator(new QRegExpValidator(rx, this)); - ui->phase3Name->setValidator(new QRegExpValidator(rx, this)); - ui->phase4Name->setValidator(new QRegExpValidator(rx, this)); - ui->phase5Name->setValidator(new QRegExpValidator(rx, this)); - ui->phase6Name->setValidator(new QRegExpValidator(rx, this)); - ui->phase7Name->setValidator(new QRegExpValidator(rx, this)); - ui->phase8Name->setValidator(new QRegExpValidator(rx, this)); - ui->cname_LE->setValidator(new QRegExpValidator(rx, this)); - #ifdef PHONON - phononLock=false; - clickObject = new Phonon::MediaObject(this); - clickOutput = new Phonon::AudioOutput(Phonon::NoCategory, this); - Phonon::createPath(clickObject, clickOutput); - connect(clickObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(mediaPlayer_state(Phonon::State,Phonon::State))); - #endif - - tabModelEditSetup(); - tabPhases(); - tabExpos(); - tabMixes(); - tabLimits(); - tabCurves(); - tabCustomSwitches(); - selectedSwitch=0; - int telTab=10; - int fswTab=9; - - if (GetEepromInterface()->getCapability(FSSwitch)) { - ui->tabSafetySwitches->setDisabled(true); - ui->tabWidget->removeTab(8); - telTab--; - fswTab--; - } else { - tabSafetySwitches(); - } - - if (GetEepromInterface()->getCapability(CustomFunctions)==0 ) { - ui->tabCustomFunctions->setDisabled(true); - ui->tabWidget->removeTab(fswTab); - telTab--; - } else { - tabCustomFunctions(); - selectedFunction=0; - } - tabTemplates(); - tabHeli(); - if (GetEepromInterface()->getCapability(Telemetry) & TM_HASTELEMETRY) { - tabTelemetry(); - } else { - ui->tabTelemetry->setDisabled(true); - ui->tabWidget->removeTab(telTab); - } - ui->tabWidget->setCurrentIndex(0); - ui->curvePreview->setMinimumWidth(240); - ui->curvePreview->setMinimumHeight(240); - resizeEvent(); - QTimer::singleShot(0, this, SLOT(shrink())); - if (openWizard) { - QTimer::singleShot(1, this, SLOT(wizard())); - } -} - -ModelEdit::~ModelEdit() -{ - delete ui; -} - - -float ModelEdit::getBarStep(int barId) -{ - switch (barId-1) { - case TELEMETRY_SOURCE_TX_BATT: - return 0.1; - break; - case TELEMETRY_SOURCE_TIMER1: - case TELEMETRY_SOURCE_TIMER2: - return 3; - break; - case TELEMETRY_SOURCE_A1: - case TELEMETRY_SOURCE_A1_MIN: - return (ui->a1RatioSB->value()/255); - break; - case TELEMETRY_SOURCE_A2: - case TELEMETRY_SOURCE_A2_MIN: - return (ui->a2RatioSB->value()/255); - break; - case TELEMETRY_SOURCE_ALT: - case TELEMETRY_SOURCE_GPS_ALT: - case TELEMETRY_SOURCE_ALT_MAX: - case TELEMETRY_SOURCE_ALT_MIN: - return 8; - break; - case TELEMETRY_SOURCE_RPM: - case TELEMETRY_SOURCE_RPM_MAX: - return 50; - break; - case TELEMETRY_SOURCE_CELLS_SUM: - case TELEMETRY_SOURCE_VFAS: - return 0.1; - break; - case TELEMETRY_SOURCE_CELL: - return 0.02; - break; - case TELEMETRY_SOURCE_HDG: - return 2; - break; - case TELEMETRY_SOURCE_DIST: - case TELEMETRY_SOURCE_DIST_MAX: - return 8; - break; - case TELEMETRY_SOURCE_CURRENT_MAX: - case TELEMETRY_SOURCE_CURRENT: - return 0.5; - break; - case TELEMETRY_SOURCE_POWER: - return 5; - break; - case TELEMETRY_SOURCE_CONSUMPTION: - return 20; - break; - case TELEMETRY_SOURCE_SPEED: - case TELEMETRY_SOURCE_SPEED_MAX: - if (g_model.frsky.imperial==1) { - return 1; - } else { - return 1.852; - } - break; - default: - return 1; - break; - } -} - -void ModelEdit::setupExposListWidget() -{ - ExposlistWidget = new MixersList(this, true); - QPushButton * qbUp = new QPushButton(this); - QPushButton * qbDown = new QPushButton(this); - QPushButton * qbClear = new QPushButton(this); - - qbUp->setText(tr("Move Up")); - qbUp->setIcon(QIcon(":/images/moveup.png")); - qbUp->setShortcut(QKeySequence(tr("Ctrl+Up"))); - qbDown->setText(tr("Move Down")); - qbDown->setIcon(QIcon(":/images/movedown.png")); - qbDown->setShortcut(QKeySequence(tr("Ctrl+Down"))); - qbClear->setText(tr("Clear Expo Settings")); - qbClear->setIcon(QIcon(":/images/clear.png")); - - ui->exposLayout->addWidget(ExposlistWidget,1,1,1,3); - ui->exposLayout->addWidget(qbUp,2,1); - ui->exposLayout->addWidget(qbClear,2,2); - ui->exposLayout->addWidget(qbDown,2,3); - - connect(ExposlistWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(expolistWidget_customContextMenuRequested(QPoint))); - connect(ExposlistWidget,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(expolistWidget_doubleClicked(QModelIndex))); - connect(ExposlistWidget,SIGNAL(mimeDropped(int,const QMimeData*,Qt::DropAction)),this,SLOT(mimeExpoDropped(int,const QMimeData*,Qt::DropAction))); - - connect(qbUp,SIGNAL(pressed()),SLOT(moveExpoUp())); - connect(qbDown,SIGNAL(pressed()),SLOT(moveExpoDown())); - connect(qbClear,SIGNAL(pressed()),SLOT(clearExpos())); - - connect(ExposlistWidget,SIGNAL(keyWasPressed(QKeyEvent*)), this, SLOT(expolistWidget_KeyPress(QKeyEvent*))); -} - -void ModelEdit::setupMixerListWidget() -{ - MixerlistWidget = new MixersList(this, false); // TODO enum - QPushButton * qbUp = new QPushButton(this); - QPushButton * qbDown = new QPushButton(this); - QPushButton * qbClear = new QPushButton(this); - - qbUp->setText(tr("Move Up")); - qbUp->setIcon(QIcon(":/images/moveup.png")); - qbUp->setShortcut(QKeySequence(tr("Ctrl+Up"))); - qbDown->setText(tr("Move Down")); - qbDown->setIcon(QIcon(":/images/movedown.png")); - qbDown->setShortcut(QKeySequence(tr("Ctrl+Down"))); - qbClear->setText(tr("Clear Mixes")); - qbClear->setIcon(QIcon(":/images/clear.png")); - - ui->mixersLayout->addWidget(MixerlistWidget,1,1,1,3); - ui->mixersLayout->addWidget(qbUp,2,1); - ui->mixersLayout->addWidget(qbClear,2,2); - ui->mixersLayout->addWidget(qbDown,2,3); - - connect(MixerlistWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(mixerlistWidget_customContextMenuRequested(QPoint))); - connect(MixerlistWidget,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(mixerlistWidget_doubleClicked(QModelIndex))); - connect(MixerlistWidget,SIGNAL(mimeDropped(int,const QMimeData*,Qt::DropAction)),this,SLOT(mimeMixerDropped(int,const QMimeData*,Qt::DropAction))); - - connect(qbUp,SIGNAL(pressed()),SLOT(moveMixUp())); - connect(qbDown,SIGNAL(pressed()),SLOT(moveMixDown())); - connect(qbClear,SIGNAL(pressed()),SLOT(clearMixes())); - - connect(MixerlistWidget,SIGNAL(keyWasPressed(QKeyEvent*)), this, SLOT(mixerlistWidget_KeyPress(QKeyEvent*))); -} - -void ModelEdit::resizeEvent(QResizeEvent *event) -{ - - if(ui->curvePreview->scene()) - { - QRect qr = ui->curvePreview->contentsRect(); - ui->curvePreview->scene()->setSceneRect(GFX_MARGIN, GFX_MARGIN, qr.width()-GFX_MARGIN*2, qr.height()-GFX_MARGIN*2); - drawCurve(); - } - - QDialog::resizeEvent(event); - -} - -void ModelEdit::applyBaseTemplate() -{ - clearMixes(false); - applyTemplate(0); - updateSettings(); - tabMixes(); -} - -void ModelEdit::updateSettings() -{ - radioData.models[id_model] = g_model; - emit modelValuesChanged(); -} - -void ModelEdit::on_tabWidget_currentChanged(int index) -{ - QSettings settings("companion9x", "companion9x"); - settings.setValue("modelEditTab",index);//ui->tabWidget->currentIndex()); - resizeEvent(); -} - -void ModelEdit::fssldValueChanged() -{ - if (fsLock) - return; - fsLock=true; - QSpinBox * fssb1[] = { ui->fsm1SB_1, ui->fsm1SB_2,ui->fsm1SB_3,ui->fsm1SB_4,ui->fsm1SB_5,ui->fsm1SB_6,ui->fsm1SB_7,ui->fsm1SB_8, - ui->fsm1SB_9, ui->fsm1SB_10,ui->fsm1SB_11,ui->fsm1SB_12,ui->fsm1SB_13,ui->fsm1SB_14,ui->fsm1SB_15,ui->fsm1SB_16, NULL }; - QSpinBox * fssb2[] = { ui->fsm2SB_1, ui->fsm2SB_2,ui->fsm2SB_3,ui->fsm2SB_4,ui->fsm2SB_5,ui->fsm2SB_6,ui->fsm2SB_7,ui->fsm2SB_8, - ui->fsm2SB_9, ui->fsm2SB_10,ui->fsm2SB_11,ui->fsm2SB_12,ui->fsm2SB_13,ui->fsm2SB_14,ui->fsm2SB_15,ui->fsm2SB_16, NULL }; - QSlider *sl = qobject_cast(sender()); - int fsId=sl->objectName().mid(sl->objectName().lastIndexOf("_")+1).toInt()-1; - int moduleid=sl->objectName().mid(3,1).toInt(); - if (moduleid==1) { - fssb1[fsId]->setValue(sl->value()); - } else { - fssb2[fsId]->setValue(sl->value()); - } - fsLock=false; -} - -void ModelEdit::fssbValueChanged() -{ - if (fsLock) - return; - fsLock=true; - QSlider * fssld1[] = { ui->fsm1SL_1, ui->fsm1SL_2,ui->fsm1SL_3,ui->fsm1SL_4,ui->fsm1SL_5,ui->fsm1SL_6,ui->fsm1SL_7,ui->fsm1SL_8, - ui->fsm1SL_9, ui->fsm1SL_10,ui->fsm1SL_11,ui->fsm1SL_12,ui->fsm1SL_13,ui->fsm1SL_14,ui->fsm1SL_15,ui->fsm1SL_16, NULL }; - QSlider * fssld2[] = { ui->fsm2SL_1, ui->fsm2SL_2,ui->fsm2SL_3,ui->fsm2SL_4,ui->fsm2SL_5,ui->fsm2SL_6,ui->fsm2SL_7,ui->fsm2SL_8, - ui->fsm2SL_9, ui->fsm2SL_10,ui->fsm2SL_11,ui->fsm2SL_12,ui->fsm2SL_13,ui->fsm2SL_14,ui->fsm2SL_15,ui->fsm2SL_16, NULL }; - QSpinBox *sb = qobject_cast(sender()); - int fsId=sb->objectName().mid(sb->objectName().lastIndexOf("_")+1).toInt()-1; - int moduleid=sb->objectName().mid(3,1).toInt(); - if (moduleid==1) { - fssld1[fsId]->setValue(sb->value()); - } else { - fssld2[fsId]->setValue(sb->value()); - } - fsLock=false; -} - -void ModelEdit::fssldEdited() -{ - QSlider *sl = qobject_cast(sender()); - int fsId=sl->objectName().mid(sl->objectName().lastIndexOf("_")+1).toInt()-1; - int moduleid=sl->objectName().mid(3,1).toInt(); - if (moduleid==1) { - g_model.moduleData[0].failsafeChannels[fsId]=sl->value(); - } else { - g_model.moduleData[1].failsafeChannels[fsId]=sl->value(); - } - updateSettings(); -} - -void ModelEdit::fssbEdited() -{ - QSpinBox *sb = qobject_cast(sender()); - int fsId=sb->objectName().mid(sb->objectName().lastIndexOf("_")+1).toInt()-1; - int moduleid=sb->objectName().mid(3,1).toInt(); - if (moduleid==1) { - g_model.moduleData[0].failsafeChannels[fsId]=sb->value(); - } else { - g_model.moduleData[1].failsafeChannels[fsId]=sb->value(); - } - updateSettings(); -} - -void ModelEdit::tabModelEditSetup() -{ - //name - QLabel * pmsl[] = {ui->swwarn_label, ui->swwarn0_label, ui->swwarn4_label, NULL}; - QCheckBox * pmchkb[] = {ui->swwarn1_ChkB,ui->swwarn2_ChkB,ui->swwarn3_ChkB,ui->swwarn5_ChkB,ui->swwarn6_ChkB, NULL}; - QSlider * tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, NULL}; - QSlider * fssld1[] = { ui->fsm1SL_1, ui->fsm1SL_2,ui->fsm1SL_3,ui->fsm1SL_4,ui->fsm1SL_5,ui->fsm1SL_6,ui->fsm1SL_7,ui->fsm1SL_8, - ui->fsm1SL_9, ui->fsm1SL_10,ui->fsm1SL_11,ui->fsm1SL_12,ui->fsm1SL_13,ui->fsm1SL_14,ui->fsm1SL_15,ui->fsm1SL_16, NULL }; - QSlider * fssld2[] = { ui->fsm2SL_1, ui->fsm2SL_2,ui->fsm2SL_3,ui->fsm2SL_4,ui->fsm2SL_5,ui->fsm2SL_6,ui->fsm2SL_7,ui->fsm2SL_8, - ui->fsm2SL_9, ui->fsm2SL_10,ui->fsm2SL_11,ui->fsm2SL_12,ui->fsm2SL_13,ui->fsm2SL_14,ui->fsm2SL_15,ui->fsm2SL_16, NULL }; - QSpinBox * fssb1[] = { ui->fsm1SB_1, ui->fsm1SB_2,ui->fsm1SB_3,ui->fsm1SB_4,ui->fsm1SB_5,ui->fsm1SB_6,ui->fsm1SB_7,ui->fsm1SB_8, - ui->fsm1SB_9, ui->fsm1SB_10,ui->fsm1SB_11,ui->fsm1SB_12,ui->fsm1SB_13,ui->fsm1SB_14,ui->fsm1SB_15,ui->fsm1SB_16, NULL }; - QSpinBox * fssb2[] = { ui->fsm2SB_1, ui->fsm2SB_2,ui->fsm2SB_3,ui->fsm2SB_4,ui->fsm2SB_5,ui->fsm2SB_6,ui->fsm2SB_7,ui->fsm2SB_8, - ui->fsm2SB_9, ui->fsm2SB_10,ui->fsm2SB_11,ui->fsm2SB_12,ui->fsm2SB_13,ui->fsm2SB_14,ui->fsm2SB_15,ui->fsm2SB_16, NULL }; - if (IS_TARANIS(GetEepromInterface()->getBoard())) { - ui->modelNameLE->setMaxLength(12); - } else { - ui->modelNameLE->setMaxLength(10); - } - ui->modelNameLE->setText(g_model.name); - fsLock=true; - if (GetEepromInterface()->getCapability(NumModules)<2) { - ui->rf2_GB->hide(); - } - - if (!GetEepromInterface()->getCapability(HasFailsafe)) { - ui->FSGB_1 ->hide(); - ui->FSGB_2->hide(); - ui->ModelSetupTab->setTabEnabled(1,0); - } else { - if (GetEepromInterface()->getCapability(HasFailsafe)<32) { - ui->FSGB_2->hide(); - } - - for (int i=0; fssld1[i]; i++) { - fssld1[i]->setValue(g_model.moduleData[0].failsafeChannels[i]); - fssld2[i]->setValue(g_model.moduleData[1].failsafeChannels[i]); - fssb1[i]->setValue(g_model.moduleData[0].failsafeChannels[i]); - fssb2[i]->setValue(g_model.moduleData[1].failsafeChannels[i]); - connect(fssld1[i],SIGNAL(valueChanged(int)),this,SLOT(fssldValueChanged())); - connect(fssld2[i],SIGNAL(valueChanged(int)),this,SLOT(fssldValueChanged())); - connect(fssb1[i],SIGNAL(valueChanged(int)),this,SLOT(fssbValueChanged())); - connect(fssb2[i],SIGNAL(valueChanged(int)),this,SLOT(fssbValueChanged())); - connect(fssld1[i],SIGNAL(sliderReleased()),this,SLOT(fssldEdited())); - connect(fssld2[i],SIGNAL(sliderReleased()),this,SLOT(fssldEdited())); - connect(fssb1[i],SIGNAL(editingFinished()),this,SLOT(fssbEdited())); - connect(fssb2[i],SIGNAL(editingFinished()),this,SLOT(fssbEdited())); - } - } - fsLock=false; - //timer1 mode direction value - populateTimerSwitchCB(ui->timer1ModeCB,g_model.timers[0].mode,GetEepromInterface()->getCapability(TimerTriggerB)); - int min = g_model.timers[0].val/60; - int sec = g_model.timers[0].val%60; - ui->timer1ValTE->setTime(QTime(0,min,sec)); - ui->timer1DirCB->setCurrentIndex(g_model.timers[0].dir); - if (!GetEepromInterface()->getCapability(ModelVoice)) { - ui->modelVoice_SB->hide(); - ui->modelVoice_label->hide(); - } else { - ui->modelVoice_SB->setValue(g_model.modelVoice+260); - } - if (!GetEepromInterface()->getCapability(PerModelThrottleInvert)) { - ui->label_thrrev->hide(); - ui->thrrevChkB->hide(); - } else { - ui->thrrevChkB->setChecked(g_model.throttleReversed); - } - if (!GetEepromInterface()->getCapability(ModelImage)) { - ui->modelImage_CB->hide(); - ui->modelImage_label->hide(); - ui->modelImage_image->hide(); - } else { - modelImageLock=true; - QStringList items; - items.append(""); - QSettings settings("companion9x", "companion9x"); - QString path=settings.value("sdPath", ".").toString(); - path.append("/BMP/"); - QDir qd(path); - int vml= GetEepromInterface()->getCapability(VoicesMaxLength)+4; - if (qd.exists()) { - QStringList filters; - filters << "*.bmp" << "*.bmp"; - foreach ( QString file, qd.entryList(filters, QDir::Files) ) { - QFileInfo fi(file); - QString temp=fi.completeBaseName(); - if (!items.contains(temp) && temp.length()<=vml) { - items.append(temp); - } - } - } - if (!items.contains(g_model.bitmap)) { - items.append(g_model.bitmap); - } - items.sort(); - ui->modelImage_CB->clear(); - foreach ( QString file, items ) { - ui->modelImage_CB->addItem(file); - if (file==g_model.bitmap) { - ui->modelImage_CB->setCurrentIndex(ui->modelImage_CB->count()-1); - QString fileName=path; - fileName.append(g_model.bitmap); - fileName.append(".bmp"); - QImage image(fileName); - if (image.isNull()) { - fileName=path; - fileName.append(g_model.bitmap); - fileName.append(".BMP"); - image.load(fileName); - } - if (!image.isNull()) { - ui->modelImage_image->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));; - } - } - } - modelImageLock=false; - } - - if (!GetEepromInterface()->getCapability(pmSwitchMask)) { - for (int i=0; pmsl[i]; i++) { - pmsl[i]->hide(); - } - for (int i=0; pmchkb[i]; i++) { - pmchkb[i]->hide(); - } - ui->tswwarn0_CB->hide(); - for (int i=0; tpmsld[i]; i++) { - tpmsld[i]->hide(); - } - ui->swwarn0_line->hide(); - ui->swwarn0_line->hide(); - ui->swwarn0_CB->hide(); - ui->swwarn4_CB->hide(); - ui->swwarn_line0->hide(); - ui->swwarn_line1->hide(); - ui->swwarn_line2->hide(); - ui->swwarn_line3->hide(); - ui->swwarn_line4->hide(); - ui->swwarn_line5->hide(); - ui->tswwarn0_label->hide(); - ui->tswwarn1_label->hide(); - ui->tswwarn2_label->hide(); - ui->tswwarn3_label->hide(); - ui->tswwarn4_label->hide(); - ui->tswwarn5_label->hide(); - ui->tswwarn6_label->hide(); - ui->tswwarn7_label->hide(); - } else { - if (GetEepromInterface()->getCapability(Pots)==3) { - ui->swwarn0_CB->setCurrentIndex(g_model.switchWarningStates & 0x01); - ui->swwarn1_ChkB->setChecked(checkbit(g_model.switchWarningStates, 1)); - ui->swwarn2_ChkB->setChecked(checkbit(g_model.switchWarningStates, 2)); - ui->swwarn3_ChkB->setChecked(checkbit(g_model.switchWarningStates, 3)); - ui->swwarn4_CB->setCurrentIndex((g_model.switchWarningStates & 0x30)>>4); - ui->swwarn5_ChkB->setChecked(checkbit(g_model.switchWarningStates, 6)); - ui->swwarn6_ChkB->setChecked(checkbit(g_model.switchWarningStates, 7)); - for (int i=0; pmchkb[i]; i++) { - connect(pmchkb[i], SIGNAL(stateChanged(int)),this,SLOT(startupSwitchEdited())); - } - connect(ui->swwarn0_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(startupSwitchEdited())); - connect(ui->swwarn4_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(startupSwitchEdited())); - } else { - ui->tswwarn0_CB->setCurrentIndex(g_model.switchWarningStates & 0x01); - uint16_t switchstate=(g_model.switchWarningStates>>1); - ui->chkSA->setValue(switchstate & 0x3); - switchstate >>= 2; - ui->chkSB->setValue(switchstate & 0x3); - switchstate >>= 2; - ui->chkSC->setValue(switchstate & 0x3); - switchstate >>= 2; - ui->chkSD->setValue(switchstate & 0x3); - switchstate >>= 2; - ui->chkSE->setValue(switchstate & 0x3); - switchstate >>= 2; - ui->chkSF->setValue((switchstate & 0x3)/2); - switchstate >>= 2; - ui->chkSG->setValue(switchstate & 0x3); - connect(ui->tswwarn0_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(startupSwitchEdited())); - for (int i=0; tpmsld[i]; i++) { - connect(tpmsld[i], SIGNAL(valueChanged(int)),this,SLOT(startupSwitchEdited())); - } - } - } - int ppmmax=GetEepromInterface()->getCapability(PPMFrameLength); - if (ppmmax>0) { - ui->ppmFrameLengthDSB->setMaximum(ppmmax); - } - if (!GetEepromInterface()->getCapability(InstantTrimSW)) { - ui->instantTrim_label->hide(); - ui->instantTrim_CB->setDisabled(true); - ui->instantTrim_CB->hide(); - } else { - switchEditLock=true; - int found=false; - for (int i=0; i< C9X_MAX_CUSTOM_FUNCTIONS; i++) { - if (g_model.funcSw[i].func==FuncInstantTrim) { - populateSwitchCB(ui->instantTrim_CB,g_model.funcSw[i].swtch,POPULATE_MSWITCHES & POPULATE_ONOFF); - found=true; - break; - } - } - if (found==false) { - populateSwitchCB(ui->instantTrim_CB,RawSwitch(),POPULATE_MSWITCHES & POPULATE_ONOFF); - } - switchEditLock=false; - } - if (GetEepromInterface()->getCapability(NoTimerDirs)) { - ui->timer1DirCB->hide(); - ui->timer2DirCB->hide(); - } - if (GetEepromInterface()->getCapability(NoThrExpo)) { - ui->label_thrExpo->hide(); - ui->thrExpoChkB->hide(); - } - if (!(GetEepromInterface()->getCapability(ExtendedTrims)>0)) { - ui->extendedTrimsChkB->hide(); - ui->extendedTrims_label->hide(); - } - if (!GetEepromInterface()->getCapability(HasTTrace)) { - ui->label_ttrace->hide(); - ui->ttraceCB->hide(); - } else { - populateTTraceCB(ui->ttraceCB,g_model.thrTraceSrc); - } - if (GetEepromInterface()->getCapability(RotaryEncoders)==0) { - ui->bcREaChkB->hide(); - ui->bcREbChkB->hide(); - } - if (GetEepromInterface()->getCapability(Pots)==3) { - ui->tswwarn0_CB->hide(); - ui->tswwarn0_label->hide(); - ui->tswwarn1_label->hide(); - ui->tswwarn2_label->hide(); - ui->tswwarn3_label->hide(); - ui->tswwarn4_label->hide(); - ui->tswwarn5_label->hide(); - ui->tswwarn6_label->hide(); - ui->tswwarn7_label->hide(); - ui->chkSA->hide(); - ui->chkSB->hide(); - ui->chkSC->hide(); - ui->chkSD->hide(); - ui->chkSE->hide(); - ui->chkSF->hide(); - ui->chkSG->hide(); - this->layout()->removeItem(ui->TaranisSwitchStartup); - ui->bcP4ChkB->hide(); - } else { - ui->swwarn0_CB->hide(); - ui->swwarn0_label->hide(); - ui->swwarn0_line->hide(); - ui->swwarn1_ChkB->hide(); - ui->swwarn1_line->hide(); - ui->swwarn2_ChkB->hide(); - ui->swwarn3_ChkB->hide(); - ui->swwarn4_CB->hide(); - ui->swwarn4_label->hide(); - ui->swwarn5_ChkB->hide(); - ui->swwarn6_ChkB->hide(); - ui->swwarn_line0->hide(); - ui->swwarn_line1->hide(); - ui->swwarn_line2->hide(); - ui->swwarn_line3->hide(); - ui->swwarn_line4->hide(); - ui->swwarn_line5->hide(); - this->layout()->removeItem(ui->StockSwitchStartup); - ui->bcP1ChkB->setText(tr("S1")); - ui->bcP2ChkB->setText(tr("S2")); - ui->bcP3ChkB->setText(tr("LS")); - } - - if (!GetEepromInterface()->getCapability(PerModelThrottleWarning)) { - ui->thrwarnChkB->setDisabled(true); - ui->thrwarnChkB->hide(); - ui->thrwarnLabel->hide(); - } else { - switchEditLock=true; - ui->thrwarnChkB->setChecked(g_model.disableThrottleWarning); - switchEditLock=false; - } - if (!GetEepromInterface()->getCapability(TimerTriggerB)) { - ui->timer1ModeBCB->hide(); - ui->timer1ModeB_label->hide(); - ui->timer2ModeBCB->hide(); - ui->timer2ModeB_label->hide(); - } else { - populateTimerSwitchBCB(ui->timer1ModeBCB,g_model.timers[0].modeB,GetEepromInterface()->getCapability(TimerTriggerB)); - populateTimerSwitchBCB(ui->timer2ModeBCB,g_model.timers[1].modeB,GetEepromInterface()->getCapability(TimerTriggerB)); - } - - int index=0; - int selindex; - int selindex2; - protocolEditLock=true; - protocol2EditLock=true; - ui->protocolCB->clear(); - for (int i=0; iisAvailable((Protocol)i)) { - ui->protocolCB->addItem(getProtocolStr(i), (QVariant)i); - if (g_model.moduleData[0].protocol == i) { - selindex = index; - } - index++; - } - } - if (GetEepromInterface()->getCapability(NumModules)>1) { - index=0; - ui->protocolCB_2->clear(); - for (int i=0; iisAvailable((Protocol)i, 1)) { - ui->protocolCB_2->addItem(getProtocolStr(i), (QVariant)i); - if (g_model.moduleData[1].protocol == i) { - selindex2 = index; - } - index++; - } - } - } - if (GetEepromInterface()->getCapability(ModelTrainerEnable)) { - trainerEditLock=true; - if (!(g_model.trainerMode||g_model.traineron)) { - ui->protocolCB_3->setCurrentIndex(0); - ui->label_PPM_3->hide(); - ui->ppmDelaySB_3->hide(); - ui->label_PPMCH_3->hide(); - ui->label_pulsePol_3->hide(); - ui->pulsePolCB_3->hide(); - ui->numChannelsSB_3->hide(); - ui->label_ppmFrameLength_3->hide(); - ui->ppmFrameLengthDSB_3->hide(); - ui->label_numChannelsStart_3->hide(); - ui->numChannelsStart_3->hide(); - } else { - ui->protocolCB_3->setCurrentIndex(1); - ui->label_PPM_3->show(); - ui->ppmDelaySB_3->show(); - ui->label_PPMCH_3->show(); - ui->label_pulsePol_3->show(); - ui->pulsePolCB_3->show(); - ui->numChannelsSB_3->show(); - ui->label_ppmFrameLength_3->show(); - ui->ppmFrameLengthDSB_3->show(); - ui->label_numChannelsStart_3->show(); - ui->numChannelsStart_3->show(); - } - trainerEditLock=false; - on_protocolCB_3_currentIndexChanged(g_model.traineron||g_model.trainerMode); - } else { - ui->rf3_GB->hide(); - } - - ui->label_PPM->hide(); - ui->ppmDelaySB->hide(); - ui->label_PPMCH->hide(); - ui->label_pulsePol->hide(); - ui->pulsePolCB->hide(); - ui->numChannelsSB->hide(); - ui->label_ppmFrameLength->hide(); - ui->ppmFrameLengthDSB->hide(); - ui->label_DSM->hide(); - ui->DSM_Type->hide(); - ui->label_PXX->hide(); - ui->pxxRxNum->hide(); - ui->label_numChannelsStart->hide(); - ui->numChannelsStart->hide(); - ui->pxxRxNum->setEnabled(false); - ui->protocolCB->setCurrentIndex(selindex); - protocolEditLock=false; - on_protocolCB_currentIndexChanged(selindex); - if (GetEepromInterface()->getCapability(NumModules)>1) { - ui->label_PPM_2->hide(); - ui->ppmDelaySB_2->hide(); - ui->label_PPMCH_2->hide(); - ui->label_pulsePol_2->hide(); - ui->pulsePolCB_2->hide(); - ui->numChannelsSB_2->hide(); - ui->label_ppmFrameLength_2->hide(); - ui->ppmFrameLengthDSB_2->hide(); - ui->label_DSM_2->hide(); - ui->DSM_Type_2->hide(); - ui->label_PXX_2->hide(); - ui->pxxRxNum_2->hide(); - ui->label_numChannelsStart_2->hide(); - ui->numChannelsStart_2->hide(); - ui->pxxRxNum_2->setEnabled(false); - ui->protocolCB_2->setCurrentIndex(selindex2); - protocol2EditLock=false; - on_protocolCB_2_currentIndexChanged(selindex2); - } - - //timer2 mode direction value - if (GetEepromInterface()->getCapability(Timers)<2) { - ui->timer2DirCB->hide(); - ui->timer2ValTE->hide(); - ui->timer2DirCB->hide(); - ui->timer2ModeCB->hide(); - ui->timer2ModeBCB->hide(); - ui->timer2ModeB_label->hide(); - ui->label_timer2->hide(); - } else { - populateTimerSwitchCB(ui->timer2ModeCB,g_model.timers[1].mode,GetEepromInterface()->getCapability(TimerTriggerB)); - min = g_model.timers[1].val/60; - sec = g_model.timers[1].val%60; - ui->timer2ValTE->setTime(QTime(0,min,sec)); - ui->timer2DirCB->setCurrentIndex(g_model.timers[1].dir); - } - if (!GetEepromInterface()->getCapability(PermTimers)) { - ui->timer1Perm->hide(); - ui->timer2Perm->hide(); - ui->timer1PermValue->hide(); - ui->timer2PermValue->hide(); - } else { - int sign=1; - int pvalue=g_model.timers[0].pvalue; - if (pvalue<0) { - pvalue=-pvalue; - sign=-1; - } - int hours=pvalue/3600; - pvalue-=hours*3600; - int minutes = pvalue/60; - int seconds = pvalue%60; - ui->timer1PermValue->setText(QString(" %1(%2:%3:%4)").arg(sign<0 ? "-" :" ").arg(hours,2,10,QLatin1Char('0')).arg(minutes,2,10,QLatin1Char('0')).arg(seconds,2,10,QLatin1Char('0'))); - // QString QString::arg ( int a, int fieldWidth = 0, int base = 10, const QChar & fillChar = QLatin1Char( ' ' ) ) const - sign=1; - pvalue=g_model.timers[1].pvalue; - if (pvalue<0) { - pvalue=-pvalue; - sign=-1; - } - hours=pvalue/3600; - pvalue-=hours*3600; - minutes = pvalue/60; - seconds = pvalue%60; - ui->timer2PermValue->setText(QString(" %1(%2:%3:%4)").arg(sign<0 ? "-" :" ").arg(hours,2,10,QLatin1Char('0')).arg(minutes,2,10,QLatin1Char('0')).arg(seconds,2,10,QLatin1Char('0'))); - ui->timer1Perm->setChecked(g_model.timers[0].persistent); - ui->timer2Perm->setChecked(g_model.timers[1].persistent); - } - if (!GetEepromInterface()->getCapability(minuteBeep)) { - ui->timer1Minute->hide(); - ui->timer2Minute->hide(); - } else { - ui->timer1Minute->setChecked(g_model.timers[0].minuteBeep); - ui->timer2Minute->setChecked(g_model.timers[1].minuteBeep); - } - - if (!GetEepromInterface()->getCapability(countdownBeep)) { - ui->timer1CountDownBeep->hide(); - ui->timer2CountDownBeep->hide(); - } else { - ui->timer1CountDownBeep->setChecked(g_model.timers[0].countdownBeep); - ui->timer2CountDownBeep->setChecked(g_model.timers[1].countdownBeep); - } - - //trim inc, thro trim, thro expo, instatrim - ui->trimIncCB->setCurrentIndex(g_model.trimInc); - ui->thrExpoChkB->setChecked(g_model.thrExpo); - ui->thrTrimChkB->setChecked(g_model.thrTrim); - - //center beep - ui->bcRUDChkB->setChecked(g_model.beepANACenter & BC_BIT_RUD); - ui->bcELEChkB->setChecked(g_model.beepANACenter & BC_BIT_ELE); - ui->bcTHRChkB->setChecked(g_model.beepANACenter & BC_BIT_THR); - ui->bcAILChkB->setChecked(g_model.beepANACenter & BC_BIT_AIL); - ui->bcP1ChkB->setChecked(g_model.beepANACenter & BC_BIT_P1); - ui->bcP2ChkB->setChecked(g_model.beepANACenter & BC_BIT_P2); - ui->bcP3ChkB->setChecked(g_model.beepANACenter & BC_BIT_P3); - ui->bcP4ChkB->setChecked(g_model.beepANACenter & BC_BIT_P4); - ui->bcREaChkB->setChecked(g_model.beepANACenter & BC_BIT_REA); - ui->bcREbChkB->setChecked(g_model.beepANACenter & BC_BIT_REB); - - // PPM settings fields - ui->ppmDelaySB->setEnabled(g_model.moduleData[0].protocol == PPM); - ui->pulsePolCB->setCurrentIndex(g_model.moduleData[0].ppmPulsePol); - ui->ppmDelaySB->setEnabled(g_model.moduleData[0].protocol == PPM); - ui->ppmDelaySB->setValue(g_model.moduleData[0].ppmDelay); - // TODO? ui->numChannelsSB->setEnabled(g_model.moduleData[0].protocol == PPM); - - ui->extendedLimitsChkB->setChecked(g_model.extendedLimits); - ui->T2ThrTrgChkB->setChecked(g_model.t2throttle); - if (!GetEepromInterface()->getCapability(Timer2ThrTrig)) { - ui->T2ThrTrg->hide(); - ui->T2ThrTrgChkB->hide(); - } - ui->ppmFrameLengthDSB->setValue(22.5+((double)g_model.moduleData[0].ppmFrameLength)*0.5); - if (!GetEepromInterface()->getCapability(PPMExtCtrl)) { - ui->ppmFrameLengthDSB->hide(); - ui->label_ppmFrameLength->hide(); - } - switch (g_model.moduleData[0].protocol) { - case PXX_DJT: - case PXX_XJT_X16: - case PXX_XJT_D8: - case PXX_XJT_LR12: - ui->pxxRxNum->setMinimum(0); - ui->pxxRxNum->setValue((g_model.modelId)); - break; - case DSM2: - if (!GetEepromInterface()->getCapability(DSM2Indexes)) { - ui->pxxRxNum->setValue(1); - } - else { - ui->pxxRxNum->setMinimum(0); - ui->pxxRxNum->setValue((g_model.modelId)); - } - ui->numChannelsSB->setValue(8); - break; - default: - ui->label_DSM->hide(); - ui->DSM_Type->hide(); - ui->DSM_Type->setEnabled(false); - ui->label_PXX->hide(); - ui->pxxRxNum->hide(); - ui->pxxRxNum->setEnabled(false); - ui->numChannelsSB->setValue(g_model.moduleData[0].channelsCount); - break; - } -} - -void ModelEdit::on_modelVoice_SB_editingFinished() -{ - g_model.modelVoice=ui->modelVoice_SB->value()-260; - updateSettings(); -} - -void ModelEdit::on_timer1Perm_toggled(bool checked) -{ - g_model.timers[0].persistent=checked; - updateSettings(); -} - -void ModelEdit::on_timer2Perm_toggled(bool checked) -{ - g_model.timers[1].persistent=checked; - updateSettings(); -} - -void ModelEdit::on_timer1Minute_toggled(bool checked) -{ - g_model.timers[0].minuteBeep=checked; - updateSettings(); -} - -void ModelEdit::on_timer2Minute_toggled(bool checked) -{ - g_model.timers[1].minuteBeep=checked; - updateSettings(); -} - -void ModelEdit::on_timer1CountDownBeep_toggled(bool checked) -{ - g_model.timers[0].countdownBeep=checked; - updateSettings(); -} - -void ModelEdit::on_timer2CountDownBeep_toggled(bool checked) -{ - g_model.timers[1].countdownBeep=checked; - updateSettings(); -} - -void ModelEdit::displayOnePhaseOneTrim(unsigned int phase_idx, unsigned int chn, QComboBox *trimUse, QSpinBox *trimVal, QSlider *trimSlider) -{ - PhaseData *phase = &g_model.phaseData[phase_idx]; - int trim = phase->trim[chn]; - if (trimUse) populateTrimUseCB(trimUse, phase_idx); - if (phase->trimRef[chn] >= 0) { - if (trimUse) trimUse->setCurrentIndex(1 + phase->trimRef[chn] - (phase->trimRef[chn] >= (int)phase_idx ? 1 : 0)); - trim = g_model.phaseData[g_model.getTrimFlightPhase(chn, phase_idx)].trim[chn]; - trimVal->setEnabled(false); - trimSlider->setEnabled(false); - } else { - trimVal->setEnabled(true); - trimSlider->setEnabled(true); - if (trimUse) trimUse->setCurrentIndex(0); - } - int trimsMax = GetEepromInterface()->getCapability(ExtendedTrims); - if (trimsMax == 0 || !g_model.extendedTrims) { - trimsMax = 125; - } - /*else if (trimsMax == 500) - trimSlider->setTickInterval(50);*/ - trimSlider->setRange(-trimsMax, +trimsMax); - trimVal->setRange(-trimsMax, +trimsMax); - trimVal->setValue(trim); - trimSlider->setValue(trim); - if (chn == 2 && g_eeGeneral.throttleReversed) - trimSlider->setInvertedAppearance(true); -} - -void ModelEdit::displayOnePhase(unsigned int phase_idx, QLineEdit *name, QComboBox *sw, QDoubleSpinBox *fadeIn, QDoubleSpinBox *fadeOut, - QComboBox *trim1Use, QSpinBox *trim1, QLabel *trim1Label, QSlider *trim1Slider, - QComboBox *trim2Use, QSpinBox *trim2, QLabel *trim2Label, QSlider *trim2Slider, - QComboBox *trim3Use, QSpinBox *trim3, QLabel *trim3Label, QSlider *trim3Slider, - QComboBox *trim4Use, QSpinBox *trim4, QLabel *trim4Label, QSlider *trim4Slider, - QLabel *gv1Label, QComboBox *gv1Use,QSpinBox *gv1Value, - QLabel *gv2Label, QComboBox *gv2Use,QSpinBox *gv2Value, - QLabel *gv3Label, QComboBox *gv3Use,QSpinBox *gv3Value, - QLabel *gv4Label, QComboBox *gv4Use,QSpinBox *gv4Value, - QLabel *gv5Label, QComboBox *gv5Use,QSpinBox *gv5Value, - QLabel *re1Label, QComboBox *re1Use,QSpinBox *re1Value, - QLabel *re2Label, QComboBox *re2Use,QSpinBox *re2Value,bool doConnect=false) -{ - phasesLock=true; - PhaseData *phase = &g_model.phaseData[phase_idx]; - if (IS_TARANIS(GetEepromInterface()->getBoard())) { - if (name) name->setMaxLength(10); - } else { - if (name) name->setMaxLength(6); - } - - if (name) name->setText(phase->name); - if (sw) populateSwitchCB(sw, phase->swtch); - - int scale=GetEepromInterface()->getCapability(SlowScale); - float range=GetEepromInterface()->getCapability(SlowRange); - int fades=GetEepromInterface()->getCapability(FlightPhasesHaveFades); - if (fades && fadeIn) { - fadeIn->setEnabled(true); - fadeOut->setEnabled(true); - fadeIn->setMaximum(range/scale); - fadeIn->setSingleStep(1.0/scale); - fadeIn->setDecimals((scale==1 ? 0 :1) ); - if (fadeIn) { - fadeIn->setValue((double)phase->fadeIn/scale); - } - fadeOut->setMaximum(range/scale); - fadeOut->setSingleStep(1.0/scale); - fadeOut->setDecimals((scale==1 ? 0 :1)); - if (fadeOut) { - fadeOut->setValue((double)phase->fadeOut/scale); - } - } else if ( fadeIn ) { - fadeIn->setDisabled(true); - fadeOut->setDisabled(true); - } - displayOnePhaseOneTrim(phase_idx, CONVERT_MODE(1)-1, trim1Use, trim1, trim1Slider); - displayOnePhaseOneTrim(phase_idx, CONVERT_MODE(2)-1, trim2Use, trim2, trim2Slider); - displayOnePhaseOneTrim(phase_idx, CONVERT_MODE(3)-1, trim3Use, trim3, trim3Slider); - displayOnePhaseOneTrim(phase_idx, CONVERT_MODE(4)-1, trim4Use, trim4, trim4Slider); - - if (gv1Use) { - populateGvarUseCB(gv1Use, phase_idx); - if (phase->gvars[0]>1024) { - gv1Use->setCurrentIndex(phase->gvars[0]-1024); - } - } - gv1Value->setMinimum(-1024); - gv1Value->setMaximum(1024); - if (phase->gvars[0]<1024) { - gv1Value->setValue(phase->gvars[0]); - gv1Value->setEnabled(true); - } else { - uint index=phase->gvars[0]-1025; - if (index>=phase_idx) { - index++; - } - PhaseData *phasegvar = &g_model.phaseData[index]; - gv1Value->setValue(phasegvar->gvars[0]); - gv1Value->setDisabled(true); - } - if (gv2Use) { - populateGvarUseCB(gv2Use, phase_idx); - if (phase->gvars[1]>1024) { - gv2Use->setCurrentIndex(phase->gvars[1]-1024); - } - } - gv2Value->setMinimum(-1024); - gv2Value->setMaximum(1024); - if (phase->gvars[1]<1024) { - gv2Value->setValue(phase->gvars[1]); - gv2Value->setEnabled(true); - } else { - uint index=phase->gvars[1]-1025; - if (index>=phase_idx) { - index++; - } - PhaseData *phasegvar = &g_model.phaseData[index]; - gv2Value->setValue(phasegvar->gvars[1]); - gv2Value->setDisabled(true); - } - if (gv3Use) { - populateGvarUseCB(gv3Use, phase_idx); - if (phase->gvars[2]>1024) { - gv3Use->setCurrentIndex(phase->gvars[2]-1024); - } - } - gv3Value->setMinimum(-1024); - gv3Value->setMaximum(1024); - if (phase->gvars[2]<1024) { - gv3Value->setValue(phase->gvars[2]); - gv3Value->setEnabled(true); - } else { - uint index=phase->gvars[2]-1025; - if (index>=phase_idx) { - index++; - } - PhaseData *phasegvar = &g_model.phaseData[index]; - gv3Value->setValue(phasegvar->gvars[2]); - gv3Value->setDisabled(true); - } - if (gv4Use) { - populateGvarUseCB(gv4Use, phase_idx); - if (phase->gvars[3]>1024) { - gv4Use->setCurrentIndex(phase->gvars[3]-1024); - } - } - gv4Value->setMinimum(-1024); - gv4Value->setMaximum(1024); - if (phase->gvars[3]<1024) { - gv4Value->setValue(phase->gvars[3]); - gv4Value->setEnabled(true); - } else { - uint index=phase->gvars[3]-1025; - if (index>=phase_idx) { - index++; - } - PhaseData *phasegvar = &g_model.phaseData[index]; - gv4Value->setValue(phasegvar->gvars[3]); - gv4Value->setDisabled(true); - } - if (gv5Use) { - populateGvarUseCB(gv5Use, phase_idx); - if (phase->gvars[4]>1024) { - gv5Use->setCurrentIndex(phase->gvars[4]-1024); - } - } - gv5Value->setMinimum(-1024); - gv5Value->setMaximum(1024); - if (phase->gvars[4]<1024) { - gv5Value->setValue(phase->gvars[4]); - gv5Value->setEnabled(true); - } else { - uint index=phase->gvars[4]-1025; - if (index>=phase_idx) { - index++; - } - PhaseData *phasegvar = &g_model.phaseData[index]; - gv5Value->setValue(phasegvar->gvars[4]); - gv5Value->setDisabled(true); - } - if (re1Value) { - re1Value->setMinimum(-1024); - re1Value->setMaximum(1024); - } - if (re2Value) { - re2Value->setMinimum(-1024); - re2Value->setMaximum(1024); - } - if (re1Use) { - populateGvarUseCB(re1Use, phase_idx); - if (phase->rotaryEncoders[0]>1024) { - re1Use->setCurrentIndex(phase->rotaryEncoders[0]-1024); - } - } - if (phase->rotaryEncoders[0]<1024) { - re1Value->setValue(phase->rotaryEncoders[0]); - re1Value->setEnabled(true); - } else { - uint index=phase->rotaryEncoders[0]-1025; - if (index>=phase_idx) { - index++; - } - PhaseData *phasegvar = &g_model.phaseData[index]; - re1Value->setValue(phasegvar->rotaryEncoders[0]); - re1Value->setDisabled(true); - } - if (re2Use) { - populateGvarUseCB(re2Use, phase_idx); - if (phase->rotaryEncoders[0]>1024) { - re1Use->setCurrentIndex(phase->rotaryEncoders[0]-1024); - } - } - if (phase->rotaryEncoders[1]<1024) { - re2Value->setValue(phase->rotaryEncoders[1]); - re2Value->setEnabled(true); - } else { - uint index=phase->rotaryEncoders[1]-1025; - if (index>=phase_idx) { - index++; - } - PhaseData *phasegvar = &g_model.phaseData[index]; - re2Value->setValue(phasegvar->rotaryEncoders[1]); - re2Value->setDisabled(true); - } - if (GetEepromInterface()->getCapability(RotaryEncoders)<2) { - if (re2Label) - re2Label->hide(); - if (re2Use) - re2Use->hide(); - re2Value->hide(); - } - if (GetEepromInterface()->getCapability(RotaryEncoders)<1) { - if (re1Label) - re1Label->hide(); - if (re1Use) - re1Use->hide(); - re1Value->hide(); - } - QString labels[] = { tr("Rud"), tr("Ele"), tr("Thr"), tr("Ail") }; - if (trim1Label) { - trim1Label->setText(labels[CONVERT_MODE(1)-1]); - trim2Label->setText(labels[CONVERT_MODE(2)-1]); - trim3Label->setText(labels[CONVERT_MODE(3)-1]); - trim4Label->setText(labels[CONVERT_MODE(4)-1]); - } - // the connects - if (doConnect) { - connect(name, SIGNAL(editingFinished()), this, SLOT(phaseName_editingFinished())); - if (sw!=NULL) { - connect(sw,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseSwitch_currentIndexChanged())); - connect(trim1Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseTrimUse_currentIndexChanged())); - connect(trim2Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseTrimUse_currentIndexChanged())); - connect(trim3Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseTrimUse_currentIndexChanged())); - connect(trim4Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseTrimUse_currentIndexChanged())); - } - if (gv1Use) connect(gv1Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseGVUse_currentIndexChanged())); - if (gv2Use) connect(gv2Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseGVUse_currentIndexChanged())); - if (gv3Use) connect(gv3Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseGVUse_currentIndexChanged())); - if (gv4Use) connect(gv4Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseGVUse_currentIndexChanged())); - if (gv5Use) connect(gv5Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseGVUse_currentIndexChanged())); - if (re1Use) connect(re1Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseREUse_currentIndexChanged())); - if (re2Use) connect(re2Use,SIGNAL(currentIndexChanged(int)),this,SLOT(phaseREUse_currentIndexChanged())); - connect(gv1Value,SIGNAL(editingFinished()),this,SLOT(phaseGVValue_editingFinished())); - connect(gv2Value,SIGNAL(editingFinished()),this,SLOT(phaseGVValue_editingFinished())); - connect(gv3Value,SIGNAL(editingFinished()),this,SLOT(phaseGVValue_editingFinished())); - connect(gv4Value,SIGNAL(editingFinished()),this,SLOT(phaseGVValue_editingFinished())); - connect(gv5Value,SIGNAL(editingFinished()),this,SLOT(phaseGVValue_editingFinished())); - connect(re1Value,SIGNAL(editingFinished()),this,SLOT(phaseREValue_editingFinished())); - connect(re2Value,SIGNAL(editingFinished()),this,SLOT(phaseREValue_editingFinished())); - - connect(fadeIn,SIGNAL(editingFinished()),this,SLOT(phaseFadeIn_editingFinished())); - connect(fadeOut,SIGNAL(editingFinished()),this,SLOT(phaseFadeOut_editingFinished())); - connect(trim1,SIGNAL(valueChanged(int)),this,SLOT(phaseTrim_valueChanged())); - connect(trim2,SIGNAL(valueChanged(int)),this,SLOT(phaseTrim_valueChanged())); - connect(trim3,SIGNAL(valueChanged(int)),this,SLOT(phaseTrim_valueChanged())); - connect(trim4,SIGNAL(valueChanged(int)),this,SLOT(phaseTrim_valueChanged())); - connect(trim1Slider,SIGNAL(valueChanged(int)),this,SLOT(phaseTrimSlider_valueChanged())); - connect(trim2Slider,SIGNAL(valueChanged(int)),this,SLOT(phaseTrimSlider_valueChanged())); - connect(trim3Slider,SIGNAL(valueChanged(int)),this,SLOT(phaseTrimSlider_valueChanged())); - connect(trim4Slider,SIGNAL(valueChanged(int)),this,SLOT(phaseTrimSlider_valueChanged())); - phasesLock=false; - } -} - -void ModelEdit::tabPhases() -{ - QSpinBox * tmp[9][5]={ - {ui->phase0GV1Value,ui->phase0GV2Value,ui->phase0GV3Value,ui->phase0GV4Value,ui->phase0GV5Value} , - {ui->phase1GV1Value,ui->phase1GV2Value,ui->phase1GV3Value,ui->phase1GV4Value,ui->phase1GV5Value} , - {ui->phase2GV1Value,ui->phase2GV2Value,ui->phase2GV3Value,ui->phase2GV4Value,ui->phase2GV5Value} , - {ui->phase3GV1Value,ui->phase3GV2Value,ui->phase3GV3Value,ui->phase3GV4Value,ui->phase3GV5Value} , - {ui->phase4GV1Value,ui->phase4GV2Value,ui->phase4GV3Value,ui->phase4GV4Value,ui->phase4GV5Value} , - {ui->phase5GV1Value,ui->phase5GV2Value,ui->phase5GV3Value,ui->phase5GV4Value,ui->phase5GV5Value} , - {ui->phase6GV1Value,ui->phase6GV2Value,ui->phase6GV3Value,ui->phase6GV4Value,ui->phase6GV5Value} , - {ui->phase7GV1Value,ui->phase7GV2Value,ui->phase7GV3Value,ui->phase7GV4Value,ui->phase7GV5Value} , - {ui->phase8GV1Value,ui->phase8GV2Value,ui->phase8GV3Value,ui->phase8GV4Value,ui->phase8GV5Value} - }; - - QSpinBox * tmp2[9][2]={ - {ui->phase0RE1Value,ui->phase0RE2Value} , - {ui->phase1RE1Value,ui->phase1RE2Value} , - {ui->phase2RE1Value,ui->phase2RE2Value} , - {ui->phase3RE1Value,ui->phase3RE2Value} , - {ui->phase4RE1Value,ui->phase4RE2Value} , - {ui->phase5RE1Value,ui->phase5RE2Value} , - {ui->phase6RE1Value,ui->phase6RE2Value} , - {ui->phase7RE1Value,ui->phase7RE2Value} , - {ui->phase8RE1Value,ui->phase8RE2Value} , - }; - - memcpy(gvarsSB, tmp, sizeof(gvarsSB)); - memcpy(reSB, tmp2, sizeof(reSB)); - - phasesLock = true; - int gvars=0; - if (GetEepromInterface()->getCapability(HasVariants)) { - if (GetCurrentFirmwareVariant() & GVARS_VARIANT) - gvars=1; - } else { - gvars=GetEepromInterface()->getCapability(Gvars); - } - if (!GetEepromInterface()->getCapability(RotaryEncoders)) { - ui->phase0reGB->hide(); - ui->phase1reGB->hide(); - ui->phase2reGB->hide(); - ui->phase3reGB->hide(); - ui->phase4reGB->hide(); - ui->phase5reGB->hide(); - ui->phase6reGB->hide(); - ui->phase7reGB->hide(); - ui->phase8reGB->hide(); - } - if (!GetEepromInterface()->getCapability(GvarsFlightPhases) || gvars==0) { - if (!GetEepromInterface()->getCapability(Gvars) || gvars==0) { - ui->phase0gvGB->hide(); - } - ui->phase1gvGB->hide(); - ui->phase2gvGB->hide(); - ui->phase3gvGB->hide(); - ui->phase4gvGB->hide(); - ui->phase5gvGB->hide(); - ui->phase6gvGB->hide(); - ui->phase7gvGB->hide(); - ui->phase8gvGB->hide(); - } - - if (!GetEepromInterface()->getCapability(GvarsAreNamed)) { - ui->phase0GV1Name->hide(); - ui->phase0GV2Name->hide(); - ui->phase0GV3Name->hide(); - ui->phase0GV4Name->hide(); - ui->phase0GV5Name->hide(); - ui->phase0GV6Name->hide(); - ui->phase0GV7Name->hide(); - } - - if (GetEepromInterface()->getCapability(Gvars) && gvars==1) { - if (!GetEepromInterface()->getCapability(GvarsHaveSources)) { - ui->phase0GV1Source->hide(); - ui->phase0GV2Source->hide(); - ui->phase0GV3Source->hide(); - ui->phase0GV4Source->hide(); - ui->phase0GV5Source->hide(); - ui->phase0GV6Source->hide(); - ui->phase0GV7Source->hide(); - } else { - populateGvSourceCB(ui->phase0GV1Source, g_model.gvsource[0]); - populateGvSourceCB(ui->phase0GV2Source, g_model.gvsource[1]); - populateGvSourceCB(ui->phase0GV3Source, g_model.gvsource[2]); - populateGvSourceCB(ui->phase0GV4Source, g_model.gvsource[3]); - populateGvSourceCB(ui->phase0GV5Source, g_model.gvsource[4]); - connect(ui->phase0GV1Source,SIGNAL(currentIndexChanged(int)),this,SLOT(GVSource_currentIndexChanged())); - connect(ui->phase0GV2Source,SIGNAL(currentIndexChanged(int)),this,SLOT(GVSource_currentIndexChanged())); - connect(ui->phase0GV3Source,SIGNAL(currentIndexChanged(int)),this,SLOT(GVSource_currentIndexChanged())); - connect(ui->phase0GV4Source,SIGNAL(currentIndexChanged(int)),this,SLOT(GVSource_currentIndexChanged())); - connect(ui->phase0GV5Source,SIGNAL(currentIndexChanged(int)),this,SLOT(GVSource_currentIndexChanged())); - } - if (IS_TARANIS(GetEepromInterface()->getBoard())) { - ui->phase0GV1Name->setMaxLength(10); - ui->phase0GV2Name->setMaxLength(10); - ui->phase0GV3Name->setMaxLength(10); - ui->phase0GV4Name->setMaxLength(10); - ui->phase0GV5Name->setMaxLength(10); - } else { - ui->phase0GV1Name->setMaxLength(6); - ui->phase0GV2Name->setMaxLength(6); - ui->phase0GV3Name->setMaxLength(6); - ui->phase0GV4Name->setMaxLength(6); - ui->phase0GV5Name->setMaxLength(6); - } - - ui->phase0GV1Name->setText(g_model.gvars_names[0]); - ui->phase0GV2Name->setText(g_model.gvars_names[1]); - ui->phase0GV3Name->setText(g_model.gvars_names[2]); - ui->phase0GV4Name->setText(g_model.gvars_names[3]); - ui->phase0GV5Name->setText(g_model.gvars_names[4]); - connect(ui->phase0GV1Name,SIGNAL(editingFinished()),this,SLOT(GVName_editingFinished())); - connect(ui->phase0GV2Name,SIGNAL(editingFinished()),this,SLOT(GVName_editingFinished())); - connect(ui->phase0GV3Name,SIGNAL(editingFinished()),this,SLOT(GVName_editingFinished())); - connect(ui->phase0GV4Name,SIGNAL(editingFinished()),this,SLOT(GVName_editingFinished())); - connect(ui->phase0GV5Name,SIGNAL(editingFinished()),this,SLOT(GVName_editingFinished())); - } - if (gvars) { - if (GetEepromInterface()->getCapability(GvarsNum)<7) { - ui->phase0GV6Name->hide(); - ui->phase0GV7Name->hide(); - ui->phase0GV6Source->hide(); - ui->phase0GV7Source->hide(); - ui->phase0GV6Value->hide(); - ui->phase0GV7Value->hide(); - ui->phase0GV6_Label->hide(); - ui->phase0GV7_Label->hide(); - } else { - populateGvSourceCB(ui->phase0GV6Source, g_model.gvsource[5]); - populateGvSourceCB(ui->phase0GV7Source, g_model.gvsource[6]); - connect(ui->phase0GV6Source,SIGNAL(currentIndexChanged(int)),this,SLOT(GVSource_currentIndexChanged())); - connect(ui->phase0GV7Source,SIGNAL(currentIndexChanged(int)),this,SLOT(GVSource_currentIndexChanged())); - ui->phase0GV6Name->setText(g_model.gvars_names[5]); - ui->phase0GV7Name->setText(g_model.gvars_names[6]); - connect(ui->phase0GV6Name,SIGNAL(editingFinished()),this,SLOT(GVName_editingFinished())); - connect(ui->phase0GV7Name,SIGNAL(editingFinished()),this,SLOT(GVName_editingFinished())); - ui->phase0GV6Value->setValue(g_model.phaseData[0].gvars[5]); - ui->phase0GV7Value->setValue(g_model.phaseData[0].gvars[6]); - connect(ui->phase0GV6Value,SIGNAL(editingFinished()),this,SLOT(phaseGVValue_editingFinished())); - connect(ui->phase0GV7Value,SIGNAL(editingFinished()),this,SLOT(phaseGVValue_editingFinished())); - } - } - - displayOnePhase(0, ui->phase0Name, NULL, ui->phase0FadeIn, ui->phase0FadeOut, NULL, ui->phase0Trim1Value, ui->phase0Trim1Label, ui->phase0Trim1Slider, NULL, ui->phase0Trim2Value, ui->phase0Trim2Label, ui->phase0Trim2Slider, NULL, ui->phase0Trim3Value, ui->phase0Trim3Label, ui->phase0Trim3Slider, NULL, ui->phase0Trim4Value, ui->phase0Trim4Label, ui->phase0Trim4Slider, ui->phase0GV1_Label, NULL , ui->phase0GV1Value, ui->phase0GV2_Label, NULL , ui->phase0GV2Value, ui->phase0GV3_Label, NULL , ui->phase0GV3Value, ui->phase0GV4_Label, NULL , ui->phase0GV4Value, ui->phase0GV5_Label, NULL , ui->phase0GV5Value,ui->phase0REA_Label,NULL, ui->phase0RE1Value,ui->phase0REB_Label, NULL, ui->phase0RE2Value, true); - displayOnePhase(1, ui->phase1Name, ui->phase1Switch, ui->phase1FadeIn, ui->phase1FadeOut, ui->phase1Trim1Use, ui->phase1Trim1Value, ui->phase1Trim1Label, ui->phase1Trim1Slider, ui->phase1Trim2Use, ui->phase1Trim2Value, ui->phase1Trim2Label, ui->phase1Trim2Slider, ui->phase1Trim3Use, ui->phase1Trim3Value, ui->phase1Trim3Label, ui->phase1Trim3Slider, ui->phase1Trim4Use, ui->phase1Trim4Value, ui->phase1Trim4Label, ui->phase1Trim4Slider, ui->phase1GV1_Label, ui->phase1GV1Use, ui->phase1GV1Value, ui->phase1GV2_Label, ui->phase1GV2Use, ui->phase1GV2Value, ui->phase1GV3_Label, ui->phase1GV3Use, ui->phase1GV3Value, ui->phase1GV4_Label, ui->phase1GV4Use, ui->phase1GV4Value, ui->phase1GV5_Label, ui->phase1GV5Use, ui->phase1GV5Value,ui->phase1REA_Label, ui->phase1RE1Use, ui->phase1RE1Value,ui->phase1REB_Label, ui->phase1RE2Use, ui->phase1RE2Value, true); - displayOnePhase(2, ui->phase2Name, ui->phase2Switch, ui->phase2FadeIn, ui->phase2FadeOut, ui->phase2Trim1Use, ui->phase2Trim1Value, ui->phase2Trim1Label, ui->phase2Trim1Slider, ui->phase2Trim2Use, ui->phase2Trim2Value, ui->phase2Trim2Label, ui->phase2Trim2Slider, ui->phase2Trim3Use, ui->phase2Trim3Value, ui->phase2Trim3Label, ui->phase2Trim3Slider, ui->phase2Trim4Use, ui->phase2Trim4Value, ui->phase2Trim4Label, ui->phase2Trim4Slider, ui->phase2GV1_Label, ui->phase2GV1Use, ui->phase2GV1Value, ui->phase2GV2_Label, ui->phase2GV2Use, ui->phase2GV2Value, ui->phase2GV3_Label, ui->phase2GV3Use, ui->phase2GV3Value, ui->phase2GV4_Label, ui->phase2GV4Use, ui->phase2GV4Value, ui->phase2GV5_Label, ui->phase2GV5Use, ui->phase2GV5Value,ui->phase2REA_Label, ui->phase2RE1Use, ui->phase2RE1Value,ui->phase2REB_Label, ui->phase2RE2Use, ui->phase2RE2Value, true); - displayOnePhase(3, ui->phase3Name, ui->phase3Switch, ui->phase3FadeIn, ui->phase3FadeOut, ui->phase3Trim1Use, ui->phase3Trim1Value, ui->phase3Trim1Label, ui->phase3Trim1Slider, ui->phase3Trim2Use, ui->phase3Trim2Value, ui->phase3Trim2Label, ui->phase3Trim2Slider, ui->phase3Trim3Use, ui->phase3Trim3Value, ui->phase3Trim3Label, ui->phase3Trim3Slider, ui->phase3Trim4Use, ui->phase3Trim4Value, ui->phase3Trim4Label, ui->phase3Trim4Slider, ui->phase3GV1_Label, ui->phase3GV1Use, ui->phase3GV1Value, ui->phase3GV2_Label, ui->phase3GV2Use, ui->phase3GV2Value, ui->phase3GV3_Label, ui->phase3GV3Use, ui->phase3GV3Value, ui->phase3GV4_Label, ui->phase3GV4Use, ui->phase3GV4Value, ui->phase3GV5_Label, ui->phase3GV5Use, ui->phase3GV5Value,ui->phase3REA_Label, ui->phase3RE1Use, ui->phase3RE1Value,ui->phase3REB_Label, ui->phase3RE2Use, ui->phase3RE2Value, true); - displayOnePhase(4, ui->phase4Name, ui->phase4Switch, ui->phase4FadeIn, ui->phase4FadeOut, ui->phase4Trim1Use, ui->phase4Trim1Value, ui->phase4Trim1Label, ui->phase4Trim1Slider, ui->phase4Trim2Use, ui->phase4Trim2Value, ui->phase4Trim2Label, ui->phase4Trim2Slider, ui->phase4Trim3Use, ui->phase4Trim3Value, ui->phase4Trim3Label, ui->phase4Trim3Slider, ui->phase4Trim4Use, ui->phase4Trim4Value, ui->phase4Trim4Label, ui->phase4Trim4Slider, ui->phase4GV1_Label, ui->phase4GV1Use, ui->phase4GV1Value, ui->phase4GV2_Label, ui->phase4GV2Use, ui->phase4GV2Value, ui->phase4GV3_Label, ui->phase4GV3Use, ui->phase4GV3Value, ui->phase4GV4_Label, ui->phase4GV4Use, ui->phase4GV4Value, ui->phase4GV5_Label, ui->phase4GV5Use, ui->phase4GV5Value,ui->phase4REA_Label, ui->phase4RE1Use, ui->phase4RE1Value,ui->phase4REB_Label, ui->phase4RE2Use, ui->phase4RE2Value, true); - displayOnePhase(5, ui->phase5Name, ui->phase5Switch, ui->phase5FadeIn, ui->phase5FadeOut, ui->phase5Trim1Use, ui->phase5Trim1Value, ui->phase5Trim1Label, ui->phase5Trim1Slider, ui->phase5Trim2Use, ui->phase5Trim2Value, ui->phase5Trim2Label, ui->phase5Trim2Slider, ui->phase5Trim3Use, ui->phase5Trim3Value, ui->phase5Trim3Label, ui->phase5Trim3Slider, ui->phase5Trim4Use, ui->phase5Trim4Value, ui->phase5Trim4Label, ui->phase5Trim4Slider, ui->phase5GV1_Label, ui->phase5GV1Use, ui->phase5GV1Value, ui->phase5GV2_Label, ui->phase5GV2Use, ui->phase5GV2Value, ui->phase5GV3_Label, ui->phase5GV3Use, ui->phase5GV3Value, ui->phase5GV4_Label, ui->phase5GV4Use, ui->phase5GV4Value, ui->phase5GV5_Label, ui->phase5GV5Use, ui->phase5GV5Value,ui->phase5REA_Label, ui->phase5RE1Use, ui->phase5RE1Value,ui->phase5REB_Label, ui->phase5RE2Use, ui->phase5RE2Value, true); - displayOnePhase(6, ui->phase6Name, ui->phase6Switch, ui->phase6FadeIn, ui->phase6FadeOut, ui->phase6Trim1Use, ui->phase6Trim1Value, ui->phase6Trim1Label, ui->phase6Trim1Slider, ui->phase6Trim2Use, ui->phase6Trim2Value, ui->phase6Trim2Label, ui->phase6Trim2Slider, ui->phase6Trim3Use, ui->phase6Trim3Value, ui->phase6Trim3Label, ui->phase6Trim3Slider, ui->phase6Trim4Use, ui->phase6Trim4Value, ui->phase6Trim4Label, ui->phase6Trim4Slider, ui->phase6GV1_Label, ui->phase6GV1Use, ui->phase6GV1Value, ui->phase6GV2_Label, ui->phase6GV2Use, ui->phase6GV2Value, ui->phase6GV3_Label, ui->phase6GV3Use, ui->phase6GV3Value, ui->phase6GV4_Label, ui->phase6GV4Use, ui->phase6GV4Value, ui->phase6GV5_Label, ui->phase6GV5Use, ui->phase6GV5Value,ui->phase6REA_Label, ui->phase6RE1Use, ui->phase6RE1Value,ui->phase6REB_Label, ui->phase6RE2Use, ui->phase6RE2Value, true); - displayOnePhase(7, ui->phase7Name, ui->phase7Switch, ui->phase7FadeIn, ui->phase7FadeOut, ui->phase7Trim1Use, ui->phase7Trim1Value, ui->phase7Trim1Label, ui->phase7Trim1Slider, ui->phase7Trim2Use, ui->phase7Trim2Value, ui->phase7Trim2Label, ui->phase7Trim2Slider, ui->phase7Trim3Use, ui->phase7Trim3Value, ui->phase7Trim3Label, ui->phase7Trim3Slider, ui->phase7Trim4Use, ui->phase7Trim4Value, ui->phase7Trim4Label, ui->phase7Trim4Slider, ui->phase7GV1_Label, ui->phase7GV1Use, ui->phase7GV1Value, ui->phase7GV2_Label, ui->phase7GV2Use, ui->phase7GV2Value, ui->phase7GV3_Label, ui->phase7GV3Use, ui->phase7GV3Value, ui->phase7GV4_Label, ui->phase7GV4Use, ui->phase7GV4Value, ui->phase7GV5_Label, ui->phase7GV5Use, ui->phase7GV5Value,ui->phase7REA_Label, ui->phase7RE1Use, ui->phase7RE1Value,ui->phase7REB_Label, ui->phase7RE2Use, ui->phase7RE2Value, true); - displayOnePhase(8, ui->phase8Name, ui->phase8Switch, ui->phase8FadeIn, ui->phase8FadeOut, ui->phase8Trim1Use, ui->phase8Trim1Value, ui->phase8Trim1Label, ui->phase8Trim1Slider, ui->phase8Trim2Use, ui->phase8Trim2Value, ui->phase8Trim2Label, ui->phase8Trim2Slider, ui->phase8Trim3Use, ui->phase8Trim3Value, ui->phase8Trim3Label, ui->phase8Trim3Slider, ui->phase8Trim4Use, ui->phase8Trim4Value, ui->phase8Trim4Label, ui->phase8Trim4Slider, ui->phase8GV1_Label, ui->phase8GV1Use, ui->phase8GV1Value, ui->phase8GV2_Label, ui->phase8GV2Use, ui->phase8GV2Value, ui->phase8GV3_Label, ui->phase8GV3Use, ui->phase8GV3Value, ui->phase8GV4_Label, ui->phase8GV4Use, ui->phase8GV4Value, ui->phase8GV5_Label, ui->phase8GV5Use, ui->phase8GV5Value,ui->phase8REA_Label, ui->phase8RE1Use, ui->phase8RE1Value,ui->phase8REB_Label, ui->phase8RE2Use, ui->phase8RE2Value, true); - - QSlider * tmpsliders[9][4]={ - {ui->phase0Trim1Slider,ui->phase0Trim2Slider,ui->phase0Trim3Slider,ui->phase0Trim4Slider}, - {ui->phase1Trim1Slider,ui->phase1Trim2Slider,ui->phase1Trim3Slider,ui->phase1Trim4Slider}, - {ui->phase2Trim1Slider,ui->phase2Trim2Slider,ui->phase2Trim3Slider,ui->phase2Trim4Slider}, - {ui->phase3Trim1Slider,ui->phase3Trim2Slider,ui->phase3Trim3Slider,ui->phase3Trim4Slider}, - {ui->phase4Trim1Slider,ui->phase4Trim2Slider,ui->phase4Trim3Slider,ui->phase4Trim4Slider}, - {ui->phase5Trim1Slider,ui->phase5Trim2Slider,ui->phase5Trim3Slider,ui->phase5Trim4Slider}, - {ui->phase6Trim1Slider,ui->phase6Trim2Slider,ui->phase6Trim3Slider,ui->phase6Trim4Slider}, - {ui->phase7Trim1Slider,ui->phase7Trim2Slider,ui->phase7Trim3Slider,ui->phase7Trim4Slider}, - {ui->phase8Trim1Slider,ui->phase8Trim2Slider,ui->phase8Trim3Slider,ui->phase8Trim4Slider} - }; - QSpinBox * tmpspinbox[9][4]={ - {ui->phase0Trim1Value,ui->phase0Trim2Value,ui->phase0Trim3Value,ui->phase0Trim4Value}, - {ui->phase1Trim1Value,ui->phase1Trim2Value,ui->phase1Trim3Value,ui->phase1Trim4Value}, - {ui->phase2Trim1Value,ui->phase2Trim2Value,ui->phase2Trim3Value,ui->phase2Trim4Value}, - {ui->phase3Trim1Value,ui->phase3Trim2Value,ui->phase3Trim3Value,ui->phase3Trim4Value}, - {ui->phase4Trim1Value,ui->phase4Trim2Value,ui->phase4Trim3Value,ui->phase4Trim4Value}, - {ui->phase5Trim1Value,ui->phase5Trim2Value,ui->phase5Trim3Value,ui->phase5Trim4Value}, - {ui->phase6Trim1Value,ui->phase6Trim2Value,ui->phase6Trim3Value,ui->phase6Trim4Value}, - {ui->phase7Trim1Value,ui->phase7Trim2Value,ui->phase7Trim3Value,ui->phase7Trim4Value}, - {ui->phase8Trim1Value,ui->phase8Trim2Value,ui->phase8Trim3Value,ui->phase8Trim4Value} - }; - memcpy(phasesTrimSliders,tmpsliders,sizeof(phasesTrimSliders)); - memcpy(phasesTrimValues,tmpspinbox,sizeof(phasesTrimValues)); - - int phases = GetEepromInterface()->getCapability(FlightPhases); - if (phases < 9) { - ui->phase8->setDisabled(true); - ui->phases->removeTab(8); - } - if (phases < 8) { - ui->phase7->setDisabled(true); - ui->phases->removeTab(7); - } - if (phases < 7) { - ui->phase6->setDisabled(true); - ui->phases->removeTab(6); - } - if (phases < 6) { - ui->phase5->setDisabled(true); - ui->phases->removeTab(5); - } - if (phases < 5) { - ui->phase4->setDisabled(true); - ui->phases->removeTab(4); - } - if (phases < 4) { - ui->phase3->setDisabled(true); - ui->phases->removeTab(3); - } - if (phases < 3) { - ui->phase2->setDisabled(true); - ui->phases->removeTab(2); - } - if (phases < 2) { - ui->phase1->setDisabled(true); - ui->phases->removeTab(1); - ui->phase0Name->setDisabled(true); - ui->phase0FadeIn->setDisabled(true); - ui->phase0FadeOut->setDisabled(true); - } - if ( GetEepromInterface()->getCapability(FlightPhasesAreNamed) ) { - for (int i=0; i < phases; i++) { - QString PhaseName=g_model.phaseData[i].name; - QString TabName; - if (i==0) { - TabName.append(QObject::tr("Flight Mode 0 (Default)")); - } else { - TabName.append(QObject::tr("FM %1").arg(i)); - } - if (!PhaseName.isEmpty()) { - TabName.append(" ("); - TabName.append(PhaseName); - TabName.append(")"); - } - ui->phases->setTabText(i,TabName); - } - } else { - QLineEdit * tmp[]= { ui->phase0Name,ui->phase1Name,ui->phase2Name,ui->phase3Name,ui->phase4Name,ui->phase5Name,ui->phase6Name,ui->phase7Name,ui->phase8Name}; - QLabel * tmp2[] = { ui->label_fm0name,ui->label_fm1name,ui->label_fm2name,ui->label_fm3name,ui->label_fm4name,ui->label_fm5name,ui->label_fm6name,ui->label_fm7name,ui->label_fm8name}; - for (int i=0; i < phases; i++) { - tmp[i]->hide(); - tmp2[i]->hide(); - } - } - ui->phases->setCurrentIndex(0); - phasesLock = false; -} - -void ModelEdit::on_phases_currentChanged(int index) -{ - phasesLock = true; - switch(index) { - case 1: - displayOnePhase(1, NULL, NULL, NULL, NULL, NULL, ui->phase1Trim1Value, NULL, ui->phase1Trim1Slider, NULL, ui->phase1Trim2Value, NULL, ui->phase1Trim2Slider, NULL, ui->phase1Trim3Value, NULL, ui->phase1Trim3Slider, NULL, ui->phase1Trim4Value, NULL, ui->phase1Trim4Slider, NULL, NULL, ui->phase1GV1Value, NULL, NULL, ui->phase1GV2Value, NULL, NULL, ui->phase1GV3Value, NULL, NULL, ui->phase1GV4Value, NULL, NULL, ui->phase1GV5Value,NULL,NULL, ui->phase1RE1Value,NULL,NULL, ui->phase1RE2Value); - break; - case 2: - displayOnePhase(2, NULL, NULL, NULL, NULL, NULL, ui->phase2Trim1Value, NULL, ui->phase2Trim1Slider, NULL, ui->phase2Trim2Value, NULL, ui->phase2Trim2Slider, NULL, ui->phase2Trim3Value, NULL, ui->phase2Trim3Slider, NULL, ui->phase2Trim4Value, NULL, ui->phase2Trim4Slider, NULL, NULL, ui->phase2GV1Value, NULL, NULL, ui->phase2GV2Value, NULL, NULL, ui->phase2GV3Value, NULL, NULL, ui->phase2GV4Value, NULL, NULL, ui->phase2GV5Value,NULL,NULL, ui->phase2RE1Value,NULL,NULL, ui->phase2RE2Value); - break; - case 3: - displayOnePhase(3, NULL, NULL, NULL, NULL, NULL, ui->phase3Trim1Value, NULL, ui->phase3Trim1Slider, NULL, ui->phase3Trim2Value, NULL, ui->phase3Trim2Slider, NULL, ui->phase3Trim3Value, NULL, ui->phase3Trim3Slider, NULL, ui->phase3Trim4Value, NULL, ui->phase3Trim4Slider, NULL, NULL, ui->phase3GV1Value, NULL, NULL, ui->phase3GV2Value, NULL, NULL, ui->phase3GV3Value, NULL, NULL, ui->phase3GV4Value, NULL, NULL, ui->phase3GV5Value,NULL,NULL, ui->phase3RE1Value,NULL,NULL, ui->phase3RE2Value); - break; - case 4: - displayOnePhase(4, NULL, NULL, NULL, NULL, NULL, ui->phase4Trim1Value, NULL, ui->phase4Trim1Slider, NULL, ui->phase4Trim2Value, NULL, ui->phase4Trim2Slider, NULL, ui->phase4Trim3Value, NULL, ui->phase4Trim3Slider, NULL, ui->phase4Trim4Value, NULL, ui->phase4Trim4Slider, NULL, NULL, ui->phase4GV1Value, NULL, NULL, ui->phase4GV2Value, NULL, NULL, ui->phase4GV3Value, NULL, NULL, ui->phase4GV4Value, NULL, NULL, ui->phase4GV5Value,NULL,NULL, ui->phase4RE1Value,NULL,NULL, ui->phase4RE2Value); - break; - case 5: - displayOnePhase(5, NULL, NULL, NULL, NULL, NULL, ui->phase5Trim1Value, NULL, ui->phase5Trim1Slider, NULL, ui->phase5Trim2Value, NULL, ui->phase5Trim2Slider, NULL, ui->phase5Trim3Value, NULL, ui->phase5Trim3Slider, NULL, ui->phase5Trim4Value, NULL, ui->phase5Trim4Slider, NULL, NULL, ui->phase5GV1Value, NULL, NULL, ui->phase5GV2Value, NULL, NULL, ui->phase5GV3Value, NULL, NULL, ui->phase5GV4Value, NULL, NULL, ui->phase5GV5Value,NULL,NULL, ui->phase5RE1Value,NULL,NULL, ui->phase5RE2Value); - break; - case 6: - displayOnePhase(6, NULL, NULL, NULL, NULL, NULL, ui->phase6Trim1Value, NULL, ui->phase6Trim1Slider, NULL, ui->phase6Trim2Value, NULL, ui->phase6Trim2Slider, NULL, ui->phase6Trim3Value, NULL, ui->phase6Trim3Slider, NULL, ui->phase6Trim4Value, NULL, ui->phase6Trim4Slider, NULL, NULL, ui->phase6GV1Value, NULL, NULL, ui->phase6GV2Value, NULL, NULL, ui->phase6GV3Value, NULL, NULL, ui->phase6GV4Value, NULL, NULL, ui->phase6GV5Value,NULL,NULL, ui->phase6RE1Value,NULL,NULL, ui->phase6RE2Value); - break; - case 7: - displayOnePhase(7, NULL, NULL, NULL, NULL, NULL, ui->phase7Trim1Value, NULL, ui->phase7Trim1Slider, NULL, ui->phase7Trim2Value, NULL, ui->phase7Trim2Slider, NULL, ui->phase7Trim3Value, NULL, ui->phase7Trim3Slider, NULL, ui->phase7Trim4Value, NULL, ui->phase7Trim4Slider, NULL, NULL, ui->phase7GV1Value, NULL, NULL, ui->phase7GV2Value, NULL, NULL, ui->phase7GV3Value, NULL, NULL, ui->phase7GV4Value, NULL, NULL, ui->phase7GV5Value,NULL,NULL, ui->phase7RE1Value,NULL,NULL, ui->phase7RE2Value); - break; - case 8: - displayOnePhase(8, NULL, NULL, NULL, NULL, NULL, ui->phase8Trim1Value, NULL, ui->phase8Trim1Slider, NULL, ui->phase8Trim2Value, NULL, ui->phase8Trim2Slider, NULL, ui->phase8Trim3Value, NULL, ui->phase8Trim3Slider, NULL, ui->phase8Trim4Value, NULL, ui->phase8Trim4Slider, NULL, NULL, ui->phase8GV1Value, NULL, NULL, ui->phase8GV2Value, NULL, NULL, ui->phase8GV3Value, NULL, NULL, ui->phase8GV4Value, NULL, NULL, ui->phase8GV5Value,NULL,NULL, ui->phase8RE1Value,NULL,NULL, ui->phase8RE2Value); - break; - } - phasesLock = false; -} - -void ModelEdit::tabExpos() -{ - // curDest -> destination channel - // i -> mixer number - QByteArray qba; - ExposlistWidget->clear(); - int curDest = -1; - - for(int i=0; imode==0) break; - QString str = ""; - while(curDest<(int)md->chn-1) { - curDest++; - str = getStickStr(curDest); - qba.clear(); - qba.append((quint8)-curDest-1); - QListWidgetItem *itm = new QListWidgetItem(str); - itm->setData(Qt::UserRole,qba); - ExposlistWidget->addItem(itm); - } - - if(curDest!=(int)md->chn) { - str = getStickStr(md->chn); - curDest = md->chn; - } else { - str = " "; - } - - switch (md->mode) { - case (1): str += " <-"; break; - case (2): str += " ->"; break; - default: str += " "; break; - }; - - str += tr("Weight") + getGVarString(md->weight).rightJustified(6, ' '); - if (!GetEepromInterface()->getCapability(ExpoIsCurve)) { - if (md->expo!=0) - str += " " + tr("Expo") + getGVarString(md->expo, true).rightJustified(7, ' '); - } else { - if (md->curveMode==0 && md->curveParam!=0) - str += " " + tr("Expo") + getGVarString(md->curveParam, true).rightJustified(7, ' '); - } - if (GetEepromInterface()->getCapability(FlightPhases)) { - if(md->phases) { - if (md->phases!=(unsigned int)(1<getCapability(FlightPhases))-1) { - int mask=1; - int first=0; - for (int i=0; igetCapability(FlightPhases);i++) { - if (!(md->phases & mask)) { - first++; - } - mask <<=1; - } - if (first>1) { - str += " " + tr("Flight modes") + QString("("); - } else { - str += " " + tr("Flight mode") + QString("("); - } - mask=1; - first=1; - for (int i=0; igetCapability(FlightPhases);i++) { - if (!(md->phases & mask)) { - if (!first) { - str += QString(", ")+ QString("%1").arg(getPhaseName(i+1, g_model.phaseData[i].name)); - } else { - str += QString("%1").arg(getPhaseName(i+1,g_model.phaseData[i].name)); - first=0; - } - } - mask <<=1; - } - str += QString(")"); - } else { - str += tr("DISABLED")+QString(" !!!"); - } - } - } - if (md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString()); - if (md->curveMode) - if (md->curveParam) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curveParam)); - if (GetEepromInterface()->getCapability(HasExpoNames)) { - QString ExpoName; - ExpoName.append(md->name); - if (!ExpoName.isEmpty()) { - str+=QString("(%1)").arg(ExpoName); - } - } - qba.clear(); - qba.append((quint8)i); - qba.append((const char*)md, sizeof(ExpoData)); - QListWidgetItem *itm = new QListWidgetItem(str); - itm->setData(Qt::UserRole,qba); // expo number - ExposlistWidget->addItem(itm); //(str); - } - - while(curDestsetData(Qt::UserRole,qba); // add new expo - ExposlistWidget->addItem(itm); - } -} - -void ModelEdit::exposEdited() -{ - updateSettings(); -} - -void ModelEdit::tabMixes() -{ - // curDest -> destination channel4 - // i -> mixer number - QByteArray qba; - MixerlistWidget->clear(); - unsigned int curDest = 0; - int i; - unsigned int outputs = GetEepromInterface()->getCapability(Outputs); - int showNames=ui->showNames_Ckb->isChecked(); - for(i=0; igetCapability(Mixes); i++) { - MixData *md = &g_model.mixData[i]; - if ((md->destCh==0) || (md->destCh>outputs+(unsigned int)GetEepromInterface()->getCapability(ExtraChannels))) continue; - QString str = ""; - while(curDest<(md->destCh-1)) { - curDest++; - if (curDest > outputs) { - str = tr("X%1 ").arg(curDest-outputs); - } else { - str = tr("CH%1%2").arg(curDest/10).arg(curDest%10); - if (GetEepromInterface()->getCapability(HasChNames) && showNames) { - QString name=g_model.limitData[curDest-1].name; - if (!name.isEmpty()) { - name.append(" "); - str=name.left(6); - } - } - } - qba.clear(); - qba.append((quint8)-curDest); - QListWidgetItem *itm = new QListWidgetItem(str); - itm->setData(Qt::UserRole,qba); - MixerlistWidget->addItem(itm); - } - - if (md->destCh > outputs) { - str = tr("X%1 ").arg(md->destCh-outputs); - } else { - str = tr("CH%1%2").arg(md->destCh/10).arg(md->destCh%10); - str.append(" "); - if (GetEepromInterface()->getCapability(HasChNames) && showNames) { - QString name=g_model.limitData[md->destCh-1].name; - if (!name.isEmpty()) { - name.append(" "); - str=name.left(6); - } - } - } - if (curDest != md->destCh) { - curDest = md->destCh; - } else { - str.fill(' '); - } - - switch(md->mltpx) { - case (1): str += " *"; break; - case (2): str += " R"; break; - default: str += " "; break; - }; - - str += " " + getGVarString(md->weight, true).rightJustified(6, ' '); - str += md->srcRaw.toString(); - unsigned int fpCount = GetEepromInterface()->getCapability(FlightPhases); - if (GetEepromInterface()->getCapability(FlightPhases)) { - if(md->phases) { - if (md->phases!=(unsigned int)(1<phases & mask)) { - first++; - } - mask <<=1; - } - if (first>1) { - str += " " + tr("Flight modes") + QString("("); - } else { - str += " " + tr("Flight mode") + QString("("); - } - mask=1; - first=1; - for (unsigned int i=0; iphases & mask)) { - if (!first) { - str += QString(", ")+ QString("%1").arg(getPhaseName(i+1, g_model.phaseData[i].name)); - } - else { - str += QString("%1").arg(getPhaseName(i+1,g_model.phaseData[i].name)); - first=0; - } - } - mask <<=1; - } - str += QString(")"); - } else { - str += tr("DISABLED")+QString(" !!!"); - } - } - } - if(md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString()); - if(md->carryTrim>0) { - str += " " +tr("No Trim"); - } else if (md->carryTrim<0) { - str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(); - } - if(md->noExpo) { - str += " " +tr("No DR/Expo"); - } - if (GetEepromInterface()->getCapability(MixFmTrim) && md->enableFmTrim==1) { - if (md->sOffset) str += " " + tr("FMTrim") + QString("(%1%)").arg(md->sOffset); - } else { - if (md->sOffset) str += " " + tr("Offset") + getGVarString(md->sOffset); - } - if (md->differential) str += " " + tr("Diff") + getGVarString(md->differential); - if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve)); - int scale=GetEepromInterface()->getCapability(SlowScale); - if (scale==0) - scale=1; - if (md->delayDown || md->delayUp) - str += tr(" Delay(u%1:d%2)").arg((double)md->delayUp/scale).arg((double)md->delayDown/scale); - if (md->speedDown || md->speedUp) - str += tr(" Slow(u%1:d%2)").arg((double)md->speedUp/scale).arg((double)md->speedDown/scale); - if (md->mixWarn) str += tr(" Warn(%1)").arg(md->mixWarn); - if (GetEepromInterface()->getCapability(HasMixerNames)) { - QString MixerName; - MixerName.append(md->name); - if (!MixerName.isEmpty()) { - str+=QString("(%1)").arg(MixerName); - } - } - qba.clear(); - qba.append((quint8)i); - qba.append((const char*)md, sizeof(MixData)); - QListWidgetItem *itm = new QListWidgetItem(str); - itm->setData(Qt::UserRole,qba); // mix number - MixerlistWidget->addItem(itm);//(str); - } - - while(curDestgetCapability(ExtraChannels)) { - curDest++; - QString str; - - if (curDest > outputs) { - str = tr("X%1 ").arg(curDest-outputs); - } else { - str = tr("CH%1%2").arg(curDest/10).arg(curDest%10); - if (GetEepromInterface()->getCapability(HasChNames) && showNames) { - QString name=g_model.limitData[curDest-1].name; - if (!name.isEmpty()) { - name.append(" "); - str=name.left(6); - } - } - } - qba.clear(); - qba.append((quint8)-curDest); - QListWidgetItem *itm = new QListWidgetItem(str); - itm->setData(Qt::UserRole,qba); // add new mixer - MixerlistWidget->addItem(itm); - } -} - -void ModelEdit::mixesEdited() -{ - updateSettings(); -} - - -void ModelEdit::tabHeli() -{ - updateHeliTab(); - - connect(ui->swashTypeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(heliEdited())); - connect(ui->swashCollectiveCB,SIGNAL(currentIndexChanged(int)),this,SLOT(heliEdited())); - connect(ui->swashRingValSB,SIGNAL(editingFinished()),this,SLOT(heliEdited())); - connect(ui->swashInvertELE,SIGNAL(stateChanged(int)),this,SLOT(heliEdited())); - connect(ui->swashInvertAIL,SIGNAL(stateChanged(int)),this,SLOT(heliEdited())); - connect(ui->swashInvertCOL,SIGNAL(stateChanged(int)),this,SLOT(heliEdited())); -} - -void ModelEdit::updateHeliTab() -{ - heliEditLock = true; - - ui->swashTypeCB->setCurrentIndex(g_model.swashRingData.type); - populateSourceCB(ui->swashCollectiveCB, g_model.swashRingData.collectiveSource, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS); - ui->swashRingValSB->setValue(g_model.swashRingData.value); - ui->swashInvertELE->setChecked(g_model.swashRingData.invertELE); - ui->swashInvertAIL->setChecked(g_model.swashRingData.invertAIL); - ui->swashInvertCOL->setChecked(g_model.swashRingData.invertCOL); - - heliEditLock = false; -} - -void ModelEdit::heliEdited() -{ - if(heliEditLock) return; - g_model.swashRingData.type = ui->swashTypeCB->currentIndex(); - g_model.swashRingData.collectiveSource = ui->swashCollectiveCB->itemData(ui->swashCollectiveCB->currentIndex()).toInt(); - g_model.swashRingData.value = ui->swashRingValSB->value(); - g_model.swashRingData.invertELE = ui->swashInvertELE->isChecked(); - g_model.swashRingData.invertAIL = ui->swashInvertAIL->isChecked(); - g_model.swashRingData.invertCOL = ui->swashInvertCOL->isChecked(); - updateSettings(); -} - -void ModelEdit::tabLimits() -{ - limitEditLock=true; - int chnames=GetEepromInterface()->getCapability(HasChNames); - QRegExp rx(CHAR_FOR_NAMES_REGEX); - foreach(QLineEdit *le, findChildren(QRegExp("CHName_[0-9]+"))) { - int len=le->objectName().mid(le->objectName().lastIndexOf("_")+1).toInt()-1; - if (chnames ) { - QString name=g_model.limitData[len].name; - if (name.trimmed().isEmpty()) { - le->setText(tr("CH %1").arg(len+1)); - } else { - le->setText(name); - } - le->setValidator(new QRegExpValidator(rx, this)); - le->setEnabled(true); - le->setReadOnly(false); - connect(le, SIGNAL(editingFinished()), this, SLOT(limitNameEdited())); - } else { - le->setText(tr("CH %1").arg(len+1)); - le->setDisabled(true); - le->setReadOnly(true); - } - } - limitEditLock=false; - foreach(QDoubleSpinBox *sb, findChildren(QRegExp("offsetDSB_[0-9]+"))) { - int sbn=sb->objectName().mid(sb->objectName().lastIndexOf("_")+1).toInt()-1; - sb->setValue(g_model.limitData[sbn].offset/10.0); - connect(sb, SIGNAL(editingFinished()), this, SLOT(limitOffsetEdited())); - } - - foreach(QSpinBox *sb, findChildren(QRegExp("minSB_[0-9]+"))) { - int sbn=sb->objectName().mid(sb->objectName().lastIndexOf("_")+1).toInt()-1; - sb->setValue(g_model.limitData[sbn].min); - connect(sb, SIGNAL(editingFinished()), this, SLOT(limitEdited())); - } - - foreach(QSpinBox *sb, findChildren(QRegExp("maxSB_[0-9]+"))) { - int sbn=sb->objectName().mid(sb->objectName().lastIndexOf("_")+1).toInt()-1; - sb->setValue(g_model.limitData[sbn].max); - connect(sb, SIGNAL(editingFinished()), this, SLOT(limitEdited())); - } - - foreach(QComboBox *cb, findChildren(QRegExp("chInvCB_[0-9]+"))) { - int cbn=cb->objectName().mid(cb->objectName().lastIndexOf("_")+1).toInt()-1; - cb->setCurrentIndex((g_model.limitData[cbn].revert) ? 1 : 0); - connect(cb, SIGNAL(currentIndexChanged(int)), this, SLOT(limitInvEdited())); - } - if (GetEepromInterface()->getCapability(PPMCenter)) { - foreach(QSpinBox *sb, findChildren(QRegExp("ppmcenter_[0-9]+"))) { - int sbn=sb->objectName().mid(sb->objectName().lastIndexOf("_")+1).toInt()-1; - sb->setValue(g_model.limitData[sbn].ppmCenter+1500); - connect(sb, SIGNAL(editingFinished()), this, SLOT(ppmcenterEdited())); - } - } else { - foreach(QSpinBox *sb, findChildren(QRegExp("ppmcenter_[0-9]+"))) { - sb->hide(); - } - ui->ppmc_label1->hide(); - ui->ppmc_label2->hide(); - } - - if (GetEepromInterface()->getCapability(SYMLimits)) { - foreach(QCheckBox *ckb, findChildren(QRegExp("symckb_[0-9]+"))) { - int ckbn=ckb->objectName().mid(ckb->objectName().lastIndexOf("_")+1).toInt()-1; - ckb->setChecked(g_model.limitData[ckbn].symetrical); - connect(ckb, SIGNAL(toggled(bool)), this, SLOT(limitSymEdited())); - } - } else { - foreach(QCheckBox *ckb, findChildren(QRegExp("symckb_[0-9]+"))) { - ckb->hide(); - } - ui->label_sym01->hide(); - ui->label_sym02->hide(); - } - - if (GetEepromInterface()->getCapability(Outputs)<17) { - ui->limitGB2->hide(); - } - setLimitMinMax(); -} - -void ModelEdit::updateCurvesTab() -{ - ControlCurveSignal(true); - foreach(QCheckBox *ChkB, findChildren(QRegExp("plotCB_[0-9]+"))) { - int ChkBn=ChkB->objectName().mid(ChkB->objectName().lastIndexOf("_")+1).toInt()-1; - ChkB->setChecked(plot_curve[ChkBn]); - } - ControlCurveSignal(false); -} - - -void ModelEdit::tabCurves() -{ - QSpinBox* tmpy[17] = { - ui->curvePt01_y, ui->curvePt02_y, ui->curvePt03_y, ui->curvePt04_y, ui->curvePt05_y, - ui->curvePt06_y, ui->curvePt07_y, ui->curvePt08_y, ui->curvePt09_y, ui->curvePt10_y, - ui->curvePt11_y, ui->curvePt12_y, ui->curvePt13_y, ui->curvePt14_y, ui->curvePt15_y, - ui->curvePt16_y, ui->curvePt17_y }; - QSpinBox* tmpx[17] = { - ui->curvePt01_x, ui->curvePt02_x, ui->curvePt03_x, ui->curvePt04_x, ui->curvePt05_x, - ui->curvePt06_x, ui->curvePt07_x, ui->curvePt08_x, ui->curvePt09_x, ui->curvePt10_x, - ui->curvePt11_x, ui->curvePt12_x, ui->curvePt13_x, ui->curvePt14_x, ui->curvePt15_x, - ui->curvePt16_x, ui->curvePt17_x }; - - QPushButton * editb[16]= { - ui->curveEdit_1,ui->curveEdit_2,ui->curveEdit_3,ui->curveEdit_4, - ui->curveEdit_5,ui->curveEdit_6,ui->curveEdit_7,ui->curveEdit_8, - ui->curveEdit_9,ui->curveEdit_10,ui->curveEdit_11,ui->curveEdit_12, - ui->curveEdit_13,ui->curveEdit_14,ui->curveEdit_15,ui->curveEdit_16 }; - - QPushButton * resetb[16]= { - ui->resetCurve_1,ui->resetCurve_2,ui->resetCurve_3,ui->resetCurve_4, - ui->resetCurve_5,ui->resetCurve_6,ui->resetCurve_7,ui->resetCurve_8, - ui->resetCurve_9,ui->resetCurve_10,ui->resetCurve_11,ui->resetCurve_12, - ui->resetCurve_13,ui->resetCurve_14,ui->resetCurve_15,ui->resetCurve_16 }; - - QCheckBox * plotcb[16]= { - ui->plotCB_1,ui->plotCB_2,ui->plotCB_3,ui->plotCB_4, - ui->plotCB_5,ui->plotCB_6,ui->plotCB_7,ui->plotCB_8, - ui->plotCB_9,ui->plotCB_10,ui->plotCB_11,ui->plotCB_12, - ui->plotCB_13,ui->plotCB_14,ui->plotCB_15,ui->plotCB_16 }; - - memcpy(spny, tmpy, sizeof(spny)); - memcpy(spnx, tmpx, sizeof(spnx)); - int numcurves=GetEepromInterface()->getCapability(NumCurves); - if (numcurves==0) { - numcurves=16; - } - - if (!GetEepromInterface()->getCapability(CustomCurves)){ - ui->curvetype_CB->setDisabled(true); - int count=0; - for (int i=0; i< GetEepromInterface()->getCapability(NumCurves3); i++) { - g_model.curves[count].count=3; - g_model.curves[count].custom=false; - count++; - } - for (int i=0; i< GetEepromInterface()->getCapability(NumCurves5); i++) { - g_model.curves[count].count=5; - g_model.curves[count].custom=false; - count++; - } - for (int i=0; i< GetEepromInterface()->getCapability(NumCurves9); i++) { - g_model.curves[count].count=9; - g_model.curves[count].custom=false; - count++; - } - for (int i=count; i< 16; i++) { - editb[i]->hide(); - plotcb[i]->hide(); - resetb[i]->hide(); - } - - } else { - ui->curvetype_CB->setEnabled(true); - } - if (!GetEepromInterface()->getCapability(HasCvNames)){ - ui->cname_LE->hide(); - ui->cname_label->hide(); - } else { - ui->cname_LE->setText(g_model.curves[0].name); - } - - for (int i=numcurves; i<16;i++) { - editb[i]->hide(); - resetb[i]->hide(); - plotcb[i]->hide(); - } - - - for (int i=0; i<16;i++) { - plot_curve[i]=FALSE; - } - redrawCurve=true; - drawing=false; -#ifdef __APPLE__ - ui->curveEdit_1->setStyleSheet("color: #00007f;"); - ui->curveEdit_2->setStyleSheet("color: #007f00;"); - ui->curveEdit_3->setStyleSheet("color: #7f0000;"); - ui->curveEdit_4->setStyleSheet("color: #007f7f;"); - ui->curveEdit_5->setStyleSheet("color: #7f007f;"); - ui->curveEdit_6->setStyleSheet("color: #7f7f00;"); - ui->curveEdit_7->setStyleSheet("color: #7f7f7f;"); - ui->curveEdit_8->setStyleSheet("color: #0000ff;"); - ui->curveEdit_9->setStyleSheet("color: #007fff;"); - ui->curveEdit_10->setStyleSheet("color: #7f00ff;"); - ui->curveEdit_11->setStyleSheet("color: #00ff00;"); - ui->curveEdit_12->setStyleSheet("color: #00ff7f;"); - ui->curveEdit_13->setStyleSheet("color: #7fff00;"); - ui->curveEdit_14->setStyleSheet("color: #ff0000;"); - ui->curveEdit_15->setStyleSheet("color: #ff007f;"); - ui->curveEdit_16->setStyleSheet("color: #ff7f00;"); -#else - ui->curveEdit_1->setStyleSheet("background-color: #00007f; color: white;"); - ui->curveEdit_2->setStyleSheet("background-color: #007f00; color: white;"); - ui->curveEdit_3->setStyleSheet("background-color: #7f0000; color: white;"); - ui->curveEdit_4->setStyleSheet("background-color: #007f7f; color: white;"); - ui->curveEdit_5->setStyleSheet("background-color: #7f007f; color: white;"); - ui->curveEdit_6->setStyleSheet("background-color: #7f7f00; color: white;"); - ui->curveEdit_7->setStyleSheet("background-color: #7f7f7f; color: white;"); - ui->curveEdit_8->setStyleSheet("background-color: #0000ff; color: white;"); - ui->curveEdit_9->setStyleSheet("background-color: #007fff; color: white;"); - ui->curveEdit_10->setStyleSheet("background-color: #7f00ff; color: white;"); - ui->curveEdit_11->setStyleSheet("background-color: #00ff00; color: white;"); - ui->curveEdit_12->setStyleSheet("background-color: #00ff7f; color: white;"); - ui->curveEdit_13->setStyleSheet("background-color: #7fff00; color: white;"); - ui->curveEdit_14->setStyleSheet("background-color: #ff0000; color: white;"); - ui->curveEdit_15->setStyleSheet("background-color: #ff007f; color: white;"); - ui->curveEdit_16->setStyleSheet("background-color: #ff7f00; color: white;"); -#endif - updateCurvesTab(); - - QGraphicsScene *scene = new QGraphicsScene(ui->curvePreview); - scene->setItemIndexMethod(QGraphicsScene::NoIndex); - ui->curvePreview->setScene(scene); - currentCurve = 0; - - connect(ui->clearMixesPB,SIGNAL(pressed()),this,SLOT(clearCurves())); - - foreach(QSpinBox *sb, findChildren(QRegExp("curvePt[0-9]+"))) { - connect(sb, SIGNAL(valueChanged(int)), this, SLOT(curvePointEdited())); - } - - foreach(QPushButton *pb, findChildren(QRegExp("resetCurve_[0-9]+"))) { - connect(pb, SIGNAL(clicked()), this, SLOT(resetCurve())); - } - - foreach(QPushButton *pb, findChildren(QRegExp("curveEdit_[0-9]+"))) { - connect(pb, SIGNAL(clicked()), this, SLOT(editCurve())); - } - - foreach(QCheckBox *ChkB, findChildren(QRegExp("plotCB_[0-9]+"))) { - connect(ChkB, SIGNAL(toggled(bool)), this, SLOT(plotCurve(bool))); - } - setCurrentCurve(currentCurve); - ui->ca_coeff_SB->hide(); - ui->ca_coeff_label->hide(); - ui->ca_ymid_SB->hide(); - ui->ca_ymid_label->hide(); -} - -void ModelEdit::on_ca_ctype_CB_currentIndexChanged() -{ - int index=ui->ca_ctype_CB->currentIndex(); - switch (index) { - case 0: - ui->ca_coeff_SB->hide(); - ui->ca_coeff_label->hide(); - ui->ca_ymid_SB->hide(); - ui->ca_ymid_label->hide(); - ui->ca_ymin_SB->show(); - ui->ca_ymin_label->show(); - ui->ca_ymin_SB->setValue(-100); - ui->ca_ymax_SB->setValue(100); - break; - case 1: - ui->ca_coeff_SB->show(); - ui->ca_coeff_label->show(); - ui->ca_ymid_SB->hide(); - ui->ca_ymid_label->hide(); - ui->ca_ymin_SB->show(); - ui->ca_ymin_label->show(); - ui->ca_ymin_SB->setValue(-100); - ui->ca_ymax_SB->setValue(100); - break; - case 2: - ui->ca_coeff_SB->show(); - ui->ca_coeff_label->show(); - ui->ca_ymid_SB->hide(); - ui->ca_ymid_label->hide(); - ui->ca_ymin_SB->hide(); - ui->ca_ymin_label->hide(); - ui->ca_ymax_SB->setValue(100); - break; - case 3: - ui->ca_coeff_SB->show(); - ui->ca_coeff_label->show(); - ui->ca_ymid_SB->show(); - ui->ca_ymid_label->show(); - ui->ca_ymin_SB->hide(); - ui->ca_ymin_label->hide(); - ui->ca_ymid_SB->setValue(0); - ui->ca_ymax_SB->setValue(100); - break; - } -} - -void ModelEdit::on_ca_apply_PB_clicked() -{ - int index=ui->ca_ctype_CB->currentIndex(); - float x; - int y; - int invert=0; - float a; - if (index==0) { - a=(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/200.0; - int numpoints=g_model.curves[currentCurve].count; - for (int i=0; ica_ymin_SB->value()+a*x; - switch (ui->ca_side_CB->currentIndex()) { - case 0: - g_model.curves[currentCurve].points[i].y=y; - break; - case 1: - if (x>=100) { - g_model.curves[currentCurve].points[i].y=y; - } - break; - case 2: - if (x<100) { - g_model.curves[currentCurve].points[i].y=y; - } - break; - } - } - } else if (index==1) { - int numpoints=g_model.curves[currentCurve].count; - for (int i=0; ica_coeff_SB->value(); - if (a>=0) { - y=round(c9xexpou(x,a)*(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/100.0+ui->ca_ymin_SB->value()); - } else { - a=-a; - x=100-x; - y=round((100.0-c9xexpou(x,a))*(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/100.0+ui->ca_ymin_SB->value()); - } - switch (ui->ca_side_CB->currentIndex()) { - case 0: - g_model.curves[currentCurve].points[i].y=y; - break; - case 1: - if (x>=50) { - g_model.curves[currentCurve].points[i].y=y; - } - break; - case 2: - if (x<50) { - g_model.curves[currentCurve].points[i].y=y; - } - break; - } - } - } else if (index==2) { - int numpoints=g_model.curves[currentCurve].count; - for (int i=0; ica_coeff_SB->value(); - if (x<0) { - x=-x; - invert=1; - } else { - invert=0; - } - if (a>=0) { - y=round(c9xexpou(x,a)*(ui->ca_ymax_SB->value()/100.0)); - } else { - a=-a; - x=100-x; - y=round((100.0-c9xexpou(x,a))*(ui->ca_ymax_SB->value()/100.0)); - } - switch (ui->ca_side_CB->currentIndex()) { - case 0: - if (invert==1) { - g_model.curves[currentCurve].points[i].y=-y; - } else { - g_model.curves[currentCurve].points[i].y=y; - } - break; - case 1: - if (invert==0) { - g_model.curves[currentCurve].points[i].y=y; - } - break; - case 2: - if (invert==1) { - g_model.curves[currentCurve].points[i].y=-y; - } - break; - } - } - } else if (index==3) { - int numpoints=g_model.curves[currentCurve].count; - for (int i=0; i=0); - a=ui->ca_coeff_SB->value(); - if (x<0) { - x=-x; - } - if (a>=0) { - y=round(c9xexpou(x,a)*((ui->ca_ymax_SB->value()-ui->ca_ymid_SB->value())/100.0)+ui->ca_ymid_SB->value()); - } else { - a=-a; - x=100-x; - y=round((100.0-c9xexpou(x,a))*((ui->ca_ymax_SB->value()-ui->ca_ymid_SB->value())/100.0)+ui->ca_ymid_SB->value()); - } - switch (ui->ca_side_CB->currentIndex()) { - case 0: - g_model.curves[currentCurve].points[i].y=y; - break; - case 1: - if (pos) { - g_model.curves[currentCurve].points[i].y=y; - } - break; - case 2: - if (!pos) { - g_model.curves[currentCurve].points[i].y=y; - } - break; - } - } - } - updateSettings(); - setCurrentCurve(currentCurve); - drawCurve(); -} - -void ModelEdit::limitSymEdited() -{ - QCheckBox *ckb = qobject_cast(sender()); - int limitId=ckb->objectName().mid(ckb->objectName().lastIndexOf("_")+1).toInt()-1; - g_model.limitData[limitId].symetrical = (ckb->checkState() ? 1 : 0); - updateSettings(); -} - -void ModelEdit::limitNameEdited() -{ - if(limitEditLock) return; - limitEditLock=true; - QLineEdit *le = qobject_cast(sender()); - int limitId=le->objectName().mid(le->objectName().lastIndexOf("_")+1).toInt()-1; - int i=0; - if (le->text()==tr("CH %1").arg(limitId+1)) { - le->setText(""); - } - for (i=0; itext().toAscii().length(); i++) { - g_model.limitData[limitId].name[i]=le->text().toAscii().at(i); - } - if (le->text().trimmed().isEmpty()) { - le->setText(tr("CH %1").arg(limitId+1)); - } - g_model.limitData[limitId].name[i]=0; - updateSettings(); - tabMixes(); - limitEditLock=false; -} - - -void ModelEdit::limitOffsetEdited() -{ - QDoubleSpinBox *dsb = qobject_cast(sender()); - int limitId=dsb->objectName().mid(dsb->objectName().lastIndexOf("_")+1).toInt()-1; - g_model.limitData[limitId].offset = round(dsb->value()*10); - updateSettings(); -} - -void ModelEdit::limitEdited() -{ - QSpinBox *sb = qobject_cast(sender()); - int limitId=sb->objectName().mid(sb->objectName().lastIndexOf("_")+1).toInt()-1; - if (sb->objectName().indexOf("max")!=-1) { - g_model.limitData[limitId].max = sb->value(); - } - else { - g_model.limitData[limitId].min = sb->value(); - } - updateSettings(); -} - -void ModelEdit::limitInvEdited() -{ - QComboBox *cb = qobject_cast(sender()); - int limitId=cb->objectName().mid(cb->objectName().lastIndexOf("_")+1).toInt()-1; - g_model.limitData[limitId].revert = cb->currentIndex(); - updateSettings(); -} - -void ModelEdit::ppmcenterEdited() -{ - QSpinBox *sb = qobject_cast(sender()); - int limitId=sb->objectName().mid(sb->objectName().lastIndexOf("_")+1).toInt()-1; - g_model.limitData[limitId].ppmCenter = sb->value()-1500; - updateSettings(); -} - -void ModelEdit::startupSwitchEdited() -{ - if (GetEepromInterface()->getCapability(Pots)==3) { - uint8_t i= 0; - i|=(uint8_t)ui->swwarn0_CB->currentIndex(); - if (i==1) { - ui->swwarn1_ChkB->setDisabled(true) ; - ui->swwarn2_ChkB->setDisabled(true) ; - ui->swwarn3_ChkB->setDisabled(true) ; - ui->swwarn4_CB->setDisabled(true) ; - ui->swwarn5_ChkB->setDisabled(true) ; - ui->swwarn6_ChkB->setDisabled(true) ; - } else { - ui->swwarn1_ChkB->setEnabled(true) ; - ui->swwarn2_ChkB->setEnabled(true) ; - ui->swwarn3_ChkB->setEnabled(true) ; - ui->swwarn4_CB->setEnabled(true) ; - ui->swwarn5_ChkB->setEnabled(true) ; - ui->swwarn6_ChkB->setEnabled(true) ; - i|=(ui->swwarn1_ChkB->isChecked() ? 1 : 0)<<1; - i|=(ui->swwarn2_ChkB->isChecked() ? 1 : 0)<<2; - i|=(ui->swwarn3_ChkB->isChecked() ? 1 : 0)<<3; - i|=((uint8_t)ui->swwarn4_CB->currentIndex() & 0x03)<<4; - i|=(ui->swwarn5_ChkB->isChecked() ? 1 : 0)<<6; - i|=(ui->swwarn6_ChkB->isChecked() ? 1 : 0)<<7; - } - g_model.switchWarningStates=i; - } else { - uint16_t i= 0; - i|=(uint16_t)ui->tswwarn0_CB->currentIndex(); - if (i==1) { - ui->chkSA->setDisabled(true); - ui->chkSB->setDisabled(true); - ui->chkSC->setDisabled(true); - ui->chkSD->setDisabled(true); - ui->chkSE->setDisabled(true); - ui->chkSF->setDisabled(true); - ui->chkSG->setDisabled(true); - } else { - ui->chkSA->setEnabled(true); - ui->chkSB->setEnabled(true); - ui->chkSC->setEnabled(true); - ui->chkSD->setEnabled(true); - ui->chkSE->setEnabled(true); - ui->chkSF->setEnabled(true); - ui->chkSG->setEnabled(true); - i|=(((uint16_t)ui->chkSA->value())<<1); - i|=(((uint16_t)ui->chkSB->value())<<3); - i|=(((uint16_t)ui->chkSC->value())<<5); - i|=(((uint16_t)ui->chkSD->value())<<7); - i|=(((uint16_t)ui->chkSE->value())<<9); - i|=(((uint16_t)ui->chkSF->value())<<12); - i|=(((uint16_t)ui->chkSG->value())<<13); - } - g_model.switchWarningStates=i; - } - updateSettings(); -} - -void ModelEdit::setCurrentCurve(int curveId) -{ - currentCurve = curveId; - curvesLock=true; - QString ss = "QSpinBox { background-color:rgb(255, 255, 127);}"; - for (int i=0; ishow(); - spny[i]->setValue(g_model.curves[currentCurve].points[i].y); - if (!g_model.curves[currentCurve].custom || i==0 || i==(g_model.curves[currentCurve].count-1)) { - spnx[i]->hide(); - if (i==0) { - spnx[i]->setValue(-100); - } - if (i==(g_model.curves[currentCurve].count-1)) { - spnx[i]->setValue(100); - } - } else { - spnx[i]->show(); - spnx[i]->setMaximum(g_model.curves[currentCurve].points[i+1].x-1); - spnx[i]->setMinimum(g_model.curves[currentCurve].points[i-1].x+1); - spnx[i]->setValue(g_model.curves[currentCurve].points[i].x); - } - } - for (int i=g_model.curves[currentCurve].count; i<17;i++) { - spny[i]->hide(); - spnx[i]->hide(); - } - int index=0; - if (g_model.curves[currentCurve].count==3) { - index=0; - } else if (g_model.curves[currentCurve].count==5) { - index=2; - } else if (g_model.curves[currentCurve].count==9) { - index=4; - } else if (g_model.curves[currentCurve].count==17) { - index=6; - } - if (g_model.curves[currentCurve].custom) { - index++; - } - if (!GetEepromInterface()->getCapability(HasCvNames)){ - ui->cname_LE->hide(); - ui->cname_label->hide(); - } else { - ui->cname_LE->setText(g_model.curves[currentCurve].name); - } - - ui->curvetype_CB->setCurrentIndex(index); - curvesLock=false; -} - -void ModelEdit::curvePointEdited() -{ - if (curvesLock) { - return; - } - /* for (int i=1; i< g_model.curves[currentCurve].count-1; i++) { - if (g_model.curves[currentCurve].points[i].x>(100-g_model.curves[currentCurve].count+i)) { - g_model.curves[currentCurve].points[i].x=(100-g_model.curves[currentCurve].count+i); - } - if (g_model.curves[currentCurve].points[i].x<=g_model.curves[currentCurve].points[i-1].x) { - spnx[i]->setValue(spnx[i-1]->value()+1); - } - } - */ - for (int i=0; i< 17; i++) { - g_model.curves[currentCurve].points[i].x=spnx[i]->value(); - g_model.curves[currentCurve].points[i].y=spny[i]->value(); - } - if (redrawCurve) - drawCurve(); - updateSettings(); -} - - -void ModelEdit::setSwitchWidgetVisibility(int i) -{ - RawSource source=RawSource(g_model.customSw[i].val1); - switch (getCSFunctionFamily(g_model.customSw[i].func)) - { - case CS_FAMILY_VOFS: - cswitchSource1[i]->setVisible(true); - cswitchSource2[i]->setVisible(false); - cswitchValue[i]->setVisible(false); - cswitchOffset[i]->setVisible(true); - populateSourceCB(cswitchSource1[i], source, POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); - cswitchOffset[i]->setDecimals(source.getDecimals(g_model)); - cswitchOffset[i]->setSingleStep(source.getStep(g_model)); - if (g_model.customSw[i].func>CS_FN_ELESS && g_model.customSw[i].funcsetMinimum(source.getStep(g_model)*-127); - cswitchOffset[i]->setMaximum(source.getStep(g_model)*127); - cswitchOffset[i]->setValue(source.getStep(g_model)*g_model.customSw[i].val2); - } else { - cswitchOffset[i]->setMinimum(source.getMin(g_model)); - cswitchOffset[i]->setMaximum(source.getMax(g_model)); - cswitchOffset[i]->setValue(source.getStep(g_model)*(g_model.customSw[i].val2+source.getRawOffset(g_model))+source.getOffset(g_model)); - } - break; - case CS_FAMILY_VBOOL: - cswitchSource1[i]->setVisible(true); - cswitchSource2[i]->setVisible(true); - cswitchValue[i]->setVisible(false); - cswitchOffset[i]->setVisible(false); - populateSwitchCB(cswitchSource1[i], RawSwitch(g_model.customSw[i].val1)); - populateSwitchCB(cswitchSource2[i], RawSwitch(g_model.customSw[i].val2)); - break; - case CS_FAMILY_VCOMP: - cswitchSource1[i]->setVisible(true); - cswitchSource2[i]->setVisible(true); - cswitchValue[i]->setVisible(false); - cswitchOffset[i]->setVisible(false); - populateSourceCB(cswitchSource1[i], RawSource(g_model.customSw[i].val1), POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); - populateSourceCB(cswitchSource2[i], RawSource(g_model.customSw[i].val2), POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); - break; - case CS_FAMILY_TIMERS: - cswitchSource1[i]->setVisible(false); - cswitchSource2[i]->setVisible(false); - cswitchValue[i]->setVisible(true); - cswitchOffset[i]->setVisible(true); - cswitchOffset[i]->setDecimals(1); - cswitchOffset[i]->setMinimum(0.1); - cswitchOffset[i]->setMaximum(175); - float value=ValToTim(g_model.customSw[i].val2); - cswitchOffset[i]->setSingleStep(0.1); - if (value>60) { - cswitchOffset[i]->setSingleStep(1); - } else if (value>2) { - cswitchOffset[i]->setSingleStep(0.5); - } - cswitchOffset[i]->setValue(value); - - cswitchValue[i]->setDecimals(1); - cswitchValue[i]->setMinimum(0.1); - cswitchValue[i]->setMaximum(175); - value=ValToTim(g_model.customSw[i].val1); - cswitchValue[i]->setSingleStep(0.1); - if (value>60) { - cswitchValue[i]->setSingleStep(1); - } else if (value>2) { - cswitchValue[i]->setSingleStep(0.5); - } - cswitchValue[i]->setValue(value); - break; - } - cswitchAnd[i]->setVisible(true); - populateSwitchCB(cswitchAnd[i], RawSwitch(g_model.customSw[i].andsw), POPULATE_AND_SWITCHES); - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { - cswitchDuration[i]->setVisible(true); - cswitchDuration[i]->setValue(g_model.customSw[i].duration/2.0); - cswitchDelay[i]->setVisible(true); - cswitchDelay[i]->setValue(g_model.customSw[i].delay/2.0); - } -} - -void ModelEdit::updateSwitchesTab() -{ - switchEditLock = true; - int num_csw=GetEepromInterface()->getCapability(CustomSwitches); - for (int i=0; i< num_csw; i++) { - populateCSWCB(csw[i], g_model.customSw[i].func); - setSwitchWidgetVisibility(i); - } - switchEditLock = false; -} - -void ModelEdit::tabCustomSwitches() -{ - switchEditLock = true; - QComboBox* tmpcsw[C9X_NUM_CSW] = {ui->cswitchFunc_1, ui->cswitchFunc_2, ui->cswitchFunc_3, ui->cswitchFunc_4, - ui->cswitchFunc_5, ui->cswitchFunc_6, ui->cswitchFunc_7, ui->cswitchFunc_8, - ui->cswitchFunc_9, ui->cswitchFunc_10, ui->cswitchFunc_11, ui->cswitchFunc_12, - ui->cswitchFunc_13, ui->cswitchFunc_14, ui->cswitchFunc_15, ui->cswitchFunc_16, - ui->cswitchFunc_17, ui->cswitchFunc_18, ui->cswitchFunc_19, ui->cswitchFunc_20, - ui->cswitchFunc_21, ui->cswitchFunc_22, ui->cswitchFunc_23, ui->cswitchFunc_24, - ui->cswitchFunc_25, ui->cswitchFunc_26, ui->cswitchFunc_27, ui->cswitchFunc_28, - ui->cswitchFunc_29, ui->cswitchFunc_30, ui->cswitchFunc_31, ui->cswitchFunc_32 }; - QLabel* cswlabel[C9X_NUM_CSW] = { ui->cswlabel_01, ui->cswlabel_02, ui->cswlabel_03, ui->cswlabel_04, - ui->cswlabel_05, ui->cswlabel_06, ui->cswlabel_07, ui->cswlabel_08, - ui->cswlabel_09, ui->cswlabel_10, ui->cswlabel_11, ui->cswlabel_12, - ui->cswlabel_13, ui->cswlabel_14, ui->cswlabel_15, ui->cswlabel_16, - ui->cswlabel_17, ui->cswlabel_18, ui->cswlabel_19, ui->cswlabel_20, - ui->cswlabel_21, ui->cswlabel_22, ui->cswlabel_23, ui->cswlabel_24, - ui->cswlabel_25, ui->cswlabel_26, ui->cswlabel_27, ui->cswlabel_28, - ui->cswlabel_29, ui->cswlabel_30, ui->cswlabel_31, ui->cswlabel_32}; - - memcpy(csw, tmpcsw, sizeof(csw)); - int num_csw=GetEepromInterface()->getCapability(CustomSwitches); - for(int i=0; i<16; i++) { - if (isetProperty("index",i); - cswitchSource1[i] = new QComboBox(this); - cswitchSource1[i]->setProperty("index",i); - connect(cswitchSource1[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customSwitchesEdited())); - ui->gridLayout_21->addWidget(cswitchSource1[i],i+1,2); - cswitchSource1[i]->setVisible(false); - cswitchValue[i] = new QDoubleSpinBox(this); - cswitchValue[i]->setMaximum(125); - cswitchValue[i]->setMinimum(-125); - cswitchValue[i]->setAccelerated(true); - cswitchValue[i]->setDecimals(0); - cswitchValue[i]->setProperty("index",i); - connect(cswitchValue[i],SIGNAL(editingFinished()),this,SLOT(customSwitchesEdited())); - ui->gridLayout_21->addWidget(cswitchValue[i],i+1,2); - cswitchValue[i]->setVisible(false); - - cswitchSource2[i] = new QComboBox(this); - cswitchSource2[i]->setProperty("index",i); - connect(cswitchSource2[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customSwitchesEdited())); - ui->gridLayout_21->addWidget(cswitchSource2[i],i+1,3); - cswitchSource2[i]->setVisible(false); - - cswitchOffset[i] = new QDoubleSpinBox(this); - cswitchOffset[i]->setProperty("index",i); - cswitchOffset[i]->setMaximum(125); - cswitchOffset[i]->setMinimum(-125); - cswitchOffset[i]->setAccelerated(true); - cswitchOffset[i]->setDecimals(0); - connect(cswitchOffset[i],SIGNAL(editingFinished()),this,SLOT(customSwitchesEdited())); - ui->gridLayout_21->addWidget(cswitchOffset[i],i+1,3); - cswitchOffset[i]->setVisible(false); - cswitchAnd[i] = new QComboBox(this); - cswitchAnd[i]->setProperty("index",i); - connect(cswitchAnd[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customSwitchesEdited())); - ui->gridLayout_21->addWidget(cswitchAnd[i],i+1,4); - cswitchAnd[i]->setVisible(false); - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { - cswitchDuration[i] = new QDoubleSpinBox(this); - cswitchDuration[i]->setProperty("index",i); - cswitchDuration[i]->setSingleStep(0.5); - cswitchDuration[i]->setMaximum(50); - cswitchDuration[i]->setMinimum(0); - cswitchDuration[i]->setAccelerated(true); - cswitchDuration[i]->setDecimals(1); - connect(cswitchDuration[i],SIGNAL(editingFinished()),this,SLOT(customSwitchesEdited())); - ui->gridLayout_21->addWidget(cswitchDuration[i],i+1,5); - cswitchDuration[i]->setVisible(false); - - cswitchDelay[i] = new QDoubleSpinBox(this); - cswitchDelay[i]->setProperty("index",i); - cswitchDelay[i]->setSingleStep(0.5); - cswitchDelay[i]->setMaximum(50); - cswitchDelay[i]->setMinimum(0); - cswitchDelay[i]->setAccelerated(true); - cswitchDelay[i]->setDecimals(1); - connect(cswitchDelay[i],SIGNAL(editingFinished()),this,SLOT(customSwitchesEdited())); - ui->gridLayout_21->addWidget(cswitchDelay[i],i+1,6); - cswitchDelay[i]->setVisible(false); - } else { - ui->cswCol3->hide(); - ui->cswCol4->hide(); - } - connect(cswlabel[i],SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(csw_customContextMenuRequested(QPoint))); - } else { - csw[i]->hide(); - cswlabel[i]->hide(); - } - } - if (num_csw>16) { - for(int i=16; i<32; i++) { - if (i<=num_csw) { - tmpcsw[i]->setProperty("index",i); - cswitchSource1[i] = new QComboBox(this); - cswitchSource1[i]->setProperty("index",i); - connect(cswitchSource1[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customSwitchesEdited())); - ui->gridLayout_22->addWidget(cswitchSource1[i],i-15,2); - cswitchSource1[i]->setVisible(false); - cswitchValue[i] = new QDoubleSpinBox(this); - cswitchValue[i]->setProperty("index",i); - cswitchValue[i]->setMaximum(125); - cswitchValue[i]->setMinimum(-125); - cswitchValue[i]->setAccelerated(true); - cswitchValue[i]->setDecimals(0); - connect(cswitchValue[i],SIGNAL(editingFinished()),this,SLOT(customSwitchesEdited())); - ui->gridLayout_22->addWidget(cswitchValue[i],i-15,2); - cswitchValue[i]->setVisible(false); - - cswitchSource2[i] = new QComboBox(this); - cswitchSource2[i]->setProperty("index",i); - connect(cswitchSource2[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customSwitchesEdited())); - ui->gridLayout_22->addWidget(cswitchSource2[i],i-15,3); - cswitchSource2[i]->setVisible(false); - - cswitchOffset[i] = new QDoubleSpinBox(this); - cswitchOffset[i]->setProperty("index",i); - cswitchOffset[i]->setMaximum(125); - cswitchOffset[i]->setMinimum(-125); - cswitchOffset[i]->setAccelerated(true); - cswitchOffset[i]->setDecimals(0); - connect(cswitchOffset[i],SIGNAL(editingFinished()),this,SLOT(customSwitchesEdited())); - ui->gridLayout_22->addWidget(cswitchOffset[i],i-15,3); - cswitchOffset[i]->setVisible(false); - cswitchAnd[i] = new QComboBox(this); - cswitchAnd[i]->setProperty("index",i); - connect(cswitchAnd[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customSwitchesEdited())); - ui->gridLayout_22->addWidget(cswitchAnd[i],i-15,4); - cswitchAnd[i]->setVisible(false); - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { - cswitchDuration[i] = new QDoubleSpinBox(this); - cswitchDuration[i]->setProperty("index",i); - cswitchDuration[i]->setSingleStep(0.5); - cswitchDuration[i]->setMaximum(50); - cswitchDuration[i]->setMinimum(0); - cswitchDuration[i]->setAccelerated(true); - cswitchDuration[i]->setDecimals(1); - connect(cswitchDuration[i],SIGNAL(editingFinished()),this,SLOT(customSwitchesEdited())); - ui->gridLayout_22->addWidget(cswitchDuration[i],i-15,5); - cswitchDuration[i]->setVisible(false); - - cswitchDelay[i] = new QDoubleSpinBox(this); - cswitchDelay[i]->setProperty("index",i); - cswitchDelay[i]->setSingleStep(0.5); - cswitchDelay[i]->setMaximum(50); - cswitchDelay[i]->setMinimum(0); - cswitchDelay[i]->setAccelerated(true); - cswitchDelay[i]->setDecimals(1); - connect(cswitchDelay[i],SIGNAL(editingFinished()),this,SLOT(customSwitchesEdited())); - ui->gridLayout_22->addWidget(cswitchDelay[i],i-15,6); - cswitchDelay[i]->setVisible(false); - } else { - ui->cswCol3_2->hide(); - ui->cswCol4_2->hide(); - } - connect(cswlabel[i],SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(csw_customContextMenuRequested(QPoint))); - } else { - csw[i]->hide(); - cswlabel[i]->hide(); - } - } - } else { - ui->cswitchGB2->hide(); - } - updateSwitchesTab(); - //connects - for (int i=0; igetCapability(CustomFunctions); - - QStringList paramarmList; - if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) { - for (int i=0; igetCapability(VoicesMaxLength)+4; - if (qd.exists()) { - QStringList filters; - filters << "*.wav" << "*.WAV"; - foreach ( QString file, qd.entryList(filters, QDir::Files) ) { - QFileInfo fi(file); - QString temp=fi.completeBaseName(); - if (!paramarmList.contains(temp) && temp.length()<=vml) { - paramarmList.append(temp); - } - } - } - } - - for (int i=0; i= 16 ? ui->fswitchlayout2 : ui->fswitchlayout1; - - fswLabel[i] = new QLabel(this); - fswLabel[i]->setFrameStyle(QFrame::Panel | QFrame::Raised); - fswLabel[i]->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed); - fswLabel[i]->setContextMenuPolicy(Qt::CustomContextMenu); - fswLabel[i]->setMouseTracking(true); - fswLabel[i]->setProperty("FunctionId", i+1); - fswLabel[i]->setText(tr("CF%1").arg(i+1)); - layout->addWidget(fswLabel[i],(i%16)+1,0); - connect(fswLabel[i],SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(fsw_customContextMenuRequested(QPoint))); - - fswtchSwtch[i] = new QComboBox(this); - fswtchSwtch[i]->setProperty("functionIndex", i); - connect(fswtchSwtch[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customFunctionEdited())); - layout->addWidget(fswtchSwtch[i],(i%16)+1,1); - populateSwitchCB(fswtchSwtch[i], g_model.funcSw[i].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF); - - fswtchFunc[i] = new QComboBox(this); - fswtchFunc[i]->setProperty("functionIndex", i); - connect(fswtchFunc[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customFunctionEdited())); - layout->addWidget(fswtchFunc[i],(i%16)+1,2); - populateFuncCB(fswtchFunc[i], g_model.funcSw[i].func); - - QHBoxLayout *paramLayout = new QHBoxLayout(); - layout->addLayout(paramLayout, (i%16)+1, 3); - - fswtchGVmode[i] = new QComboBox(this); - fswtchGVmode[i]->setProperty("functionIndex", i); - connect(fswtchGVmode[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customFunctionEdited())); - paramLayout->addWidget(fswtchGVmode[i]); - populateGVmodeCB(fswtchGVmode[i], g_model.funcSw[i].adjustMode); - - fswtchParamGV[i] = new QCheckBox(this); - fswtchParamGV[i]->setProperty("functionIndex", i); - fswtchParamGV[i]->setText("GV"); - fswtchParamGV[i]->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); - connect(fswtchParamGV[i],SIGNAL(stateChanged(int)),this,SLOT(customFunctionEdited())); - paramLayout->addWidget(fswtchParamGV[i]); - - fswtchParam[i] = new QDoubleSpinBox(this); - fswtchParam[i]->setProperty("functionIndex", i); - fswtchParam[i]->setAccelerated(true); - fswtchParam[i]->setDecimals(0); - connect(fswtchParam[i],SIGNAL(editingFinished()),this,SLOT(customFunctionEdited())); - paramLayout->addWidget(fswtchParam[i]); - - fswtchParamT[i] = new QComboBox(this); - fswtchParamT[i]->setProperty("functionIndex", i); - paramLayout->addWidget(fswtchParamT[i]); - populateFuncParamCB(fswtchParamT[i], func, g_model.funcSw[i].param, g_model.funcSw[i].adjustMode); - connect(fswtchParamT[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customFunctionEdited())); - - fswtchParamArmT[i] = new QComboBox(this); - fswtchParamArmT[i]->setProperty("functionIndex", i); - populateFuncParamArmTCB(fswtchParamArmT[i],&g_model, g_model.funcSw[i].paramarm, paramarmList); - fswtchParamArmT[i]->setEditable(true); - paramLayout->addWidget(fswtchParamArmT[i]); - - connect(fswtchParamArmT[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customFunctionEdited())); - connect(fswtchParamArmT[i],SIGNAL(editTextChanged ( const QString)),this,SLOT(customFunctionEdited())); - -#ifdef PHONON - playBT[i] = new QPushButton(this); - playBT[i]->setObjectName(QString("play_%1").arg(i)); - playBT[i]->setIcon(QIcon(":/images/play.png")); - paramLayout->addWidget(playBT[i]); - connect(playBT[i],SIGNAL(pressed()),this,SLOT(playMusic())); -#endif - - QHBoxLayout *repeatLayout = new QHBoxLayout(); - layout->addLayout(repeatLayout, (i%16)+1, 4); - - fswtchRepeat[i] = new QComboBox(this); - fswtchRepeat[i]->setProperty("functionIndex", i); - connect(fswtchRepeat[i],SIGNAL(currentIndexChanged(int)),this,SLOT(customFunctionEdited())); - repeatLayout->addWidget(fswtchRepeat[i],(i%16)+1); - populateRepeatCB(fswtchRepeat[i], g_model.funcSw[i].repeatParam); - - fswtchEnable[i] = new QCheckBox(this); - fswtchEnable[i]->setProperty("functionIndex", i); - fswtchEnable[i]->setText(tr("ON")); - repeatLayout->addWidget(fswtchEnable[i],(i%16)+1); - fswtchEnable[i]->setChecked(g_model.funcSw[i].enabled); - connect(fswtchEnable[i],SIGNAL(stateChanged(int)),this,SLOT(customFunctionEdited())); - - refreshCustomFunction(i); - } - - if (num_fsw <= 16) { - ui->FSwitchGB2->hide(); - } - - switchEditLock = false; -} - -void ModelEdit::tabSafetySwitches() -{ - for(int i=0; igrid_tabSafetySwitches->addWidget(safetySwitchSwtch[i],i+1,1); - connect(safetySwitchSwtch[i],SIGNAL(currentIndexChanged(int)),this,SLOT(safetySwitchesEdited())); - - safetySwitchValue[i] = new QSpinBox(this); - safetySwitchValue[i]->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - safetySwitchValue[i]->setMaximum(125); - safetySwitchValue[i]->setMinimum(-125); - safetySwitchValue[i]->setAccelerated(true); - safetySwitchValue[i]->setValue(g_model.safetySw[i].val); - ui->grid_tabSafetySwitches->addWidget(safetySwitchValue[i],i+1,2); - connect(safetySwitchValue[i],SIGNAL(editingFinished()),this,SLOT(safetySwitchesEdited())); - } -} - -void ModelEdit::customFieldEdited() -{ - if (telemetryLock) return; - int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields); - if (cols==0) cols=2; - - for (int i=0; igetCapability(TelemetryCSFields); i++) { - int screen=i/(4*cols); - int r=((i%(4*cols))%4); - int c=((i%(4*cols))/4); - if (g_model.frsky.screens[screen].type==0) { - g_model.frsky.screens[screen].body.lines[r].source[c]=csf[i]->currentIndex(); - } - } - updateSettings(); -} - -void ModelEdit::customSwitchesEdited() -{ - if(switchEditLock) return; - - switchEditLock = true; - int i=-1; - QString indextext=sender()->property("index").toString(); - if (!indextext.isEmpty()) { - i=indextext.toInt(); - } else { - // should not happen - switchEditLock = false; - return; - } - bool chAr; - float value, step; - int newval; - chAr = (getCSFunctionFamily(g_model.customSw[i].func) != getCSFunctionFamily(csw[i]->itemData(csw[i]->currentIndex()).toInt())); - g_model.customSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt(); - if(chAr) { - if (getCSFunctionFamily(g_model.customSw[i].func)==CS_FAMILY_TIMERS) { - g_model.customSw[i].val1 = -119; - g_model.customSw[i].val2 = -119; - } else { - g_model.customSw[i].val1 = 0; - g_model.customSw[i].val2 = 0; - } - g_model.customSw[i].andsw = 0; - setSwitchWidgetVisibility(i); - } - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { - g_model.customSw[i].duration= (uint8_t)round(cswitchDuration[i]->value()*2); - g_model.customSw[i].delay= (uint8_t)round(cswitchDelay[i]->value()*2); - } - RawSource source; - switch (getCSFunctionFamily(g_model.customSw[i].func)) - { - case (CS_FAMILY_VOFS): - if (g_model.customSw[i].val1 != cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt()) { - source=RawSource(g_model.customSw[i].val1); - g_model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt(); - RawSource newSource = RawSource(g_model.customSw[i].val1); - if (newSource.type == SOURCE_TYPE_TELEMETRY) { - if (g_model.customSw[i].func>CS_FN_ELESS && g_model.customSw[i].funcCS_FN_ELESS && g_model.customSw[i].funcvalue()/source.getStep(g_model)); - } else { - g_model.customSw[i].val2 = ((cswitchOffset[i]->value()-source.getOffset(g_model))/source.getStep(g_model))-source.getRawOffset(g_model); - } - } - setSwitchWidgetVisibility(i); - } else { - source=RawSource(g_model.customSw[i].val1); - if (g_model.customSw[i].func>CS_FN_ELESS && g_model.customSw[i].funcvalue()/source.getStep(g_model)); - cswitchOffset[i]->setValue(g_model.customSw[i].val2*source.getStep(g_model)); - } else { - g_model.customSw[i].val2 = ((cswitchOffset[i]->value()-source.getOffset(g_model))/source.getStep(g_model))-source.getRawOffset(g_model); - cswitchOffset[i]->setValue((g_model.customSw[i].val2 +source.getRawOffset(g_model))*source.getStep(g_model)+source.getOffset(g_model)); - } - } - break; - case (CS_FAMILY_TIMERS): { - value=cswitchOffset[i]->value(); - newval=TimToVal(value); - if (newval>g_model.customSw[i].val2) { - if (value >=60) { - value=round(value); - step=1; - } else if (value>=2) { - value=(round(value*2.0)/2); - step=0.5; - } else { - step=0.1; - } - } else { - if (value <=2) { - step=0.1; - } else if (value<=60) { - value=(round(value*2.0)/2); - step=0.5; - } else { - value=round(value); - step=1; - } - } - g_model.customSw[i].val2=TimToVal(value); - value=ValToTim(g_model.customSw[i].val2); - cswitchOffset[i]->setValue(value); - cswitchOffset[i]->setSingleStep(step); - - value=cswitchValue[i]->value(); - newval=TimToVal(value); - if (newval>g_model.customSw[i].val1) { - if (value >=60) { - value=round(value); - step=1; - } else if (value>=2) { - value=(round(value*2.0)/2); - step=0.5; - } else { - step=0.1; - } - } else { - if (value <=2) { - step=0.1; - } else if (value<=60) { - value=(round(value*2.0)/2); - step=0.5; - } else { - value=round(value); - step=1; - } - } - g_model.customSw[i].val1=TimToVal(value); - value=ValToTim(g_model.customSw[i].val1); - cswitchValue[i]->setValue(value); - cswitchValue[i]->setSingleStep(step); - break; - } - case (CS_FAMILY_VBOOL): - case (CS_FAMILY_VCOMP): - g_model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt(); - g_model.customSw[i].val2 = cswitchSource2[i]->itemData(cswitchSource2[i]->currentIndex()).toInt(); - break; - } - g_model.customSw[i].andsw = cswitchAnd[i]->itemData(cswitchAnd[i]->currentIndex()).toInt(); - updateSettings(); - switchEditLock = false; -} - -#ifdef PHONON - -void ModelEdit::mediaPlayer_state(Phonon::State newState, Phonon::State oldState) -{ - if (phononLock) - return; - phononLock=true; - if ((newState==Phonon::StoppedState || newState==Phonon::PausedState) && oldState==Phonon::PlayingState) { - clickObject->stop(); - clickObject->clearQueue(); - clickObject->clear(); - for (int i=0; igetCapability(CustomFunctions); i++) { - playBT[i]->setObjectName(QString("play_%1").arg(i)); - playBT[i]->setIcon(QIcon(":/images/play.png")); - } - } - if (newState==Phonon::ErrorState) { - clickObject->stop(); - clickObject->clearQueue(); - clickObject->clear(); - for (int i=0; igetCapability(CustomFunctions); i++) { - playBT[i]->setObjectName(QString("play_%1").arg(i)); - playBT[i]->setIcon(QIcon(":/images/play.png")); - } - } - - phononLock=false; -} -#endif - -void ModelEdit::playMusic() -{ - QPushButton *playButton = qobject_cast(sender()); - int index=playButton->objectName().mid(5,2).toInt(); - QString function=playButton->objectName().left(4); - QSettings settings("companion9x", "companion9x"); - QString path=settings.value("sdPath", ".").toString(); - QDir qd(path); - QString track; - if (qd.exists()) { - if (GetEepromInterface()->getCapability(VoicesAsNumbers)) { - track=path+QString("/%1.wav").arg(int(fswtchParam[index]->value()),4,10,(const QChar)'0'); - } else { - path.append("/SOUNDS/"); - QString lang=radioData.generalSettings.ttsLanguage; - if (lang.isEmpty()) - lang="en"; - path.append(lang); - if (fswtchParamArmT[index]->currentText()!="----") { - track=path+"/"+fswtchParamArmT[index]->currentText()+".wav"; - } - } - QFile file(track); - if (!file.exists()) { - QMessageBox::critical(this, tr("Error"), tr("Unable to find sound file %1!").arg(track)); - track.clear(); - } -#ifdef PHONON - if (function=="play" && !track.isEmpty()) { - clickObject->clear(); - clickObject->setCurrentSource(Phonon::MediaSource(track)); - clickObject->play(); - playBT[index]->setObjectName(QString("stop_%1").arg(index)); - playBT[index]->setIcon(QIcon(":/images/stop.png")); - } else { - clickObject->stop(); - clickObject->clear(); - playBT[index]->setObjectName(QString("play_%1").arg(index)); - playBT[index]->setIcon(QIcon(":/images/play.png")); - } -#endif - } -} - -#define CUSTOM_FUNCTION_NUMERIC_PARAM (1<<0) -#define CUSTOM_FUNCTION_SOURCE_PARAM (1<<1) -#define CUSTOM_FUNCTION_FILE_PARAM (1<<2) -#define CUSTOM_FUNCTION_GV_MODE (1<<3) -#define CUSTOM_FUNCTION_GV_TOOGLE (1<<4) -#define CUSTOM_FUNCTION_ENABLE (1<<5) -#define CUSTOM_FUNCTION_REPEAT (1<<6) -#define CUSTOM_FUNCTION_PLAY (1<<7) - -void ModelEdit::customFunctionEdited() -{ - if (switchEditLock) return; - switchEditLock = true; - - int index = sender()->property("functionIndex").toInt(); - refreshCustomFunction(index, true); - - updateSettings(); - switchEditLock = false; -} - -void ModelEdit::refreshCustomFunction(int i, bool modified) -{ - unsigned int widgetsMask = 0; - if (modified) { - g_model.funcSw[i].swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt()); - g_model.funcSw[i].func = (AssignFunc)fswtchFunc[i]->currentIndex(); - g_model.funcSw[i].enabled =fswtchEnable[i]->isChecked(); - g_model.funcSw[i].repeatParam = (AssignFunc)fswtchRepeat[i]->currentIndex(); - g_model.funcSw[i].adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex(); - } - - int index = fswtchFunc[i]->currentIndex(); - - if (index>=FuncSafetyCh1 && index<=FuncSafetyCh16) { - fswtchParam[i]->setDecimals(0); - fswtchParam[i]->setSingleStep(1); - fswtchParam[i]->setMinimum(-125); - fswtchParam[i]->setMaximum(125); - if (modified) { - g_model.funcSw[i].param = fswtchParam[i]->value(); - } - fswtchParam[i]->setValue(g_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) g_model.funcSw[i].param = fswtchParam[i]->value()*10.0; - fswtchParam[i]->setValue(g_model.funcSw[i].param/10.0); - widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE; - } else if (index>=FuncAdjustGV1 && index<=FuncAdjustGV5) { - if (modified) g_model.funcSw[i].adjustMode = fswtchGVmode[i]->currentIndex(); - widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE; - if (g_model.funcSw[i].adjustMode==0) { - if (modified) g_model.funcSw[i].param = fswtchParam[i]->value(); - fswtchParam[i]->setDecimals(0); - fswtchParam[i]->setSingleStep(1); - fswtchParam[i]->setMinimum(-125); - fswtchParam[i]->setMaximum(125); - fswtchParam[i]->setValue(g_model.funcSw[i].param); - widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; - } else { - if (modified) g_model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); - populateFuncParamCB(fswtchParamT[i], index, g_model.funcSw[i].param, g_model.funcSw[i].adjustMode); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; - } - } else if (index==FuncReset) { - if (modified) g_model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); - populateFuncParamCB(fswtchParamT[i], index, g_model.funcSw[i].param); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; - } else if (index==FuncVolume) { - if (modified) g_model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); - populateFuncParamCB(fswtchParamT[i], index, g_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 (modified) g_model.funcSw[i].repeatParam = fswtchRepeat[i]->itemData(fswtchRepeat[i]->currentIndex()).toInt(); - if (index != FuncBackgroundMusic) { - if (GetEepromInterface()->getCapability(HasFuncRepeat)) { - widgetsMask |= CUSTOM_FUNCTION_REPEAT; - } - } - if (index==FuncPlayValue) { - if (modified) g_model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); - populateFuncParamCB(fswtchParamT[i], index, g_model.funcSw[i].param); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT; - } else if (index==FuncPlayPrompt || index==FuncPlayBoth) { - if (GetEepromInterface()->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); - g_model.funcSw[i].param = std::min(fswtchParam[i]->value(),5.0)+(fswtchParamGV[i]->isChecked() ? 250 : 0); - } else { - g_model.funcSw[i].param = fswtchParam[i]->value(); - } - } - if (g_model.funcSw[i].param>250 && (index!=FuncPlayBoth)) { - fswtchParamGV[i]->setChecked(true); - fswtchParam[i]->setValue(g_model.funcSw[i].param-250); - fswtchParam[i]->setMaximum(5); - } else { - fswtchParamGV[i]->setChecked(false); - fswtchParam[i]->setValue(g_model.funcSw[i].param); - } - if (g_model.funcSw[i].param < 251) - widgetsMask |= CUSTOM_FUNCTION_PLAY; - } else { - widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; - if (modified) { - memset(g_model.funcSw[i].paramarm, 0, sizeof(g_model.funcSw[i].paramarm)); - int vml=GetEepromInterface()->getCapability(VoicesMaxLength); - if (fswtchParamArmT[i]->currentText() != "----") { - widgetsMask |= CUSTOM_FUNCTION_PLAY; - for (int j=0; jcurrentText().length(),vml); j++) { - g_model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); - } - } - } - } - } else if (index==FuncBackgroundMusic) { - widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; - if (modified) { - memset(g_model.funcSw[i].paramarm, 0, sizeof(g_model.funcSw[i].paramarm)); - int vml=GetEepromInterface()->getCapability(VoicesMaxLength); - if (fswtchParamArmT[i]->currentText() != "----") { - widgetsMask |= CUSTOM_FUNCTION_PLAY; - for (int j=0; jcurrentText().length(),vml); j++) { - g_model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); - } - } - } - } else if (index==FuncPlaySound) { - if (modified) g_model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); - populateFuncParamCB(fswtchParamT[i], index, g_model.funcSw[i].param); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; - } else if (index==FuncPlayHaptic) { - if (modified) g_model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); - populateFuncParamCB(fswtchParamT[i], index, g_model.funcSw[i].param); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; - } - } else if (g_model.funcSw[i].swtch.type!=SWITCH_TYPE_NONE) { - if (modified) g_model.funcSw[i].param = fswtchParam[i]->value(); - fswtchParam[i]->setDecimals(0); - fswtchParam[i]->setSingleStep(1); - fswtchParam[i]->setValue(g_model.funcSw[i].param); - if (index<=FuncInstantTrim) { - widgetsMask |= CUSTOM_FUNCTION_ENABLE; - } - } - - fswtchParam[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_NUMERIC_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(false); - fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT); - fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE); -#ifdef PHONON - playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY); -#endif -} - -void ModelEdit::tabTelemetry() -{ - QSettings settings("companion9x", "companion9x"); - QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); - float a1ratio; - float a2ratio; - - QGroupBox* barsgb[3] = { ui->CS1Bars, ui->CS2Bars, ui->CS3Bars }; - QGroupBox* numsgb[3] = { ui->CS1Nums, ui->CS2Nums, ui->CS3Nums }; - - QComboBox* barscb[12] = { ui->telBarCS1B1_CB, ui->telBarCS1B2_CB, ui->telBarCS1B3_CB, ui->telBarCS1B4_CB, - ui->telBarCS2B1_CB, ui->telBarCS2B2_CB, ui->telBarCS2B3_CB, ui->telBarCS2B4_CB, - ui->telBarCS3B1_CB, ui->telBarCS3B2_CB, ui->telBarCS3B3_CB, ui->telBarCS3B4_CB}; - QDoubleSpinBox* minsb[12] = { ui->telMinCS1SB1, ui->telMinCS1SB2, ui->telMinCS1SB3, ui->telMinCS1SB4, - ui->telMinCS2SB1, ui->telMinCS2SB2, ui->telMinCS2SB3, ui->telMinCS2SB4, - ui->telMinCS3SB1, ui->telMinCS3SB2, ui->telMinCS3SB3, ui->telMinCS3SB4}; - QDoubleSpinBox* maxsb[12] = { ui->telMaxCS1SB1, ui->telMaxCS1SB2, ui->telMaxCS1SB3, ui->telMaxCS1SB4, - ui->telMaxCS2SB1, ui->telMaxCS2SB2, ui->telMaxCS2SB3, ui->telMaxCS2SB4, - ui->telMaxCS3SB1, ui->telMaxCS3SB2, ui->telMaxCS3SB3, ui->telMaxCS3SB4}; - QComboBox* tmp[36] = { ui->telemetryCS1F1_CB, ui->telemetryCS1F2_CB, ui->telemetryCS1F3_CB, ui->telemetryCS1F4_CB, ui->telemetryCS1F5_CB, ui->telemetryCS1F6_CB, ui->telemetryCS1F7_CB, ui->telemetryCS1F8_CB, ui->telemetryCS1F9_CB, ui->telemetryCS1F10_CB, ui->telemetryCS1F11_CB, ui->telemetryCS1F12_CB, - ui->telemetryCS2F1_CB, ui->telemetryCS2F2_CB, ui->telemetryCS2F3_CB, ui->telemetryCS2F4_CB, ui->telemetryCS2F5_CB, ui->telemetryCS2F6_CB, ui->telemetryCS2F7_CB, ui->telemetryCS2F8_CB, ui->telemetryCS2F9_CB, ui->telemetryCS2F10_CB, ui->telemetryCS2F11_CB, ui->telemetryCS2F12_CB, - ui->telemetryCS3F1_CB, ui->telemetryCS3F2_CB, ui->telemetryCS3F3_CB, ui->telemetryCS3F4_CB, ui->telemetryCS3F5_CB, ui->telemetryCS3F6_CB, ui->telemetryCS3F7_CB, ui->telemetryCS3F8_CB, ui->telemetryCS3F9_CB, ui->telemetryCS3F10_CB, ui->telemetryCS3F11_CB, ui->telemetryCS3F12_CB}; - - memcpy(barsGB, barsgb, sizeof(barsGB)); - memcpy(numsGB, numsgb, sizeof(numsGB)); - memcpy(barsCB, barscb, sizeof(barsCB)); - memcpy(maxSB, maxsb, sizeof(maxSB)); - memcpy(minSB, minsb, sizeof(minSB)); - memcpy(csf, tmp, sizeof(csf)); - - telemetryLock=true; - ui->telemetryCSType1->setCurrentIndex(g_model.frsky.screens[0].type); - ui->telemetryCSType2->setCurrentIndex(g_model.frsky.screens[1].type); - ui->telemetryCSType3->setCurrentIndex(g_model.frsky.screens[2].type); - - for (int i=0; i<3; i++) { - bool isNum = (g_model.frsky.screens[i].type==0); - barsGB[i]->setVisible(!isNum); - numsGB[i]->setVisible(isNum); - } - - connect(ui->telemetryCSType1,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int))); - connect(ui->telemetryCSType2,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int))); - connect(ui->telemetryCSType3,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int))); - - //frsky Settings - if (!GetEepromInterface()->getCapability(TelemetryRSSIModel) ) { - ui->RSSIGB->hide(); - } - ui->rssiAlarm1SB->setValue(g_model.frsky.rssiAlarms[0].value); - ui->rssiAlarm2SB->setValue(g_model.frsky.rssiAlarms[1].value); - ui->rssiAlarm1CB->setCurrentIndex(g_model.frsky.rssiAlarms[0].level); - ui->rssiAlarm2CB->setCurrentIndex(g_model.frsky.rssiAlarms[1].level); - - if (!GetEepromInterface()->getCapability(HasAltitudeSel)) { - ui->AltitudeGPS_ChkB->hide(); - } else { - ui->AltitudeGPS_ChkB->setChecked(g_model.frsky.FrSkyGpsAlt); - } - int varioCap=GetEepromInterface()->getCapability(HasVario); - // if (IS_TARANIS(GetEepromInterface()->getBoard())) { - if (false) { - ui->AltitudeToolbar_ChkB->setChecked(g_model.frsky.altitudeDisplayed); - } else { - ui->AltitudeToolbar_ChkB->hide(); - } - if (!varioCap) { - ui->varioLimitMax_DSB->hide(); - ui->varioLimitMinOff_ChkB->hide(); - ui->varioLimitMin_DSB->hide(); - ui->varioLimitCenterMin_DSB->hide(); - ui->varioLimitCenterMax_DSB->hide(); - ui->varioLimit_label->hide(); - ui->VarioLabel_1->hide(); - ui->VarioLabel_2->hide(); - ui->VarioLabel_3->hide(); - ui->VarioLabel_4->hide(); - ui->varioSourceCB->hide(); - ui->varioSource_label->hide(); - } else { - if (!GetEepromInterface()->getCapability(HasVarioSink)) { - ui->varioLimitMinOff_ChkB->hide(); - ui->varioLimitMin_DSB->hide(); - ui->varioLimitCenterMin_DSB->hide(); - ui->VarioLabel_1->hide(); - ui->VarioLabel_2->hide(); - } - ui->varioLimitMin_DSB->setValue(g_model.frsky.varioMin-10); - ui->varioLimitMax_DSB->setValue(g_model.frsky.varioMax+10); - ui->varioLimitCenterMax_DSB->setValue((g_model.frsky.varioCenterMax/10.0)+0.5); - ui->varioSourceCB->setCurrentIndex(g_model.frsky.varioSource); - if (g_model.frsky.varioCenterMin==-16) { - ui->varioLimitMinOff_ChkB->setChecked(true); - ui->varioLimitCenterMin_DSB->setValue(-2.0); - ui->varioLimitCenterMin_DSB->setDisabled(true); - } else { - ui->varioLimitMinOff_ChkB->setChecked(false); - ui->varioLimitCenterMin_DSB->setValue((g_model.frsky.varioCenterMin/10.0)-0.5); - } - int mask=1; - for (int i=0; i< ui->varioSourceCB->count(); i++) { - if (!(varioCap&mask)) { - QModelIndex index = ui->varioSourceCB->model()->index(i, 0); - QVariant v(0); - ui->varioSourceCB->model()->setData(index, v, Qt::UserRole - 1); - } - mask <<=1; - } - } - - if (!(GetEepromInterface()->getCapability(HasAltitudeSel)||GetEepromInterface()->getCapability(HasVario))) { - ui->altimetryGB->hide(); - } - if (GetEepromInterface()->getCapability(NoTelemetryProtocol)) { - g_model.frsky.usrProto=1; - ui->frskyProtoCB->setDisabled(true); - } else { - ui->frskyProtoCB->setEnabled(true); - } - - if (GetEepromInterface()->getCapability(TelemetryCSFields)==0) { - ui->groupBox_5->hide(); - } else { - if (GetEepromInterface()->getCapability(TelemetryCSFields)==8) { - ui->tabCsView->removeTab(1); - ui->tabCsView->removeTab(2); - } - if (GetEepromInterface()->getCapability(TelemetryCSFields)==16) { - ui->tabCsView->removeTab(2); - } - int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields); - if (cols==0) cols=2; - for (int screen=0; screen<(GetEepromInterface()->getCapability(TelemetryCSFields)/(4*cols)); screen++) { - for (int c=0; chide(); - } - } - } - } - - if (!GetEepromInterface()->getCapability(TelemetryUnits)) { - ui->frskyUnitsCB->setDisabled(true); - int index=0; - if (firmware_id.contains("imperial")) { - index=1; - } - ui->frskyUnitsCB->setCurrentIndex(index); - } - if ((GetEepromInterface()->getCapability(Telemetry)&TM_HASWSHH)) { - ui->frskyProtoCB->addItem(tr("Winged Shadow How High")); - } else { - ui->frskyProtoCB->addItem(tr("Winged Shadow How High (not supported)")); - } - ui->a1UnitCB->setCurrentIndex(g_model.frsky.channels[0].type); - if (g_model.frsky.channels[0].type==0 || g_model.frsky.channels[0].type==1 || g_model.frsky.channels[0].type==2) { - a1ratio=(g_model.frsky.channels[0].ratio<a1RatioSB->setDecimals(1); - ui->a1RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); - } else { - a1ratio=g_model.frsky.channels[0].ratio<a1RatioSB->setDecimals(0); - ui->a1RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); - } - ui->a1RatioSB->setValue(a1ratio); - - updateA1Fields(); - - if (g_model.frsky.channels[1].type==0 || g_model.frsky.channels[1].type==1 || g_model.frsky.channels[1].type==2) { - a2ratio=(g_model.frsky.channels[1].ratio<a2RatioSB->setDecimals(1); - ui->a2RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); - } else { - a2ratio=g_model.frsky.channels[1].ratio<a2RatioSB->setDecimals(0); - ui->a2RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); - } - ui->a2RatioSB->setValue(a2ratio); - updateA2Fields(); - - ui->a11LevelCB->setCurrentIndex(g_model.frsky.channels[0].alarms[0].level); - ui->a11GreaterCB->setCurrentIndex(g_model.frsky.channels[0].alarms[0].greater); - ui->a12LevelCB->setCurrentIndex(g_model.frsky.channels[0].alarms[1].level); - ui->a12GreaterCB->setCurrentIndex(g_model.frsky.channels[0].alarms[1].greater); - ui->a2UnitCB->setCurrentIndex(g_model.frsky.channels[1].type); - ui->a21LevelCB->setCurrentIndex(g_model.frsky.channels[1].alarms[0].level); - ui->a21GreaterCB->setCurrentIndex(g_model.frsky.channels[1].alarms[0].greater); - ui->a22LevelCB->setCurrentIndex(g_model.frsky.channels[1].alarms[1].level); - ui->a22GreaterCB->setCurrentIndex(g_model.frsky.channels[1].alarms[1].greater); - if (!(GetEepromInterface()->getCapability(Telemetry)&TM_HASOFFSET)) { - ui->a1CalibSB->hide(); - ui->a2CalibSB->hide(); - ui->a1CalibLabel->hide(); - ui->a2CalibLabel->hide(); - } else { - ui->label_A1Max->setText(tr("Range")); - ui->label_A2Max->setText(tr("Range")); - } - ui->frskyProtoCB->setCurrentIndex(g_model.frsky.usrProto); - ui->frskyUnitsCB->setCurrentIndex(g_model.frsky.imperial); - ui->frskyBladesCB->setCurrentIndex(g_model.frsky.blades); - ui->frskyCurrentCB->setCurrentIndex(g_model.frsky.currentSource); - ui->frskyVoltCB->setCurrentIndex(g_model.frsky.voltsSource); - - for (int screen=0; screen<2;screen++) { - for (int rows=0; rows<4; rows++) { - for (int cols=0; cols<3; cols++) { - int index=screen*12+cols*4+rows; - populateCustomScreenFieldCB(csf[index], g_model.frsky.screens[screen].body.lines[rows].source[cols], (rows<4), g_model.frsky.usrProto); - } - } - } - - for (int j=0; j<12; j++) { - int screen = j/4; - int field = j%4; - populateCustomScreenFieldCB(barsCB[j], g_model.frsky.screens[screen].body.bars[field].source, false, g_model.frsky.usrProto); - switch (g_model.frsky.screens[screen].body.bars[field].source-1) { - case TELEMETRY_SOURCE_TX_BATT: - case TELEMETRY_SOURCE_A1: - case TELEMETRY_SOURCE_A1_MIN: - case TELEMETRY_SOURCE_A2: - case TELEMETRY_SOURCE_A2_MIN: - case TELEMETRY_SOURCE_CELLS_SUM: - case TELEMETRY_SOURCE_VFAS: - case TELEMETRY_SOURCE_CURRENT_MAX: - case TELEMETRY_SOURCE_CURRENT: - minsb[j]->setDecimals(1); - maxsb[j]->setDecimals(1); - break; - case TELEMETRY_SOURCE_CELL: - minsb[j]->setDecimals(2); - maxsb[j]->setDecimals(2); - break; - default: - minsb[j]->setDecimals(0); - maxsb[j]->setDecimals(0); - } - minsb[j]->setMinimum(getBarValue(g_model.frsky.screens[screen].body.bars[field].source, 0, &g_model.frsky)); - minsb[j]->setMaximum(getBarValue(g_model.frsky.screens[screen].body.bars[field].source, 255, &g_model.frsky)); - minsb[j]->setSingleStep(getBarStep(g_model.frsky.screens[screen].body.bars[field].source)); - minsb[j]->setValue(getBarValue(g_model.frsky.screens[screen].body.bars[field].source, g_model.frsky.screens[screen].body.bars[field].barMin, &g_model.frsky)); - maxsb[j]->setMinimum(getBarValue(g_model.frsky.screens[screen].body.bars[field].source, 0, &g_model.frsky)); - maxsb[j]->setMaximum(getBarValue(g_model.frsky.screens[screen].body.bars[field].source, 255, &g_model.frsky)); - maxsb[j]->setSingleStep(getBarStep(g_model.frsky.screens[screen].body.bars[field].source)); - maxsb[j]->setValue(getBarValue(g_model.frsky.screens[screen].body.bars[field].source, (255-g_model.frsky.screens[screen].body.bars[field].barMax), &g_model.frsky)); - - if (g_model.frsky.screens[screen].body.bars[field].source==0 || g_model.frsky.screens[screen].type==0) { - minsb[j]->setDisabled(true); - maxsb[j]->setDisabled(true); - } - connect(barsCB[j],SIGNAL(currentIndexChanged(int)),this,SLOT(telBarCBcurrentIndexChanged(int))); - connect(maxSB[j],SIGNAL(editingFinished()),this,SLOT(telMaxSBeditingFinished())); - connect(minSB[j],SIGNAL(editingFinished()),this,SLOT(telMinSBeditingFinished())); - } - telemetryLock=false; -} - -void ModelEdit::updateA1Fields() -{ - float a1ratio,a11value, a12value; - if (g_model.frsky.channels[0].ratio==0) { - ui->a11ValueSB->setMinimum(0); - ui->a11ValueSB->setMaximum(0); - ui->a12ValueSB->setMinimum(0); - ui->a12ValueSB->setMaximum(0); - ui->a1CalibSB->setMinimum(0); - ui->a1CalibSB->setMaximum(0); - ui->a1CalibSB->setValue(0); - ui->a11ValueSB->setValue(0); - ui->a12ValueSB->setValue(0); - return; - } - - if (g_model.frsky.channels[0].type==0 || g_model.frsky.channels[0].type==1 || g_model.frsky.channels[0].type==2) { - a1ratio=(g_model.frsky.channels[0].ratio<a11ValueSB->setDecimals(2); - ui->a11ValueSB->setSingleStep(a1ratio/255.0); - ui->a12ValueSB->setDecimals(2); - ui->a12ValueSB->setSingleStep(a1ratio/255.0); - ui->a11ValueSB->setMinimum((g_model.frsky.channels[0].ratio*1.0*g_model.frsky.channels[0].offset)/2550.0); - ui->a11ValueSB->setMaximum(a1ratio+(g_model.frsky.channels[0].ratio*1.0*g_model.frsky.channels[0].offset)/2550.0); - ui->a12ValueSB->setMinimum((g_model.frsky.channels[0].offset*1.0*g_model.frsky.channels[0].ratio)/2550.0); - ui->a12ValueSB->setMaximum(a1ratio+(g_model.frsky.channels[0].offset*1.0*g_model.frsky.channels[0].ratio)/2550.0); - } else { - a1ratio=g_model.frsky.channels[0].ratio<a11ValueSB->setDecimals(2); - ui->a11ValueSB->setSingleStep(a1ratio/255.0); - ui->a12ValueSB->setDecimals(2); - ui->a12ValueSB->setSingleStep(a1ratio/255.0); - ui->a11ValueSB->setMinimum((g_model.frsky.channels[0].offset*1.0*g_model.frsky.channels[0].ratio)/255.0); - ui->a11ValueSB->setMaximum(a1ratio+(g_model.frsky.channels[0].offset*1.0*g_model.frsky.channels[0].ratio)/255.0); - ui->a12ValueSB->setMinimum((g_model.frsky.channels[0].offset*1.0*g_model.frsky.channels[0].ratio)/255.0); - ui->a12ValueSB->setMaximum(a1ratio+(g_model.frsky.channels[0].offset*1.0*g_model.frsky.channels[0].ratio)/255.0); - } - ui->a1CalibSB->setDecimals(2); - ui->a1CalibSB->setMaximum((a1ratio*127)/255.0); - ui->a1CalibSB->setMinimum((-a1ratio*128)/255.0); - ui->a1CalibSB->setSingleStep(a1ratio/255.0); - ui->a1CalibSB->setValue((g_model.frsky.channels[0].offset*a1ratio)/255); - a11value=a1ratio*(g_model.frsky.channels[0].alarms[0].value/255.0+g_model.frsky.channels[0].offset/255.0); - a12value=a1ratio*(g_model.frsky.channels[0].alarms[1].value/255.0+g_model.frsky.channels[0].offset/255.0);; - ui->a11ValueSB->setValue(a11value); - ui->a12ValueSB->setValue(a12value); -} - -void ModelEdit::updateA2Fields() -{ - float a2ratio,a21value, a22value; - if (g_model.frsky.channels[1].ratio==0) { - ui->a21ValueSB->setMinimum(0); - ui->a21ValueSB->setMaximum(0); - ui->a22ValueSB->setMinimum(0); - ui->a22ValueSB->setMaximum(0); - ui->a2CalibSB->setMinimum(0); - ui->a2CalibSB->setMaximum(0); - ui->a2CalibSB->setValue(0); - ui->a21ValueSB->setValue(0); - ui->a22ValueSB->setValue(0); - return; - } - if (g_model.frsky.channels[1].type==0) { - a2ratio=g_model.frsky.channels[1].ratio/10.0; - ui->a21ValueSB->setDecimals(2); - ui->a21ValueSB->setSingleStep(a2ratio/255.0); - ui->a22ValueSB->setDecimals(2); - ui->a22ValueSB->setSingleStep(a2ratio/255.0); - ui->a21ValueSB->setMinimum((g_model.frsky.channels[1].offset*1.0*g_model.frsky.channels[1].ratio)/2550.0); - ui->a21ValueSB->setMaximum(a2ratio+(g_model.frsky.channels[1].offset*1.0*g_model.frsky.channels[1].ratio)/2550.0); - ui->a22ValueSB->setMinimum((g_model.frsky.channels[1].offset*1.0*g_model.frsky.channels[1].ratio*1.0)/2550.0); - ui->a22ValueSB->setMaximum(a2ratio+(g_model.frsky.channels[1].offset*1.0*g_model.frsky.channels[1].ratio)/2550.0); - } else { - a2ratio=g_model.frsky.channels[1].ratio; - ui->a21ValueSB->setDecimals(2); - ui->a21ValueSB->setSingleStep(a2ratio/255.0); - ui->a22ValueSB->setDecimals(2); - ui->a22ValueSB->setSingleStep(a2ratio/255.0); - ui->a21ValueSB->setMinimum((g_model.frsky.channels[1].offset*1.0*g_model.frsky.channels[1].ratio)/255.0); - ui->a21ValueSB->setMaximum(a2ratio+(g_model.frsky.channels[1].offset*1.0*g_model.frsky.channels[1].ratio)/255.0); - ui->a22ValueSB->setMinimum((g_model.frsky.channels[1].offset*1.0*g_model.frsky.channels[1].ratio)/255.0); - ui->a22ValueSB->setMaximum(a2ratio+(g_model.frsky.channels[1].offset*1.0*g_model.frsky.channels[1].ratio)/255.0); - } - ui->a2CalibSB->setDecimals(2); - ui->a2CalibSB->setMaximum((a2ratio*127)/255.0); - ui->a2CalibSB->setMinimum((-a2ratio*128)/255.0); - ui->a2CalibSB->setSingleStep(a2ratio/255.0); - ui->a2CalibSB->setValue((g_model.frsky.channels[1].offset*a2ratio)/255.0); - a21value=a2ratio*(g_model.frsky.channels[1].alarms[0].value/255.0+g_model.frsky.channels[1].offset/255.0); - a22value=a2ratio*(g_model.frsky.channels[1].alarms[1].value/255.0+g_model.frsky.channels[1].offset/255.0); - ui->a21ValueSB->setValue(a21value); - ui->a22ValueSB->setValue(a22value); -} - -void ModelEdit::tabTemplates() -{ - ui->templateList->clear(); - ui->templateList->addItem(tr("Simple 4-CH")); - ui->templateList->addItem(tr("T-Cut")); - ui->templateList->addItem(tr("Sticky T-Cut")); - ui->templateList->addItem(tr("V-Tail")); - ui->templateList->addItem(tr("Elevon\\Delta")); - ui->templateList->addItem(tr("Heli Setup")); - ui->templateList->addItem(tr("Heli Setup with gyro gain control")); - ui->templateList->addItem(tr("Gyro gain control")); - ui->templateList->addItem(tr("Heli Setup (Futaba's channel assignment style)")); - ui->templateList->addItem(tr("Heli Setup with gyro gain control (Futaba's channel assignment style)")); - ui->templateList->addItem(tr("Gyro gain control (Futaba's channel assignment style)")); - ui->templateList->addItem(tr("Servo Test")); - ui->templateList->addItem(tr("MultiCopter")); - ui->templateList->addItem(tr("Use Model Config Wizard")); -} - -void ModelEdit::on_modelNameLE_editingFinished() -{ - int length=ui->modelNameLE->maxLength(); - strncpy(g_model.name, ui->modelNameLE->text().toAscii(), length); - updateSettings(); -} - -void ModelEdit::on_modelImage_CB_currentIndexChanged(int index) -{ - if (modelImageLock) - return; - strncpy(g_model.bitmap, ui->modelImage_CB->currentText().toAscii(), GetEepromInterface()->getCapability(VoicesMaxLength)); - QSettings settings("companion9x", "companion9x"); - QString path=settings.value("sdPath", ".").toString(); - path.append("/BMP/"); - QDir qd(path); - if (qd.exists()) { - QString fileName=path; - fileName.append(g_model.bitmap); - fileName.append(".bmp"); - QImage image(fileName); - if (image.isNull()) { - fileName=path; - fileName.append(g_model.bitmap); - fileName.append(".BMP"); - image.load(fileName); - } - if (!image.isNull()) { - ui->modelImage_image->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));; - } else { - ui->modelImage_image->clear(); - } - } else { - ui->modelImage_image->clear(); - } - updateSettings(); -} - -void ModelEdit::phaseName_editingFinished() -{ - QLineEdit *lineEdit = qobject_cast(sender()); - int phase = lineEdit->objectName().mid(5,1).toInt(); - QString PhaseName=lineEdit->text(); - QString TabName; - if (phase==0) { - TabName.append(QObject::tr("Flight Mode 0 (Default)")); - } else { - TabName.append(QObject::tr("FM %1").arg(phase)); - } - - if (!PhaseName.isEmpty()) { - TabName.append(" ("); - TabName.append(PhaseName); - TabName.append(")"); - } - ui->phases->setTabText(phase,TabName); - int length=lineEdit->maxLength(); - strncpy(g_model.phaseData[phase].name, lineEdit->text().toAscii(), length); - updateSettings(); -} - -void ModelEdit::phaseSwitch_currentIndexChanged() -{ - QComboBox *comboBox = qobject_cast(sender()); - int phase = comboBox->objectName().mid(5,1).toInt(); - g_model.phaseData[phase].swtch = RawSwitch(comboBox->itemData(comboBox->currentIndex()).toInt()); - updateSettings(); -} - -void ModelEdit::phaseFadeIn_editingFinished() -{ - QDoubleSpinBox *spinBox = qobject_cast(sender()); - int phase = spinBox->objectName().mid(5,1).toInt(); - int scale=GetEepromInterface()->getCapability(SlowScale); - g_model.phaseData[phase].fadeIn = round(spinBox->value()*scale); - updateSettings(); -} - -void ModelEdit::phaseFadeOut_editingFinished() -{ - QDoubleSpinBox *spinBox = qobject_cast(sender()); - int phase = spinBox->objectName().mid(5,1).toInt(); - int scale=GetEepromInterface()->getCapability(SlowScale); - g_model.phaseData[phase].fadeOut = round(spinBox->value()*scale); - updateSettings(); -} - -void ModelEdit::on_timer1ModeCB_currentIndexChanged(int index) -{ - g_model.timers[0].mode = TimerMode(ui->timer1ModeCB->itemData(index).toInt()); - updateSettings(); -} - -void ModelEdit::on_timer1DirCB_currentIndexChanged(int index) -{ - g_model.timers[0].dir = index; - updateSettings(); -} - -void ModelEdit::on_timer1ValTE_editingFinished() -{ - g_model.timers[0].val = ui->timer1ValTE->time().minute()*60 + ui->timer1ValTE->time().second(); - updateSettings(); -} - -void ModelEdit::on_timer1ModeBCB_currentIndexChanged(int index) -{ - g_model.timers[0].modeB = ui->timer1ModeBCB->itemData(index).toInt(); - updateSettings(); -} - -void ModelEdit::on_timer2ModeCB_currentIndexChanged(int index) -{ - g_model.timers[1].mode = TimerMode(ui->timer2ModeCB->itemData(index).toInt()); - updateSettings(); -} - -void ModelEdit::on_timer2DirCB_currentIndexChanged(int index) -{ - g_model.timers[1].dir = index; - updateSettings(); -} - -void ModelEdit::on_timer2ValTE_editingFinished() -{ - g_model.timers[1].val = ui->timer2ValTE->time().minute()*60 + ui->timer2ValTE->time().second(); - updateSettings(); -} - -void ModelEdit::on_timer2ModeBCB_currentIndexChanged(int index) -{ - g_model.timers[1].modeB = ui->timer2ModeBCB->itemData(index).toInt(); - updateSettings(); -} - -void ModelEdit::on_trimIncCB_currentIndexChanged(int index) -{ - g_model.trimInc = index; - updateSettings(); -} - -void ModelEdit::on_ttraceCB_currentIndexChanged(int index) -{ - g_model.thrTraceSrc = index; - updateSettings(); -} - -void ModelEdit::on_pulsePolCB_currentIndexChanged(int index) -{ - g_model.moduleData[0].ppmPulsePol = index; - updateSettings(); -} - -void ModelEdit::on_pulsePolCB_2_currentIndexChanged(int index) -{ - g_model.moduleData[1].ppmPulsePol = index; - updateSettings(); -} - -void ModelEdit::on_pulsePolCB_3_currentIndexChanged(int index) -{ - g_model.moduleData[2].ppmPulsePol = index; - updateSettings(); -} - -void ModelEdit::on_protocolCB_currentIndexChanged(int index) -{ - if (!protocolEditLock) { - protocolEditLock=true; - - g_model.moduleData[0].protocol=(Protocol)ui->protocolCB->itemData(index).toInt(); - int protocol=g_model.moduleData[0].protocol; - // g_model.protocol = (Protocol)index; - if (protocol==PXX_XJT_D8 || protocol==OFF) { - ui->FSGB_1->hide(); - } else { - ui->fsm1CB->setCurrentIndex(g_model.moduleData[0].failsafeMode); - on_fsm1CB_currentIndexChanged(g_model.moduleData[0].failsafeMode); - ui->FSGB_1->show(); - } - updateSettings(); - - ui->ppmDelaySB->setEnabled(!protocol); - ui->numChannelsSB->setEnabled(!protocol); - - if (GetEepromInterface()->getCapability(HasPPMStart)) { - ui->numChannelsSB->setSingleStep(1); - } else { - ui->numChannelsSB->setSingleStep(2); - } - - switch (protocol) { - case OFF: - ui->label_PPM->hide(); - ui->ppmDelaySB->hide(); - ui->label_PPMCH->hide(); - ui->label_pulsePol->hide(); - ui->pulsePolCB->hide(); - ui->numChannelsSB->hide(); - ui->label_ppmFrameLength->hide(); - ui->ppmFrameLengthDSB->hide(); - ui->label_DSM->hide(); - ui->DSM_Type->hide(); - ui->label_PXX->hide(); - ui->pxxRxNum->hide(); - ui->label_numChannelsStart->hide(); - ui->numChannelsStart->hide(); - break; - case PXX_XJT_X16: - case PXX_XJT_D8: - case PXX_XJT_LR12: - case PXX_DJT: - ui->label_PPM->hide(); - ui->ppmDelaySB->hide(); - ui->ppmDelaySB->setEnabled(false); - ui->label_PPMCH->show(); - ui->label_pulsePol->hide(); - ui->pulsePolCB->hide(); - ui->numChannelsSB->show(); - ui->numChannelsSB->setEnabled(true); - ui->label_ppmFrameLength->hide(); - ui->ppmFrameLengthDSB->hide(); - ui->ppmFrameLengthDSB->setEnabled(false); - ui->label_DSM->hide(); - ui->DSM_Type->hide(); - ui->DSM_Type->setEnabled(false); - ui->label_PXX->show(); - ui->pxxRxNum->setMinimum(0); - ui->pxxRxNum->show(); - ui->pxxRxNum->setEnabled(true); - ui->pxxRxNum->setValue((g_model.moduleData[0].channelsCount-8)/2+1); - ui->label_numChannelsStart->show(); - ui->numChannelsStart->show(); - ui->numChannelsStart->setValue(g_model.moduleData[0].channelsStart+1); - ui->numChannelsSB->setMinimum(g_model.moduleData[0].channelsStart+4); - ui->numChannelsSB->setValue(g_model.moduleData[0].channelsStart+g_model.moduleData[0].channelsCount); - break; - case LP45: - case DSM2: - case DSMX: - ui->label_pulsePol->hide(); - ui->pulsePolCB->hide(); - ui->label_PPM->hide(); - ui->ppmDelaySB->hide(); - ui->ppmDelaySB->setEnabled(false); - ui->label_PPMCH->hide(); - ui->label_numChannelsStart->hide(); - ui->numChannelsStart->hide(); - ui->numChannelsSB->hide(); - ui->numChannelsSB->setEnabled(false); - ui->label_ppmFrameLength->hide(); - ui->ppmFrameLengthDSB->hide(); - ui->ppmFrameLengthDSB->setEnabled(false); - if (!GetEepromInterface()->getCapability(DSM2Indexes)) { - ui->label_PXX->hide(); - ui->pxxRxNum->hide(); - ui->pxxRxNum->setEnabled(false); - } - else { - ui->pxxRxNum->setMinimum(0); - ui->pxxRxNum->setValue(g_model.modelId); - ui->label_PXX->show(); - ui->pxxRxNum->show(); - ui->pxxRxNum->setEnabled(true); - } - ui->DSM_Type->setEnabled(false); - ui->label_DSM->hide(); - ui->DSM_Type->hide(); - break; - default: - if (GetEepromInterface()->getCapability(HasPPMStart)) { - ui->label_numChannelsStart->show(); - ui->numChannelsStart->show(); - } - else { - ui->label_numChannelsStart->hide(); - ui->numChannelsStart->hide(); - } - ui->numChannelsStart->setValue(g_model.moduleData[0].channelsStart+1); - ui->numChannelsSB->setMinimum(g_model.moduleData[0].channelsStart+4); - ui->numChannelsSB->setValue(g_model.moduleData[0].channelsStart + g_model.moduleData[0].channelsCount); - ui->label_pulsePol->show(); - ui->pulsePolCB->show(); - ui->label_DSM->hide(); - ui->DSM_Type->hide(); - ui->DSM_Type->setEnabled(false); - ui->label_PXX->hide(); - ui->pxxRxNum->hide(); - ui->pxxRxNum->setEnabled(false); - ui->label_PPM->show(); - ui->ppmDelaySB->show(); - ui->ppmDelaySB->setEnabled(true); - ui->label_PPMCH->show(); - ui->numChannelsSB->show(); - ui->numChannelsSB->setEnabled(true); - ui->ppmFrameLengthDSB->setEnabled(true); - ui->ppmFrameLengthDSB->setMinimum(g_model.moduleData[0].channelsCount*(g_model.extendedLimits ? 2.250 :2)+3.5); - if (GetEepromInterface()->getCapability(PPMExtCtrl)) { - ui->ppmFrameLengthDSB->show(); - ui->label_ppmFrameLength->show(); - } - - break; - } - protocolEditLock=false; - } -} - -void ModelEdit::on_protocolCB_2_currentIndexChanged(int index) -{ - if (!protocol2EditLock) { - protocol2EditLock=true; - - g_model.moduleData[1].protocol=(Protocol)ui->protocolCB_2->itemData(index).toInt(); - int protocol=g_model.moduleData[1].protocol; - if (protocol==PXX_XJT_X16 || protocol==PXX_XJT_LR12) { - ui->FSGB_2->show(); - ui->fsm2CB->setCurrentIndex(g_model.moduleData[1].failsafeMode); - on_fsm2CB_currentIndexChanged(g_model.moduleData[1].failsafeMode); - } else { - ui->FSGB_2->hide(); - } - // g_model.protocol = (Protocol)index; - updateSettings(); - - ui->ppmDelaySB_2->setEnabled(!protocol); - ui->numChannelsSB_2->setEnabled(!protocol); - - if (GetEepromInterface()->getCapability(HasPPMStart)) { - ui->numChannelsSB_2->setSingleStep(1); - } else { - ui->numChannelsSB_2->setSingleStep(2); - } - - switch (protocol) { - case OFF: - ui->label_PPM_2->hide(); - ui->ppmDelaySB_2->hide(); - ui->label_PPMCH_2->hide(); - ui->label_pulsePol_2->hide(); - ui->pulsePolCB_2->hide(); - ui->numChannelsSB_2->hide(); - ui->label_ppmFrameLength_2->hide(); - ui->ppmFrameLengthDSB_2->hide(); - ui->label_DSM_2->hide(); - ui->DSM_Type_2->hide(); - ui->label_PXX_2->hide(); - ui->pxxRxNum_2->hide(); - ui->label_numChannelsStart_2->hide(); - ui->numChannelsStart_2->hide(); - break; - case PXX_XJT_X16: - case PXX_XJT_D8: - case PXX_XJT_LR12: - case PXX_DJT: - ui->label_PPM_2->hide(); - ui->ppmDelaySB_2->hide(); - ui->ppmDelaySB_2->setEnabled(false); - ui->label_PPMCH_2->show(); - ui->label_pulsePol_2->hide(); - ui->pulsePolCB_2->hide(); - ui->numChannelsSB_2->show(); - ui->numChannelsSB_2->setEnabled(true); - ui->label_ppmFrameLength_2->hide(); - ui->ppmFrameLengthDSB_2->hide(); - ui->ppmFrameLengthDSB_2->setEnabled(false); - ui->label_DSM_2->hide(); - ui->DSM_Type_2->hide(); - ui->DSM_Type_2->setEnabled(false); - ui->label_PXX_2->show(); - ui->pxxRxNum_2->setMinimum(0); - ui->pxxRxNum_2->show(); - ui->pxxRxNum_2->setEnabled(true); - ui->pxxRxNum_2->setValue(g_model.modelId); - ui->label_numChannelsStart_2->show(); - ui->numChannelsStart_2->show(); - ui->numChannelsStart_2->setValue(g_model.moduleData[1].channelsStart+1); - ui->numChannelsSB_2->setMinimum(g_model.moduleData[1].channelsStart+4); - ui->numChannelsSB_2->setValue(g_model.moduleData[1].channelsStart+g_model.moduleData[1].channelsCount); - break; - case LP45: - case DSM2: - case DSMX: - ui->label_pulsePol_2->hide(); - ui->pulsePolCB_2->hide(); - ui->label_PPM_2->hide(); - ui->ppmDelaySB_2->hide(); - ui->ppmDelaySB_2->setEnabled(false); - ui->label_PPMCH_2->hide(); - ui->numChannelsSB_2->hide(); - ui->numChannelsSB_2->setEnabled(false); - ui->label_ppmFrameLength_2->hide(); - ui->ppmFrameLengthDSB_2->hide(); - ui->ppmFrameLengthDSB_2->setEnabled(false); - if (!GetEepromInterface()->getCapability(DSM2Indexes)) { - ui->label_PXX_2->hide(); - ui->pxxRxNum_2->hide(); - ui->pxxRxNum_2->setEnabled(false); - } else { - ui->pxxRxNum_2->setMinimum(0); - ui->pxxRxNum_2->setValue(g_model.modelId); - ui->label_PXX_2->show(); - ui->pxxRxNum_2->show(); - ui->pxxRxNum_2->setEnabled(true); - } - ui->DSM_Type_2->setEnabled(false); - ui->label_DSM_2->hide(); - ui->DSM_Type_2->hide(); - break; - default: - if (GetEepromInterface()->getCapability(HasPPMStart)) { - ui->label_numChannelsStart_2->show(); - ui->numChannelsStart_2->show(); - } else { - ui->label_numChannelsStart_2->hide(); - ui->numChannelsStart_2->hide(); - } - ui->numChannelsStart_2->setValue(g_model.moduleData[1].channelsStart+1); - ui->numChannelsSB_2->setMinimum(g_model.moduleData[1].channelsStart+4); - ui->numChannelsSB_2->setValue(g_model.moduleData[1].channelsStart+g_model.moduleData[1].channelsCount); - ui->label_pulsePol_2->show(); - ui->pulsePolCB_2->show(); - ui->pulsePolCB_2->setCurrentIndex(g_model.moduleData[1].ppmPulsePol); - ui->label_DSM_2->hide(); - ui->DSM_Type_2->hide(); - ui->DSM_Type_2->setEnabled(false); - ui->label_PXX_2->hide(); - ui->pxxRxNum_2->hide(); - ui->pxxRxNum_2->setEnabled(false); - ui->label_PPM_2->show(); - ui->ppmDelaySB_2->show(); - ui->ppmDelaySB_2->setEnabled(true); - ui->ppmDelaySB_2->setValue(g_model.moduleData[1].ppmDelay); - ui->label_PPMCH_2->show(); - ui->numChannelsSB_2->show(); - ui->numChannelsSB_2->setEnabled(true); - ui->ppmFrameLengthDSB_2->setEnabled(true); - ui->ppmFrameLengthDSB_2->setMinimum(g_model.moduleData[1].channelsCount*(g_model.extendedLimits ? 2.250 :2)+3.5); - if (GetEepromInterface()->getCapability(PPMExtCtrl)) { - ui->ppmFrameLengthDSB_2->show(); - ui->label_ppmFrameLength_2->show(); - ui->ppmFrameLengthDSB_2->setValue(g_model.moduleData[1].ppmFrameLength/2.0+22.5); - } - break; - } - protocol2EditLock=false; - } -} - -void ModelEdit::on_protocolCB_3_currentIndexChanged(int index) -{ - if (!trainerEditLock) { - trainerEditLock=true; - - g_model.moduleData[2].protocol=ui->protocolCB_3->currentIndex(); - g_model.trainerMode=ui->protocolCB_3->currentIndex(); - updateSettings(); - switch (index) { - case 0: - ui->label_PPM_3->hide(); - ui->ppmDelaySB_3->hide(); - ui->label_PPMCH_3->hide(); - ui->label_pulsePol_3->hide(); - ui->pulsePolCB_3->hide(); - ui->numChannelsSB_3->hide(); - ui->label_ppmFrameLength_3->hide(); - ui->ppmFrameLengthDSB_3->hide(); - ui->label_numChannelsStart_3->hide(); - ui->numChannelsStart_3->hide(); - break; - default: - ui->label_PPM_3->show(); - ui->ppmDelaySB_3->show(); - ui->label_PPMCH_3->show(); - ui->label_pulsePol_3->show(); - ui->pulsePolCB_3->show(); - ui->numChannelsSB_3->show(); - ui->label_ppmFrameLength_3->show(); - ui->ppmFrameLengthDSB_3->show(); - ui->label_numChannelsStart_3->show(); - ui->numChannelsStart_3->show(); - ui->numChannelsStart_3->setValue(g_model.moduleData[2].channelsStart+1); - ui->numChannelsSB_3->setMinimum(g_model.moduleData[2].channelsStart+4); - ui->numChannelsSB_3->setValue(g_model.moduleData[2].channelsStart+g_model.moduleData[2].channelsCount); - ui->pulsePolCB_3->setCurrentIndex(g_model.moduleData[2].ppmPulsePol); - ui->ppmDelaySB_3->setValue(g_model.moduleData[2].ppmDelay); - ui->ppmFrameLengthDSB_3->setMinimum(g_model.moduleData[2].channelsCount*(g_model.extendedLimits ? 2.250 :2)+3.5); - if (GetEepromInterface()->getCapability(PPMExtCtrl)) { - ui->ppmFrameLengthDSB_3->show(); - ui->label_ppmFrameLength_3->show(); - ui->ppmFrameLengthDSB_3->setValue(g_model.moduleData[2].ppmFrameLength/2.0+22.5); - } - break; - } - trainerEditLock=false; - } -} - - -void ModelEdit::on_numChannelsSB_editingFinished() -{ - // TODO only accept valid values - g_model.moduleData[0].channelsCount = 1+ui->numChannelsSB->value()-ui->numChannelsStart->value(); - ui->ppmFrameLengthDSB->setMinimum(g_model.moduleData[0].channelsCount*(g_model.extendedLimits ? 2.250 :2)+3.5); - updateSettings(); -} - -void ModelEdit::on_numChannelsSB_2_editingFinished() -{ - // TODO only accept valid values - g_model.moduleData[1].channelsCount = 1+ui->numChannelsSB_2->value()-ui->numChannelsStart_2->value(); - ui->ppmFrameLengthDSB_2->setMinimum(g_model.moduleData[1].channelsCount*(g_model.extendedLimits ? 2.250 :2.0)+3.5); - updateSettings(); -} - -void ModelEdit::on_numChannelsSB_3_editingFinished() -{ - // TODO only accept valid values - g_model.moduleData[2].channelsCount = 1+ui->numChannelsSB_3->value()-ui->numChannelsStart_3->value(); - ui->ppmFrameLengthDSB_3->setMinimum(g_model.moduleData[2].channelsCount*(g_model.extendedLimits ? 2.250 :2)+3.5); - updateSettings(); -} - -void ModelEdit::on_numChannelsStart_editingFinished() -{ - // TODO only accept valid values - g_model.moduleData[0].channelsStart = ui->numChannelsStart->value()-1; - ui->numChannelsSB->setMinimum(g_model.moduleData[0].channelsStart+4); - ui->numChannelsSB->setValue(g_model.moduleData[0].channelsStart+g_model.moduleData[0].channelsCount); - updateSettings(); -} - -void ModelEdit::on_numChannelsStart_2_editingFinished() -{ - // TODO only accept valid values - g_model.moduleData[1].channelsStart = ui->numChannelsStart_2->value()-1; - ui->numChannelsSB_2->setMinimum(g_model.moduleData[1].channelsStart+4); - ui->numChannelsSB_2->setValue(g_model.moduleData[1].channelsStart+g_model.moduleData[1].channelsCount); - updateSettings(); -} - -void ModelEdit::on_numChannelsStart_3_editingFinished() -{ - // TODO only accept valid values - g_model.moduleData[2].channelsStart = ui->numChannelsStart_3->value()-1; - ui->numChannelsSB_3->setMinimum(g_model.moduleData[2].channelsStart+4); - ui->numChannelsSB_3->setValue(g_model.moduleData[2].channelsStart+g_model.moduleData[2].channelsCount); - updateSettings(); -} - -void ModelEdit::on_ppmDelaySB_editingFinished() -{ - if(protocolEditLock) return; - // TODO only accept valid values - g_model.moduleData[0].ppmDelay = ui->ppmDelaySB->value(); - updateSettings(); -} - -void ModelEdit::on_ppmDelaySB_2_editingFinished() -{ - if(protocol2EditLock) return; - // TODO only accept valid values - g_model.moduleData[1].ppmDelay = ui->ppmDelaySB_2->value(); - updateSettings(); -} - -void ModelEdit::on_ppmDelaySB_3_editingFinished() -{ - if(trainerEditLock) return; - // TODO only accept valid values - g_model.moduleData[2].ppmDelay = ui->ppmDelaySB_3->value(); - updateSettings(); -} - -void ModelEdit::on_DSM_Type_currentIndexChanged(int index) -{ - if(protocolEditLock) return; - // g_model.moduleData[0].channelsCount = (index*2)+8; - updateSettings(); -} - -void ModelEdit::on_DSM_Type_2_currentIndexChanged(int index) -{ - if(protocol2EditLock) return; - // g_model.moduleData[1].channelsCount = (index*2)+8; - updateSettings(); -} - -void ModelEdit::on_pxxRxNum_editingFinished() -{ - if(protocolEditLock) - return; - - if (!GetEepromInterface()->getCapability(DSM2Indexes)) { - // g_model.moduleData[0].channelsCount = (ui->pxxRxNum->value()-1)*2+8; - } else { - g_model.modelId = ui->pxxRxNum->value(); - } - updateSettings(); -} - -void ModelEdit::on_pxxRxNum_2_editingFinished() -{ - if(protocol2EditLock) - return; - - /* if (!GetEepromInterface()->getCapability(DSM2Indexes)) { - g_model.moduleData[1].channelsCount = (ui->pxxRxNum_2->value()-1)*2+8; - } */ - updateSettings(); -} - -void ModelEdit::on_ppmFrameLengthDSB_editingFinished() -{ - g_model.moduleData[0].ppmFrameLength = (ui->ppmFrameLengthDSB->value()-22.5)/0.5; - updateSettings(); -} - -void ModelEdit::on_ppmFrameLengthDSB_2_editingFinished() -{ - g_model.moduleData[1].ppmFrameLength = (ui->ppmFrameLengthDSB_2->value()-22.5)/0.5; - updateSettings(); -} - -void ModelEdit::on_ppmFrameLengthDSB_3_editingFinished() -{ - g_model.moduleData[2].ppmFrameLength = (ui->ppmFrameLengthDSB_3->value()-22.5)/0.5; - updateSettings(); -} - -void ModelEdit::on_fsm1CB_currentIndexChanged(int index) -{ - QSpinBox * fssb[] = { ui->fsm1SB_1, ui->fsm1SB_2,ui->fsm1SB_3,ui->fsm1SB_4,ui->fsm1SB_5,ui->fsm1SB_6,ui->fsm1SB_7,ui->fsm1SB_8, - ui->fsm1SB_9, ui->fsm1SB_10,ui->fsm1SB_11,ui->fsm1SB_12,ui->fsm1SB_13,ui->fsm1SB_14,ui->fsm1SB_15,ui->fsm1SB_16, NULL }; - QSlider * fssld[] = { ui->fsm1SL_1, ui->fsm1SL_2,ui->fsm1SL_3,ui->fsm1SL_4,ui->fsm1SL_5,ui->fsm1SL_6,ui->fsm1SL_7,ui->fsm1SL_8, - ui->fsm1SL_9, ui->fsm1SL_10,ui->fsm1SL_11,ui->fsm1SL_12,ui->fsm1SL_13,ui->fsm1SL_14,ui->fsm1SL_15,ui->fsm1SL_16, NULL }; - g_model.moduleData[0].failsafeMode=index; - for (int i=0; fssb[i]; i++) { - if (index==1) { - fssb[i]->setEnabled(true); - fssld[i]->setEnabled(true); - } else { - fssb[i]->setDisabled(true); - fssld[i]->setDisabled(true); - } - } - updateSettings(); -} - -void ModelEdit::on_fsm2CB_currentIndexChanged(int index) -{ - QSpinBox * fssb[] = { ui->fsm2SB_1, ui->fsm2SB_2,ui->fsm2SB_3,ui->fsm2SB_4,ui->fsm2SB_5,ui->fsm2SB_6,ui->fsm2SB_7,ui->fsm2SB_8, - ui->fsm2SB_9, ui->fsm2SB_10,ui->fsm2SB_11,ui->fsm2SB_12,ui->fsm2SB_13,ui->fsm2SB_14,ui->fsm2SB_15,ui->fsm2SB_16, NULL }; - QSlider * fssld[] = { ui->fsm2SL_1, ui->fsm2SL_2,ui->fsm2SL_3,ui->fsm2SL_4,ui->fsm2SL_5,ui->fsm2SL_6,ui->fsm2SL_7,ui->fsm2SL_8, - ui->fsm2SL_9, ui->fsm2SL_10,ui->fsm2SL_11,ui->fsm2SL_12,ui->fsm2SL_13,ui->fsm2SL_14,ui->fsm2SL_15,ui->fsm2SL_16, NULL }; - g_model.moduleData[1].failsafeMode=index; - for (int i=0; fssb[i]; i++) { - if (index==1) { - fssb[i]->setEnabled(true); - fssld[i]->setEnabled(true); - } else { - fssb[i]->setDisabled(true); - fssld[i]->setDisabled(true); - } - } - updateSettings(); -} - -void ModelEdit::on_instantTrim_CB_currentIndexChanged(int index) -{ - if(switchEditLock) return; - bool found=false; - for (int i=0; i< C9X_MAX_CUSTOM_FUNCTIONS; i++) { - if (g_model.funcSw[i].func==FuncInstantTrim) { - g_model.funcSw[i].swtch = RawSwitch(ui->instantTrim_CB->itemData(ui->instantTrim_CB->currentIndex()).toInt()); - found=true; - } - } - if (found==false) { - for (int i=0; i< C9X_MAX_CUSTOM_FUNCTIONS; i++) { - if (g_model.funcSw[i].swtch==RawSwitch()) { - g_model.funcSw[i].swtch = RawSwitch(ui->instantTrim_CB->itemData(ui->instantTrim_CB->currentIndex()).toInt()); - g_model.funcSw[i].func = FuncInstantTrim; - break; - } - } - } - updateSettings(); -} - -void ModelEdit::on_a1UnitCB_currentIndexChanged(int index) { - float a1ratio; - g_model.frsky.channels[0].type=index; - switch (index) { - case 0: - case 1: - case 2: - ui->a1RatioSB->setDecimals(1); - ui->a1RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); - a1ratio=(g_model.frsky.channels[0].ratio<a1RatioSB->setDecimals(0); - ui->a1RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); - a1ratio=(g_model.frsky.channels[0].ratio<a1RatioSB->setValue(a1ratio); - updateA1Fields(); - updateSettings(); -} - -void ModelEdit::on_a1RatioSB_valueChanged() -{ - if (telemetryLock) return; - if (g_model.frsky.channels[0].type==0 || g_model.frsky.channels[0].type==1 || g_model.frsky.channels[0].type==2) { - g_model.frsky.channels[0].multiplier = findmult(ui->a1RatioSB->value(), 25.5); - float singlestep =(1<a1RatioSB->setSingleStep(singlestep); - ui->a1RatioSB->setValue(round(ui->a1RatioSB->value()/singlestep)*singlestep); - telemetryLock=false; - } else { - g_model.frsky.channels[0].multiplier = findmult(ui->a1RatioSB->value(), 255); - float singlestep =(1<a1RatioSB->setSingleStep(singlestep); - ui->a1RatioSB->setValue(round(ui->a1RatioSB->value()/singlestep)*singlestep); - telemetryLock=false; - } -} - -void ModelEdit::on_a1RatioSB_editingFinished() -{ - float a1ratio, a1calib, a11value,a12value; - if (telemetryLock) return; - if (g_model.frsky.channels[0].type==0 || g_model.frsky.channels[0].type==1 || g_model.frsky.channels[0].type==2) { - g_model.frsky.channels[0].multiplier = findmult(ui->a1RatioSB->value(), 25.5); - ui->a1CalibSB->setSingleStep((1<a11ValueSB->setSingleStep((1<a12ValueSB->setSingleStep((1<a1RatioSB->value()*10))/(1 <a1RatioSB->value(), 255); - ui->a1CalibSB->setSingleStep(1<a11ValueSB->setSingleStep(1<a12ValueSB->setSingleStep(1<a1RatioSB->value()/(1 << g_model.frsky.channels[0].multiplier)); - } - ui->a1CalibSB->setMaximum((ui->a1RatioSB->value()*127)/255); - ui->a1CalibSB->setMinimum((ui->a1RatioSB->value()*-128)/255); - ui->a11ValueSB->setMaximum(ui->a1RatioSB->value()); - ui->a12ValueSB->setMaximum(ui->a1RatioSB->value()); - repaint(); - a1ratio=g_model.frsky.channels[0].ratio * (1 << g_model.frsky.channels[0].multiplier); - a1calib=ui->a1CalibSB->value(); - a11value=ui->a11ValueSB->value(); - a12value=ui->a12ValueSB->value(); - if (g_model.frsky.channels[0].type==0) { - a1calib*=10; - a11value*=10; - a12value*=10; - } - if (a1calib>0) { - if (a1calib>((a1ratio*127)/255)) { - g_model.frsky.channels[0].offset=127; - } else { - g_model.frsky.channels[0].offset=round(a1calib*255/a1ratio); - } - } - if (a1calib<0) { - if (a1calib<((a1ratio*-128)/255)) { - g_model.frsky.channels[0].offset=-128; - } else { - g_model.frsky.channels[0].offset=round(a1calib*255/a1ratio); - } - } - g_model.frsky.channels[0].alarms[0].value=round((a11value*255-g_model.frsky.channels[0].offset*(g_model.frsky.channels[0].ratio<a1CalibSB->value()/a1ratio)); - a1calib=a1ratio*g_model.frsky.channels[0].offset/255.0; - a11value=ui->a11ValueSB->value(); - a12value=ui->a12ValueSB->value(); - if (a11value(a1ratio+a1calib)) { - a11value=a1ratio+a1calib; - } - if (a12value(a1ratio+a1calib)) { - a12value=a1ratio+a1calib; - } - g_model.frsky.channels[0].alarms[0].value=round(((a11value-a1calib)*255)/a1ratio); - g_model.frsky.channels[0].alarms[1].value=round(((a12value-a1calib)*255)/a1ratio); - } else { - g_model.frsky.channels[0].offset=0; - g_model.frsky.channels[0].alarms[0].value=0; - g_model.frsky.channels[0].alarms[1].value=0; - } - updateA1Fields(); - telBarUpdate(); - updateSettings(); -} - -void ModelEdit::on_a11LevelCB_currentIndexChanged(int index) -{ - g_model.frsky.channels[0].alarms[0].level = index; - updateSettings(); -} - -void ModelEdit::on_frskyUnitsCB_currentIndexChanged(int index) -{ - g_model.frsky.imperial=index; - updateSettings(); -} - -void ModelEdit::on_frskyBladesCB_currentIndexChanged(int index) -{ - g_model.frsky.blades=index; - updateSettings(); -} - -void ModelEdit::on_frskyCurrentCB_currentIndexChanged(int index) -{ - g_model.frsky.currentSource=index; - updateSettings(); -} - -void ModelEdit::on_frskyVoltCB_currentIndexChanged(int index) -{ - g_model.frsky.voltsSource=index; - updateSettings(); -} - -void ModelEdit::on_frskyProtoCB_currentIndexChanged(int index) -{ - if (telemetryLock) return; - int bindex[12]; - telemetryLock=true; - for (int i=0; i<12; i++) { - bindex[i]=barsCB[i]->currentIndex(); - g_model.frsky.usrProto=index; - populateCustomScreenFieldCB(barsCB[i], bindex[i], false, g_model.frsky.usrProto); - } - if (!GetEepromInterface()->getCapability(TelemetryCSFields)) { - ui->groupBox_5->hide(); - } else { - for (int screen=0; screen<2;screen++) { - for (int rows=0; rows<4; rows++) { - for (int cols=0; cols<3; cols++) { - int index=screen*12+cols*4+rows; - populateCustomScreenFieldCB(csf[index], g_model.frsky.screens[screen].body.lines[rows].source[cols], (rows<4), g_model.frsky.usrProto); - } - } - } - } - telemetryLock=false; - if (index==0) { - for (int i=0; i<12; i++) { - if (bindex[i]>2) { - barsCB[i]->setCurrentIndex(0); - } else { - barsCB[i]->setCurrentIndex(bindex[i]); - } - } - } else if (index==2) { - for (int i=0; i<12; i++) { - if (bindex[i]>3) { - barsCB[i]->setCurrentIndex(0); - } else { - barsCB[i]->setCurrentIndex(bindex[i]); - } - } - } else { - for (int i=0; i<12; i++) { - barsCB[i]->setCurrentIndex(bindex[i]); - } - } - updateSettings(); -} - -void ModelEdit::on_a11GreaterCB_currentIndexChanged(int index) -{ - g_model.frsky.channels[0].alarms[0].greater = index; - updateSettings(); -} - -void ModelEdit::on_a11ValueSB_editingFinished() -{ - float a1ratio, a1calib, a11value; - a1ratio=g_model.frsky.channels[0].ratio<a11ValueSB->value(); - if (g_model.frsky.channels[0].type==0) { - a1ratio/=10; - } - if (a11value<((a1calib*a1ratio)/255)) { - g_model.frsky.channels[0].alarms[0].value=0; - } else if (a11value>(a1ratio+(a1calib*a1ratio)/255)) { - g_model.frsky.channels[0].alarms[0].value=255; - } else { - g_model.frsky.channels[0].alarms[0].value = round((a11value-((a1calib*a1ratio)/255))/a1ratio*255); - } - updateA1Fields(); - updateSettings(); -} - -void ModelEdit::on_a12LevelCB_currentIndexChanged(int index) -{ - g_model.frsky.channels[0].alarms[1].level = index; - updateSettings(); -} - -void ModelEdit::on_a12GreaterCB_currentIndexChanged(int index) -{ - g_model.frsky.channels[0].alarms[1].greater = index; - updateSettings(); -} - -void ModelEdit::on_a12ValueSB_editingFinished() -{ - float a1ratio, a1calib, a12value; - a1ratio=g_model.frsky.channels[0].ratio<a12ValueSB->value(); - if (g_model.frsky.channels[0].type==0) { - a1ratio/=10; - } - if (a12value<((a1calib*a1ratio)/255)) { - g_model.frsky.channels[0].alarms[1].value=0; - } else if (a12value>(a1ratio+(a1calib*a1ratio)/255)) { - g_model.frsky.channels[0].alarms[1].value=255; - } else { - g_model.frsky.channels[0].alarms[1].value = round((a12value-((a1calib*a1ratio)/255))/a1ratio*255); - } - updateA1Fields(); - updateSettings(); -} - -void ModelEdit::on_a2UnitCB_currentIndexChanged(int index) { - float a2ratio; - g_model.frsky.channels[1].type=index; - switch (index) { - case 0: - case 1: - case 2: - ui->a2RatioSB->setDecimals(1); - ui->a2RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); - a2ratio=(g_model.frsky.channels[1].ratio<a2RatioSB->setDecimals(0); - ui->a2RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); - a2ratio=g_model.frsky.channels[1].ratio<a2RatioSB->setValue(a2ratio); - updateA2Fields(); - updateSettings(); -} - -void ModelEdit::on_a2RatioSB_valueChanged() -{ - if (telemetryLock) return; - if (g_model.frsky.channels[1].type==0 || g_model.frsky.channels[1].type==1 || g_model.frsky.channels[1].type==2) { - g_model.frsky.channels[1].multiplier = findmult(ui->a2RatioSB->value(), 25.5); - float singlestep =(1<a2RatioSB->setSingleStep(singlestep); - ui->a2RatioSB->setValue(round(ui->a2RatioSB->value()/singlestep)*singlestep); - telemetryLock=false; - } else { - g_model.frsky.channels[1].multiplier = findmult(ui->a2RatioSB->value(), 255); - float singlestep =(1<a2RatioSB->setSingleStep(singlestep); - ui->a2RatioSB->setValue(round(ui->a2RatioSB->value()/singlestep)*singlestep); - telemetryLock=false; - } -} - -void ModelEdit::on_a2RatioSB_editingFinished() -{ - float a2ratio, a2calib, a21value,a22value; - if (telemetryLock) return; - if (g_model.frsky.channels[1].type==0 || g_model.frsky.channels[1].type==1 || g_model.frsky.channels[1].type==2) { - g_model.frsky.channels[1].multiplier = findmult(ui->a2RatioSB->value(), 25.5); - ui->a2CalibSB->setSingleStep((1<a21ValueSB->setSingleStep((1<a22ValueSB->setSingleStep((1<a2RatioSB->value()*10))/(1 << g_model.frsky.channels[1].multiplier)); - } else { - g_model.frsky.channels[1].multiplier = findmult(ui->a2RatioSB->value(), 255); - ui->a2CalibSB->setSingleStep(1<a21ValueSB->setSingleStep(1<a22ValueSB->setSingleStep(1<a2RatioSB->value()/(1 << g_model.frsky.channels[1].multiplier)); - } - ui->a2CalibSB->setMaximum((ui->a2RatioSB->value()*127)/255); - ui->a2CalibSB->setMinimum((ui->a2RatioSB->value()*-128)/255); - ui->a21ValueSB->setMaximum(ui->a2RatioSB->value()); - ui->a22ValueSB->setMaximum(ui->a2RatioSB->value()); - repaint(); - a2ratio=g_model.frsky.channels[1].ratio * (1 << g_model.frsky.channels[1].multiplier); - a2calib=ui->a2CalibSB->value(); - a21value=ui->a21ValueSB->value(); - a22value=ui->a22ValueSB->value(); - if (g_model.frsky.channels[1].type==0 || g_model.frsky.channels[1].type==1 || g_model.frsky.channels[1].type==2) { - a2calib*=10; - a21value*=10; - a22value*=10; - } - if (a2calib>0) { - if (a2calib>((a2ratio*127)/255)) { - g_model.frsky.channels[1].offset=127; - } else { - g_model.frsky.channels[1].offset=round(a2calib*255/a2ratio); - } - } - if (a2calib<0) { - if (a2calib<((a2ratio*-128)/255)) { - g_model.frsky.channels[1].offset=-128; - } else { - g_model.frsky.channels[1].offset=round(a2calib*255/a2ratio); - } - } - g_model.frsky.channels[1].alarms[0].value=round((a21value*255-g_model.frsky.channels[1].offset*(g_model.frsky.channels[1].ratio<a2CalibSB->value()/a2ratio)); - a2calib=a2ratio*g_model.frsky.channels[1].offset/255.0; - a21value=ui->a21ValueSB->value(); - a22value=ui->a22ValueSB->value(); - if (a21value(a2ratio+a2calib)) { - a21value=a2ratio+a2calib; - } - if (a22value(a2ratio+a2calib)) { - a22value=a2ratio+a2calib; - } - g_model.frsky.channels[1].alarms[0].value=round(((a21value-a2calib)*255)/a2ratio); - g_model.frsky.channels[1].alarms[1].value=round(((a22value-a2calib)*255)/a2ratio); - } else { - g_model.frsky.channels[1].offset=0; - g_model.frsky.channels[1].alarms[0].value=0; - g_model.frsky.channels[1].alarms[1].value=0; - } - updateA2Fields(); - telBarUpdate(); - updateSettings(); -} - -void ModelEdit::on_a21LevelCB_currentIndexChanged(int index) -{ - g_model.frsky.channels[1].alarms[0].level = index; - updateSettings(); -} - -void ModelEdit::on_a21GreaterCB_currentIndexChanged(int index) -{ - g_model.frsky.channels[1].alarms[0].greater = index; - updateSettings(); -} - -void ModelEdit::on_a21ValueSB_editingFinished() -{ - float a2ratio, a2calib, a21value; - a2ratio=g_model.frsky.channels[1].ratio<a21ValueSB->value(); - if (g_model.frsky.channels[1].type==0) { - a2ratio/=10; - } - if (a21value<((a2calib*a2ratio)/255)) { - g_model.frsky.channels[1].alarms[0].value=0; - } else if (a21value>(a2ratio+(a2calib*a2ratio)/255)) { - g_model.frsky.channels[1].alarms[0].value=255; - } else { - g_model.frsky.channels[1].alarms[0].value = round((a21value-((a2calib*a2ratio)/255))/a2ratio*255); - } - updateA2Fields(); - updateSettings(); -} - -void ModelEdit::on_a22LevelCB_currentIndexChanged(int index) -{ - g_model.frsky.channels[1].alarms[1].level = index; - updateSettings(); -} - -void ModelEdit::on_a22GreaterCB_currentIndexChanged(int index) -{ - g_model.frsky.channels[1].alarms[1].greater = index; - updateSettings(); -} - -void ModelEdit::on_a22ValueSB_editingFinished() -{ - float a2ratio, a2calib, a22value; - a2ratio=g_model.frsky.channels[1].ratio<a22ValueSB->value(); - if (g_model.frsky.channels[1].type==0) { - a2ratio/=10; - } - if (a22value<((a2calib*a2ratio)/255)) { - g_model.frsky.channels[1].alarms[1].value=0; - } else if (a22value>(a2ratio+(a2calib*a2ratio)/255)) { - g_model.frsky.channels[1].alarms[1].value=255; - } else { - g_model.frsky.channels[1].alarms[1].value = round((a22value-((a2calib*a2ratio)/255))/a2ratio*255); - } - updateA2Fields(); - updateSettings(); -} - -void ModelEdit::on_rssiAlarm1CB_currentIndexChanged(int index) { - if (telemetryLock) return; - g_model.frsky.rssiAlarms[0].level=index; - updateSettings(); -} - -void ModelEdit::on_rssiAlarm2CB_currentIndexChanged(int index) { - if (telemetryLock) return; - g_model.frsky.rssiAlarms[1].level=index; - updateSettings(); -} - -void ModelEdit::on_rssiAlarm1SB_editingFinished() { - if (telemetryLock) return; - g_model.frsky.rssiAlarms[0].value=(ui->rssiAlarm1SB->value()); - updateSettings(); -} - -void ModelEdit::on_rssiAlarm2SB_editingFinished() { - if (telemetryLock) return; - g_model.frsky.rssiAlarms[1].value=(ui->rssiAlarm2SB->value()); - updateSettings(); -} - -void ModelEdit::on_AltitudeGPS_ChkB_toggled(bool checked) -{ - if (telemetryLock) return; - g_model.frsky.FrSkyGpsAlt = checked; - updateSettings(); - //AltitudeGPS_CB -} - -void ModelEdit::on_showNames_Ckb_toggled(bool checked) -{ - tabMixes(); -} -void ModelEdit::on_varioSourceCB_currentIndexChanged(int index) -{ - if (telemetryLock) return; - g_model.frsky.varioSource = index; - updateSettings(); -} - -void ModelEdit::on_varioLimitMin_DSB_editingFinished() -{ - if (telemetryLock) return; - g_model.frsky.varioMin= round(ui->varioLimitMin_DSB->value()+10); - updateSettings(); -} - -void ModelEdit::on_varioLimitMax_DSB_editingFinished() -{ - if (telemetryLock) return; - g_model.frsky.varioMax= round(ui->varioLimitMax_DSB->value()-10); - updateSettings(); -} - -void ModelEdit::on_varioLimitCenterMin_DSB_editingFinished() -{ - if (telemetryLock) return; - if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) { - ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value()); - } - g_model.frsky.varioCenterMin= round((ui->varioLimitCenterMin_DSB->value()+0.5)*10); - updateSettings(); -} - -void ModelEdit::on_varioLimitMinOff_ChkB_toggled(bool checked) -{ - if (telemetryLock) return; - g_model.frsky.varioCenterMin = -16; - if (!checked) { - telemetryLock=true; - ui->varioLimitCenterMin_DSB->setValue(-2.0); - ui->varioLimitCenterMin_DSB->setEnabled(true); - telemetryLock=false; - } else { - ui->varioLimitCenterMin_DSB->setValue(-2.0); - ui->varioLimitCenterMin_DSB->setDisabled(true); - } - updateSettings(); -} - -void ModelEdit::on_varioLimitCenterMax_DSB_editingFinished() -{ - if (telemetryLock) return; - if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) { - ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value()); - } - g_model.frsky.varioCenterMax= round((ui->varioLimitCenterMax_DSB->value()-0.5)*10); - updateSettings(); -} - -void ModelEdit::telBarUpdate() -{ - int index; - telemetryLock=true; - for (int i=0; i<12; i++) { - int screen=i/4; - index=barsCB[i]->currentIndex(); - if (index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1_MIN || index==TELEMETRY_SOURCE_A2_MIN) { - minSB[i]->setMinimum(getBarValue(index, 0, &g_model.frsky)); - minSB[i]->setMaximum(getBarValue(index, 255, &g_model.frsky)); - minSB[i]->setSingleStep(getBarStep(index)); - maxSB[i]->setMinimum(getBarValue(index, 0, &g_model.frsky)); - maxSB[i]->setMaximum(getBarValue(index, 255, &g_model.frsky)); - maxSB[i]->setSingleStep(getBarStep(index)); - minSB[i]->setValue(getBarValue(index, g_model.frsky.screens[screen].body.bars[i%4].barMin, &g_model.frsky)); - maxSB[i]->setValue(getBarValue(index, 255-g_model.frsky.screens[screen].body.bars[i%4].barMax, &g_model.frsky)); - } - } - telemetryLock=false; -} - -void ModelEdit::ScreenTypeCBcurrentIndexChanged(int index) -{ - if (telemetryLock) return; - - QComboBox *comboBox = qobject_cast(sender()); - int screen = comboBox->objectName().right(1).toInt() -1; - telemetryLock=true; - g_model.frsky.screens[screen].type=index; - - for (int i=0; i<3; i++) { - bool isNum = (g_model.frsky.screens[i].type==0); - barsGB[i]->setVisible(!isNum); - numsGB[i]->setVisible(isNum); - } - - telemetryLock=false; - updateSettings(); -} - -void ModelEdit::telBarCBcurrentIndexChanged(int index) -{ - if (telemetryLock) return; - QComboBox *comboBox = qobject_cast(sender()); - int screenId = comboBox->objectName().mid(8,1).toInt() - 1; - int barId = comboBox->objectName().mid(10,1).toInt() - 1; - int bar=barId+screenId*4; - g_model.frsky.screens[screenId].body.bars[barId].source=index; - telemetryLock=true; - if (index==0) { - g_model.frsky.screens[screenId].body.bars[barId].barMin=0; - g_model.frsky.screens[screenId].body.bars[barId].barMax=0; - minSB[bar]->setDisabled(true); - maxSB[bar]->setDisabled(true); - } else { - minSB[bar]->setEnabled(true); - maxSB[bar]->setEnabled(true); - } - switch (index-1) { - case TELEMETRY_SOURCE_TX_BATT: - case TELEMETRY_SOURCE_A1: - case TELEMETRY_SOURCE_A1_MIN: - case TELEMETRY_SOURCE_A2: - case TELEMETRY_SOURCE_A2_MIN: - case TELEMETRY_SOURCE_CELLS_SUM: - case TELEMETRY_SOURCE_VFAS: - case TELEMETRY_SOURCE_CURRENT_MAX: - case TELEMETRY_SOURCE_CURRENT: - minSB[bar]->setDecimals(1); - maxSB[bar]->setDecimals(1); - break; - case TELEMETRY_SOURCE_CELL: - minSB[bar]->setDecimals(2); - maxSB[bar]->setDecimals(2); - break; - default: - minSB[bar]->setDecimals(0); - maxSB[bar]->setDecimals(0); - } - minSB[bar]->setMinimum(getBarValue(index, 0, &g_model.frsky)); - minSB[bar]->setMaximum(getBarValue(index, 255, &g_model.frsky)); - minSB[bar]->setSingleStep(getBarStep(index)); - maxSB[bar]->setMinimum(getBarValue(index, 0, &g_model.frsky)); - maxSB[bar]->setMaximum(getBarValue(index, 255, &g_model.frsky)); - maxSB[bar]->setSingleStep(getBarStep(index)); - minSB[bar]->setValue(getBarValue(index, g_model.frsky.screens[screenId].body.bars[barId].barMin, &g_model.frsky)); - maxSB[bar]->setValue(getBarValue(index, 255-g_model.frsky.screens[screenId].body.bars[barId].barMax, &g_model.frsky)); - telemetryLock=false; - updateSettings(); -} - -void ModelEdit::telMinSBeditingFinished() -{ - if (telemetryLock) return; - QDoubleSpinBox *spinBox = qobject_cast(sender()); - int screenId = spinBox->objectName().mid(8,1).toInt() - 1; - int barId = spinBox->objectName().right(1).toInt() - 1; - int minId = barId+screenId*4; - telemetryLock=true; - if (g_model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1 || g_model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1_MIN) { - g_model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-ui->a1CalibSB->value())/getBarStep(g_model.frsky.screens[screenId].body.bars[barId].source)); - } else if (g_model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2 || g_model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2_MIN) { - g_model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-ui->a2CalibSB->value())/getBarStep(g_model.frsky.screens[screenId].body.bars[barId].source)); - } else { - g_model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-getBarValue(g_model.frsky.screens[screenId].body.bars[barId].source, 0, &g_model.frsky))/getBarStep(g_model.frsky.screens[screenId].body.bars[barId].source)); - } - spinBox->setValue(getBarValue(g_model.frsky.screens[screenId].body.bars[barId].source, g_model.frsky.screens[screenId].body.bars[barId].barMin, &g_model.frsky)); - if (maxSB[minId]->value()value()) { - g_model.frsky.screens[screenId].body.bars[minId].barMax=(255-g_model.frsky.screens[screenId].body.bars[barId].barMin+1); - maxSB[minId]->setValue(getBarValue(g_model.frsky.screens[screenId].body.bars[barId].source, 255-g_model.frsky.screens[screenId].body.bars[barId].barMax, &g_model.frsky)); - } - maxSB[minId]->setMinimum(getBarValue(g_model.frsky.screens[screenId].body.bars[barId].source, (g_model.frsky.screens[screenId].body.bars[barId].barMin+1), &g_model.frsky)); - telemetryLock=false; - updateSettings(); -} - -void ModelEdit::telMaxSBeditingFinished() -{ - if (telemetryLock) return; - QDoubleSpinBox *spinBox = qobject_cast(sender()); - int screenId = spinBox->objectName().mid(8,1).toInt() - 1; - int barId = spinBox->objectName().right(1).toInt() - 1; - telemetryLock=true; - if (g_model.frsky.screens[screenId].body.bars[barId].source==5) { - g_model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-ui->a1CalibSB->value())/getBarStep(g_model.frsky.screens[screenId].body.bars[barId].source))); - } else if (g_model.frsky.screens[screenId].body.bars[barId].source==6) { - g_model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-ui->a2CalibSB->value())/getBarStep(g_model.frsky.screens[screenId].body.bars[barId].source))); - } else { - g_model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-getBarValue(g_model.frsky.screens[screenId].body.bars[barId].source, 0, &g_model.frsky))/getBarStep(g_model.frsky.screens[screenId].body.bars[barId].source) )); - } - spinBox->setValue(getBarValue(g_model.frsky.screens[screenId].body.bars[barId].source, (255-g_model.frsky.screens[screenId].body.bars[barId].barMax), &g_model.frsky)); - telemetryLock=false; - updateSettings(); -} - -void ModelEdit::on_thrTrimChkB_toggled(bool checked) -{ - g_model.thrTrim = checked; - updateSettings(); -} - -void ModelEdit::on_thrExpoChkB_toggled(bool checked) -{ - g_model.thrExpo = checked; - updateSettings(); -} - -void ModelEdit::on_AltitudeToolbar_ChkB_toggled(bool checked) -{ - g_model.frsky.altitudeDisplayed = checked; - updateSettings(); -} - -void ModelEdit::on_bcRUDChkB_toggled(bool checked) -{ - if(checked) { - g_model.beepANACenter |= BC_BIT_RUD; - } else { - g_model.beepANACenter &= ~BC_BIT_RUD; - } - updateSettings(); -} - -void ModelEdit::on_bcELEChkB_toggled(bool checked) -{ - if(checked) { - g_model.beepANACenter |= BC_BIT_ELE; - } else { - g_model.beepANACenter &= ~BC_BIT_ELE; - } - updateSettings(); -} - -void ModelEdit::on_bcTHRChkB_toggled(bool checked) -{ - if(checked) { - g_model.beepANACenter |= BC_BIT_THR; - } else { - g_model.beepANACenter &= ~BC_BIT_THR; - } - updateSettings(); -} - -void ModelEdit::on_bcAILChkB_toggled(bool checked) -{ - if(checked) { - g_model.beepANACenter |= BC_BIT_AIL; - } else { - g_model.beepANACenter &= ~BC_BIT_AIL; - } - updateSettings(); -} - -void ModelEdit::on_bcP1ChkB_toggled(bool checked) -{ - if(checked) { - g_model.beepANACenter |= BC_BIT_P1; - } else { - g_model.beepANACenter &= ~BC_BIT_P1; - } - updateSettings(); -} - -void ModelEdit::on_bcP2ChkB_toggled(bool checked) -{ - if(checked) { - g_model.beepANACenter |= BC_BIT_P2; - } else { - g_model.beepANACenter &= ~BC_BIT_P2; - } - updateSettings(); -} - -void ModelEdit::on_bcP3ChkB_toggled(bool checked) -{ - if(checked) { - g_model.beepANACenter |= BC_BIT_P3; - } else { - g_model.beepANACenter &= ~BC_BIT_P3; - } - updateSettings(); -} - -void ModelEdit::on_bcP4ChkB_toggled(bool checked) -{ - if(checked) { - g_model.beepANACenter |= BC_BIT_P4; - } else { - g_model.beepANACenter &= ~BC_BIT_P4; - } - updateSettings(); -} - -void ModelEdit::on_bcREaChkB_toggled(bool checked) -{ - if(checked) { - g_model.beepANACenter |= BC_BIT_REA; - } else { - g_model.beepANACenter &= ~BC_BIT_REA; - } - updateSettings(); -} - -void ModelEdit::on_bcREbChkB_toggled(bool checked) -{ - if(checked) { - g_model.beepANACenter |= BC_BIT_REB; - } else { - g_model.beepANACenter &= ~BC_BIT_REB; - } - updateSettings(); -} - -void ModelEdit::phaseGVValue_editingFinished() -{ - if (phasesLock) return; - QSpinBox *spinBox = qobject_cast(sender()); - int phase = spinBox->objectName().mid(5,1).toInt(); - int gvar = spinBox->objectName().mid(8,1).toInt()-1; - g_model.phaseData[phase].gvars[gvar] = spinBox->value(); - updateSettings(); -} - -void ModelEdit::GVName_editingFinished() -{ - if (phasesLock) return; - QLineEdit *lineedit = qobject_cast(sender()); - int gvar = lineedit->objectName().mid(8,1).toInt()-1; - memset(&g_model.gvars_names[gvar],0,sizeof(g_model.gvars_names[gvar])); - const char * le=lineedit->text().toAscii(); - strncpy(g_model.gvars_names[gvar], le, sizeof(g_model.gvars_names[gvar])-1); - updateSettings(); -} - -void ModelEdit::GVSource_currentIndexChanged() -{ - QComboBox *comboBox = qobject_cast(sender()); - int gvar = comboBox->objectName().mid(8,1).toInt()-1; - int index=comboBox->currentIndex(); - g_model.gvsource[gvar]=index; - updateSettings(); -} - -void ModelEdit::phaseGVUse_currentIndexChanged() -{ - if (phasesLock) return; - phasesLock=true; - QComboBox *comboBox = qobject_cast(sender()); - int phase = comboBox->objectName().mid(5,1).toInt(); - int gvar = comboBox->objectName().mid(8,1).toInt()-1; - int index=comboBox->currentIndex(); - if (index == 0) { - int value=g_model.phaseData[phase].gvars[gvar]; - if (value>1024) { - value=0; - } - gvarsSB[phase][gvar]->setValue(value); - gvarsSB[phase][gvar]->setEnabled(true); - g_model.phaseData[phase].gvars[gvar]=value; - } else { - g_model.phaseData[phase].gvars[gvar]=1024+index; - int value=gvarsSB[index+(index>phase ?0 :-1)][gvar]->value(); - gvarsSB[phase][gvar]->setValue(value); - gvarsSB[phase][gvar]->setDisabled(true); - } - phasesLock=false; - updateSettings(); -} - -void ModelEdit::phaseREValue_editingFinished() -{ - if (phasesLock) return; - QSpinBox *spinBox = qobject_cast(sender()); - int phase = spinBox->objectName().mid(5,1).toInt(); - int gvar = spinBox->objectName().mid(8,1).toInt()-1; - g_model.phaseData[phase].rotaryEncoders[gvar] = spinBox->value(); - updateSettings(); -} - -void ModelEdit::phaseREUse_currentIndexChanged() -{ - if (phasesLock) return; - phasesLock=true; - QComboBox *comboBox = qobject_cast(sender()); - int phase = comboBox->objectName().mid(5,1).toInt(); - int re = comboBox->objectName().mid(8,1).toInt()-1; - int index=comboBox->currentIndex(); - if (index == 0) { - int value=g_model.phaseData[phase].rotaryEncoders[re]; - if (value>1024) { - value=0; - } - reSB[phase][re]->setValue(value); - reSB[phase][re]->setEnabled(true); - g_model.phaseData[phase].rotaryEncoders[re]=value; - } else { - g_model.phaseData[phase].rotaryEncoders[re]=1024+index; - int value=reSB[index+(index>phase ?0 :-1)][re]->value(); - reSB[phase][re]->setValue(value); - reSB[phase][re]->setDisabled(true) ; - } - phasesLock=false; - updateSettings(); -} - -void ModelEdit::phaseTrimUse_currentIndexChanged() -{ - if (phasesLock) return; - QComboBox *comboBox = qobject_cast(sender()); - int phase = comboBox->objectName().mid(5,1).toInt(); - int trim = comboBox->objectName().mid(10,1).toInt(); - - int chn = CONVERT_MODE(trim)-1; - int index=comboBox->currentIndex(); - - if (index == 0) { - g_model.phaseData[phase].trim[chn] = g_model.phaseData[g_model.getTrimFlightPhase(chn, phase)].trim[chn]; - g_model.phaseData[phase].trimRef[chn] = -1; - } else { - g_model.phaseData[phase].trim[chn] = 0; - g_model.phaseData[phase].trimRef[chn] = index - 1 + (index > (int)phase ? 1 : 0); - } - - phasesLock = true; - displayOnePhaseOneTrim(phase, chn, NULL, phasesTrimValues[phase][trim-1], phasesTrimSliders[phase][trim-1]); - phasesLock = false; - updateSettings(); -} - -void ModelEdit::phaseTrim_valueChanged() -{ - if (phasesLock) return; - QSpinBox *spinBox = qobject_cast(sender()); - int phase = spinBox->objectName().mid(5,1).toInt(); - int trim = spinBox->objectName().mid(10,1).toInt(); - - int chn = CONVERT_MODE(trim)-1; - g_model.phaseData[phase].trim[chn] = spinBox->value(); - phasesLock=true; - phasesTrimSliders[phase][trim-1]->setValue(spinBox->value()); - phasesLock=false; - updateSettings(); -} - -void ModelEdit::phaseTrimSlider_valueChanged() -{ - if (phasesLock) return; - QSlider *slider = qobject_cast(sender()); - int phase = slider->objectName().mid(5,1).toInt(); - int trim = slider->objectName().mid(10,1).toInt(); - - int chn = CONVERT_MODE(trim)-1; - g_model.phaseData[phase].trim[chn] = slider->value(); - phasesLock=true; - phasesTrimValues[phase][trim-1]->setValue(slider->value()); - phasesLock=false; - updateSettings(); -} - -QSpinBox *ModelEdit::getNodeSB(int i) // get the SpinBox that corresponds to the selected node -{ - return spny[i]; -} - -QSpinBox *ModelEdit::getNodeSBX(int i) // get the SpinBox that corresponds to the selected node -{ - return spnx[i]; -} - -void ModelEdit::drawCurve() -{ - - if (drawing) - return; - drawing=true; - curvesLock=true; - int k,i; - QColor * plot_color[16]; - - plot_color[0]=new QColor(0,0,127); - plot_color[1]=new QColor(0,127,0); - plot_color[2]=new QColor(127,0,0); - plot_color[3]=new QColor(0,127,127); - plot_color[4]=new QColor(127,0,127); - plot_color[5]=new QColor(127,127,0); - plot_color[6]=new QColor(127,127,127); - plot_color[7]=new QColor(0,0,255); - plot_color[8]=new QColor(0,127,255); - plot_color[9]=new QColor(127,0,255); - plot_color[10]=new QColor(0,255,0); - plot_color[11]=new QColor(0,255,127); - plot_color[12]=new QColor(127,255,0); - plot_color[13]=new QColor(255,0,0); - plot_color[14]=new QColor(255,0,127); - plot_color[15]=new QColor(255,127,0); - - if(currentCurve<0 || currentCurve>15) return; - - Node *nodel = 0; - Node *nodex = 0; - - QGraphicsScene *scene = ui->curvePreview->scene(); - QPen pen; - QColor color; - scene->clear(); - - qreal width = scene->sceneRect().width(); - qreal height = scene->sceneRect().height(); - - qreal centerX = scene->sceneRect().left() + width/2; //center X - qreal centerY = scene->sceneRect().top() + height/2; //center Y - - QGraphicsSimpleTextItem *ti; - ti = scene->addSimpleText(tr("Editing curve %1").arg(currentCurve+1)); - ti->setPos(3,3); - - scene->addLine(centerX,GFX_MARGIN,centerX,height+GFX_MARGIN); - scene->addLine(GFX_MARGIN,centerY,width+GFX_MARGIN,centerY); - pen.setWidth(2); - pen.setStyle(Qt::SolidLine); - int numcurves=GetEepromInterface()->getCapability(NumCurves); - if (numcurves==0) { - numcurves=16; - } - - for(k=0; kaddLine(GFX_MARGIN + i*width/(numpoints-1),centerY - (qreal)g_model.curves[k].points[i].y*height/200,GFX_MARGIN + (i+1)*width/(numpoints-1),centerY - (qreal)g_model.curves[k].points[i+1].y*height/200,pen); - } else { - scene->addLine(centerX + (qreal)g_model.curves[k].points[i].x*width/200,centerY - (qreal)g_model.curves[k].points[i].y*height/200,centerX + (qreal)g_model.curves[k].points[i+1].x*width/200,centerY - (qreal)g_model.curves[k].points[i+1].y*height/200,pen); - } - } - } - } - int numpoints=g_model.curves[currentCurve].count; - - for(int i=0; isetColor(*plot_color[currentCurve]); - if (!g_model.curves[currentCurve].custom) { - nodex->setFixedX(true); - nodex->setPos(GFX_MARGIN + i*width/(numpoints-1),centerY - (qreal)g_model.curves[currentCurve].points[i].y*height/200); - } else { - if (i>0 && i<(numpoints-1)) { - nodex->setFixedX(false); - nodex->setMinX(g_model.curves[currentCurve].points[i-1].x+1); - nodex->setMaxX(g_model.curves[currentCurve].points[i+1].x-1); - spnx[i]->setMaximum(g_model.curves[currentCurve].points[i+1].x-1); - spnx[i]->setMinimum(g_model.curves[currentCurve].points[i-1].x+1); - } else { - nodex->setFixedX(true); - } - nodex->setPos(centerX + (qreal)g_model.curves[currentCurve].points[i].x*width/200,centerY - (qreal)g_model.curves[currentCurve].points[i].y*height/200); - } - scene->addItem(nodex); - if(i>0) scene->addItem(new Edge(nodel, nodex)); - } - curvesLock=false; - drawing=false; -} - - -bool ModelEdit::gm_insertMix(int idx) -{ - if (idx<0 || idx>=GetEepromInterface()->getCapability(Mixes) || g_model.mixData[GetEepromInterface()->getCapability(Mixes)-1].destCh > 0) { - QMessageBox::information(this, "companion9x", tr("Not enough available mixers!")); - return false; - } - - int i = g_model.mixData[idx].destCh; - memmove(&g_model.mixData[idx+1],&g_model.mixData[idx], - (GetEepromInterface()->getCapability(Mixes)-(idx+1))*sizeof(MixData) ); - memset(&g_model.mixData[idx],0,sizeof(MixData)); - g_model.mixData[idx].srcRaw = RawSource(SOURCE_TYPE_NONE); - g_model.mixData[idx].destCh = i; - g_model.mixData[idx].weight = 100; - return true; -} - -void ModelEdit::gm_deleteMix(int index) -{ - memmove(&g_model.mixData[index],&g_model.mixData[index+1], - (GetEepromInterface()->getCapability(Mixes)-(index+1))*sizeof(MixData)); - memset(&g_model.mixData[GetEepromInterface()->getCapability(Mixes)-1],0,sizeof(MixData)); -} - -void ModelEdit::gm_openMix(int index) -{ - if(index<0 || index>=GetEepromInterface()->getCapability(Mixes)) return; - - MixData mixd(g_model.mixData[index]); - updateSettings(); - tabMixes(); - - MixerDialog *g = new MixerDialog(this, &mixd, g_eeGeneral.stickMode); - if(g->exec()) { - g_model.mixData[index] = mixd; - updateSettings(); - tabMixes(); - } else { - if (mixInserted) { - gm_deleteMix(index); - } - mixInserted=false; - updateSettings(); - tabMixes(); - } -} - -int ModelEdit::getMixerIndex(unsigned int dch) -{ - int i = 0; - while ((g_model.mixData[i].destCh<=dch) && (g_model.mixData[i].destCh) && (igetCapability(Mixes))) i++; - if(i==GetEepromInterface()->getCapability(Mixes)) return -1; - return i; -} - -bool ModelEdit::gm_insertExpo(int idx) -{ - if (idx<0 || idx>=C9X_MAX_EXPOS || g_model.expoData[C9X_MAX_EXPOS-1].mode > 0) { - QMessageBox::information(this, "companion9x", tr("Not enough available expos!")); - return false; - } - - int chn = g_model.expoData[idx].chn; - memmove(&g_model.expoData[idx+1],&g_model.expoData[idx], - (C9X_MAX_EXPOS-(idx+1))*sizeof(ExpoData) ); - memset(&g_model.expoData[idx],0,sizeof(ExpoData)); - g_model.expoData[idx].chn = chn; - g_model.expoData[idx].weight = 100; - g_model.expoData[idx].mode = 3 /* TODO enum */; - return true; -} - -void ModelEdit::gm_deleteExpo(int index) -{ - memmove(&g_model.expoData[index],&g_model.expoData[index+1], - (C9X_MAX_EXPOS-(index+1))*sizeof(ExpoData)); - memset(&g_model.expoData[C9X_MAX_EXPOS-1],0,sizeof(ExpoData)); -} - -void ModelEdit::gm_openExpo(int index) -{ - if(index<0 || index>=C9X_MAX_EXPOS) return; - - ExpoData mixd(g_model.expoData[index]); - updateSettings(); - tabExpos(); - - ExpoDialog *g = new ExpoDialog(this, &mixd, g_eeGeneral.stickMode); - if(g->exec()) { - g_model.expoData[index] = mixd; - updateSettings(); - tabExpos(); - } else { - if (expoInserted) { - gm_deleteExpo(index); - } - expoInserted=false; - updateSettings(); - tabExpos(); - } -} - -int ModelEdit::getExpoIndex(unsigned int dch) -{ - unsigned int i = 0; - while (g_model.expoData[i].chn<=dch && g_model.expoData[i].mode && iitem(index.row())->data(Qt::UserRole).toByteArray().at(0); - if (idx<0) { - int i = -idx; - idx = getMixerIndex(i); //get mixer index to insert - if (!gm_insertMix(idx)) - return; - g_model.mixData[idx].destCh = i; - mixInserted=true; - } else { - mixInserted=false; - } - gm_openMix(idx); -} - - -void ModelEdit::expolistWidget_doubleClicked(QModelIndex index) -{ - expoOpen(ExposlistWidget->item(index.row())); -} - -void ModelEdit::exposDeleteList(QList list) -{ - qSort(list.begin(), list.end()); - - int iDec = 0; - foreach(int idx, list) { - gm_deleteExpo(idx-iDec); - iDec++; - } -} - -void ModelEdit::mixersDeleteList(QList list) -{ - qSort(list.begin(), list.end()); - - int iDec = 0; - foreach(int idx, list) { - gm_deleteMix(idx-iDec); - iDec++; - } -} - -QList ModelEdit::createMixListFromSelected() -{ - QList list; - foreach(QListWidgetItem *item, MixerlistWidget->selectedItems()) { - int idx= item->data(Qt::UserRole).toByteArray().at(0); - if(idx>=0 && idxgetCapability(Mixes)) list << idx; - } - return list; -} - -QList ModelEdit::createExpoListFromSelected() -{ - QList list; - foreach(QListWidgetItem *item, ExposlistWidget->selectedItems()) { - int idx= item->data(Qt::UserRole).toByteArray().at(0); - if(idx>=0 && idx list) -{ - for(int i=0; icount(); i++) { - int t = MixerlistWidget->item(i)->data(Qt::UserRole).toByteArray().at(0); - if(list.contains(t)) - MixerlistWidget->item(i)->setSelected(true); - } -} - -void ModelEdit::setSelectedByExpoList(QList list) -{ - for(int i=0; icount(); i++) { - int t = ExposlistWidget->item(i)->data(Qt::UserRole).toByteArray().at(0); - if(list.contains(t)) - ExposlistWidget->item(i)->setSelected(true); - } -} - -void ModelEdit::mixersDelete(bool ask) -{ - QMessageBox::StandardButton ret = QMessageBox::No; - - if(ask) - ret = QMessageBox::warning(this, "companion9x", - tr("Delete Selected Mixes?"), - QMessageBox::Yes | QMessageBox::No); - - - if ((ret == QMessageBox::Yes) || (!ask)) { - mixersDeleteList(createMixListFromSelected()); - updateSettings(); - tabMixes(); - } -} - -void ModelEdit::mixersCut() -{ - mixersCopy(); - mixersDelete(false); -} - -void ModelEdit::mixersCopy() -{ - - QList list = createMixListFromSelected(); - - QByteArray mxData; - foreach(int idx, list) { - mxData.append((char*)&g_model.mixData[idx],sizeof(MixData)); - } - - QMimeData *mimeData = new QMimeData; - mimeData->setData("application/x-companion9x-mix", mxData); - QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); -} - -void ModelEdit::exposDelete(bool ask) -{ - QMessageBox::StandardButton ret = QMessageBox::No; - - if(ask) - ret = QMessageBox::warning(this, "companion9x", - tr("Delete Selected Expos?"), - QMessageBox::Yes | QMessageBox::No); - - - if ((ret == QMessageBox::Yes) || (!ask)) { - exposDeleteList(createExpoListFromSelected()); - updateSettings(); - tabExpos(); - } -} - -void ModelEdit::exposCut() -{ - exposCopy(); - exposDelete(false); -} - -void ModelEdit::exposCopy() -{ - QList list = createExpoListFromSelected(); - - QByteArray mxData; - foreach(int idx, list) { - mxData.append((char*)&g_model.expoData[idx],sizeof(ExpoData)); - } - - QMimeData *mimeData = new QMimeData; - mimeData->setData("application/x-companion9x-expo", mxData); - QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); -} - -void ModelEdit::mimeExpoDropped(int index, const QMimeData *data, Qt::DropAction /*action*/) -{ - int idx = ExposlistWidget->item(index > 0 ? index-1 : 0)->data(Qt::UserRole).toByteArray().at(0); - pasteExpoMimeData(data, idx); -} - -void ModelEdit::mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction /*action*/) -{ - int idx= MixerlistWidget->item(index > 0 ? index-1 : 0)->data(Qt::UserRole).toByteArray().at(0); - pasteMixerMimeData(data, idx); -} - -void ModelEdit::pasteMixerMimeData(const QMimeData * mimeData, int destIdx) -{ - if(mimeData->hasFormat("application/x-companion9x-mix")) { - int idx; // mixer index - int dch; - - if(destIdx<0) { - dch = -destIdx; - idx = getMixerIndex(dch) - 1; //get mixer index to insert - } else { - idx = destIdx; - dch = g_model.mixData[idx].destCh; - } - - QByteArray mxData = mimeData->data("application/x-companion9x-mix"); - - int i = 0; - while(igetCapability(Mixes)) break; - - if (!gm_insertMix(idx)) - break; - MixData *md = &g_model.mixData[idx]; - memcpy(md,mxData.mid(i,sizeof(MixData)).constData(),sizeof(MixData)); - md->destCh = dch; - i += sizeof(MixData); - } - - updateSettings(); - tabMixes(); - } -} -#include -#include -void ModelEdit::pasteExpoMimeData(const QMimeData * mimeData, int destIdx) -{ - if (mimeData->hasFormat("application/x-companion9x-expo")) { - int idx; // mixer index - int dch; - - if (destIdx < 0) { - dch = -destIdx - 1; - idx = getExpoIndex(dch) - 1; //get expo index to insert - } else { - idx = destIdx; - dch = g_model.expoData[idx].chn; - } - - QByteArray mxData = mimeData->data("application/x-companion9x-expo"); - - int i = 0; - while (i < mxData.size()) { - idx++; - if (!gm_insertExpo(idx)) - break; - ExpoData *md = &g_model.expoData[idx]; - memcpy(md, mxData.mid(i, sizeof(ExpoData)).constData(), sizeof(ExpoData)); - md->chn = dch; - i += sizeof(ExpoData); - } - - updateSettings(); - tabExpos(); - } -} - -void ModelEdit::mixersPaste() -{ - const QClipboard *clipboard = QApplication::clipboard(); - const QMimeData *mimeData = clipboard->mimeData(); - QListWidgetItem *item = MixerlistWidget->currentItem(); - if (item) - pasteMixerMimeData(mimeData, item->data(Qt::UserRole).toByteArray().at(0)); -} - -void ModelEdit::mixersDuplicate() -{ - mixersCopy(); - mixersPaste(); -} - -void ModelEdit::exposPaste() -{ - const QClipboard *clipboard = QApplication::clipboard(); - const QMimeData *mimeData = clipboard->mimeData(); - QListWidgetItem *item = ExposlistWidget->currentItem(); - if (item) - pasteExpoMimeData(mimeData, item->data(Qt::UserRole).toByteArray().at(0)); -} - -void ModelEdit::exposDuplicate() -{ - exposCopy(); - exposPaste(); -} - -void ModelEdit::mixerOpen() -{ - int idx = MixerlistWidget->currentItem()->data(Qt::UserRole).toByteArray().at(0); - if(idx<0) { - int i = -idx; - idx = getMixerIndex(i); //get mixer index to insert - if (!gm_insertMix(idx)) - return; - g_model.mixData[idx].destCh = i; - mixInserted=true; - } else { - mixInserted=false; - } - - gm_openMix(idx); -} - -void ModelEdit::mixerAdd() -{ - if (!MixerlistWidget->currentItem()) - return; - int index = MixerlistWidget->currentItem()->data(Qt::UserRole).toByteArray().at(0); - - if(index<0) { // if empty then return relavent index - int i = -index; - index = getMixerIndex(i); //get mixer index to insert - if (!gm_insertMix(index)) - return; - g_model.mixData[index].destCh = i; - mixInserted=true; - } else { - index++; - if (!gm_insertMix(index)) - return; - g_model.mixData[index].destCh = g_model.mixData[index-1].destCh; - mixInserted=true; - } - gm_openMix(index); -} - -void ModelEdit::expoOpen(QListWidgetItem *item) -{ - if (!item) - item = ExposlistWidget->currentItem(); - - int idx = item->data(Qt::UserRole).toByteArray().at(0); - if (idx<0) { - int ch = -idx-1; - idx = getExpoIndex(ch); // get expo index to insert - if (!gm_insertExpo(idx)) - return; - g_model.expoData[idx].chn = ch; - expoInserted=true; - } else { - expoInserted=false; - } - gm_openExpo(idx); -} - -void ModelEdit::expoAdd() -{ - int index = ExposlistWidget->currentItem()->data(Qt::UserRole).toByteArray().at(0); - - if(index<0) { // if empty then return relevant index - expoOpen(); - } else { - index++; - if (!gm_insertExpo(index)) - return; - g_model.expoData[index].chn = g_model.expoData[index-1].chn; - } - gm_openExpo(index); -} - -void ModelEdit::mixerlistWidget_customContextMenuRequested(QPoint pos) -{ - QPoint globalPos = MixerlistWidget->mapToGlobal(pos); - - const QClipboard *clipboard = QApplication::clipboard(); - const QMimeData *mimeData = clipboard->mimeData(); - bool hasData = mimeData->hasFormat("application/x-companion9x-mix"); - - QMenu contextMenu; - contextMenu.addAction(QIcon(":/images/add.png"), tr("&Add"),this,SLOT(mixerAdd()),tr("Ctrl+A")); - contextMenu.addAction(QIcon(":/images/edit.png"), tr("&Edit"),this,SLOT(mixerOpen()),tr("Enter")); - contextMenu.addSeparator(); - contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(mixersDelete()),tr("Delete")); - contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(mixersCopy()),tr("Ctrl+C")); - contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(mixersCut()),tr("Ctrl+X")); - contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(mixersPaste()),tr("Ctrl+V"))->setEnabled(hasData); - contextMenu.addAction(QIcon(":/images/duplicate.png"), tr("Du&plicate"),this,SLOT(mixersDuplicate()),tr("Ctrl+U")); - contextMenu.addSeparator(); - contextMenu.addAction(QIcon(":/images/moveup.png"), tr("Move Up"),this,SLOT(moveMixUp()),tr("Ctrl+Up")); - contextMenu.addAction(QIcon(":/images/movedown.png"), tr("Move Down"),this,SLOT(moveMixDown()),tr("Ctrl+Down")); - - contextMenu.exec(globalPos); -} - -void ModelEdit::expolistWidget_customContextMenuRequested(QPoint pos) -{ - QPoint globalPos = ExposlistWidget->mapToGlobal(pos); - - const QClipboard *clipboard = QApplication::clipboard(); - const QMimeData *mimeData = clipboard->mimeData(); - bool hasData = mimeData->hasFormat("application/x-companion9x-expo"); - - QMenu contextMenu; - contextMenu.addAction(QIcon(":/images/add.png"), tr("&Add"),this,SLOT(expoAdd()),tr("Ctrl+A")); - contextMenu.addAction(QIcon(":/images/edit.png"), tr("&Edit"),this,SLOT(expoOpen()),tr("Enter")); - contextMenu.addSeparator(); - contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(exposDelete()),tr("Delete")); - contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(exposCopy()),tr("Ctrl+C")); - contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(exposCut()),tr("Ctrl+X")); - contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(exposPaste()),tr("Ctrl+V"))->setEnabled(hasData); - contextMenu.addAction(QIcon(":/images/duplicate.png"), tr("Du&plicate"),this,SLOT(exposDuplicate()),tr("Ctrl+U")); - contextMenu.addSeparator(); - contextMenu.addAction(QIcon(":/images/moveup.png"), tr("Move Up"),this,SLOT(moveExpoUp()),tr("Ctrl+Up")); - contextMenu.addAction(QIcon(":/images/movedown.png"), tr("Move Down"),this,SLOT(moveExpoDown()),tr("Ctrl+Down")); - - contextMenu.exec(globalPos); -} - -void ModelEdit::cswPaste() -{ - const QClipboard *clipboard = QApplication::clipboard(); - const QMimeData *mimeData = clipboard->mimeData(); - if (mimeData->hasFormat("application/x-companion9x-csw")) { - QByteArray cswData = mimeData->data("application/x-companion9x-csw"); - - CustomSwData *csw = &g_model.customSw[selectedSwitch]; - memcpy(csw, cswData.mid(0, sizeof(CustomSwData)).constData(), sizeof(CustomSwData)); - updateSettings(); - updateSelectedSwitch(); - } -} - -void ModelEdit::cswDelete() -{ - g_model.customSw[selectedSwitch].clear(); - updateSettings(); - updateSelectedSwitch(); -} - -void ModelEdit::cswCopy() -{ - QByteArray cswData; - cswData.append((char*)&g_model.customSw[selectedSwitch],sizeof(CustomSwData)); - QMimeData *mimeData = new QMimeData; - mimeData->setData("application/x-companion9x-csw", cswData); - QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); -} - -void ModelEdit::updateSelectedSwitch() -{ - switchEditLock = true; - populateCSWCB(csw[selectedSwitch], g_model.customSw[selectedSwitch].func); - setSwitchWidgetVisibility(selectedSwitch); - switchEditLock = false; -} - -void ModelEdit::cswCut() -{ - cswCopy(); - cswDelete(); -} - -void ModelEdit::csw_customContextMenuRequested(QPoint pos) -{ - QLabel *label = (QLabel *)sender(); - if (!label) - return; - QString name=label->objectName(); - if (!name.startsWith("cswlabel")) - return; - selectedSwitch=name.mid(9,2).toInt()-1; - - QPoint globalPos = label->mapToGlobal(pos); - - const QClipboard *clipboard = QApplication::clipboard(); - const QMimeData *mimeData = clipboard->mimeData(); - bool hasData = mimeData->hasFormat("application/x-companion9x-csw"); - - QMenu contextMenu; - contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(cswDelete()),tr("Delete")); - contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(cswCopy()),tr("Ctrl+C")); - contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(cswCut()),tr("Ctrl+X")); - contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(cswPaste()),tr("Ctrl+V"))->setEnabled(hasData); - - contextMenu.exec(globalPos); -} - -void ModelEdit::fsw_customContextMenuRequested(QPoint pos) -{ - QLabel *label = (QLabel *)sender(); - if (!label) - return; - int fsw=label->property("FunctionId").toInt(); - if (!(fsw>0 && fsw<=32)) - return; - selectedFunction=fsw-1; - - QPoint globalPos = label->mapToGlobal(pos); - - const QClipboard *clipboard = QApplication::clipboard(); - const QMimeData *mimeData = clipboard->mimeData(); - bool hasData = mimeData->hasFormat("application/x-companion9x-fsw"); - - QMenu contextMenu; - contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(fswDelete()),tr("Delete")); - contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C")); - contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X")); - contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData); - - contextMenu.exec(globalPos); -} - -void ModelEdit::fswPaste() -{ - const QClipboard *clipboard = QApplication::clipboard(); - const QMimeData *mimeData = clipboard->mimeData(); - if (mimeData->hasFormat("application/x-companion9x-fsw")) { - QByteArray fswData = mimeData->data("application/x-companion9x-fsw"); - - FuncSwData *fsw = &g_model.funcSw[selectedFunction]; - memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData)); - updateSettings(); - tabCustomFunctions(); - } -} - -void ModelEdit::fswDelete() -{ - g_model.funcSw[selectedFunction].clear(); - updateSettings(); - tabCustomFunctions(); -} - -void ModelEdit::fswCopy() -{ - QByteArray fswData; - fswData.append((char*)&g_model.funcSw[selectedFunction],sizeof(FuncSwData)); - QMimeData *mimeData = new QMimeData; - mimeData->setData("application/x-companion9x-fsw", fswData); - QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); -} - -void ModelEdit::fswCut() -{ - fswCopy(); - fswDelete(); -} - -void ModelEdit::mixerlistWidget_KeyPress(QKeyEvent *event) -{ - if(event->matches(QKeySequence::SelectAll)) mixerAdd(); //Ctrl A - if(event->matches(QKeySequence::Delete)) mixersDelete(); - if(event->matches(QKeySequence::Copy)) mixersCopy(); - if(event->matches(QKeySequence::Cut)) mixersCut(); - if(event->matches(QKeySequence::Paste)) mixersPaste(); - if(event->matches(QKeySequence::Underline)) mixersDuplicate(); - - if(event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) mixerOpen(); - if(event->matches(QKeySequence::MoveToNextLine)) - MixerlistWidget->setCurrentRow(MixerlistWidget->currentRow()+1); - if(event->matches(QKeySequence::MoveToPreviousLine)) - MixerlistWidget->setCurrentRow(MixerlistWidget->currentRow()-1); -} - -void ModelEdit::expolistWidget_KeyPress(QKeyEvent *event) -{ - if(event->matches(QKeySequence::SelectAll)) expoAdd(); //Ctrl A - if(event->matches(QKeySequence::Delete)) exposDelete(); - if(event->matches(QKeySequence::Copy)) exposCopy(); - if(event->matches(QKeySequence::Cut)) exposCut(); - if(event->matches(QKeySequence::Paste)) exposPaste(); - if(event->matches(QKeySequence::Underline)) exposDuplicate(); - - if(event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) expoOpen(); - if(event->matches(QKeySequence::MoveToNextLine)) - ExposlistWidget->setCurrentRow(ExposlistWidget->currentRow()+1); - if(event->matches(QKeySequence::MoveToPreviousLine)) - ExposlistWidget->setCurrentRow(ExposlistWidget->currentRow()-1); -} - -int ModelEdit::gm_moveMix(int idx, bool dir) //true=inc=down false=dec=up -{ - if(idx>GetEepromInterface()->getCapability(Mixes) || (idx==0 && !dir) || (idx==GetEepromInterface()->getCapability(Mixes) && dir)) return idx; - - int tdx = dir ? idx+1 : idx-1; - MixData &src=g_model.mixData[idx]; - MixData &tgt=g_model.mixData[tdx]; - - unsigned int outputs = GetEepromInterface()->getCapability(Outputs); - if((src.destCh==0) || (src.destCh>outputs) || (tgt.destCh>outputs)) return idx; - - if(tgt.destCh!=src.destCh) { - if ((dir) && (src.destCh0)) src.destCh--; - return idx; - } - - //flip between idx and tgt - MixData temp; - memcpy(&temp,&src,sizeof(MixData)); - memcpy(&src,&tgt,sizeof(MixData)); - memcpy(&tgt,&temp,sizeof(MixData)); - return tdx; -} - -void ModelEdit::moveMixUp() -{ - QList list = createMixListFromSelected(); - QList highlightList; - foreach(int idx, list) { - highlightList << gm_moveMix(idx, false); - } - updateSettings(); - tabMixes(); - setSelectedByMixList(highlightList); -} - -void ModelEdit::moveMixDown() -{ - QList list = createMixListFromSelected(); - QList highlightList; - foreach(int idx, list) { - highlightList << gm_moveMix(idx, true); - } - updateSettings(); - tabMixes(); - setSelectedByMixList(highlightList); -} - -int ModelEdit::gm_moveExpo(int idx, bool dir) //true=inc=down false=dec=up -{ - if(idx>C9X_MAX_EXPOS || (idx==C9X_MAX_EXPOS && dir)) return idx; - - int tdx = dir ? idx+1 : idx-1; - ExpoData temp; - temp.clear(); - ExpoData &src=g_model.expoData[idx]; - ExpoData &tgt=g_model.expoData[tdx]; - if (!dir && tdx<0 && src.chn>0) { - src.chn--; - return idx; - } else if (!dir && tdx<0) { - return idx; - } - - if(memcmp(&src,&temp,sizeof(ExpoData))==0) return idx; - bool tgtempty=(memcmp(&tgt,&temp,sizeof(ExpoData))==0 ? 1:0); - if(tgt.chn!=src.chn || tgtempty) { - if ((dir) && (src.chn<(NUM_STICKS-1))) src.chn++; - if ((!dir) && (src.chn>0)) src.chn--; - return idx; - } - - //flip between idx and tgt - memcpy(&temp,&src,sizeof(ExpoData)); - memcpy(&src,&tgt,sizeof(ExpoData)); - memcpy(&tgt,&temp,sizeof(ExpoData)); - return tdx; -} - -void ModelEdit::moveExpoUp() -{ - QList list = createExpoListFromSelected(); - QList highlightList; - foreach(int idx, list) { - highlightList << gm_moveExpo(idx, false); - } - updateSettings(); - tabExpos(); - setSelectedByExpoList(highlightList); -} - -void ModelEdit::moveExpoDown() -{ - QList list = createExpoListFromSelected(); - QList highlightList; - foreach(int idx, list) { - highlightList << gm_moveExpo(idx, true); - } - updateSettings(); - tabExpos(); - setSelectedByExpoList(highlightList); -} - -void ModelEdit::launchSimulation() -{ - if (GetEepromInterface()->getSimulator()) { - RadioData *simuData = new RadioData; - *simuData = radioData; - simuData->models[id_model] = g_model; - if (GetEepromInterface()->getCapability(SimulatorType)) { - xsimulatorDialog sd(this); - sd.loadParams(*simuData, id_model); - sd.exec(); - } else { - simulatorDialog sd(this); - sd.loadParams(*simuData, id_model); - sd.exec(); - } - } else { - QMessageBox::warning(NULL, - QObject::tr("Warning"), - QObject::tr("Simulator for this firmware is not yet available")); - } -} - -void ModelEdit::on_pushButton_clicked() -{ - launchSimulation(); -} - -void ModelEdit::resetCurve() -{ - QPushButton *button = (QPushButton *)sender(); - int btn=button->objectName().mid(button->objectName().lastIndexOf("_")+1).toInt()-1; - if (btn!=currentCurve) { - int res = QMessageBox::question(this, "companion9x",tr("Are you sure you want to delete curve %1 ?").arg(btn+1),QMessageBox::Yes | QMessageBox::No); - if (res == QMessageBox::No) { - return; - } - } - memset(g_model.curves[btn].name,0,sizeof(g_model.curves[btn].name)); - ui->cname_LE->clear(); - g_model.curves[btn].count=5; - g_model.curves[btn].custom=false; - curvesLock=true; - for (int i=0; i<17; i++) { - g_model.curves[btn].points[i].x=0; - g_model.curves[btn].points[i].y=0; - spnx[i]->setMinimum(-100); - spnx[i]->setMaximum(100); - spnx[i]->setValue(0); - spny[i]->setValue(0); - } - curvesLock=false; - updateCurvesTab(); - if (btn==currentCurve) { - ui->curvetype_CB->setCurrentIndex(2); - } - updateSettings(); - drawCurve(); -} - -void ModelEdit::editCurve() -{ - QPushButton *button = (QPushButton *)sender(); - int btn=button->objectName().mid(button->objectName().lastIndexOf("_")+1).toInt()-1; - setCurrentCurve(btn); - drawCurve(); -} - -void ModelEdit::plotCurve(bool checked) -{ - QCheckBox *chk = (QCheckBox *)sender(); - int btn=chk->objectName().mid(chk->objectName().lastIndexOf("_")+1).toInt()-1; - plot_curve[btn] = checked; - drawCurve(); -} - -void ModelEdit::on_T2ThrTrgChkB_toggled(bool checked) -{ - g_model.t2throttle = checked; - updateSettings(); -} - -void ModelEdit::on_extendedLimitsChkB_toggled(bool checked) -{ - g_model.extendedLimits = checked; - setLimitMinMax(); - updateSettings(); -} - -void ModelEdit::on_thrwarnChkB_toggled(bool checked) -{ - if (switchEditLock) - return; - g_model.disableThrottleWarning = checked; - updateSettings(); -} - -void ModelEdit::on_thrrevChkB_toggled(bool checked) -{ - g_model.throttleReversed = checked; - updateSettings(); -} - -void ModelEdit::on_extendedTrimsChkB_toggled(bool checked) -{ - g_model.extendedTrims = checked; - tabPhases(); - updateSettings(); -} - -void ModelEdit::setLimitMinMax() -{ - on_numChannelsSB_editingFinished(); - on_numChannelsSB_2_editingFinished(); - on_numChannelsSB_3_editingFinished(); - int v = g_model.extendedLimits ? 125 : 100; - foreach(QSpinBox *sb, findChildren(QRegExp("minSB_[0-9]+"))) { - sb->setMaximum(25); - sb->setMinimum(-v); - } - foreach(QSpinBox *sb, findChildren(QRegExp("maxSB_[0-9]+"))) { - sb->setMaximum(v); - sb->setMinimum(-25); - } -} - - -void ModelEdit::safetySwitchesEdited() -{ - for(int i=0; iitemData(safetySwitchSwtch[i]->currentIndex()).toInt()); - g_model.safetySw[i].val = safetySwitchValue[i]->value(); - } - updateSettings(); -} - - - -void ModelEdit::on_templateList_doubleClicked(QModelIndex index) -{ - QString text = ui->templateList->item(index.row())->text(); - if (index.row()==13) { - uint64_t result=0xffffffff; - modelConfigDialog *mcw = new modelConfigDialog(radioData, &result, this); - mcw->exec(); - if (result!=0xffffffff) { - applyNumericTemplate(result); - updateSettings(); - tabMixes(); - } - } else { - int res = QMessageBox::question(this,tr("Apply Template?"),tr("Apply template \"%1\"?").arg(text),QMessageBox::Yes | QMessageBox::No); - if(res!=QMessageBox::Yes) return; - applyTemplate(index.row()); - updateSettings(); - tabMixes(); - } -} - - -MixData* ModelEdit::setDest(uint8_t dch) -{ - uint8_t i = 0; - while ((g_model.mixData[i].destCh<=dch) && (g_model.mixData[i].destCh) && (igetCapability(Mixes))) i++; - if(i==GetEepromInterface()->getCapability(Mixes)) return &g_model.mixData[0]; - - memmove(&g_model.mixData[i+1],&g_model.mixData[i], - (GetEepromInterface()->getCapability(Mixes)-(i+1))*sizeof(MixData) ); - memset(&g_model.mixData[i],0,sizeof(MixData)); - g_model.mixData[i].destCh = dch; - return &g_model.mixData[i]; -} - -void ModelEdit::clearExpos(bool ask) -{ - if(ask) { - int res = QMessageBox::question(this,tr("Clear Expos?"),tr("Really clear all the expos?"),QMessageBox::Yes | QMessageBox::No); - if(res!=QMessageBox::Yes) return; - } - memset(g_model.expoData,0,sizeof(g_model.expoData)); //clear all expos - updateSettings(); - tabExpos(); -} - -void ModelEdit::clearMixes(bool ask) -{ - if(ask) { - int res = QMessageBox::question(this,tr("Clear Mixes?"),tr("Really clear all the mixes?"),QMessageBox::Yes | QMessageBox::No); - if(res!=QMessageBox::Yes) return; - } - memset(g_model.mixData,0,sizeof(g_model.mixData)); //clear all mixes - updateSettings(); - tabMixes(); -} - -void ModelEdit::clearCurves(bool ask) -{ - if(ask) { - int res = QMessageBox::question(this,tr("Clear Curves?"),tr("Really clear all the curves?"),QMessageBox::Yes | QMessageBox::No); - if(res!=QMessageBox::Yes) return; - } - curvesLock=true; - if (!GetEepromInterface()->getCapability(CustomCurves)){ - ui->curvetype_CB->setDisabled(true); - int count=0; - for (int j=0; j< GetEepromInterface()->getCapability(NumCurves3); j++) { - g_model.curves[count].count=3; - g_model.curves[count].custom=false; - memset(g_model.curves[j].name,0,sizeof(g_model.curves[j].name)); - for (int i=0; i<17; i++) { - g_model.curves[count].points[i].x=0; - g_model.curves[count].points[i].y=0; - } - count++; - } - for (int j=0; j< GetEepromInterface()->getCapability(NumCurves5); j++) { - g_model.curves[count].count=5; - g_model.curves[count].custom=false; - memset(g_model.curves[j].name,0,sizeof(g_model.curves[j].name)); - for (int i=0; i<17; i++) { - g_model.curves[count].points[i].x=0; - g_model.curves[count].points[i].y=0; - } - count++; - } - for (int j=0; j< GetEepromInterface()->getCapability(NumCurves9); j++) { - g_model.curves[count].count=9; - g_model.curves[count].custom=false; - memset(g_model.curves[j].name,0,sizeof(g_model.curves[j].name)); - for (int i=0; i<17; i++) { - g_model.curves[count].points[i].x=0; - g_model.curves[count].points[i].y=0; - } - count++; - } - for (int j=count; j<16; j++) { - g_model.curves[j].count=5; - g_model.curves[j].custom=false; - memset(g_model.curves[j].name,0,sizeof(g_model.curves[j].name)); - for (int i=0; i<17; i++) { - g_model.curves[j].points[i].x=0; - g_model.curves[j].points[i].y=0; - } - } - } else { - for (int j=0; j<16; j++) { - g_model.curves[j].count=5; - g_model.curves[j].custom=false; - memset(g_model.curves[j].name,0,sizeof(g_model.curves[j].name)); - for (int i=0; i<17; i++) { - g_model.curves[j].points[i].x=0; - g_model.curves[j].points[i].y=0; - } - } - } - for (int i=0; i<17; i++) { - spnx[i]->setMinimum(-100); - spnx[i]->setMaximum(100); - spnx[i]->setValue(0); - spny[i]->setValue(0); - } - currentCurve=0; - curvesLock=false; - if (GetEepromInterface()->getCapability(NumCurves3)>0) { - ui->curvetype_CB->setCurrentIndex(0); - } else { - ui->curvetype_CB->setCurrentIndex(2); - } - ui->cname_LE->clear(); - updateSettings(); - drawCurve(); -} - -void ModelEdit::setCurve(uint8_t c, int8_t ar[]) -{ - int len=sizeof(ar)/sizeof(int8_t); - if (GetEepromInterface()->getCapability(CustomCurves)) { - if (GetEepromInterface()->getCapability(NumCurves)>c) { - if (len<9) { - g_model.curves[c].count=5; - g_model.curves[c].custom=false; - for (int i=0; i< 5; i++) { - g_model.curves[c].points[i].y=ar[i]; - } - } else { - g_model.curves[c].count=5; - g_model.curves[c].custom=false; - for (int i=0; i< 5; i++) { - g_model.curves[c].points[i].y=ar[i]; - } - } - } - } else { - if (len<9) { - g_model.curves[c].count=5; - g_model.curves[c].custom=false; - for (int i=0; i< 5; i++) { - g_model.curves[c].points[i].y=ar[i]; - } - } else { - g_model.curves[c+8].count=5; - g_model.curves[c+8].custom=false; - for (int i=0; i< 5; i++) { - g_model.curves[c+8].points[i].y=ar[i]; - } - } - } -} - -void ModelEdit::setSwitch(unsigned int idx, unsigned int func, int v1, int v2) -{ - g_model.customSw[idx-1].func = func; - g_model.customSw[idx-1].val1 = v1; - g_model.customSw[idx-1].val2 = v2; -} - -void ModelEdit::applyNumericTemplate(uint64_t tpl) -{ - clearCurves(false); - clearExpos(false); - clearMixes(false); - int8_t heli_ar1[] = {-100, -20, 30, 70, 90}; - int8_t heli_ar2[] = {80, 70, 60, 70, 100}; - int8_t heli_ar3[] = {100, 90, 80, 90, 100}; - int8_t heli_ar4[] = {-30, -15, 0, 50, 100}; - int8_t heli_ar5[] = {-100, -50, 0, 50, 100}; - bool rx[10]; - for (int i=0; i<10 ; i++) { - rx[i]=false; - } - int thrsw=GetEepromInterface()->getCapability(GetThrSwitch); - MixData *md = &g_model.mixData[0]; - uint8_t spo2ch=(tpl & 0x0F); - tpl>>=4; - uint8_t spo1ch=(tpl & 0x0F); - tpl>>=4; - uint8_t fla2ch=(tpl & 0x0F); - tpl>>=4; - uint8_t fla1ch=(tpl & 0x0F); - tpl>>=4; - uint8_t rud2ch=(tpl & 0x0F); - tpl>>=4; - uint8_t ele2ch=(tpl & 0x0F); - tpl>>=4; - uint8_t ail2ch=(tpl & 0x0F); - tpl>>=4; - uint8_t chstyle=(tpl & 0x03); - tpl>>=2; - uint8_t gyro=(tpl & 0x03); - tpl>>=2; - uint8_t tailtype=(tpl & 0x03); - tpl>>=2; - uint8_t swashtype=(tpl & 0x07); - tpl>>=3; - uint8_t ruddertype=(tpl & 0x03); - tpl>>=2; - uint8_t spoilertype=(tpl & 0x3); - tpl>>=2; - uint8_t flaptype=(tpl & 0x03); - tpl>>=2; - uint8_t ailerontype=(tpl & 0x03); - tpl>>=2; - uint8_t enginetype=(tpl & 0x03); - tpl>>=2; - uint8_t modeltype=(tpl & 0x03); - - #define ICC(x) icc[(x)-1] - uint8_t icc[4] = {0}; - for(uint8_t i=1; i<=4; i++) //generate inverse array - for(uint8_t j=1; j<=4; j++) if(CC(i)==j) icc[j-1]=i; - - int ailerons; - int flaps; - int throttle; - int spoilers; - int elevators; - int rudders; - int sign; - uint8_t rxch; - switch (modeltype) { - case 0: - ailerons=ailerontype; - flaps=flaptype; - throttle=1; - switch (tailtype) { - case 0: - case 1: - rudders=1; - elevators=1; - break; - case 2: - rudders=1; - elevators=2; - break; - } - rxch=ICC(STK_RUD); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); - if (tailtype==1) { - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); - } - rx[rxch-1]=true; - rxch=ICC(STK_ELE); - if (tailtype==1) { - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); - } - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); - rx[rxch-1]=true; - rxch=ICC(STK_THR); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("THR").toAscii().data(),6); - rx[rxch-1]=true; - if (ail2ch > 0) { - rx[ail2ch-1]=true; - } - if (ele2ch > 0) { - rx[ele2ch-1]=true; - } - if (fla1ch > 0) { - rx[fla1ch-1]=true; - } - if (fla2ch > 0) { - rx[fla2ch-1]=true; - } - if (ailerons>0) { - rxch=ICC(STK_AIL); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); - rx[rxch-1]=true; - } - if (ailerons>1) { - if (ail2ch==0) { - for (int j=0; j<10 ; j++) { - if (!rx[j]) { - md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6); - rx[j]=true; - break; - } - } - } else { - md=setDest(ail2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6); - } - } - if (elevators>1) { - if (ele2ch==0) { - for (int j=0; j<10 ; j++) { - if (!rx[j]) { - md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();;strncpy(md->name, tr("ELE2").toAscii().data(),6); - rx[j]=true; - break; - } - } - }else{ - md=setDest(ele2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();;strncpy(md->name, tr("ELE2").toAscii().data(),6); - } - } - if (flaps>0) { - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->speedUp=4; md->speedDown=4; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->speedUp=4; md->speedDown=4; - } - sign=-1; - for (uint8_t i=0; i< flaps; i++) { - sign*=-1; - int index; - if (i==0) { - index=fla1ch; - } else { - index=fla2ch; - } - if (index==0) { - for (int j=0; j<10 ; j++) { - if (!rx[j]) { - md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); - rx[j]=true; - break; - } - } - } else { - md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); - } - } - break; - case 1: - setCurve(CURVE5(1),heli_ar1); - setCurve(CURVE5(2),heli_ar2); - setCurve(CURVE5(3),heli_ar3); - setCurve(CURVE5(4),heli_ar4); - setCurve(CURVE5(5),heli_ar5); - setCurve(CURVE5(6),heli_ar5); - switch (swashtype) { - case 0: - g_model.swashRingData.type = HELI_SWASH_TYPE_90; - break; - case 1: - g_model.swashRingData.type = HELI_SWASH_TYPE_120; - break; - case 2: - g_model.swashRingData.type = HELI_SWASH_TYPE_120X; - break; - case 3: - g_model.swashRingData.type = HELI_SWASH_TYPE_140; - break; - case 4: - g_model.swashRingData.type = HELI_SWASH_TYPE_NONE; - break; - } - g_model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); - - if (chstyle==0) { - if (swashtype!=4) { - md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); - md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6); - } else { - md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); - md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6); - } - md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - switch (gyro) { - case 1: - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); - break; - case 2: - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); - break; - } - } else { - if (swashtype!=4) { - md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); - md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6); - } else { - md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); - md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6); - } - md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - switch (gyro) { - case 1: - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); - break; - case 2: - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); - break; - } - } - // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; - break; - case 2: - ailerons=ailerontype; - flaps=flaptype; - spoilers=spoilertype; - throttle=enginetype; - switch (tailtype) { - case 0: - case 1: - rudders=1; - elevators=1; - break; - case 2: - rudders=1; - elevators=2; - break; - } - if (throttle==1) { - rxch=ICC(STK_THR); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("THR").toAscii().data(),6); - rx[rxch-1]=true; - } - rxch=ICC(STK_RUD); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); - if (tailtype==1) { - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); - } - rx[rxch-1]=true; - rxch=ICC(STK_ELE); - if (tailtype==1) { - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); - } - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); - rx[rxch-1]=true; - if (ail2ch > 0) { - rx[ail2ch-1]=true; - } - if (ele2ch > 0) { - rx[ele2ch-1]=true; - } - if (fla1ch > 0) { - rx[fla1ch-1]=true; - } - if (fla2ch > 0) { - rx[fla2ch-1]=true; - } - if (spo1ch > 0) { - rx[spo1ch-1]=true; - } - if (spo2ch > 0) { - rx[spo2ch-1]=true; - } - - if (ailerons>0) { - rxch=ICC(STK_AIL); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); - rx[rxch-1]=true; - } - if (ailerons>1) { - if (ail2ch==0) { - for (int j=0; j<10 ; j++) { - if (!rx[j]) { - md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6); - rx[j]=true; - break; - } - } - } else { - md=setDest(ail2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6); - } - } - if (elevators>1) { - if (ele2ch==0) { - for (int j=0; j<10 ; j++) { - if (!rx[j]) { - md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE2").toAscii().data(),6); - rx[j]=true; - break; - } - } - } else { - md=setDest(ele2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE2").toAscii().data(),6); - } - } - if (flaps>0) { - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6);md->speedUp=4; md->speedDown=4; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6);md->speedUp=4; md->speedDown=4; - } - sign=-1; - for (uint8_t i=0; i< flaps; i++) { - sign*=-1; - int index; - if (i==0) { - index=fla1ch; - } else { - index=fla2ch; - } - if (index==0) { - for (int j=0; j<10 ; j++) { - if (!rx[j]) { - md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); - rx[j]=true; - break; - } - } - } else { - md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); - } - } - if (spoilers>0) { - md=setDest(12); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);strncpy(md->name, tr("SPOIL").toAscii().data(),6); md->speedUp=4;;md->speedDown=4; - md=setDest(12); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);strncpy(md->name, tr("SPOIL").toAscii().data(),6);md->speedUp=4;md->speedDown=4; - } - sign=-1; - for (uint8_t i=0; i< spoilers; i++) { - sign*=-1; - int index; - if (i==0) { - index=spo1ch; - } else { - index=spo2ch; - } - if (index==0) { - for (int j=0; j<10 ; j++) { - if (!rx[j]) { - md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 11); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("SPOIL%1").arg(i+1).toAscii().data(),6); - rx[j]=true; - break; - } - } - } else { - md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 11); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("SPOIL%1").arg(i+1).toAscii().data(),6); - } - } - break; - case 3: - flaps=flaptype; - throttle=enginetype; - rudders=ruddertype; - if (throttle==1) { - rxch=ICC(STK_THR); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("THR").toAscii().data(),6); - rx[rxch-1]=true; - } - rxch=ICC(STK_ELE); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); - rx[rxch-1]=true; - rxch=ICC(STK_AIL); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); - rx[rxch-1]=true; - if (rudders>0) { - rxch=ICC(STK_RUD); - md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); - rx[rxch-1]=true; - } - if (rud2ch > 0) { - rx[rud2ch-1]=true; - } - if (fla1ch > 0) { - rx[fla1ch-1]=true; - } - if (fla2ch > 0) { - rx[fla2ch-1]=true; - } - if (rudders>1) { - if (rud2ch==0) { - for (int j=0; j<10 ; j++) { - if (!rx[j]) { - md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD2").toAscii().data(),6); - rx[j]=true; - break; - } - } - } else { - md=setDest(rud2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD2").toAscii().data(),6); - } - } - if (flaps>0) { - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->sOffset=0; md->speedUp=4; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->sOffset=0; md->speedUp=4; - } - sign=-1; - for (uint8_t i=0; i< flaps; i++) { - sign*=-1; - int index; - if (i==0) { - index=fla1ch; - } else { - index=fla2ch; - } - if (index==0) { - for (int j=0; j<10 ; j++) { - if (!rx[j]) { - md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->speedUp=4; md->speedDown=4; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); - rx[j]=true; - break; - } - } - } else { - md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->speedUp=4; md->speedDown=4; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); - } - } - break; - } - updateHeliTab(); - updateCurvesTab(); - if (modeltype==1 && swashtype!=4) { - ui->tabWidget->setCurrentIndex(1); - } else { - ui->tabWidget->setCurrentIndex(4); - } - resizeEvent(); -} - -void ModelEdit::applyTemplate(uint8_t idx) -{ - int8_t heli_ar1[] = {-100, -20, 30, 70, 90}; - int8_t heli_ar2[] = {80, 70, 60, 70, 100}; - int8_t heli_ar3[] = {100, 90, 80, 90, 100}; - int8_t heli_ar4[] = {-30, -15, 0, 50, 100}; - int8_t heli_ar5[] = {-100, -50, 0, 50, 100}; - - int thrsw=GetEepromInterface()->getCapability(GetThrSwitch); - MixData *md = &g_model.mixData[0]; - - //CC(STK) -> vSTK - //ICC(vSTK) -> STK - #define ICC(x) icc[(x)-1] - uint8_t icc[4] = {0}; - for(uint8_t i=1; i<=4; i++) //generate inverse array - for(uint8_t j=1; j<=4; j++) if(CC(i)==j) icc[j-1]=i; - - - uint8_t j = 0; - - //Simple 4-Ch - if(idx==j++) { - if (md->destCh) - clearMixes(); - md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch(); - } - - //T-Cut - if(idx==j++) { - md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - } - - //sticky t-cut - if(idx==j++) { - md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 12); md->mltpx=MLTPX_REP; - md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_CH, 13); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP; - md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - setSwitch(0xB, CS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99); - setSwitch(0xC, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0); - updateSwitchesTab(); - } - - //V-Tail - if(idx==j++) { - clearMixes(); - md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch(); - } - - //Elevon\\Delta - if(idx==j++) { - clearMixes(); - md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch(); - md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch(); - } - - //Heli Setup - if(idx==j++) { - clearMixes(); //This time we want a clean slate - clearCurves(); - - // Set up Mixes - // 3 cyclic channels - md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch(); - - // rudder - md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); - - // throttle - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - - // gyro gain - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); - - // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; - - g_model.swashRingData.type = HELI_SWASH_TYPE_120; - g_model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); - - // set up Curves - setCurve(CURVE5(1),heli_ar1); - setCurve(CURVE5(2),heli_ar2); - setCurve(CURVE5(3),heli_ar3); - setCurve(CURVE5(4),heli_ar4); - setCurve(CURVE5(5),heli_ar5); - setCurve(CURVE5(6),heli_ar5); - - // make sure curves are redrawn - updateHeliTab(); - updateCurvesTab(); - resizeEvent(); - } - - //Heli Setup gyro gain control - if(idx==j++) { - clearMixes(); //This time we want a clean slate - clearCurves(); - - // Set up Mixes - // 3 cyclic channels - md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch(); - - // rudder - md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); - - // throttle - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - - // gyro gain - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100; - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100; - - // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; - - g_model.swashRingData.type = HELI_SWASH_TYPE_120; - g_model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); - - // set up Curves - setCurve(CURVE5(1),heli_ar1); - setCurve(CURVE5(2),heli_ar2); - setCurve(CURVE5(3),heli_ar3); - setCurve(CURVE5(4),heli_ar4); - setCurve(CURVE5(5),heli_ar5); - setCurve(CURVE5(6),heli_ar5); - - // make sure curves are redrawn - updateHeliTab(); - updateCurvesTab(); - resizeEvent(); - } - - // gyro gain control - if(idx==j++) { - int res = QMessageBox::question(this,tr("Clear Mixes?"),tr("Really clear existing mixes on CH6?"),QMessageBox::Yes | QMessageBox::No); - if(res!=QMessageBox::Yes) return; - // first clear mix on ch6 - bool found=true; - while (found) { - found=false; - for (int i=0; i< GetEepromInterface()->getCapability(Mixes); i++) { - if (g_model.mixData[i].destCh==6) { - gm_deleteMix(i); - found=true; - break; - } - } - } - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100; - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100; - } - - //Heli Setup futaba style - if(idx==j++) { - clearMixes(); //This time we want a clean slate - clearCurves(); - - // Set up Mixes - // 3 cyclic channels - md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch(); - - // rudder - md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); - - // throttle - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - - // gyro gain - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); - - // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; - - g_model.swashRingData.type = HELI_SWASH_TYPE_120; - g_model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); - - // set up Curves - setCurve(CURVE5(1),heli_ar1); - setCurve(CURVE5(2),heli_ar2); - setCurve(CURVE5(3),heli_ar3); - setCurve(CURVE5(4),heli_ar4); - setCurve(CURVE5(5),heli_ar5); - setCurve(CURVE5(6),heli_ar5); - - // make sure curves are redrawn - updateHeliTab(); - updateCurvesTab(); - resizeEvent(); - } - - // Heli setup futaba style with gyro gain control - if(idx==j++) { - clearMixes(); //This time we want a clean slate - clearCurves(); - - // Set up Mixes - // 3 cyclic channels - md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch(); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch(); - - // rudder - md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); - - // throttle - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - - // gyro gain - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100; - - // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; - - g_model.swashRingData.type = HELI_SWASH_TYPE_120; - g_model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); - - // set up Curves - setCurve(CURVE5(1),heli_ar1); - setCurve(CURVE5(2),heli_ar2); - setCurve(CURVE5(3),heli_ar3); - setCurve(CURVE5(4),heli_ar4); - setCurve(CURVE5(5),heli_ar5); - setCurve(CURVE5(6),heli_ar5); - - // make sure curves are redrawn - updateHeliTab(); - updateCurvesTab(); - resizeEvent(); - } - - // gyro gain control futaba style - if(idx==j++) { - int res = QMessageBox::question(this,tr("Clear Mixes?"),tr("Really clear existing mixes on CH5?"),QMessageBox::Yes | QMessageBox::No); - if(res!=QMessageBox::Yes) return; - // first clear mix on ch6 - bool found=true; - while (found) { - found=false; - for (int i=0; i< GetEepromInterface()->getCapability(Mixes); i++) { - if (g_model.mixData[i].destCh==5) { - gm_deleteMix(i); - found=true; - break; - } - } - } - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100; - } - - //Servo Test - if(idx==j++) { - md=setDest(15); md->srcRaw=RawSource(SOURCE_TYPE_CH, 15); md->weight= 100; md->speedUp = 8; md->speedDown = 8; md->swtch=RawSwitch(); - md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_CUSTOM_SWITCH, 0); md->weight= 110; md->swtch=RawSwitch(); - md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP; - md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP; - setSwitch(1, CS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue()); - setSwitch(2, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105); - setSwitch(3, CS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105); - - // redraw switches tab - updateSwitchesTab(); - } - - //MultiCopter - if(idx==j++) { - if (md->destCh) - clearMixes(); - md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=50; md->swtch=RawSwitch(); //CH1 AIL - md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-50; md->swtch=RawSwitch(); //CH2 ELE - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(); //CH3 THR - md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); //CH4 RUD - } -} - -void ModelEdit::ControlCurveSignal(bool flag) -{ - foreach(QSpinBox *sb, findChildren(QRegExp("curvePt[0-9]+"))) { - sb->blockSignals(flag); - } -} - -void ModelEdit::shrink() { -#if defined __APPLE__ - QSettings settings("companion9x", "companion9x"); - QPoint pos = settings.value("mepos", QPoint(0, 0)).toPoint(); - QSize size = settings.value("mesize", QSize(800, 625)).toSize(); - move(pos); - resize(size); -# else - const int height = QApplication::desktop()->height(); - QSettings settings("companion9x", "companion9x"); - QPoint pos = settings.value("mepos", QPoint(100, 100)).toPoint(); - QSize size = settings.value("mesize", QSize(800, 625)).toSize(); - if (size.height() < height) { - move(pos); - resize(size); - } else { - resize(0,0); - } -#endif - ui->curvePreview->repaint(); -} - -void ModelEdit::on_cname_LE_editingFinished() { - if (GetEepromInterface()->getCapability(HasCvNames)) { - int i=0; - for (i=0; icname_LE->text().toAscii().length(); i++) { - g_model.curves[currentCurve].name[i]=ui->cname_LE->text().toAscii().at(i); - } - g_model.curves[currentCurve].name[i]=0; - } - updateSettings(); -} - -void ModelEdit::on_curvetype_CB_currentIndexChanged(int index) { - if (curvesLock) - return; - int numcurves=GetEepromInterface()->getCapability(NumCurves); - if (numcurves==0) { - numcurves=16; - } - int numpoint[]={3,3,5,5,9,9,17,17}; - bool custom[]={false,true,false,true,false,true,false,true}; - int currpoints=g_model.curves[currentCurve].count; - bool currcustom=g_model.curves[currentCurve].custom; - curvesLock=true; - int totalpoints=0; - for (int i=0; i< numcurves; i++) { - if (i!=currentCurve) { - totalpoints+=g_model.curves[i].count; - if (g_model.curves[i].custom) { - totalpoints+=g_model.curves[i].count-2; - } - } - } - totalpoints+=numpoint[index]; - if (currcustom) { - totalpoints+=numpoint[index]-2; - } - int fwpoints=GetEepromInterface()->getCapability(NumCurvePoints); - if (fwpoints!=0) { - if (fwpointscurvetype_CB->setCurrentIndex(oldindex); - curvesLock=false; - return; - } - } - // let's be sure that for standard curves X values are set correctly. - if (!currcustom) { - for (int i=0; i< currpoints; i++) { - spnx[i]->setMinimum(-100); - spnx[i]->setMaximum(100); - spnx[i]->setValue(-100+((200*i)/(currpoints-1))); - } - } - if (numpoint[index]==currpoints) { - for (int i=0; i< currpoints; i++) { - spnx[i]->setMinimum(-100); - spnx[i]->setMaximum(100); - spnx[i]->setValue(-100+((200*i)/(currpoints-1))); - } - for (int i=currpoints; i< 17; i++) { - spnx[i]->setMinimum(-100); - spnx[i]->setMaximum(100); - spnx[i]->setValue(0); - spny[i]->setValue(0); - } - } else if (numpoint[index]>currpoints) { - for (int i=0; i< 17; i++) { - g_model.curves[currentCurve].points[i].x=spnx[i]->value(); - g_model.curves[currentCurve].points[i].y=spny[i]->value(); - spnx[i]->setMinimum(-100); - spnx[i]->setMaximum(100); - } - int currintervals=currpoints-1; - int diffpoints=numpoint[index]-currpoints; - int skip=diffpoints/currintervals; - for (int i=0; i< currpoints; i++) { - if (custom[index]) { - spnx[i+(skip*i)]->setValue(g_model.curves[currentCurve].points[i].x); - } else { - spnx[i+(skip*i)]->setValue(-100+(200*i)/currintervals); - } - spny[i+(skip*i)]->setValue(g_model.curves[currentCurve].points[i].y); - if (i>0) { - int diffx=spnx[i+(skip*i)]->value()-spnx[(i-1)+(skip*(i-1))]->value(); - int diffy=spny[i+(skip*i)]->value()-spny[(i-1)+(skip*(i-1))]->value(); - for (int j=1; j<= skip; j++) { - spny[(i-1)+skip*(i-1)+j]->setValue(spny[(i-1)+(skip*(i-1))]->value()+((diffy*j)/(skip+1))); - spnx[(i-1)+skip*(i-1)+j]->setValue(spnx[(i-1)+(skip*(i-1))]->value()+((diffx*j)/(skip+1))); - } - } - } - } else { - int intervals=numpoint[index]-1; - int diffpoints=currpoints-numpoint[index]; - int skip=diffpoints/intervals; - for (int i=0; i< numpoint[index]; i++) { - spnx[i]->setMinimum(-100); - spnx[i]->setMaximum(100); - if (custom[index]) { - spnx[i]->setValue(spnx[i+skip*i]->value()); - } else { - spnx[i]->setValue(-100+(200*i)/intervals); - } - spny[i]->setValue(spny[i+skip*i]->value()); - } - for (int i=numpoint[index]; i< 17; i++) { - spnx[i]->setValue(0); - spny[i]->setValue(0); - } - } - curvesLock=false; - for (int i=0; i< 17; i++) { - g_model.curves[currentCurve].points[i].x=spnx[i]->value(); - g_model.curves[currentCurve].points[i].y=spny[i]->value(); - } - g_model.curves[currentCurve].count=numpoint[index]; - g_model.curves[currentCurve].custom=custom[index]; - setCurrentCurve(currentCurve); - if (redrawCurve) - drawCurve(); - updateSettings(); -} - -void ModelEdit::closeEvent(QCloseEvent *event) -{ - QSettings settings("companion9x", "companion9x"); - settings.setValue("mepos", pos()); - settings.setValue("mesize", size()); - event->accept(); -} - -void ModelEdit::wizard() -{ - uint64_t result=0xffffffff; - modelConfigDialog *mcw = new modelConfigDialog(radioData, &result, this); - mcw->exec(); - if (result!=0xffffffff) { - applyNumericTemplate(result); - updateSettings(); - tabMixes(); - } else if (this->isNew) { - memset(&g_model, 0, sizeof(ModelData)); - accept(); - } -} diff --git a/companion/src/modeledit.h b/companion/src/modeledit.h deleted file mode 100644 index f6a2785c3..000000000 --- a/companion/src/modeledit.h +++ /dev/null @@ -1,393 +0,0 @@ -#ifndef MODELEDIT_H -#define MODELEDIT_H - -#include -#include -#include -#include "eeprominterface.h" -#include "mixerslist.h" -#ifdef PHONON -#include -#include -#include -#endif -namespace Ui { - class ModelEdit; -} - -class ModelEdit : public QDialog -{ - Q_OBJECT - -public: - explicit ModelEdit(RadioData &radioData, uint8_t id , bool openWizard =false, bool inNew =false, QWidget *parent = 0); - ~ModelEdit(); - - void applyBaseTemplate(); - bool redrawCurve; - void drawCurve(); - bool drawing; - bool mixInserted; - bool expoInserted; - bool openWizard; - bool isNew; -private: - Ui::ModelEdit *ui; - - QSpinBox* spny[17]; - QSpinBox* spnx[17]; - QSpinBox* gvarsSB[9][5]; - QSpinBox* reSB[9][2]; - QGroupBox* barsGB[3]; - QGroupBox* numsGB[3]; - QComboBox* barsCB[12]; - QDoubleSpinBox* minSB[12]; - QDoubleSpinBox* maxSB[12]; - QComboBox* csf[36]; - QComboBox* csw[C9X_NUM_CSW]; - MixersList *ExposlistWidget; - - MixersList *MixerlistWidget; - - RadioData &radioData; - int id_model; - ModelData g_model; - GeneralSettings g_eeGeneral; - bool protocolEditLock; - bool protocol2EditLock; - bool trainerEditLock; - bool switchEditLock; - bool heliEditLock; - bool limitEditLock; - bool phasesLock; - bool telemetryLock; - bool curvesLock; - bool phononLock; - bool fsLock; - bool modelImageLock; - bool plot_curve[16]; - int selectedSwitch; - int selectedFunction; - QDoubleSpinBox * cswitchValue[C9X_NUM_CSW]; - QDoubleSpinBox * cswitchOffset[C9X_NUM_CSW]; - QComboBox * cswitchAnd[C9X_NUM_CSW]; - QDoubleSpinBox * cswitchDuration[C9X_NUM_CSW]; - QDoubleSpinBox * cswitchDelay[C9X_NUM_CSW]; - QComboBox * cswitchSource1[C9X_NUM_CSW]; - QComboBox * cswitchSource2[C9X_NUM_CSW]; - QLabel * fswLabel[C9X_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS]; - QCheckBox * fswtchParamGV[C9X_MAX_CUSTOM_FUNCTIONS]; - QDoubleSpinBox * fswtchParam[C9X_MAX_CUSTOM_FUNCTIONS]; - QPushButton * playBT[C9X_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS]; - QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS]; - - QSpinBox * safetySwitchValue[C9X_NUM_CHNOUT]; - QComboBox * safetySwitchSwtch[C9X_NUM_CHNOUT]; - QSlider * phasesTrimSliders[9][4]; - QSpinBox * phasesTrimValues[9][4]; - - void setupExposListWidget(); - void setupMixerListWidget(); - float getBarStep(int barId); - void telBarUpdate(); - - void updateSettings(); - void tabModelEditSetup(); - void tabPhases(); - void tabExpos(); - void tabMixes(); - void tabHeli(); - void tabLimits(); - void tabCurves(); - void tabCustomSwitches(); - void tabSafetySwitches(); - void tabCustomFunctions(); - void tabTelemetry(); - void tabTemplates(); - void updateCurvesTab(); - void setSwitchWidgetVisibility(int i); - void setLimitMinMax(); - void updateSelectedSwitch(); - void updateSwitchesTab(); - void updateHeliTab(); - void updateA1Fields(); - void updateA2Fields(); - - void launchSimulation(); - void resizeEvent(QResizeEvent *event = 0); - - - int currentCurve; - void setCurrentCurve(int curveId); - - QSpinBox *getNodeSB(int i); - QSpinBox *getNodeSBX(int i); - - int getExpoIndex(unsigned int dch); - bool gm_insertExpo(int idx); - void gm_deleteExpo(int index); - void gm_openExpo(int index); - int gm_moveExpo(int idx, bool dir); - void exposDeleteList(QList list); - QList createExpoListFromSelected(); - void setSelectedByExpoList(QList list); - - int getMixerIndex(unsigned int dch); - bool gm_insertMix(int idx); - void gm_deleteMix(int index); - void gm_openMix(int index); - int gm_moveMix(int idx, bool dir); - void mixersDeleteList(QList list); - QList createMixListFromSelected(); - void setSelectedByMixList(QList list); - - void applyTemplate(uint8_t idx); - void applyNumericTemplate(uint64_t tpl); - MixData* setDest(uint8_t dch); - void setCurve(uint8_t c, int8_t ar[]); - void setSwitch(unsigned int idx, unsigned int func, int v1, int v2); - void on_phaseSwitch_currentIndexChanged(unsigned int phase, int index); - void on_phaseFadeIn_valueChanged(unsigned int phase, int value); - void on_phaseFadeOut_valueChanged(unsigned int phase, int value); - void on_phaseTrim_valueChanged(unsigned int phase, unsigned int stick, int value); - void on_phaseTrimUse_currentIndexChanged(unsigned int phase, unsigned int stick, int index, QSpinBox *trim, QSlider *slider); - void displayOnePhaseOneTrim(unsigned int phase_idx, unsigned int trim_idx, QComboBox *trimUse, QSpinBox *trimVal, QSlider *trimSlider); - void displayOnePhase(unsigned int phase_idx, QLineEdit *name, QComboBox *sw, QDoubleSpinBox *fadeIn, QDoubleSpinBox *fadeOut, QComboBox *trim1Use, QSpinBox *trim1, QLabel *trim1Label, QSlider *trim1Slider, QComboBox *trim2Use, QSpinBox *trim2, QLabel *trim2Label, QSlider *trim2Slider, QComboBox *trim3Use, QSpinBox *trim3, QLabel *trim3Label, QSlider *trim3Slider, QComboBox *trim4Use, QSpinBox *trim4, QLabel *trim4Label, QSlider *trim4Slider, QLabel *gv1Label, QComboBox *gv1Use,QSpinBox *gv1Value, QLabel *gv2Label, QComboBox *gv2Use,QSpinBox *gv2Value, QLabel *gv3Label, QComboBox *gv3Use,QSpinBox *gv3Value, QLabel *gv4Label, QComboBox *gv4Use,QSpinBox *gv4Value, QLabel *gv5Label, QComboBox *gv5Use,QSpinBox *gv5Value, QLabel *re1Label, QComboBox *re1Use,QSpinBox *re1Value, QLabel *re2Label, QComboBox *re2Use,QSpinBox *re2Value,bool doConnect); - - void incSubtrim(uint8_t idx, int16_t inc); -#ifdef PHONON - Phonon::MediaObject *clickObject; - Phonon::AudioOutput *clickOutput; -#endif - -signals: - void modelValuesChanged(); - -private slots: - void clearExpos(bool ask=true); - void clearMixes(bool ask=true); - void clearCurves(bool ask=true); - void on_modelVoice_SB_editingFinished(); - void on_T2ThrTrgChkB_toggled(bool checked); - void on_ttraceCB_currentIndexChanged(int index); - void on_instantTrim_CB_currentIndexChanged(int index); - void on_extendedLimitsChkB_toggled(bool checked); - void on_extendedTrimsChkB_toggled(bool checked); - void on_thrwarnChkB_toggled(bool checked); - void on_thrrevChkB_toggled(bool checked); - void on_timer1Perm_toggled(bool checked); - void on_timer2Perm_toggled(bool checked); - void on_timer1Minute_toggled(bool checked); - void on_timer2Minute_toggled(bool checked); - void on_timer1CountDownBeep_toggled(bool checked); - void on_timer2CountDownBeep_toggled(bool checked); - void fssldEdited(); - void fssbEdited(); - void fssldValueChanged(); - void fssbValueChanged(); - void resetCurve(); - void editCurve(); - void playMusic(); -#ifdef PHONON - void mediaPlayer_state(Phonon::State newState, Phonon::State oldState); -#endif - - void plotCurve(bool checked); -//phases slots - void phaseName_editingFinished(); - void phaseSwitch_currentIndexChanged(); - void phaseFadeIn_editingFinished(); - void phaseFadeOut_editingFinished(); - void phaseTrimUse_currentIndexChanged(); - void phaseTrim_valueChanged(); - void phaseTrimSlider_valueChanged(); - void GVName_editingFinished(); - void GVSource_currentIndexChanged(); - void phaseGVValue_editingFinished(); - void phaseGVUse_currentIndexChanged(); - void phaseREValue_editingFinished(); - void phaseREUse_currentIndexChanged(); - - void mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction action); - void pasteMixerMimeData(const QMimeData * mimeData, int destIdx); - - void mimeExpoDropped(int index, const QMimeData *data, Qt::DropAction action); - void pasteExpoMimeData(const QMimeData * mimeData, int destIdx); - - void on_pushButton_clicked(); - - void exposDelete(bool ask=true); - void exposCut(); - void exposCopy(); - void exposPaste(); - void exposDuplicate(); - void expoOpen(QListWidgetItem *item = NULL); - void expoAdd(); - - void cswDelete(); - void cswCopy(); - void cswPaste(); - void cswCut(); - - void fswDelete(); - void fswCopy(); - void fswPaste(); - void fswCut(); - - void moveExpoUp(); - void moveExpoDown(); - - void mixersDelete(bool ask=true); - void mixersCut(); - void mixersCopy(); - void mixersPaste(); - void mixersDuplicate(); - void mixerOpen(); - void mixerAdd(); - void moveMixUp(); - void moveMixDown(); - - void expolistWidget_customContextMenuRequested(QPoint pos); - void expolistWidget_doubleClicked(QModelIndex index); - void expolistWidget_KeyPress(QKeyEvent *event); - - - void mixerlistWidget_customContextMenuRequested(QPoint pos); - void mixerlistWidget_doubleClicked(QModelIndex index); - void mixerlistWidget_KeyPress(QKeyEvent *event); - - void csw_customContextMenuRequested(QPoint pos); - void fsw_customContextMenuRequested(QPoint pos); - - - void curvePointEdited(); - void on_ca_ctype_CB_currentIndexChanged(); - void on_ca_apply_PB_clicked(); - - void on_cname_LE_editingFinished(); - void limitOffsetEdited(); - void limitSymEdited(); - void limitEdited(); - void limitNameEdited(); - void limitInvEdited(); - void ppmcenterEdited(); - void customSwitchesEdited(); - void safetySwitchesEdited(); - void customFunctionEdited(); - void refreshCustomFunction(int index, bool modified=false); - void startupSwitchEdited(); - void exposEdited(); - void mixesEdited(); - void heliEdited(); - - void on_bcRUDChkB_toggled(bool checked); - void on_bcELEChkB_toggled(bool checked); - void on_bcTHRChkB_toggled(bool checked); - void on_bcAILChkB_toggled(bool checked); - void on_bcP1ChkB_toggled(bool checked); - void on_bcP2ChkB_toggled(bool checked); - void on_bcP3ChkB_toggled(bool checked); - void on_bcP4ChkB_toggled(bool checked); - void on_bcREaChkB_toggled(bool checked); - void on_bcREbChkB_toggled(bool checked); - - void on_thrExpoChkB_toggled(bool checked); - void on_thrTrimChkB_toggled(bool checked); - void on_a1UnitCB_currentIndexChanged(int index); - void on_a2UnitCB_currentIndexChanged(int index); - void on_a1RatioSB_editingFinished(); - void on_a1RatioSB_valueChanged(); - void on_a1CalibSB_editingFinished(); - void on_a11LevelCB_currentIndexChanged(int index); - void on_a11GreaterCB_currentIndexChanged(int index); - void on_a11ValueSB_editingFinished(); - void on_a12LevelCB_currentIndexChanged(int index); - void on_a12GreaterCB_currentIndexChanged(int index); - void on_a12ValueSB_editingFinished(); - void on_a2RatioSB_editingFinished(); - void on_a2RatioSB_valueChanged(); - void on_a2CalibSB_editingFinished(); - void on_a21LevelCB_currentIndexChanged(int index); - void on_a21GreaterCB_currentIndexChanged(int index); - void on_a21ValueSB_editingFinished(); - void on_a22LevelCB_currentIndexChanged(int index); - void on_a22GreaterCB_currentIndexChanged(int index); - void on_a22ValueSB_editingFinished(); - void on_frskyProtoCB_currentIndexChanged(int index); - void on_frskyUnitsCB_currentIndexChanged(int index); - void on_frskyBladesCB_currentIndexChanged(int index); - void on_frskyCurrentCB_currentIndexChanged(int index); - void on_frskyVoltCB_currentIndexChanged(int index); - void on_AltitudeToolbar_ChkB_toggled(bool checked); - void on_rssiAlarm1CB_currentIndexChanged(int index); - void on_rssiAlarm2CB_currentIndexChanged(int index); - void on_rssiAlarm1SB_editingFinished(); - void on_rssiAlarm2SB_editingFinished(); - void on_AltitudeGPS_ChkB_toggled(bool checked); - void on_showNames_Ckb_toggled(bool checked); - void on_varioSourceCB_currentIndexChanged(int index); - void on_varioLimitMin_DSB_editingFinished(); - void on_varioLimitMax_DSB_editingFinished(); - void on_varioLimitCenterMin_DSB_editingFinished(); - void on_varioLimitMinOff_ChkB_toggled(bool checked); - void on_varioLimitCenterMax_DSB_editingFinished(); - void telBarCBcurrentIndexChanged(int index); - void ScreenTypeCBcurrentIndexChanged(int index); - void telMaxSBeditingFinished(); - void telMinSBeditingFinished(); - void customFieldEdited(); - void on_ppmDelaySB_editingFinished(); - void on_ppmDelaySB_2_editingFinished(); - void on_ppmDelaySB_3_editingFinished(); - void on_numChannelsSB_editingFinished(); - void on_numChannelsSB_2_editingFinished(); - void on_numChannelsSB_3_editingFinished(); - void on_numChannelsStart_editingFinished(); - void on_numChannelsStart_2_editingFinished(); - void on_numChannelsStart_3_editingFinished(); -// void void ModelEdit::on_numChannelsStart_3_editingFinished(); - void on_protocolCB_currentIndexChanged(int index); - void on_protocolCB_2_currentIndexChanged(int index); - void on_protocolCB_3_currentIndexChanged(int index); - void on_pulsePolCB_currentIndexChanged(int index); - void on_pulsePolCB_2_currentIndexChanged(int index); - void on_pulsePolCB_3_currentIndexChanged(int index); - void on_ppmFrameLengthDSB_editingFinished(); - void on_ppmFrameLengthDSB_2_editingFinished(); - void on_ppmFrameLengthDSB_3_editingFinished(); - void on_DSM_Type_currentIndexChanged(int index); - void on_DSM_Type_2_currentIndexChanged(int index); - void on_pxxRxNum_editingFinished(); - void on_pxxRxNum_2_editingFinished(); - void on_fsm1CB_currentIndexChanged(int index); - void on_fsm2CB_currentIndexChanged(int index); - - // TODO void on_trimSWCB_currentIndexChanged(int index); - void on_trimIncCB_currentIndexChanged(int index); - void on_timer1DirCB_currentIndexChanged(int index); - void on_timer1ModeCB_currentIndexChanged(int index); - void on_timer1ValTE_editingFinished(); - void on_timer1ModeBCB_currentIndexChanged(int index); - void on_timer2DirCB_currentIndexChanged(int index); - void on_timer2ModeCB_currentIndexChanged(int index); - void on_timer2ValTE_editingFinished(); - void on_timer2ModeBCB_currentIndexChanged(int index); - void on_modelNameLE_editingFinished(); - void on_modelImage_CB_currentIndexChanged(int index); - void on_phases_currentChanged(int index); - void on_tabWidget_currentChanged(int index); - void on_templateList_doubleClicked(QModelIndex index); - void ControlCurveSignal(bool flag); - void shrink(); - void wizard(); - void closeEvent(QCloseEvent *event); - void on_curvetype_CB_currentIndexChanged(int index); -}; - -#endif // MODELEDIT_H diff --git a/companion/src/modeledit.ui b/companion/src/modeledit.ui deleted file mode 100644 index e4f3119f1..000000000 --- a/companion/src/modeledit.ui +++ /dev/null @@ -1,24504 +0,0 @@ - - - ModelEdit - - - - 0 - 0 - 1130 - 698 - - - - - 0 - 0 - - - - Dialog - - - - :/icon.png:/icon.png - - - true - - - - - - Simulate - - - - :/images/simulate.png:/images/simulate.png - - - - - - - QTabWidget::North - - - 0 - - - - Setup - - - - - - true - - - 0 - - - true - - - false - - - - ModelSetup - - - - - - Timer2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Disable Throttle Warning - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - - - - Extended Limits - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Throttle Trim - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Throttle Source - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - - - - - Center beep - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Trim Increment - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - Exponential - - - - - Extra Fine - - - - - Fine - - - - - Medium - - - - - Coarse - - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Switch startup Warning - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 6 - - - 0 - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - 3POS - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Check - - - Qt::AlignCenter - - - - - - - Qt::LeftToRight - - - THR - - - - - - - - ON - - - - - OFF - - - - - - - - Qt::LeftToRight - - - RUD - - - - - - - Qt::LeftToRight - - - ELE - - - - - - - Qt::LeftToRight - - - AIL - - - - - - - Qt::LeftToRight - - - GEA - - - - - - - true - - - - ID0 - - - - - ID1 - - - - - ID2 - - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - - QLayout::SetMinimumSize - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - ON - - - - - OFF - - - - - - - - - 0 - 0 - - - - SB - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - SD - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - SA - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Check - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - SC - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - SG - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - SE - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - SF - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - 0 - - - 1 - - - 1 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - - - - REa - - - - - - - RUD - - - - - - - ELE - - - - - - - THR - - - - - - - AIL - - - - - - - P1 - - - - - - - P2 - - - - - - - P3 - - - - - - - REb - - - - - - - RS - - - - - - - - - - - - - - - - Throttle2Trig - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 16777215 - 16777215 - - - - - - - - - 0 - 0 - - - - - - - - - - - Instant Trim - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Extended Trims - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - - - - - - - Reverse Throttle Operation - - - - - - - Reverse throttle operation. -If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well. - - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 0 - - - - - - - - - - - - - - - Master - - - - - Slave - - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - usec - - - 100 - - - 800 - - - 50 - - - 300 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - PPM delay - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Pulse Shift (polarity) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Trainer Mode - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - mSec - - - 1 - - - 12.500000000000000 - - - 32.500000000000000 - - - 0.500000000000000 - - - 22.500000000000000 - - - - - - - - 0 - 0 - - - - - Negative - - - - - Positive - - - - - - - - PPM Frame Length - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - font-weight:bold; - - - Master/Trainer Port - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - ch - - - 1 - - - 16 - - - 2 - - - 8 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - ch - - - 1 - - - 32 - - - 1 - - - 8 - - - - - - - - 0 - 0 - - - - Channels - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Start - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - - - - PPM delay - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - Polarity - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - Negative - - - - - Positive - - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - usec - - - 100 - - - 800 - - - 50 - - - 300 - - - - - - - - 0 - 0 - - - - PPM Frame Length - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - mSec - - - 1 - - - 12.500000000000000 - - - 32.500000000000000 - - - 0.500000000000000 - - - 22.500000000000000 - - - - - - - - 0 - 0 - - - - - - - 1 - - - 125 - - - 1 - - - 1 - - - - - - - Qt::Horizontal - - - - 5 - 20 - - - - - - - - - 0 - 0 - - - - DSM Type - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - LP4/LP5 - - - - - DSM2only - - - - - DSM2/DSMX - - - - - - - - - 0 - 0 - - - - RX Number - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - PPM - - - - - Silver A - - - - - Silver B - - - - - Silver C - - - - - Trac 09 - - - - - - - - font-weight: bold; - - - RF Module 1 - - - - - - - - 0 - 0 - - - - Protocol - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 0 - - - - - - - - - - Start - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - ch - - - 1 - - - 32 - - - 1 - - - 1 - - - - - - - - 0 - 0 - - - - Channels - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - ch - - - 1 - - - 16 - - - 2 - - - 8 - - - - - - - - - - - - - - - - - - PPM delay - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - usec - - - 100 - - - 800 - - - 50 - - - 300 - - - - - - - - 0 - 0 - - - - - Negative - - - - - Positive - - - - - - - - - 0 - 0 - - - - Polarity - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - RX Number - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - - - 1 - - - 125 - - - 1 - - - 1 - - - - - - - - 0 - 0 - - - - DSM Type - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - LP4/LP5 - - - - - DSM2only - - - - - DSM2/DSMX - - - - - - - - font-weight:bold; - - - RF Module 2 - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 0 - - - - - - - - - 0 - 0 - - - - PPM Frame Length - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - mSec - - - 1 - - - 12.500000000000000 - - - 32.500000000000000 - - - 0.500000000000000 - - - 22.500000000000000 - - - - - - - Qt::Horizontal - - - - 5 - 20 - - - - - - - - - PPM - - - - - Silver A - - - - - Silver B - - - - - Silver C - - - - - Trac 09 - - - - - - - - - 0 - 0 - - - - Protocol - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Start - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - ch - - - 1 - - - 32 - - - 1 - - - 1 - - - - - - - - 0 - 0 - - - - Channels - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - ch - - - 1 - - - 16 - - - 2 - - - 8 - - - - - - - - - - - - - - Throttle Expo - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Model Name - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Timer1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 2 - - - - - true - - - QDateTimeEdit::MinuteSection - - - mm:ss - - - - - - - - Count Down - - - - - Count Up - - - - - - - - - - - - 0 - 0 - - - - TriggerB - - - - - - - - - - Persistent - - - - - - - (00:00:00) - - - - - - - MinuteBeep - - - - - - - CountDownBeep - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 2 - - - - - true - - - QDateTimeEdit::MinuteSection - - - mm:ss - - - - - - - - Count Down - - - - - Count Up - - - - - - - - - - - - 0 - 0 - - - - TriggerB - - - - - - - - - - Persistent - - - - - - - (00:00:00) - - - - - - - MinuteBeep - - - - - - - CountDownBeep - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 0 - 0 - - - - 10 - - - - - - - Model Voice - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - - - 260 - - - 511 - - - 1 - - - 260 - - - - - - - Model Image - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 64 - 32 - - - - - 64 - 32 - - - - QFrame::Panel - - - QFrame::Raised - - - - - - true - - - - - - - - - - - - - Failsafe - - - - - - External module - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH12 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH01 - - - - - - - CH04 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH10 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - CH02 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH11 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH03 - - - - - - - CH09 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - CH05 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - CH06 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - CH07 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH08 - - - - - - - Qt::Vertical - - - - - - - CH13 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - CH14 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - CH15 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - CH16 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - true - - - -100 - - - 100 - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - - - Failsafe Mode - - - - - - - - Hold - - - - - Custom - - - - - No Pulses - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - Internal Module - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - CH14 - - - - - - - CH09 - - - - - - - CH02 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH01 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH04 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH12 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH10 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH03 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH11 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - CH05 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - CH06 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - CH07 - - - - - - - CH08 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - CH13 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - CH15 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - CH16 - - - - - - - -100 - - - 100 - - - Qt::Horizontal - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - - - Failsafe Mode - - - - - - - - Hold - - - - - Custom - - - - - No Pulses - - - - - - - - - - - - - - - - - - Heli Setup - - - - - - Qt::Horizontal - - - - 647 - 20 - - - - - - - - Swash Ring - - - - - - - - - - Swash Type - - - - - - - - Off - - - - - 120 - - - - - 120X - - - - - 140 - - - - - 90 - - - - - - - - - - Invert Elevator - - - - - - - Invert Aileron - - - - - - - Invert Collective - - - - - - - - - Invert - - - - - - - Collective - - - - - - - - - - 0 - - - 100 - - - 1 - - - 0 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Flight Modes - - - - - - - - 0 - - - - Flight Mode 0 (Default) - - - - - - - - Fade In - - - - - - - 1 - - - - - - - 1 - - - - - - - Fade Out - - - - - - - 6 - - - - - - - Flight Mode Name - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Vertical - - - QSlider::TicksBothSides - - - 25 - - - - - - - Qt::Vertical - - - false - - - false - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - - trim1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 1 - 0 - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - trim2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 1 - 0 - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - trim4 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 1 - 0 - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - trim3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 1 - 0 - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Horizontal - - - - - - - - - - - - GVAR1 - - - - - - - 6 - - - - - - - 6 - - - - - - - -100 - - - 100 - - - - - - - GVAR2 - - - - - - - 6 - - - - - - - -100 - - - 100 - - - - - - - GVAR3 - - - - - - - -100 - - - 100 - - - - - - - GVAR4 - - - - - - - 6 - - - - - - - -100 - - - 100 - - - - - - - GVAR5 - - - - - - - 6 - - - - - - - -100 - - - 100 - - - - - - - - - - - - - - - - - - - - - - -100 - - - 100 - - - - - - - - - - GVAR6 - - - - - - - 6 - - - - - - - GVAR7 - - - - - - - - - - - - - 6 - - - - - - - -100 - - - 100 - - - - - - - - - - - - - Rotary encoder B - - - - - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - - - - - Rotary encoder A - - - - - - - - - - - - - FM 1 - - - - - - - - 1 - - - - - - - 6 - - - - - - - Flight Mode Name - - - - - - - Switch - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Fade Out - - - - - - - 1 - - - - - - - Fade In - - - - - - - - - - - Qt::Vertical - - - QSlider::TicksBothSides - - - 25 - - - - - - - Qt::Vertical - - - false - - - false - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - - trim1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - trim4 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - - - - GVAR1 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR2 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR3 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR4 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR5 - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - Rotary encoder A - - - - - - - - - - Rotary encoder B - - - - - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - - - - - - - - - - - - - Qt::Horizontal - - - - - - - - FM 2 - - - - - - - - 1 - - - - - - - 1 - - - - - - - Fade Out - - - - - - - 6 - - - - - - - Flight Mode Name - - - - - - - Switch - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Fade In - - - - - - - - - - - Qt::Vertical - - - QSlider::TicksBothSides - - - 25 - - - - - - - Qt::Vertical - - - false - - - false - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - - trim1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - trim4 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Qt::Horizontal - - - - - - - - - - - - GVAR1 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR2 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR3 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR4 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR5 - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - Rotary encoder A - - - - - - - - - - -100 - - - 100 - - - - - - - Rotary encoder B - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - FM 3 - - - - - - - - Fade Out - - - - - - - Fade In - - - - - - - 6 - - - - - - - Flight Mode Name - - - - - - - Switch - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 1 - - - - - - - 1 - - - - - - - - - - - Qt::Vertical - - - QSlider::TicksBothSides - - - 25 - - - - - - - Qt::Vertical - - - false - - - false - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - - trim1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - trim4 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Qt::Horizontal - - - - - - - - - - - - GVAR1 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR2 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR3 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR4 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR5 - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - Rotary encoder A - - - - - - - - - - -100 - - - 100 - - - - - - - Rotary encoder B - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - FM 4 - - - - - - - - Flight Mode Name - - - - - - - 6 - - - - - - - Switch - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Fade In - - - - - - - Fade Out - - - - - - - 1 - - - - - - - 1 - - - - - - - - - - - Qt::Vertical - - - QSlider::TicksBothSides - - - 25 - - - - - - - Qt::Vertical - - - false - - - false - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - - trim1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - trim4 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Qt::Horizontal - - - - - - - - - - - - GVAR1 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR2 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR3 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR4 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR5 - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - Rotary encoder A - - - - - - - - - - -100 - - - 100 - - - - - - - Rotary encoder B - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - FM 5 - - - - - - - - Qt::Vertical - - - QSlider::TicksBothSides - - - 25 - - - - - - - Qt::Vertical - - - false - - - false - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - - trim1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - trim4 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - Flight Mode Name - - - - - - - 6 - - - - - - - Switch - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 1 - - - - - - - 1 - - - - - - - Fade In - - - - - - - Fade Out - - - - - - - - - Qt::Horizontal - - - - - - - - - - - - GVAR1 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR2 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR3 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR4 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR5 - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - Rotary encoder A - - - - - - - - - - -100 - - - 100 - - - - - - - Rotary encoder B - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - FM 6 - - - - - - - - Qt::Vertical - - - QSlider::TicksBothSides - - - 25 - - - - - - - Qt::Vertical - - - false - - - false - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - - trim1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - trim4 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - 6 - - - - - - - Flight Mode Name - - - - - - - Switch - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Fade In - - - - - - - 1 - - - - - - - 1 - - - - - - - Fade Out - - - - - - - - - - - - - - GVAR1 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR2 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR3 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR4 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR5 - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - Rotary encoder A - - - - - - - - - - -100 - - - 100 - - - - - - - Rotary encoder B - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - Qt::Horizontal - - - - - - - - FM 7 - - - - - - Qt::Horizontal - - - - - - - - - 6 - - - - - - - Flight Mode Name - - - - - - - Switch - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 1 - - - - - - - 1 - - - - - - - Fade In - - - - - - - Fade Out - - - - - - - - - - - Qt::Vertical - - - QSlider::TicksBothSides - - - 25 - - - - - - - Qt::Vertical - - - false - - - false - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - - trim1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - trim4 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - - - - GVAR1 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR2 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR3 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR4 - - - - - - - - - - -100 - - - 100 - - - - - - - GVAR5 - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - Rotary encoder A - - - - - - - - - - -100 - - - 100 - - - - - - - Rotary encoder B - - - - - - - - - - -100 - - - 100 - - - - - - - - - - - - - FM 8 - - - - - - - - Qt::Vertical - - - QSlider::TicksBothSides - - - 25 - - - - - - - Qt::Vertical - - - false - - - false - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 25 - - - - - - - - - trim1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - trim4 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - trim3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::AlignCenter - - - true - - - -896 - - - 896 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Qt::Horizontal - - - - - - - - - 1 - - - - - - - Flight Mode Name - - - - - - - Switch - - - - - - - - - - 6 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Fade In - - - - - - - Fade Out - - - - - - - 1 - - - - - - - - - - - - - - GVAR5 - - - - - - - -100 - - - 100 - - - - - - - - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - - - - - -100 - - - 100 - - - - - - - - - - GVAR4 - - - - - - - GVAR2 - - - - - - - - - - - - - GVAR1 - - - - - - - -100 - - - 100 - - - - - - - GVAR3 - - - - - - - - - - - - - - - - Rotary encoder B - - - - - - - - - - -100 - - - 100 - - - - - - - - - - -100 - - - 100 - - - - - - - Rotary encoder A - - - - - - - - - - - - - - - - - - - Sticks - - - - - - - - - - Mixes - - - - - - - - - Show channels names in mixes - - - - - - - - Limits - - - - - - true - - - - - 0 - 0 - 998 - 481 - - - - - 0 - 0 - - - - - - - - 0 - 0 - - - - - - - - QLayout::SetMinimumSize - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Offset - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Min - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Max - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Invert - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - Center - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Sym - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Channel - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - - 0 - 0 - - - - - - - - QLayout::SetMinimumSize - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Offset - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Min - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Max - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Invert - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - 1 - - - -100.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - --- - - - - - INV - - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - Center - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1375 - - - 1625 - - - 1500 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Sym - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Channel - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - 0 - 0 - - - - 6 - - - true - - - - - - - - - - - - - - - Curves - - - - - - - 1 - 0 - - - - Qt::ScrollBarAsNeeded - - - true - - - - - 0 - 0 - 969 - 467 - - - - - 0 - 0 - - - - - - - Qt::Horizontal - - - - 5 - 20 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - 0 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 0 - 127 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 1 - - - - - - - - - - - - 127 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 127 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 127 - 0 - 0 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 3 - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - true - - - - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 127 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 127 - - - - - - - - - 146 - 145 - 144 - - - - - - - 0 - 0 - 127 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 128 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 128 - 0 - 0 - - - - - - - - - 146 - 145 - 144 - - - - - - - 127 - 0 - 0 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 0 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 127 - 0 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 2 - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 127 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 127 - 0 - - - - - - - - - 146 - 145 - 144 - - - - - - - 0 - 127 - 0 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 0 - 127 - - - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 0 - 127 - - - - - - - - - 146 - 145 - 144 - - - - - - - 127 - 0 - 127 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 0 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 127 - 127 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 4 - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 255 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 0 - 127 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 15 - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 0 - 127 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 0 - 127 - - - - - - - - - 146 - 145 - 144 - - - - - - - 255 - 0 - 127 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 255 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 127 - 0 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 16 - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 127 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 127 - 0 - - - - - - - - - 146 - 145 - 144 - - - - - - - 255 - 127 - 0 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 127 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 127 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 127 - 127 - 0 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 6 - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 0 - - - - - - - - - 146 - 145 - 144 - - - - - - - 127 - 127 - 0 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 128 - 128 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 128 - 128 - - - - - - - - - 146 - 145 - 144 - - - - - - - 0 - 127 - 127 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - - - - - 127 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 127 - 0 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 127 - 0 - 127 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 5 - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 123 - 0 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 0 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - 123 - 0 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 0 - 255 - - - - - - - - - 146 - 145 - 144 - - - - - - - 123 - 0 - 255 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - - - - - 0 - 128 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 128 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 128 - 255 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 9 - - - - - - - - - - - - 0 - 255 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 255 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 255 - 0 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 11 - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 255 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 255 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 255 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 255 - 0 - - - - - - - - - 146 - 145 - 144 - - - - - - - 0 - 255 - 0 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 255 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 255 - 127 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 255 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 255 - 127 - - - - - - - - - 146 - 145 - 144 - - - - - - - 0 - 255 - 127 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - - - - - 0 - 255 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 255 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 255 - 127 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 12 - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 127 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 127 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - - - 127 - 127 - 127 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 7 - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 127 - - - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 127 - - - - - - - - - 146 - 145 - 144 - - - - - - - 127 - 127 - 127 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 0 - 0 - 255 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 8 - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - - - 146 - 145 - 144 - - - - - - - 0 - 0 - 255 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 128 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 127 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 128 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 127 - 255 - - - - - - - - - 146 - 145 - 144 - - - - - - - 0 - 128 - 255 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 123 - 0 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 0 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 0 - 255 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 10 - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 127 - 255 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 127 - 255 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 127 - 255 - 0 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 13 - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 255 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 255 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 255 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 255 - 0 - - - - - - - - - 146 - 145 - 144 - - - - - - - 127 - 255 - 0 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - :/images/clear.png:/images/clear.png - - - - 14 - 14 - - - - - - - - - - - - - 255 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 0 - 0 - - - - - - - 150 - 147 - 145 - - - - - - - - Curve 14 - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 0 - 0 - - - - - - - - - 146 - 145 - 144 - - - - - - - 255 - 0 - 0 - - - - - - - 165 - 164 - 164 - - - - - - - 151 - 150 - 149 - - - - - - - 244 - 244 - 244 - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 5 - - - - - - - - - - - - Curve type - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 3 points - - - - - 3 points custom - - - - - 5 points - - - - - 5 points custom - - - - - 9 points - - - - - 9 points custom - - - - - 17 points - - - - - 17 points custom - - - - - - - - Curve name - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 6 - - - - - - - - 0 - 0 - - - - - 400 - 400 - - - - Qt::AlignCenter - - - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 0 - - - - - - - - 0 - - - 2 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - -100 - - - 100 - - - - - - - Qt::Vertical - - - - 5 - 20 - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 5 - 20 - - - - - - - - - 50 - false - - - - false - - - Curve Creator - - - - - - Y at X=100 - - - - - - - - Both - - - - - x>0 - - - - - x<0 - - - - - - - - - Linear - - - - - Single Expo - - - - - Symmetrical f(x)=-f(-x) - - - - - Symmetrical f(x)=f(-x) - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Apply - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Side - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Y at X=-100 - - - - - - - Y at X=0 - - - - - - - - 0 - 0 - - - - -100 - - - 100 - - - - - - - Curve type - - - - - - - Coefficient - - - - - - - - 0 - 0 - - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - -100 - - - 100 - - - - - - - - 0 - 0 - - - - -100 - - - 100 - - - - - - - - - - - - - - Clear All Curves - - - - :/images/clear.png:/images/clear.png - - - - - - - - Custom switches - - - - - - true - - - - - 0 - 0 - 716 - 482 - - - - - - - - 0 - 0 - - - - - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CS9 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - Duration - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSF - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSD - - - - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - AND - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - V2 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - V1 - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CS6 - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - false - - - QFrame::Panel - - - QFrame::Raised - - - CS1 - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CS8 - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CS7 - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSA - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSB - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSC - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CS5 - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - Function - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CS3 - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CS2 - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSE - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSG - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CS4 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - Delay - - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CST - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - AND - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - V2 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - V1 - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSM - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSP - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSH - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSO - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSN - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSQ - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSR - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSS - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSL - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSK - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - Function - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSJ - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSI - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSU - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSV - - - - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - QFrame::Panel - - - QFrame::Raised - - - CSW - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - Duration - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - Delay - - - - - - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - - - - - - Safety Switches - - - - - - - 0 - 0 - - - - true - - - - - 0 - 0 - 163 - 354 - - - - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Channel - - - Qt::AlignCenter - - - 3 - - - - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Switch - - - Qt::AlignCenter - - - 3 - - - - - - - QFrame::Panel - - - QFrame::Raised - - - 0 - - - Value - - - Qt::AlignCenter - - - 3 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH1 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH2 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH3 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH4 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH5 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH6 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH7 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH8 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH9 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH10 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH11 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH12 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH13 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH14 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH15 - - - - - - - - 0 - 0 - - - - QFrame::Panel - - - QFrame::Raised - - - CH16 - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - - - - - - Custom Functions - - - - - - true - - - - - 0 - 0 - 526 - 48 - - - - - - - - 0 - 0 - - - - - - - - - - QLayout::SetNoConstraint - - - - - QFrame::Panel - - - QFrame::Raised - - - Switch - - - Qt::AlignCenter - - - - - - - QFrame::Panel - - - QFrame::Raised - - - Function - - - Qt::AlignCenter - - - - - - - QFrame::Panel - - - QFrame::Raised - - - Param - - - Qt::AlignCenter - - - - - - - QFrame::Panel - - - QFrame::Raised - - - Enable - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - 0 - 0 - - - - - - - - - - QLayout::SetNoConstraint - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QFrame::Panel - - - QFrame::Raised - - - Switch - - - Qt::AlignCenter - - - - - - - QFrame::Panel - - - QFrame::Raised - - - Function - - - Qt::AlignCenter - - - - - - - QFrame::Panel - - - QFrame::Raised - - - Param - - - Qt::AlignCenter - - - - - - - QFrame::Panel - - - QFrame::Raised - - - Enable - - - - - - - - - - - - Qt::Vertical - - - - 20 - 579 - - - - - - - - - - - - - Telemetry - - - - - - - - QLayout::SetMinimumSize - - - - - - 0 - 0 - - - - Serial Protocol - - - - 1 - - - 1 - - - - - - - - 0 - 0 - - - - Volt source - - - - - - - - 0 - 0 - - - - - Metric - - - - - Imperial - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Current source - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - Protocol - - - - - - - - 0 - 0 - - - - - NONE - - - - - A1 - - - - - A2 - - - - - FAS - - - - - - - - - 0 - 0 - - - - - None - - - - - FrSky Sensor Hub - - - - - - - - - 0 - 0 - - - - - A1 - - - - - A2 - - - - - FAS - - - - - CEL - - - - - - - - - 0 - 0 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Units - - - - - - - - 0 - 0 - - - - Blades - - - - - - - - - - - - - 0 - 0 - - - - Altimetry / Vario - - - - 1 - - - 1 - - - - - - - - 0 - 0 - - - - - Alti - - - - - Alti+ - - - - - Vario - - - - - A1 - - - - - A2 - - - - - - - - - - - 0 - 0 - - - - Sink Max - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - 1 - - - -2.000000000000000 - - - 0.000000000000000 - - - 0.100000000000000 - - - -0.500000000000000 - - - - - - - - 0 - 0 - - - - 1 - - - -1.000000000000000 - - - 2.000000000000000 - - - 0.100000000000000 - - - 0.500000000000000 - - - - - - - - 0 - 0 - - - - 0 - - - 3.000000000000000 - - - 17.000000000000000 - - - 10.000000000000000 - - - - - - - - 0 - 0 - - - - 0 - - - -17.000000000000000 - - - -3.000000000000000 - - - -10.000000000000000 - - - - - - - - 0 - 0 - - - - Off - - - - - - - - 0 - 0 - - - - Climb Max - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Sink Min - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Climb Min - - - Qt::AlignCenter - - - - - - - - - Vario source - - - - - - - Vario limits - - - - - - - - - - 0 - 0 - - - - Use GPS as altitude source - - - - - - - - 0 - 0 - - - - Display altitude in toolbar - - - - - - - - - - - - - - - - QLayout::SetMinimumSize - - - - - - 0 - 0 - - - - true - - - - - - A1 - - - false - - - - 1 - - - 1 - - - - - - - - 0 - 0 - - - - Unit - - - - - - - - 0 - 0 - - - - Max Value - - - - - - - - 0 - 0 - - - - Alarm 1 - - - - - - - - 0 - 0 - - - - - ---- - - - - - Yellow - - - - - Orange - - - - - Red - - - - - - - - - 0 - 0 - - - - - < - - - - - > - - - - - - - - - 0 - 0 - - - - Alarm 2 - - - - - - - - 0 - 0 - - - - - ---- - - - - - Yellow - - - - - Orange - - - - - Red - - - - - - - - - 0 - 0 - - - - - < - - - - - > - - - - - - - - - 0 - 0 - - - - Min Value - - - - - - - true - - - - 0 - 0 - - - - 0 - - - 255.000000000000000 - - - - - - - - 0 - 0 - - - - 2 - - - -12.800000000000001 - - - 12.699999999999999 - - - 0.100000000000000 - - - - - - - true - - - - 0 - 0 - - - - 0 - - - 255.000000000000000 - - - - - - - true - - - - 0 - 0 - - - - 0 - - - 255.000000000000000 - - - - - - - - 0 - 0 - - - - - Volts (V) - - - - - Amps (A) - - - - - Speed (m/s or ft/s) - - - - - Raw (-) - - - - - Speed (km/h or miles/h) - - - - - Meters (m or ft) - - - - - Temp (°) - - - - - Fuel (%) - - - - - mAmps (mA) - - - - - - - - - - - - - A2 - - - - 1 - - - 1 - - - - - - - - 0 - 0 - - - - Unit - - - - - - - - 0 - 0 - - - - Max Value - - - - - - - - 0 - 0 - - - - Alarm 1 - - - - - - - - 0 - 0 - - - - - ---- - - - - - Yellow - - - - - Orange - - - - - Red - - - - - - - - - 0 - 0 - - - - - < - - - - - > - - - - - - - - - 0 - 0 - - - - Alarm 2 - - - - - - - - 0 - 0 - - - - - ---- - - - - - Yellow - - - - - Orange - - - - - Red - - - - - - - - - 0 - 0 - - - - - < - - - - - > - - - - - - - - - 0 - 0 - - - - Min Value - - - - - - - true - - - - 0 - 0 - - - - 0 - - - 255.000000000000000 - - - - - - - - 0 - 0 - - - - 2 - - - -0.800000000000000 - - - 0.700000000000000 - - - 0.100000000000000 - - - - - - - true - - - - 0 - 0 - - - - 0 - - - 255.000000000000000 - - - - - - - true - - - - 0 - 0 - - - - 0 - - - 255.000000000000000 - - - - - - - - 0 - 0 - - - - - Volts (V) - - - - - Amps (A) - - - - - Speed (m/s or ft/s) - - - - - Raw (-) - - - - - Speed (km/h or miles/h) - - - - - Meters (m or ft) - - - - - Temp (°) - - - - - Fuel (%) - - - - - mAmps (mA) - - - - - - - - - - - - - - 0 - 0 - - - - RSSI - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - Alarm 1 - - - - - - - - 0 - 0 - - - - - ---- - - - - - Yellow - - - - - Orange - - - - - Red - - - - - - - - true - - - - 0 - 0 - - - - - - - 20 - - - 80 - - - 1 - - - 50 - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Alarm 2 - - - - - - - - 0 - 0 - - - - - ---- - - - - - Yellow - - - - - Orange - - - - - Red - - - - - - - - true - - - - 0 - 0 - - - - - - - 20 - - - 80 - - - 1 - - - 50 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - 1 - - - 1 - - - - - - 0 - 0 - - - - 0 - - - - Telemetry screen 1 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Custom Screen Type - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - Nums - - - - - Bars - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - - - - - - Source - - - Qt::AlignCenter - - - - - - - Min - - - Qt::AlignCenter - - - - - - - Gauge - - - Qt::AlignCenter - - - - - - - Max - - - Qt::AlignCenter - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 1 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 2 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 3 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 4 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - - Telemetry screen 2 - - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - - - - - - Source - - - Qt::AlignCenter - - - - - - - Min - - - Qt::AlignCenter - - - - - - - Gauge - - - Qt::AlignCenter - - - - - - - Max - - - Qt::AlignCenter - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 1 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 2 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 3 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 4 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - - - - 0 - 0 - - - - Custom Screen Type - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - Nums - - - - - Bars - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Telemetry screen 3 - - - - - - - - - 0 - 0 - - - - Custom Screen Type - - - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - Nums - - - - - Bars - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - - - - - - - - - - Source - - - Qt::AlignCenter - - - - - - - Min - - - Qt::AlignCenter - - - - - - - Gauge - - - Qt::AlignCenter - - - - - - - Max - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 1 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 2 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 3 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - false - - - Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) - - - - QFrame::Panel - - - QFrame::Raised - - - Gauge 4 - - - Qt::AlignCenter - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - - Templates - - - - - - - - - - - - - tabWidget - modelNameLE - modelVoice_SB - timer1ValTE - timer1DirCB - timer1ModeCB - timer1ModeBCB - timer1Perm - timer1Minute - timer1CountDownBeep - timer2ValTE - timer2DirCB - timer2ModeCB - timer2ModeBCB - timer2Perm - timer2Minute - timer2CountDownBeep - swwarn0_CB - swwarn1_ChkB - swwarn2_ChkB - swwarn3_ChkB - swwarn4_CB - swwarn5_ChkB - swwarn6_ChkB - tswwarn0_CB - chkSA - chkSB - chkSC - chkSD - chkSE - chkSF - chkSG - bcRUDChkB - bcELEChkB - bcTHRChkB - bcAILChkB - bcP1ChkB - bcP2ChkB - bcP3ChkB - bcP4ChkB - bcREaChkB - bcREbChkB - swashTypeCB - swashCollectiveCB - swashRingValSB - swashInvertELE - swashInvertAIL - swashInvertCOL - phase0Name - phase0Trim2Slider - phase0Trim1Slider - phase0Trim4Slider - phase0Trim3Slider - phase0Trim2Value - phase0Trim3Value - phase0Trim1Value - phase0Trim4Value - phase0GV1Source - phase0GV1Name - phase0GV1Value - phase0GV2Source - phase0GV2Name - phase0GV2Value - phase0GV3Source - phase0GV3Name - phase0GV3Value - phase0GV4Source - phase0GV4Name - phase0GV4Value - phase0GV5Source - phase0GV5Name - phase0GV5Value - phase0RE1Value - phase0RE2Value - phase1Name - phase1Switch - phase1Trim2Slider - phase1Trim1Slider - phase1Trim4Slider - phase1Trim3Slider - phase1Trim2Use - phase1Trim2Value - phase1Trim3Use - phase1Trim3Value - phase1Trim1Use - phase1Trim1Value - phase1Trim4Use - phase1Trim4Value - phase1GV1Use - phase1GV1Value - phase1GV2Use - phase1GV2Value - phase1GV3Use - phase1GV3Value - phase1GV4Use - phase1GV4Value - phase1GV5Use - phase1GV5Value - phase1RE1Use - phase1RE1Value - phase1RE2Use - phase1RE2Value - phase2Name - phase2Switch - phase2Trim2Slider - phase2Trim1Slider - phase2Trim4Slider - phase2Trim3Slider - phase2Trim2Use - phase2Trim2Value - phase2Trim3Use - phase2Trim3Value - phase2Trim1Use - phase2Trim1Value - phase2Trim4Use - phase2Trim4Value - phase2GV1Use - phase2GV1Value - phase2GV2Use - phase2GV2Value - phase2GV3Use - phase2GV3Value - phase2GV4Use - phase2GV4Value - phase2GV5Use - phase2GV5Value - phase2RE1Use - phase2RE1Value - phase2RE2Use - phase2RE2Value - phase3Name - phase3Switch - phase3Trim2Slider - phase3Trim1Slider - phase3Trim4Slider - phase3Trim3Slider - phase3Trim2Use - phase3Trim2Value - phase3Trim3Use - phase3Trim3Value - phase3Trim1Use - phase3Trim1Value - phase3Trim4Use - phase3Trim4Value - phase3GV1Use - phase3GV1Value - phase3GV2Use - phase3GV2Value - phase3GV3Use - phase3GV3Value - phase3GV4Use - phase3GV4Value - phase3GV5Use - phase3GV5Value - phase3RE1Use - phase3RE1Value - phase3RE2Use - phase3RE2Value - phase4Name - phase4Switch - phase4Trim2Slider - phase4Trim1Slider - phase4Trim4Slider - phase4Trim3Slider - phase4Trim2Use - phase4Trim2Value - phase4Trim3Use - phase4Trim3Value - phase4Trim1Use - phase4Trim1Value - phase4Trim4Use - phase4Trim4Value - phase4GV1Use - phase4GV1Value - phase4GV2Use - phase4GV2Value - phase4GV3Use - phase4GV3Value - phase4GV4Use - phase4GV4Value - phase4GV5Use - phase4GV5Value - phase4RE1Use - phase4RE1Value - phase4RE2Use - phase4RE2Value - phase5Name - phase5Switch - phase5Trim2Slider - phase5Trim1Slider - phase5Trim4Slider - phase5Trim3Slider - phase5Trim2Use - phase5Trim2Value - phase5Trim3Use - phase5Trim3Value - phase5Trim1Use - phase5Trim1Value - phase5Trim4Use - phase5Trim4Value - phase5GV1Use - phase5GV1Value - phase5GV2Use - phase5GV2Value - phase5GV3Use - phase5GV3Value - phase5GV4Use - phase5GV4Value - phase5GV5Use - phase5GV5Value - phase5RE1Use - phase5RE1Value - phase5RE2Use - phase5RE2Value - phase6Name - phase6Switch - phase6Trim2Slider - phase6Trim1Slider - phase6Trim4Slider - phase6Trim3Slider - phase6Trim2Use - phase6Trim2Value - phase6Trim3Use - phase6Trim3Value - phase6Trim1Use - phase6Trim1Value - phase6Trim4Use - phase6Trim4Value - phase6GV1Use - phase6GV1Value - phase6GV2Use - phase6GV2Value - phase6GV3Use - phase6GV3Value - phase6GV4Use - phase6GV4Value - phase6GV5Use - phase6GV5Value - phase6RE1Use - phase6RE1Value - phase6RE2Use - phase6RE2Value - phase7Name - phase7Switch - phase7Trim2Slider - phase7Trim1Slider - phase7Trim4Slider - phase7Trim3Slider - phase7Trim2Use - phase7Trim2Value - phase7Trim3Use - phase7Trim3Value - phase7Trim1Use - phase7Trim1Value - phase7Trim4Use - phase7Trim4Value - phase7GV1Use - phase7GV1Value - phase7GV2Use - phase7GV2Value - phase7GV3Use - phase7GV3Value - phase7GV4Use - phase7GV4Value - phase7GV5Use - phase7GV5Value - phase7RE1Use - phase7RE1Value - phase7RE2Use - phase7RE2Value - phase8Name - phase8Switch - phase8Trim2Slider - phase8Trim1Slider - phase8Trim4Slider - phase8Trim3Slider - phase8Trim2Use - phase8Trim2Value - phase8Trim3Use - phase8Trim3Value - phase8Trim1Use - phase8Trim1Value - phase8Trim4Use - phase8Trim4Value - phase8GV1Use - phase8GV1Value - phase8GV2Use - phase8GV2Value - phase8GV3Use - phase8GV3Value - phase8GV4Use - phase8GV4Value - phase8GV5Use - phase8GV5Value - phase8RE1Use - phase8RE1Value - phase8RE2Use - phase8RE2Value - CHName_01 - offsetDSB_1 - symckb_1 - minSB_1 - maxSB_1 - chInvCB_1 - ppmcenter_1 - CHName_02 - offsetDSB_2 - symckb_2 - minSB_2 - maxSB_2 - chInvCB_2 - ppmcenter_2 - CHName_03 - offsetDSB_3 - symckb_3 - minSB_3 - maxSB_3 - chInvCB_3 - ppmcenter_3 - CHName_04 - offsetDSB_4 - symckb_4 - minSB_4 - maxSB_4 - chInvCB_4 - ppmcenter_4 - CHName_05 - offsetDSB_5 - symckb_5 - minSB_5 - maxSB_5 - chInvCB_5 - ppmcenter_5 - CHName_06 - offsetDSB_6 - symckb_6 - minSB_6 - maxSB_6 - chInvCB_6 - ppmcenter_6 - CHName_07 - offsetDSB_7 - symckb_7 - minSB_7 - maxSB_7 - chInvCB_7 - ppmcenter_7 - CHName_08 - offsetDSB_8 - symckb_8 - minSB_8 - maxSB_8 - chInvCB_8 - ppmcenter_8 - CHName_09 - offsetDSB_9 - symckb_9 - minSB_9 - maxSB_9 - chInvCB_9 - ppmcenter_9 - CHName_10 - offsetDSB_10 - symckb_10 - minSB_10 - maxSB_10 - chInvCB_10 - ppmcenter_10 - CHName_11 - offsetDSB_11 - symckb_11 - minSB_11 - maxSB_11 - chInvCB_11 - ppmcenter_11 - CHName_12 - offsetDSB_12 - symckb_12 - minSB_12 - maxSB_12 - chInvCB_12 - ppmcenter_12 - CHName_13 - offsetDSB_13 - symckb_13 - minSB_13 - maxSB_13 - chInvCB_13 - ppmcenter_13 - CHName_14 - offsetDSB_14 - symckb_14 - minSB_14 - maxSB_14 - chInvCB_14 - ppmcenter_14 - CHName_15 - offsetDSB_15 - symckb_15 - minSB_15 - maxSB_15 - chInvCB_15 - ppmcenter_15 - CHName_16 - offsetDSB_16 - symckb_16 - minSB_16 - maxSB_16 - chInvCB_16 - ppmcenter_16 - CHName_17 - offsetDSB_17 - symckb_17 - minSB_17 - maxSB_17 - chInvCB_17 - ppmcenter_17 - CHName_18 - offsetDSB_18 - symckb_18 - minSB_18 - maxSB_18 - chInvCB_18 - ppmcenter_18 - CHName_19 - offsetDSB_19 - symckb_19 - minSB_19 - maxSB_19 - chInvCB_19 - ppmcenter_19 - CHName_20 - offsetDSB_20 - symckb_20 - minSB_20 - maxSB_20 - chInvCB_20 - ppmcenter_20 - CHName_21 - offsetDSB_21 - symckb_21 - minSB_21 - maxSB_21 - chInvCB_21 - ppmcenter_21 - CHName_22 - offsetDSB_22 - symckb_22 - minSB_22 - maxSB_22 - chInvCB_22 - ppmcenter_22 - CHName_23 - offsetDSB_23 - symckb_23 - minSB_23 - maxSB_23 - chInvCB_23 - ppmcenter_23 - CHName_24 - offsetDSB_24 - symckb_24 - minSB_24 - maxSB_24 - chInvCB_24 - ppmcenter_24 - CHName_25 - offsetDSB_25 - symckb_25 - minSB_25 - maxSB_25 - chInvCB_25 - ppmcenter_25 - CHName_26 - offsetDSB_26 - symckb_26 - minSB_26 - maxSB_26 - chInvCB_26 - ppmcenter_26 - CHName_27 - offsetDSB_27 - symckb_27 - minSB_27 - maxSB_27 - chInvCB_27 - ppmcenter_27 - CHName_28 - offsetDSB_28 - symckb_28 - minSB_28 - maxSB_28 - chInvCB_28 - ppmcenter_28 - CHName_29 - offsetDSB_29 - symckb_29 - minSB_29 - maxSB_29 - chInvCB_29 - ppmcenter_29 - CHName_30 - offsetDSB_30 - symckb_30 - minSB_30 - maxSB_30 - chInvCB_30 - ppmcenter_30 - CHName_31 - offsetDSB_31 - symckb_31 - minSB_31 - maxSB_31 - chInvCB_31 - ppmcenter_31 - CHName_32 - offsetDSB_32 - symckb_32 - minSB_32 - maxSB_32 - chInvCB_32 - ppmcenter_32 - a11LevelCB - a1RatioSB - a11ValueSB - a22GreaterCB - a1CalibSB - scrollArea - a21ValueSB - a21LevelCB - scrollArea_5 - a1UnitCB - a2CalibSB - a12ValueSB - a22ValueSB - a21GreaterCB - a22LevelCB - clearMixesPB - pushButton - a12GreaterCB - a2RatioSB - templateList - a11GreaterCB - a12LevelCB - scrollArea_2 - curvePt01_y - curvePt01_x - curvePt02_y - curvePt02_x - curvePt03_y - curvePt03_x - curvePt04_y - curvePt04_x - curvePt05_y - curvePt05_x - curvePt06_y - curvePt06_x - curvePt07_y - curvePt07_x - curvePt08_y - curvePt08_x - curvePt09_y - curvePt09_x - curvePt10_y - curvePt10_x - curvePt11_y - curvePt11_x - curvePt12_y - curvePt12_x - curvePt13_y - curvePt13_x - curvePt14_y - curvePt14_x - curvePt15_y - curvePt15_x - curvePt16_y - curvePt16_x - curvePt17_y - curvePt17_x - resetCurve_1 - curveEdit_1 - plotCB_1 - resetCurve_2 - curveEdit_2 - plotCB_2 - resetCurve_3 - curveEdit_3 - plotCB_3 - resetCurve_4 - curveEdit_4 - plotCB_4 - resetCurve_5 - curveEdit_5 - plotCB_5 - resetCurve_6 - curveEdit_6 - plotCB_6 - resetCurve_7 - curveEdit_7 - plotCB_7 - resetCurve_8 - curveEdit_8 - plotCB_8 - resetCurve_9 - curveEdit_9 - plotCB_9 - resetCurve_10 - curveEdit_10 - plotCB_10 - resetCurve_11 - curveEdit_11 - plotCB_11 - resetCurve_12 - curveEdit_12 - plotCB_12 - resetCurve_13 - curveEdit_13 - plotCB_13 - resetCurve_14 - curveEdit_14 - plotCB_14 - resetCurve_15 - curveEdit_15 - plotCB_15 - resetCurve_16 - curveEdit_16 - plotCB_16 - curvePreview - curvetype_CB - cswitchFunc_15 - cswitchFunc_13 - cswitchFunc_14 - cswitchFunc_4 - cswitchFunc_8 - cswitchFunc_7 - cswitchFunc_9 - cswitchFunc_10 - cswitchFunc_11 - cswitchFunc_12 - cswitchFunc_6 - cswitchFunc_1 - cswitchFunc_5 - cswitchFunc_2 - cswitchFunc_3 - cswitchFunc_16 - cswitchFunc_31 - cswitchFunc_32 - cswitchFunc_30 - cswitchFunc_29 - cswitchFunc_25 - cswitchFunc_20 - cswitchFunc_23 - cswitchFunc_26 - cswitchFunc_27 - cswitchFunc_28 - cswitchFunc_22 - cswitchFunc_17 - cswitchFunc_18 - cswitchFunc_19 - cswitchFunc_24 - cswitchFunc_21 - frskyUnitsCB - frskyCurrentCB - frskyProtoCB - frskyVoltCB - frskyBladesCB - varioSourceCB - varioLimitCenterMin_DSB - varioLimitCenterMax_DSB - varioLimitMax_DSB - varioLimitMin_DSB - varioLimitMinOff_ChkB - a2UnitCB - rssiAlarm1CB - rssiAlarm1SB - tabCsView - telemetryCSType1 - telemetryCS1F1_CB - telemetryCS1F3_CB - telBarCS1B1_CB - telMinCS1SB1 - telMaxCS1SB1 - telBarCS1B2_CB - telMinCS1SB2 - telMaxCS1SB2 - telBarCS1B3_CB - telMinCS1SB3 - telMaxCS1SB3 - telBarCS1B4_CB - telMinCS1SB4 - telMaxCS1SB4 - telemetryCS2F1_CB - telemetryCS2F3_CB - telBarCS2B1_CB - telMinCS2SB1 - telMaxCS2SB1 - telBarCS2B2_CB - telMinCS2SB2 - telMaxCS2SB2 - telBarCS2B3_CB - telMinCS2SB3 - telMaxCS2SB3 - telBarCS2B4_CB - telMinCS2SB4 - telMaxCS2SB4 - telemetryCS3F1_CB - telemetryCS3F3_CB - telBarCS3B1_CB - telMinCS3SB1 - telMaxCS3SB1 - telBarCS3B2_CB - telMinCS3SB2 - telMaxCS3SB2 - telBarCS3B3_CB - telMinCS3SB3 - telMaxCS3SB3 - telBarCS3B4_CB - telMinCS3SB4 - telMaxCS3SB4 - - - - - - diff --git a/companion/src/modeledit/CMakeLists.txt b/companion/src/modeledit/CMakeLists.txt new file mode 100644 index 000000000..aa00bc7dc --- /dev/null +++ b/companion/src/modeledit/CMakeLists.txt @@ -0,0 +1,54 @@ +include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + +set(modeledit_NAMES + modeledit + setup + heli + curves + telemetry + expodialog + mixerdialog +) + +set(modeledit_SRCS + modelpanel.cpp + flightmodes.cpp + inputs.cpp + mixes.cpp + channels.cpp + customswitches.cpp + customfunctions.cpp + # templates.cpp + mixerslist.cpp + node.cpp + edge.cpp +) + +set(modeledit_HDRS + modelpanel.h + flightmodes.h + inputs.h + mixes.h + channels.h + customswitches.h + customfunctions.h + # templates.h + mixerslist.h + node.h +) + +set(modeledit_UIS + flightmode.ui + telemetry_analog.ui +) + +foreach(name ${modeledit_NAMES}) + set(modeledit_SRCS ${modeledit_SRCS} ${name}.cpp) + set(modeledit_HDRS ${modeledit_HDRS} ${name}.h) + set(modeledit_UIS ${modeledit_UIS} ${name}.ui) +endforeach() + +qt4_wrap_ui(modeledit_SRCS ${modeledit_UIS}) +qt4_wrap_cpp(modeledit_SRCS ${modeledit_HDRS}) + +add_library(modeledit ${modeledit_SRCS}) \ No newline at end of file diff --git a/companion/src/modeledit/channels.cpp b/companion/src/modeledit/channels.cpp new file mode 100644 index 000000000..09b6a367b --- /dev/null +++ b/companion/src/modeledit/channels.cpp @@ -0,0 +1,179 @@ +#include "channels.h" +#include +#include +#include +#include +#include +#include + +Channels::Channels(QWidget * parent, ModelData & model): + ModelPanel(parent, model) +{ + QGridLayout * gridLayout = new QGridLayout(this); + + int col = 1; + if (GetEepromInterface()->getCapability(ChannelsName)) + addLabel(gridLayout, tr("Name"), col++); + addLabel(gridLayout, tr("Offset"), col++); + addLabel(gridLayout, tr("Min"), col++); + addLabel(gridLayout, tr("Max"), col++); + addLabel(gridLayout, tr("Invert"), col++); + if (GetEepromInterface()->getCapability(PPMCenter)) + addLabel(gridLayout, tr("Center"), col++); + if (GetEepromInterface()->getCapability(SYMLimits)) + addLabel(gridLayout, tr("Sym"), col++); + + for (int i=0; igetCapability(Outputs); i++) { + col = 0; + + // Channel label + QLabel *label = new QLabel(this); + label->setText(tr("Channel %1").arg(i+1)); + gridLayout->addWidget(label, i+1, col++, 1, 1); + + // Channel name + int nameLen = GetEepromInterface()->getCapability(ChannelsName); + if (nameLen > 0) { + QLineEdit * name = new QLineEdit(this); + name->setProperty("index", i); + name->setMaxLength(nameLen); + QRegExp rx(CHAR_FOR_NAMES_REGEX); + name->setValidator(new QRegExpValidator(rx, this)); + name->setText(model.limitData[i].name); + connect(name, SIGNAL(editingFinished()), this, SLOT(nameEdited())); + gridLayout->addWidget(name, i+1, col++, 1, 1); + } + + // Channel offset + QDoubleSpinBox * offset = new QDoubleSpinBox(this); + offset->setProperty("index", i); + offset->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + offset->setAccelerated(true); + offset->setDecimals(1); + offset->setMinimum(-100); + offset->setSingleStep(0.1); + offset->setValue(float(model.limitData[i].offset) / 10); + connect(offset, SIGNAL(editingFinished()), this, SLOT(offsetEdited())); + gridLayout->addWidget(offset, i+1, col++, 1, 1); + + // Channel min + QSpinBox * minSB = new QSpinBox(this); + minSB->setProperty("index", i); + minSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + minSB->setAccelerated(true); + minSB->setMinimum(model.extendedLimits ? -125 : -100); + minSB->setMaximum(0); + minSB->setValue(model.limitData[i].min); + connect(minSB, SIGNAL(editingFinished()), this, SLOT(minEdited())); + gridLayout->addWidget(minSB, i+1, col++, 1, 1); + + // Channel max + QSpinBox * maxSB = new QSpinBox(this); + maxSB->setProperty("index", i); + maxSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + maxSB->setAccelerated(true); + maxSB->setMinimum(0); + maxSB->setMaximum(model.extendedLimits ? 125 : 100); + maxSB->setValue(model.limitData[i].max); + connect(maxSB, SIGNAL(editingFinished()), this, SLOT(maxEdited())); + gridLayout->addWidget(maxSB, i+1, col++, 1, 1); + + // Channel inversion + QComboBox * invCB = new QComboBox(this); + invCB->insertItems(0, QStringList() << tr("---") << tr("INV")); + invCB->setProperty("index", i); + invCB->setCurrentIndex((model.limitData[i].revert) ? 1 : 0); + connect(invCB, SIGNAL(currentIndexChanged(int)), this, SLOT(invEdited())); + gridLayout->addWidget(invCB, i+1, col++, 1, 1); + + // PPM center + if (GetEepromInterface()->getCapability(PPMCenter)) { + QSpinBox * center = new QSpinBox(this); + center->setProperty("index", i); + center->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + center->setMinimum(1375); + center->setMaximum(1625); + center->setValue(1500); + center->setValue(model.limitData[i].ppmCenter + 1500); + connect(center, SIGNAL(editingFinished()), this, SLOT(ppmcenterEdited())); + gridLayout->addWidget(center, i+1, col++, 1, 1); + } + + // Symetrical limits + if (GetEepromInterface()->getCapability(SYMLimits)) { + QCheckBox * symlimits = new QCheckBox(this); + symlimits->setProperty("index", i); + symlimits->setChecked(model.limitData[i].symetrical); + connect(symlimits, SIGNAL(toggled(bool)), this, SLOT(symlimitsEdited())); + gridLayout->addWidget(symlimits, i+1, col++, 1, 1); + } + } + + // setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + // setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); +} + +Channels::~Channels() +{ +} + +void Channels::symlimitsEdited() +{ + QCheckBox * ckb = qobject_cast(sender()); + int index = ckb->property("index").toInt(); + model.limitData[index].symetrical = (ckb->checkState() ? 1 : 0); + emit modified(); +} + +void Channels::nameEdited() +{ + if (!lock) { + lock = true; + QLineEdit *le = qobject_cast(sender()); + int index = le->property("index").toInt(); + strcpy(model.limitData[index].name, le->text().toAscii()); + lock = false; + emit modified(); + } +} + +void Channels::offsetEdited() +{ + QDoubleSpinBox *dsb = qobject_cast(sender()); + int index = dsb->property("index").toInt(); + model.limitData[index].offset = round(dsb->value()*10); + emit modified(); +} + +void Channels::minEdited() +{ + QSpinBox *sb = qobject_cast(sender()); + int index = sb->property("index").toInt(); + model.limitData[index].min = sb->value(); + emit modified(); +} + +void Channels::maxEdited() +{ + QSpinBox *sb = qobject_cast(sender()); + int index = sb->property("index").toInt(); + model.limitData[index].max = sb->value(); + emit modified(); +} + +void Channels::invEdited() +{ + QComboBox *cb = qobject_cast(sender()); + int index = cb->property("index").toInt(); + model.limitData[index].revert = cb->currentIndex(); + emit modified(); +} + +void Channels::ppmcenterEdited() +{ + QSpinBox *sb = qobject_cast(sender()); + int index = sb->property("index").toInt(); + model.limitData[index].ppmCenter = sb->value() - 1500; + emit modified(); +} + diff --git a/companion/src/modeledit/channels.h b/companion/src/modeledit/channels.h new file mode 100644 index 000000000..ee372ecd7 --- /dev/null +++ b/companion/src/modeledit/channels.h @@ -0,0 +1,25 @@ +#ifndef CHANNELS_H +#define CHANNELS_H + +#include "modelpanel.h" + +class Channels : public ModelPanel +{ + Q_OBJECT + + public: + Channels(QWidget *parent, ModelData & model); + ~Channels(); + + private slots: + void symlimitsEdited(); + void nameEdited(); + void offsetEdited(); + void minEdited(); + void maxEdited(); + void invEdited(); + void ppmcenterEdited(); + +}; + +#endif // CHANNELS_H diff --git a/companion/src/modeledit/curvedialog.ui b/companion/src/modeledit/curvedialog.ui new file mode 100644 index 000000000..f8ccccba3 --- /dev/null +++ b/companion/src/modeledit/curvedialog.ui @@ -0,0 +1,217 @@ + + + Dialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + + + Curve type + + + + + + + + 0 + 0 + + + + -100 + + + 100 + + + + + + + Coefficient + + + + + + + + Both + + + + + x>0 + + + + + x<0 + + + + + + + + Y at X=0 + + + + + + + + 0 + 0 + + + + -100 + + + 100 + + + + + + + + 0 + 0 + + + + -100 + + + 100 + + + + + + + Side + + + + + + + Y at X=-100 + + + + + + + + 0 + 0 + + + + -100 + + + 100 + + + + + + + Y at X=100 + + + + + + + + Linear + + + + + Single Expo + + + + + Symmetrical f(x)=-f(-x) + + + + + Symmetrical f(x)=f(-x) + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/companion/src/modeledit/curves.cpp b/companion/src/modeledit/curves.cpp new file mode 100644 index 000000000..54cf80e93 --- /dev/null +++ b/companion/src/modeledit/curves.cpp @@ -0,0 +1,722 @@ +#include "curves.h" +#include "ui_curves.h" +#include "node.h" +#include "edge.h" +#include +#include +#include +#include + +// TODO Capability CustomCurves to be removed + +#define GFX_MARGIN 16 + +static const QColor colors[C9X_MAX_CURVES] = { + QColor(0,0,127), + QColor(0,127,0), + QColor(127,0,0), + QColor(0,127,127), + QColor(127,0,127), + QColor(127,127,0), + QColor(127,127,127), + QColor(0,0,255), + QColor(0,127,255), + QColor(127,0,255), + QColor(0,255,0), + QColor(0,255,127), + QColor(127,255,0), + QColor(255,0,0), + QColor(255,0,127), + QColor(255,127,0), +}; + +#if 0 +#ifdef __APPLE__ + ui->curveEdit_1->setStyleSheet("color: #00007f;"); + ui->curveEdit_2->setStyleSheet("color: #007f00;"); + ui->curveEdit_3->setStyleSheet("color: #7f0000;"); + ui->curveEdit_4->setStyleSheet("color: #007f7f;"); + ui->curveEdit_5->setStyleSheet("color: #7f007f;"); + ui->curveEdit_6->setStyleSheet("color: #7f7f00;"); + ui->curveEdit_7->setStyleSheet("color: #7f7f7f;"); + ui->curveEdit_8->setStyleSheet("color: #0000ff;"); + ui->curveEdit_9->setStyleSheet("color: #007fff;"); + ui->curveEdit_10->setStyleSheet("color: #7f00ff;"); + ui->curveEdit_11->setStyleSheet("color: #00ff00;"); + ui->curveEdit_12->setStyleSheet("color: #00ff7f;"); + ui->curveEdit_13->setStyleSheet("color: #7fff00;"); + ui->curveEdit_14->setStyleSheet("color: #ff0000;"); + ui->curveEdit_15->setStyleSheet("color: #ff007f;"); + ui->curveEdit_16->setStyleSheet("color: #ff7f00;"); +#else + ui->curveEdit_1->setStyleSheet("background-color: #00007f; color: white;"); + ui->curveEdit_2->setStyleSheet("background-color: #007f00; color: white;"); + ui->curveEdit_3->setStyleSheet("background-color: #7f0000; color: white;"); + ui->curveEdit_4->setStyleSheet("background-color: #007f7f; color: white;"); + ui->curveEdit_5->setStyleSheet("background-color: #7f007f; color: white;"); + ui->curveEdit_6->setStyleSheet("background-color: #7f7f00; color: white;"); + ui->curveEdit_7->setStyleSheet("background-color: #7f7f7f; color: white;"); + ui->curveEdit_8->setStyleSheet("background-color: #0000ff; color: white;"); + ui->curveEdit_9->setStyleSheet("background-color: #007fff; color: white;"); + ui->curveEdit_10->setStyleSheet("background-color: #7f00ff; color: white;"); + ui->curveEdit_11->setStyleSheet("background-color: #00ff00; color: white;"); + ui->curveEdit_12->setStyleSheet("background-color: #00ff7f; color: white;"); + ui->curveEdit_13->setStyleSheet("background-color: #7fff00; color: white;"); + ui->curveEdit_14->setStyleSheet("background-color: #ff0000; color: white;"); + ui->curveEdit_15->setStyleSheet("background-color: #ff007f; color: white;"); + ui->curveEdit_16->setStyleSheet("background-color: #ff7f00; color: white;"); +#endif +#endif + +Curves::Curves(QWidget * parent, ModelData & model): + ModelPanel(parent, model), + ui(new Ui::Curves), + currentCurve(0) +{ + ui->setupUi(this); + + if (!GetEepromInterface()->getCapability(HasCvNames)) { + ui->cname_LE->hide(); + ui->cname_label->hide(); + } + + QGraphicsScene *scene = new QGraphicsScene(ui->curvePreview); + scene->setItemIndexMethod(QGraphicsScene::NoIndex); + ui->curvePreview->setScene(scene); + + QIcon clearIcon; + clearIcon.addFile(":/images/clear.png", QSize(), QIcon::Normal, QIcon::Off); + + for (int i=0; igetCapability(NumCurves); i++) { + visibleCurves[i] = false; + // The reset curve button + QPushButton * reset = new QPushButton(this); + reset->setProperty("index", i); + reset->setMinimumSize(QSize(0, 0)); + reset->setIcon(clearIcon); + reset->setIconSize(QSize(14, 14)); + connect(reset, SIGNAL(clicked()), this, SLOT(resetCurve())); + ui->curvesLayout->addWidget(reset, i, 0, 1, 1); + + // The edit curve button + QPushButton * edit = new QPushButton(this); + edit->setProperty("index", i); + QPalette palette; + palette.setBrush(QPalette::Active, QPalette::Button, QBrush(colors[i])); + palette.setBrush(QPalette::Active, QPalette::ButtonText, QBrush(Qt::white)); + edit->setPalette(palette); + edit->setText(tr("Curve %1").arg(i+1)); + connect(edit, SIGNAL(clicked()), this, SLOT(editCurve())); + ui->curvesLayout->addWidget(edit, i, 1, 1, 1); + + // The curve plot checkbox + QCheckBox * plot = new QCheckBox(this); + plot->setProperty("index", i); + plot->setPalette(palette); + connect(plot, SIGNAL(toggled(bool)), this, SLOT(plotCurve(bool))); + ui->curvesLayout->addWidget(plot, i, 2, 1, 1); + } + + visibleCurves[0] = true; + + for (int i=0; isetProperty("index", i); + spny[i]->setMinimum(-100); + spny[i]->setMaximum(+100); + spny[i]->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + spny[i]->setAccelerated(true); + connect(spny[i], SIGNAL(valueChanged(int)), this, SLOT(onPointEdited())); + ui->pointsLayout->addWidget(spny[i], i, 0, 1, 1); + + spnx[i] = new QSpinBox(this); + spnx[i]->setProperty("index", i); + spnx[i]->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + spnx[i]->setAccelerated(true); + connect(spnx[i], SIGNAL(valueChanged(int)), this, SLOT(onPointEdited())); + ui->pointsLayout->addWidget(spnx[i], i, 1, 1, 1); + } +} + +Curves::~Curves() +{ + delete ui; +} + +void Curves::editCurve() +{ + QPushButton *button = (QPushButton *)sender(); + int index = button->property("index").toInt(); + setCurrentCurve(index); + update(); +} + +void Curves::resetCurve() +{ + QPushButton *button = (QPushButton *)sender(); + int index = button->property("index").toInt(); + int res = QMessageBox::question(this, "companion9x", tr("Are you sure you want to reset curve %1 ?").arg(index+1), QMessageBox::Yes | QMessageBox::No); + if (res == QMessageBox::Yes) { + model.curves[index].clear(5); + update(); + emit modified(); + } +} + +void Curves::plotCurve(bool checked) +{ + QCheckBox *chk = (QCheckBox *)sender(); + int index = chk->property("index").toInt(); + visibleCurves[index] = checked; + updateCurve(); +} + +void Curves::update() +{ + lock = true; + + if (GetEepromInterface()->getCapability(HasCvNames)) { + ui->cname_LE->setText(model.curves[currentCurve].name); + } + + int count = model.curves[currentCurve].count; + for (int i=0; ishow(); + spny[i]->setValue(model.curves[currentCurve].points[i].y); + if (model.curves[currentCurve].custom) { + spnx[i]->show(); + if (i==0 || i==model.curves[currentCurve].count-1) { + spnx[i]->setDisabled(true); + spnx[i]->setMaximum(+100); + spnx[i]->setMinimum(-100); + } + else { + spnx[i]->setMaximum(model.curves[currentCurve].points[i+1].x); + spnx[i]->setMinimum(model.curves[currentCurve].points[i-1].x); + } + spnx[i]->setValue(model.curves[currentCurve].points[i].x); + } + else { + spnx[i]->hide(); + } + } + for (int i=count; ihide(); + spnx[i]->hide(); + } + + updateCurveType(); + updateCurve(); + + lock = false; +} + +void Curves::setCurrentCurve(int index) +{ + currentCurve = index; +} + +void Curves::updateCurveType() +{ + int index = model.curves[currentCurve].custom; + if (model.curves[currentCurve].count==5) + index += 2; + else if (model.curves[currentCurve].count==9) + index += 4; + else if (model.curves[currentCurve].count==17) + index += 6; + ui->curvetype_CB->setCurrentIndex(index); +} + +void Curves::updateCurve() +{ + Node * nodel = 0; + Node * nodex = 0; + QColor color; + + QGraphicsScene *scene = ui->curvePreview->scene(); + scene->clear(); + + qreal width = scene->sceneRect().width(); + qreal height = scene->sceneRect().height(); + + qreal centerX = scene->sceneRect().left() + width/2; //center X + qreal centerY = scene->sceneRect().top() + height/2; //center Y + + QGraphicsSimpleTextItem *ti = scene->addSimpleText(tr("Editing curve %1").arg(currentCurve+1)); + ti->setPos(3, 3); + + scene->addLine(centerX, GFX_MARGIN, centerX, height+GFX_MARGIN); + scene->addLine(GFX_MARGIN, centerY, width+GFX_MARGIN, centerY); + + QPen pen; + pen.setWidth(2); + pen.setStyle(Qt::SolidLine); + + int numcurves = GetEepromInterface()->getCapability(NumCurves); + for (int k=0; kaddLine(centerX + (qreal)model.curves[k].points[i].x*width/200,centerY - (qreal)model.curves[k].points[i].y*height/200,centerX + (qreal)model.curves[k].points[i+1].x*width/200,centerY - (qreal)model.curves[k].points[i+1].y*height/200,pen); + else + scene->addLine(GFX_MARGIN + i*width/(numpoints-1),centerY - (qreal)model.curves[k].points[i].y*height/200,GFX_MARGIN + (i+1)*width/(numpoints-1),centerY - (qreal)model.curves[k].points[i+1].y*height/200,pen); + } + } + } + + int numpoints = model.curves[currentCurve].count; + for (int i=0; isetProperty("index", i); + nodex->setColor(colors[currentCurve]); + if (model.curves[currentCurve].custom) { + if (i>0 && isetFixedX(false); + nodex->setMinX(model.curves[currentCurve].points[i-1].x); + nodex->setMaxX(model.curves[currentCurve].points[i+1].x); + } + else { + nodex->setFixedX(true); + } + nodex->setPos(centerX + (qreal)model.curves[currentCurve].points[i].x*width/200,centerY - (qreal)model.curves[currentCurve].points[i].y*height/200); + } + else { + nodex->setFixedX(true); + nodex->setPos(GFX_MARGIN + i*width/(numpoints-1), centerY - (qreal)model.curves[currentCurve].points[i].y*height/200); + } + connect(nodex, SIGNAL(moved(int, int)), this, SLOT(onNodeMoved(int, int))); + connect(nodex, SIGNAL(focus()), this, SLOT(onNodeFocus())); + connect(nodex, SIGNAL(unfocus()), this, SLOT(onNodeUnfocus())); + scene->addItem(nodex); + if (i>0) scene->addItem(new Edge(nodel, nodex)); + } +} + +void Curves::onPointEdited() +{ + if (!lock) { + lock = true; + int index = sender()->property("index").toInt(); + model.curves[currentCurve].points[index].x = spnx[index]->value(); + model.curves[currentCurve].points[index].y = spny[index]->value(); + updateCurve(); + emit modified(); + lock = false; + } +} + +void Curves::onNodeMoved(int x, int y) +{ + if (!lock) { + lock = true; + int index = sender()->property("index").toInt(); + model.curves[currentCurve].points[index].x = x; + model.curves[currentCurve].points[index].y = y; + spnx[index]->setValue(x); + spny[index]->setValue(y); + emit modified(); + lock = false; + } +} + +void Curves::onNodeFocus() +{ + int index = sender()->property("index").toInt(); + spny[index]->setFocus(); +} + +void Curves::onNodeUnfocus() +{ + int index = sender()->property("index").toInt(); + spny[index]->clearFocus(); + updateCurve(); +} + +void Curves::on_curvetype_CB_currentIndexChanged(int index) +{ + static const int numpoint[] = {3,3,5,5,9,9,17,17}; + static const bool custom[] = {false,true,false,true,false,true,false,true}; + + if (!lock) { + lock = true; + + int numcurves = GetEepromInterface()->getCapability(NumCurves); + // int currpoints = model.curves[currentCurve].count; + // bool currcustom = model.curves[currentCurve].custom; + + int totalpoints=0; + for (int i=0; igetCapability(NumCurvePoints); + if (fwpoints!=0) { + if (fwpoints < totalpoints) { + QMessageBox::warning(this, "companion9x", tr("Not enough free points in EEPROM to store the curve.")); + updateCurveType(); + lock = false; + return; + } + } + + model.curves[currentCurve].count = numpoint[index]; + model.curves[currentCurve].custom = custom[index]; + + // TODO something better! + for (int i=0; i= model.curves[currentCurve].count-1 ? +100 : -100 + (200*i)/(numpoint[index]-1)); + model.curves[currentCurve].points[i].y = 0; + } + + update(); + emit modified(); + lock = false; + } +} + +void Curves::on_cname_LE_editingFinished() +{ + memset(model.curves[currentCurve].name, 0, sizeof(model.curves[currentCurve].name)); + strcpy(model.curves[currentCurve].name, ui->cname_LE->text().toAscii()); + emit modified(); +} + +void Curves::resizeEvent(QResizeEvent *event) +{ + QRect qr = ui->curvePreview->contentsRect(); + ui->curvePreview->scene()->setSceneRect(GFX_MARGIN, GFX_MARGIN, qr.width()-GFX_MARGIN*2, qr.height()-GFX_MARGIN*2); + updateCurve(); + + ModelPanel::resizeEvent(event); +} + +#if 0 +void ModelEdit::on_ca_ctype_CB_currentIndexChanged() +{ + int index=ui->ca_ctype_CB->currentIndex(); + switch (index) { + case 0: + ui->ca_coeff_SB->hide(); + ui->ca_coeff_label->hide(); + ui->ca_ymid_SB->hide(); + ui->ca_ymid_label->hide(); + ui->ca_ymin_SB->show(); + ui->ca_ymin_label->show(); + ui->ca_ymin_SB->setValue(-100); + ui->ca_ymax_SB->setValue(100); + break; + case 1: + ui->ca_coeff_SB->show(); + ui->ca_coeff_label->show(); + ui->ca_ymid_SB->hide(); + ui->ca_ymid_label->hide(); + ui->ca_ymin_SB->show(); + ui->ca_ymin_label->show(); + ui->ca_ymin_SB->setValue(-100); + ui->ca_ymax_SB->setValue(100); + break; + case 2: + ui->ca_coeff_SB->show(); + ui->ca_coeff_label->show(); + ui->ca_ymid_SB->hide(); + ui->ca_ymid_label->hide(); + ui->ca_ymin_SB->hide(); + ui->ca_ymin_label->hide(); + ui->ca_ymax_SB->setValue(100); + break; + case 3: + ui->ca_coeff_SB->show(); + ui->ca_coeff_label->show(); + ui->ca_ymid_SB->show(); + ui->ca_ymid_label->show(); + ui->ca_ymin_SB->hide(); + ui->ca_ymin_label->hide(); + ui->ca_ymid_SB->setValue(0); + ui->ca_ymax_SB->setValue(100); + break; + } +} + +void ModelEdit::on_ca_apply_PB_clicked() +{ + int index=ui->ca_ctype_CB->currentIndex(); + float x; + int y; + int invert=0; + float a; + if (index==0) { + a=(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/200.0; + int numpoints=model.curves[currentCurve].count; + for (int i=0; ica_ymin_SB->value()+a*x; + switch (ui->ca_side_CB->currentIndex()) { + case 0: + model.curves[currentCurve].points[i].y=y; + break; + case 1: + if (x>=100) { + model.curves[currentCurve].points[i].y=y; + } + break; + case 2: + if (x<100) { + model.curves[currentCurve].points[i].y=y; + } + break; + } + } + } else if (index==1) { + int numpoints=model.curves[currentCurve].count; + for (int i=0; ica_coeff_SB->value(); + if (a>=0) { + y=round(c9xexpou(x,a)*(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/100.0+ui->ca_ymin_SB->value()); + } else { + a=-a; + x=100-x; + y=round((100.0-c9xexpou(x,a))*(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/100.0+ui->ca_ymin_SB->value()); + } + switch (ui->ca_side_CB->currentIndex()) { + case 0: + model.curves[currentCurve].points[i].y=y; + break; + case 1: + if (x>=50) { + model.curves[currentCurve].points[i].y=y; + } + break; + case 2: + if (x<50) { + model.curves[currentCurve].points[i].y=y; + } + break; + } + } + } else if (index==2) { + int numpoints=model.curves[currentCurve].count; + for (int i=0; ica_coeff_SB->value(); + if (x<0) { + x=-x; + invert=1; + } else { + invert=0; + } + if (a>=0) { + y=round(c9xexpou(x,a)*(ui->ca_ymax_SB->value()/100.0)); + } else { + a=-a; + x=100-x; + y=round((100.0-c9xexpou(x,a))*(ui->ca_ymax_SB->value()/100.0)); + } + switch (ui->ca_side_CB->currentIndex()) { + case 0: + if (invert==1) { + model.curves[currentCurve].points[i].y=-y; + } else { + model.curves[currentCurve].points[i].y=y; + } + break; + case 1: + if (invert==0) { + model.curves[currentCurve].points[i].y=y; + } + break; + case 2: + if (invert==1) { + model.curves[currentCurve].points[i].y=-y; + } + break; + } + } + } else if (index==3) { + int numpoints=model.curves[currentCurve].count; + for (int i=0; i=0); + a=ui->ca_coeff_SB->value(); + if (x<0) { + x=-x; + } + if (a>=0) { + y=round(c9xexpou(x,a)*((ui->ca_ymax_SB->value()-ui->ca_ymid_SB->value())/100.0)+ui->ca_ymid_SB->value()); + } else { + a=-a; + x=100-x; + y=round((100.0-c9xexpou(x,a))*((ui->ca_ymax_SB->value()-ui->ca_ymid_SB->value())/100.0)+ui->ca_ymid_SB->value()); + } + switch (ui->ca_side_CB->currentIndex()) { + case 0: + model.curves[currentCurve].points[i].y=y; + break; + case 1: + if (pos) { + model.curves[currentCurve].points[i].y=y; + } + break; + case 2: + if (!pos) { + model.curves[currentCurve].points[i].y=y; + } + break; + } + } + } + updateSettings(); + setCurrentCurve(currentCurve); + drawCurve(); +} + +void ModelEdit::clearCurves(bool ask) +{ + if(ask) { + int res = QMessageBox::question(this,tr("Clear Curves?"),tr("Really clear all the curves?"),QMessageBox::Yes | QMessageBox::No); + if(res!=QMessageBox::Yes) return; + } + curvesLock=true; + if (!GetEepromInterface()->getCapability(CustomCurves)){ + ui->curvetype_CB->setDisabled(true); + int count=0; + for (int j=0; j< GetEepromInterface()->getCapability(NumCurves3); j++) { + model.curves[count].count=3; + model.curves[count].custom=false; + memset(model.curves[j].name,0,sizeof(model.curves[j].name)); + for (int i=0; i<17; i++) { + model.curves[count].points[i].x=0; + model.curves[count].points[i].y=0; + } + count++; + } + for (int j=0; j< GetEepromInterface()->getCapability(NumCurves5); j++) { + model.curves[count].count=5; + model.curves[count].custom=false; + memset(model.curves[j].name,0,sizeof(model.curves[j].name)); + for (int i=0; i<17; i++) { + model.curves[count].points[i].x=0; + model.curves[count].points[i].y=0; + } + count++; + } + for (int j=0; j< GetEepromInterface()->getCapability(NumCurves9); j++) { + model.curves[count].count=9; + model.curves[count].custom=false; + memset(model.curves[j].name,0,sizeof(model.curves[j].name)); + for (int i=0; i<17; i++) { + model.curves[count].points[i].x=0; + model.curves[count].points[i].y=0; + } + count++; + } + for (int j=count; j<16; j++) { + model.curves[j].count=5; + model.curves[j].custom=false; + memset(model.curves[j].name,0,sizeof(model.curves[j].name)); + for (int i=0; i<17; i++) { + model.curves[j].points[i].x=0; + model.curves[j].points[i].y=0; + } + } + } else { + for (int j=0; j<16; j++) { + model.curves[j].count=5; + model.curves[j].custom=false; + memset(model.curves[j].name,0,sizeof(model.curves[j].name)); + for (int i=0; i<17; i++) { + model.curves[j].points[i].x=0; + model.curves[j].points[i].y=0; + } + } + } + for (int i=0; i<17; i++) { + spnx[i]->setMinimum(-100); + spnx[i]->setMaximum(100); + spnx[i]->setValue(0); + spny[i]->setValue(0); + } + currentCurve=0; + curvesLock=false; + if (GetEepromInterface()->getCapability(NumCurves3)>0) { + ui->curvetype_CB->setCurrentIndex(0); + } else { + ui->curvetype_CB->setCurrentIndex(2); + } + ui->cname_LE->clear(); + updateSettings(); + drawCurve(); +} + +void ModelEdit::setCurve(uint8_t c, int8_t ar[]) +{ + int len=sizeof(ar)/sizeof(int8_t); + if (GetEepromInterface()->getCapability(CustomCurves)) { + if (GetEepromInterface()->getCapability(NumCurves)>c) { + if (len<9) { + model.curves[c].count=5; + model.curves[c].custom=false; + for (int i=0; i< 5; i++) { + model.curves[c].points[i].y=ar[i]; + } + } else { + model.curves[c].count=5; + model.curves[c].custom=false; + for (int i=0; i< 5; i++) { + model.curves[c].points[i].y=ar[i]; + } + } + } + } else { + if (len<9) { + model.curves[c].count=5; + model.curves[c].custom=false; + for (int i=0; i< 5; i++) { + model.curves[c].points[i].y=ar[i]; + } + } else { + model.curves[c+8].count=5; + model.curves[c+8].custom=false; + for (int i=0; i< 5; i++) { + model.curves[c+8].points[i].y=ar[i]; + } + } + } +} + +void ModelEdit::ControlCurveSignal(bool flag) +{ + foreach(QSpinBox *sb, findChildren(QRegExp("curvePt[0-9]+"))) { + sb->blockSignals(flag); + } +} +#endif diff --git a/companion/src/modeledit/curves.h b/companion/src/modeledit/curves.h new file mode 100644 index 000000000..a1086dde0 --- /dev/null +++ b/companion/src/modeledit/curves.h @@ -0,0 +1,47 @@ +#ifndef CURVES_H +#define CURVES_H + +#include "modelpanel.h" +#include + +namespace Ui { + class Curves; +} + +class Curves : public ModelPanel +{ + Q_OBJECT + + public: + Curves(QWidget *parent, ModelData & model); + virtual ~Curves(); + + virtual void update(); + + private slots: + void resetCurve(); + void editCurve(); + void plotCurve(bool checked); + void on_cname_LE_editingFinished(); + void on_curvetype_CB_currentIndexChanged(int index); + void onPointEdited(); + void onNodeMoved(int x, int y); + void onNodeFocus(); + void onNodeUnfocus(); + + protected: + virtual void resizeEvent(QResizeEvent *event); + + private: + Ui::Curves *ui; + int currentCurve; + bool visibleCurves[C9X_MAX_CURVES]; + QSpinBox * spnx[C9X_MAX_POINTS]; + QSpinBox * spny[C9X_MAX_POINTS]; + void setCurrentCurve(int index); + void updateCurve(); + void updateCurveType(); + +}; + +#endif // CURVES_H diff --git a/companion/src/modeledit/curves.ui b/companion/src/modeledit/curves.ui new file mode 100644 index 000000000..17ad1d39a --- /dev/null +++ b/companion/src/modeledit/curves.ui @@ -0,0 +1,167 @@ + + + Curves + + + + 0 + 0 + 638 + 587 + + + + Form + + + + + + + + + + + + + Curve type + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 3 points + + + + + 3 points custom + + + + + 5 points + + + + + 5 points custom + + + + + 9 points + + + + + 9 points custom + + + + + 17 points + + + + + 17 points custom + + + + + + + + Curve name + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 6 + + + + + + + + 0 + 0 + + + + + 400 + 400 + + + + Qt::AlignCenter + + + + + + + + + 0 + + + 2 + + + 0 + + + 0 + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp new file mode 100644 index 000000000..26333d6b6 --- /dev/null +++ b/companion/src/modeledit/customfunctions.cpp @@ -0,0 +1,473 @@ +#include "customfunctions.h" +#include +#include +#include +#include +#include +#include +#include "helpers.h" + +CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings): + ModelPanel(parent, model), + generalSettings(generalSettings), + phononLock(false) +{ + QGridLayout * gridLayout = new QGridLayout(this); + + int col = 1; + addLabel(gridLayout, tr("Switch"), col++); + addLabel(gridLayout, tr("Function"), col++); + addLabel(gridLayout, tr("Parameters"), col++); + addLabel(gridLayout, tr("Enable"), col++); + + lock = true; + int num_fsw = GetEepromInterface()->getCapability(CustomFunctions); + + QStringList paramarmList; + if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) { + for (int i=0; igetCapability(VoicesMaxLength)+4; + if (qd.exists()) { + QStringList filters; + filters << "*.wav" << "*.WAV"; + foreach ( QString file, qd.entryList(filters, QDir::Files) ) { + QFileInfo fi(file); + QString temp=fi.completeBaseName(); + if (!paramarmList.contains(temp) && temp.length()<=vml) { + paramarmList.append(temp); + } + } + } + } + + for (int i=0; isetContextMenuPolicy(Qt::CustomContextMenu); + label->setMouseTracking(true); + label->setProperty("index", i); + label->setText(tr("CF%1").arg(i+1)); + gridLayout->addWidget(label, i+1, 0); + connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint))); + + // The switch + fswtchSwtch[i] = new QComboBox(this); + fswtchSwtch[i]->setProperty("index", i); + connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); + gridLayout->addWidget(fswtchSwtch[i], i+1, 1); + populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF); + + // The function + fswtchFunc[i] = new QComboBox(this); + fswtchFunc[i]->setProperty("index", i); + connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); + gridLayout->addWidget(fswtchFunc[i], i+1, 2); + populateFuncCB(fswtchFunc[i], model.funcSw[i].func); + + QHBoxLayout *paramLayout = new QHBoxLayout(); + gridLayout->addLayout(paramLayout, i+1, 3); + + fswtchGVmode[i] = new QComboBox(this); + fswtchGVmode[i]->setProperty("index", i); + connect(fswtchGVmode[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); + paramLayout->addWidget(fswtchGVmode[i]); + populateGVmodeCB(fswtchGVmode[i], model.funcSw[i].adjustMode); + + fswtchParamGV[i] = new QCheckBox(this); + fswtchParamGV[i]->setProperty("index", i); + fswtchParamGV[i]->setText("GV"); + fswtchParamGV[i]->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); + connect(fswtchParamGV[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); + paramLayout->addWidget(fswtchParamGV[i]); + + fswtchParam[i] = new QDoubleSpinBox(this); + fswtchParam[i]->setProperty("index", i); + fswtchParam[i]->setAccelerated(true); + fswtchParam[i]->setDecimals(0); + connect(fswtchParam[i], SIGNAL(editingFinished()), this, SLOT(customFunctionEdited())); + paramLayout->addWidget(fswtchParam[i]); + + fswtchParamT[i] = new QComboBox(this); + fswtchParamT[i]->setProperty("index", i); + paramLayout->addWidget(fswtchParamT[i]); + populateFuncParamCB(fswtchParamT[i], func, model.funcSw[i].param, model.funcSw[i].adjustMode); + connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); + + fswtchParamArmT[i] = new QComboBox(this); + fswtchParamArmT[i]->setProperty("index", i); + populateFuncParamArmTCB(fswtchParamArmT[i],&model, model.funcSw[i].paramarm, paramarmList); + fswtchParamArmT[i]->setEditable(true); + paramLayout->addWidget(fswtchParamArmT[i]); + + connect(fswtchParamArmT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); + connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited())); + +#ifdef PHONON + playBT[i] = new QPushButton(this); + playBT[i]->setObjectName(QString("play_%1").arg(i)); + playBT[i]->setIcon(QIcon(":/images/play.png")); + paramLayout->addWidget(playBT[i]); + connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic())); +#endif + + QHBoxLayout *repeatLayout = new QHBoxLayout(); + gridLayout->addLayout(repeatLayout, i+1, 4); + + fswtchRepeat[i] = new QComboBox(this); + fswtchRepeat[i]->setProperty("index", i); + connect(fswtchRepeat[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); + repeatLayout->addWidget(fswtchRepeat[i], i+1); + populateRepeatCB(fswtchRepeat[i], model.funcSw[i].repeatParam); + + fswtchEnable[i] = new QCheckBox(this); + fswtchEnable[i]->setProperty("index", i); + fswtchEnable[i]->setText(tr("ON")); + repeatLayout->addWidget(fswtchEnable[i], i+1); + fswtchEnable[i]->setChecked(model.funcSw[i].enabled); + connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); + } + + lock = false; +} + +CustomFunctionsPanel::~CustomFunctionsPanel() +{ +} + +#ifdef PHONON + +void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::State oldState) +{ + if (phononLock) + return; + phononLock=true; + if ((newState==Phonon::StoppedState || newState==Phonon::PausedState) && oldState==Phonon::PlayingState) { + clickObject->stop(); + clickObject->clearQueue(); + clickObject->clear(); + for (int i=0; igetCapability(CustomFunctions); i++) { + playBT[i]->setObjectName(QString("play_%1").arg(i)); + playBT[i]->setIcon(QIcon(":/images/play.png")); + } + } + if (newState==Phonon::ErrorState) { + clickObject->stop(); + clickObject->clearQueue(); + clickObject->clear(); + for (int i=0; igetCapability(CustomFunctions); i++) { + playBT[i]->setObjectName(QString("play_%1").arg(i)); + playBT[i]->setIcon(QIcon(":/images/play.png")); + } + } + + phononLock=false; +} +#endif + +void CustomFunctionsPanel::playMusic() +{ + QPushButton *playButton = qobject_cast(sender()); + int index=playButton->objectName().mid(5,2).toInt(); + QString function=playButton->objectName().left(4); + QSettings settings("companion9x", "companion9x"); + QString path=settings.value("sdPath", ".").toString(); + QDir qd(path); + QString track; + if (qd.exists()) { + if (GetEepromInterface()->getCapability(VoicesAsNumbers)) { + track=path+QString("/%1.wav").arg(int(fswtchParam[index]->value()),4,10,(const QChar)'0'); + } else { + path.append("/SOUNDS/"); + QString lang = generalSettings.ttsLanguage; + if (lang.isEmpty()) + lang="en"; + path.append(lang); + if (fswtchParamArmT[index]->currentText()!="----") { + track=path+"/"+fswtchParamArmT[index]->currentText()+".wav"; + } + } + QFile file(track); + if (!file.exists()) { + QMessageBox::critical(this, tr("Error"), tr("Unable to find sound file %1!").arg(track)); + track.clear(); + } +#ifdef PHONON + if (function=="play" && !track.isEmpty()) { + clickObject->clear(); + clickObject->setCurrentSource(Phonon::MediaSource(track)); + clickObject->play(); + playBT[index]->setObjectName(QString("stop_%1").arg(index)); + playBT[index]->setIcon(QIcon(":/images/stop.png")); + } else { + clickObject->stop(); + clickObject->clear(); + playBT[index]->setObjectName(QString("play_%1").arg(index)); + playBT[index]->setIcon(QIcon(":/images/play.png")); + } +#endif + } +} + +#define CUSTOM_FUNCTION_NUMERIC_PARAM (1<<0) +#define CUSTOM_FUNCTION_SOURCE_PARAM (1<<1) +#define CUSTOM_FUNCTION_FILE_PARAM (1<<2) +#define CUSTOM_FUNCTION_GV_MODE (1<<3) +#define CUSTOM_FUNCTION_GV_TOOGLE (1<<4) +#define CUSTOM_FUNCTION_ENABLE (1<<5) +#define CUSTOM_FUNCTION_REPEAT (1<<6) +#define CUSTOM_FUNCTION_PLAY (1<<7) + +void CustomFunctionsPanel::customFunctionEdited() +{ + if (!lock) { + lock = true; + + int index = sender()->property("index").toInt(); + refreshCustomFunction(index, true); + + emit modified(); + lock = false; + } +} + +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].repeatParam = (AssignFunc)fswtchRepeat[i]->currentIndex(); + model.funcSw[i].adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex(); + } + + int index = fswtchFunc[i]->currentIndex(); + + if (index>=FuncSafetyCh1 && index<=FuncSafetyCh16) { + fswtchParam[i]->setDecimals(0); + fswtchParam[i]->setSingleStep(1); + fswtchParam[i]->setMinimum(-125); + fswtchParam[i]->setMaximum(125); + 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 + CUSTOM_FUNCTION_ENABLE; + } else if (index>=FuncAdjustGV1 && index<=FuncAdjustGV5) { + 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); + 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], 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], index, model.funcSw[i].param); + widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; + } else if (index==FuncVolume) { + if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); + populateFuncParamCB(fswtchParamT[i], 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 (modified) model.funcSw[i].repeatParam = fswtchRepeat[i]->itemData(fswtchRepeat[i]->currentIndex()).toInt(); + if (index != FuncBackgroundMusic) { + if (GetEepromInterface()->getCapability(HasFuncRepeat)) { + widgetsMask |= CUSTOM_FUNCTION_REPEAT; + } + } + if (index==FuncPlayValue) { + if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); + populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param); + widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT; + } else if (index==FuncPlayPrompt || index==FuncPlayBoth) { + if (GetEepromInterface()->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=GetEepromInterface()->getCapability(VoicesMaxLength); + if (fswtchParamArmT[i]->currentText() != "----") { + widgetsMask |= CUSTOM_FUNCTION_PLAY; + for (int j=0; jcurrentText().length(),vml); j++) { + model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); + } + } + } + } + } else if (index==FuncBackgroundMusic) { + widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; + if (modified) { + memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); + int vml=GetEepromInterface()->getCapability(VoicesMaxLength); + if (fswtchParamArmT[i]->currentText() != "----") { + widgetsMask |= CUSTOM_FUNCTION_PLAY; + for (int j=0; jcurrentText().length(),vml); j++) { + model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); + } + } + } + } else if (index==FuncPlaySound) { + if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); + populateFuncParamCB(fswtchParamT[i], 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], index, model.funcSw[i].param); + widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; + } + } else if (model.funcSw[i].swtch.type!=SWITCH_TYPE_NONE) { + 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); + 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(false); + fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT); + fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE); +#ifdef PHONON + playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY); +#endif +} + +void CustomFunctionsPanel::update() +{ + for (int i=0; igetCapability(CustomFunctions); i++) { + refreshCustomFunction(i); + } +} + +void CustomFunctionsPanel::fswPaste() +{ + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + if (mimeData->hasFormat("application/x-companion9x-fsw")) { + QByteArray fswData = mimeData->data("application/x-companion9x-fsw"); + + FuncSwData *fsw = &model.funcSw[selectedFunction]; + memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData)); + // TODO update switch and func + populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF); + populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func); + refreshCustomFunction(selectedFunction); + emit modified(); + } +} + +void CustomFunctionsPanel::fswDelete() +{ + model.funcSw[selectedFunction].clear(); + // TODO update switch and func + populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF); + populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func); + refreshCustomFunction(selectedFunction); + emit modified(); +} + +void CustomFunctionsPanel::fswCopy() +{ + QByteArray fswData; + fswData.append((char*)&model.funcSw[selectedFunction],sizeof(FuncSwData)); + QMimeData *mimeData = new QMimeData; + mimeData->setData("application/x-companion9x-fsw", fswData); + QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); +} + +void CustomFunctionsPanel::fswCut() +{ + fswCopy(); + fswDelete(); +} + +void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos) +{ + QLabel *label = (QLabel *)sender(); + selectedFunction = label->property("index").toInt(); + + QPoint globalPos = label->mapToGlobal(pos); + + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + bool hasData = mimeData->hasFormat("application/x-companion9x-fsw"); + + QMenu contextMenu; + contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(fswDelete()),tr("Delete")); + contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C")); + contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X")); + contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData); + + contextMenu.exec(globalPos); +} diff --git a/companion/src/modeledit/customfunctions.h b/companion/src/modeledit/customfunctions.h new file mode 100644 index 000000000..e6729da6a --- /dev/null +++ b/companion/src/modeledit/customfunctions.h @@ -0,0 +1,61 @@ +#ifndef CUSTOMFUNCTIONS_H +#define CUSTOMFUNCTIONS_H + +#include "modelpanel.h" +#include +#include +#include +#include +#include +#ifdef PHONON +#include +#include +#include +#endif + +class CustomFunctionsPanel : public ModelPanel +{ + Q_OBJECT + + public: + CustomFunctionsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings); + ~CustomFunctionsPanel(); + + virtual void update(); + + private slots: + void customFunctionEdited(); + void fsw_customContextMenuRequested(QPoint pos); + void refreshCustomFunction(int index, bool modified=false); + void playMusic(); +#ifdef PHONON + void mediaPlayer_state(Phonon::State newState, Phonon::State oldState); +#endif + void fswDelete(); + void fswCopy(); + void fswPaste(); + void fswCut(); + + private: + GeneralSettings & generalSettings; + bool phononLock; + QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS]; + QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS]; + QCheckBox * fswtchParamGV[C9X_MAX_CUSTOM_FUNCTIONS]; + QDoubleSpinBox * fswtchParam[C9X_MAX_CUSTOM_FUNCTIONS]; + QPushButton * playBT[C9X_MAX_CUSTOM_FUNCTIONS]; + QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS]; + QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS]; + QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS]; + QComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS]; + QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS]; +#ifdef PHONON + Phonon::MediaObject *clickObject; + Phonon::AudioOutput *clickOutput; +#endif + + int selectedFunction; + +}; + +#endif // CUSTOMFUNCTIONS_H diff --git a/companion/src/modeledit/customswitches.cpp b/companion/src/modeledit/customswitches.cpp new file mode 100644 index 000000000..b20cd1f68 --- /dev/null +++ b/companion/src/modeledit/customswitches.cpp @@ -0,0 +1,399 @@ +#include "customswitches.h" +#include +#include +#include +#include +#include +#include +#include "helpers.h" + +CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): + ModelPanel(parent, model), + selectedSwitch(0) +{ + QGridLayout * gridLayout = new QGridLayout(this); + + int col = 1; + addLabel(gridLayout, tr("Function"), col++); + addLabel(gridLayout, tr("V1"), col++); + addLabel(gridLayout, tr("V2"), col++); + addLabel(gridLayout, tr("AND"), col++); + if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + addLabel(gridLayout, tr("Duration"), col++); + addLabel(gridLayout, tr("Delay"), col++); + } + + lock = true; + for (int i=0; igetCapability(CustomSwitches); i++) { + // The label + QLabel * label = new QLabel(this); + label->setProperty("index", i); + if (i < 9) + label->setText(tr("CS%1").arg(i+1)); + else + label->setText(tr("CS%1").arg(QChar('A'+i-9))); + label->setContextMenuPolicy(Qt::CustomContextMenu); + label->setMouseTracking(true); + connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint))); + gridLayout->addWidget(label, i+1, 0); + + // The function + csw[i] = new QComboBox(this); + csw[i]->setProperty("index", i); + connect(csw[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + gridLayout->addWidget(csw[i], i+1, 1); + + // V1 + cswitchSource1[i] = new QComboBox(this); + cswitchSource1[i]->setProperty("index",i); + connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + gridLayout->addWidget(cswitchSource1[i], i+1, 2); + cswitchSource1[i]->setVisible(false); + cswitchValue[i] = new QDoubleSpinBox(this); + cswitchValue[i]->setMaximum(125); + cswitchValue[i]->setMinimum(-125); + cswitchValue[i]->setAccelerated(true); + cswitchValue[i]->setDecimals(0); + cswitchValue[i]->setProperty("index", i); + connect(cswitchValue[i], SIGNAL(editingFinished()), this, SLOT(edited())); + gridLayout->addWidget(cswitchValue[i], i+1, 2); + cswitchValue[i]->setVisible(false); + + // V2 + cswitchSource2[i] = new QComboBox(this); + cswitchSource2[i]->setProperty("index", i); + connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + gridLayout->addWidget(cswitchSource2[i], i+1, 3); + cswitchSource2[i]->setVisible(false); + cswitchOffset[i] = new QDoubleSpinBox(this); + cswitchOffset[i]->setProperty("index",i); + cswitchOffset[i]->setMaximum(125); + cswitchOffset[i]->setMinimum(-125); + cswitchOffset[i]->setAccelerated(true); + cswitchOffset[i]->setDecimals(0); + connect(cswitchOffset[i], SIGNAL(editingFinished()), this, SLOT(edited())); + gridLayout->addWidget(cswitchOffset[i], i+1, 3); + cswitchOffset[i]->setVisible(false); + + // AND + cswitchAnd[i] = new QComboBox(this); + cswitchAnd[i]->setProperty("index", i); + connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + gridLayout->addWidget(cswitchAnd[i], i+1, 4); + cswitchAnd[i]->setVisible(false); + + if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + // Duration + cswitchDuration[i] = new QDoubleSpinBox(this); + cswitchDuration[i]->setProperty("index", i); + cswitchDuration[i]->setSingleStep(0.5); + cswitchDuration[i]->setMaximum(50); + cswitchDuration[i]->setMinimum(0); + cswitchDuration[i]->setAccelerated(true); + cswitchDuration[i]->setDecimals(1); + connect(cswitchDuration[i],SIGNAL(editingFinished()), this, SLOT(edited())); + gridLayout->addWidget(cswitchDuration[i], i+1, 5); + cswitchDuration[i]->setVisible(false); + + // Delay + cswitchDelay[i] = new QDoubleSpinBox(this); + cswitchDelay[i]->setProperty("index", i); + cswitchDelay[i]->setSingleStep(0.5); + cswitchDelay[i]->setMaximum(50); + cswitchDelay[i]->setMinimum(0); + cswitchDelay[i]->setAccelerated(true); + cswitchDelay[i]->setDecimals(1); + connect(cswitchDelay[i], SIGNAL(editingFinished()), this, SLOT(edited())); + gridLayout->addWidget(cswitchDelay[i], i+1, 6); + cswitchDelay[i]->setVisible(false); + } + } + + lock = false; +} + +CustomSwitchesPanel::~CustomSwitchesPanel() +{ +} + +void CustomSwitchesPanel::edited() +{ + if (!lock) { + lock = true; + int i = sender()->property("index").toInt(); + bool chAr; + float value, step; + int newval; + chAr = (getCSFunctionFamily(model.customSw[i].func) != getCSFunctionFamily(csw[i]->itemData(csw[i]->currentIndex()).toInt())); + model.customSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt(); + if(chAr) { + if (getCSFunctionFamily(model.customSw[i].func)==CS_FAMILY_TIMERS) { + model.customSw[i].val1 = -119; + model.customSw[i].val2 = -119; + } else { + model.customSw[i].val1 = 0; + model.customSw[i].val2 = 0; + } + model.customSw[i].andsw = 0; + setSwitchWidgetVisibility(i); + } + if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + model.customSw[i].duration= (uint8_t)round(cswitchDuration[i]->value()*2); + model.customSw[i].delay= (uint8_t)round(cswitchDelay[i]->value()*2); + } + RawSource source; + switch (getCSFunctionFamily(model.customSw[i].func)) + { + case (CS_FAMILY_VOFS): + if (model.customSw[i].val1 != cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt()) { + source=RawSource(model.customSw[i].val1); + model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt(); + RawSource newSource = RawSource(model.customSw[i].val1); + if (newSource.type == SOURCE_TYPE_TELEMETRY) { + if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcCS_FN_ELESS && model.customSw[i].funcvalue()/source.getStep(model)); + } else { + model.customSw[i].val2 = ((cswitchOffset[i]->value()-source.getOffset(model))/source.getStep(model))-source.getRawOffset(model); + } + } + setSwitchWidgetVisibility(i); + } else { + source=RawSource(model.customSw[i].val1); + if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcvalue()/source.getStep(model)); + cswitchOffset[i]->setValue(model.customSw[i].val2*source.getStep(model)); + } else { + model.customSw[i].val2 = ((cswitchOffset[i]->value()-source.getOffset(model))/source.getStep(model))-source.getRawOffset(model); + cswitchOffset[i]->setValue((model.customSw[i].val2 +source.getRawOffset(model))*source.getStep(model)+source.getOffset(model)); + } + } + break; + case (CS_FAMILY_TIMERS): { + value=cswitchOffset[i]->value(); + newval=TimToVal(value); + if (newval>model.customSw[i].val2) { + if (value >=60) { + value=round(value); + step=1; + } else if (value>=2) { + value=(round(value*2.0)/2); + step=0.5; + } else { + step=0.1; + } + } else { + if (value <=2) { + step=0.1; + } else if (value<=60) { + value=(round(value*2.0)/2); + step=0.5; + } else { + value=round(value); + step=1; + } + } + model.customSw[i].val2=TimToVal(value); + value=ValToTim(model.customSw[i].val2); + cswitchOffset[i]->setValue(value); + cswitchOffset[i]->setSingleStep(step); + + value=cswitchValue[i]->value(); + newval=TimToVal(value); + if (newval>model.customSw[i].val1) { + if (value >=60) { + value=round(value); + step=1; + } else if (value>=2) { + value=(round(value*2.0)/2); + step=0.5; + } else { + step=0.1; + } + } else { + if (value <=2) { + step=0.1; + } else if (value<=60) { + value=(round(value*2.0)/2); + step=0.5; + } else { + value=round(value); + step=1; + } + } + model.customSw[i].val1=TimToVal(value); + value=ValToTim(model.customSw[i].val1); + cswitchValue[i]->setValue(value); + cswitchValue[i]->setSingleStep(step); + break; + } + case (CS_FAMILY_VBOOL): + case (CS_FAMILY_VCOMP): + model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt(); + model.customSw[i].val2 = cswitchSource2[i]->itemData(cswitchSource2[i]->currentIndex()).toInt(); + break; + } + model.customSw[i].andsw = cswitchAnd[i]->itemData(cswitchAnd[i]->currentIndex()).toInt(); + emit modified(); + lock = false; + } +} + +void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) +{ + RawSource source = RawSource(model.customSw[i].val1); + switch (getCSFunctionFamily(model.customSw[i].func)) + { + case CS_FAMILY_VOFS: + cswitchSource1[i]->setVisible(true); + cswitchSource2[i]->setVisible(false); + cswitchValue[i]->setVisible(false); + cswitchOffset[i]->setVisible(true); + populateSourceCB(cswitchSource1[i], source, POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + cswitchOffset[i]->setDecimals(source.getDecimals(model)); + cswitchOffset[i]->setSingleStep(source.getStep(model)); + if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcsetMinimum(source.getStep(model)*-127); + cswitchOffset[i]->setMaximum(source.getStep(model)*127); + cswitchOffset[i]->setValue(source.getStep(model)*model.customSw[i].val2); + } else { + cswitchOffset[i]->setMinimum(source.getMin(model)); + cswitchOffset[i]->setMaximum(source.getMax(model)); + cswitchOffset[i]->setValue(source.getStep(model)*(model.customSw[i].val2+source.getRawOffset(model))+source.getOffset(model)); + } + break; + case CS_FAMILY_VBOOL: + cswitchSource1[i]->setVisible(true); + cswitchSource2[i]->setVisible(true); + cswitchValue[i]->setVisible(false); + cswitchOffset[i]->setVisible(false); + populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1)); + populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2)); + break; + case CS_FAMILY_VCOMP: + cswitchSource1[i]->setVisible(true); + cswitchSource2[i]->setVisible(true); + cswitchValue[i]->setVisible(false); + cswitchOffset[i]->setVisible(false); + populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + break; + case CS_FAMILY_TIMERS: + cswitchSource1[i]->setVisible(false); + cswitchSource2[i]->setVisible(false); + cswitchValue[i]->setVisible(true); + cswitchOffset[i]->setVisible(true); + cswitchOffset[i]->setDecimals(1); + cswitchOffset[i]->setMinimum(0.1); + cswitchOffset[i]->setMaximum(175); + float value=ValToTim(model.customSw[i].val2); + cswitchOffset[i]->setSingleStep(0.1); + if (value>60) { + cswitchOffset[i]->setSingleStep(1); + } else if (value>2) { + cswitchOffset[i]->setSingleStep(0.5); + } + cswitchOffset[i]->setValue(value); + + cswitchValue[i]->setDecimals(1); + cswitchValue[i]->setMinimum(0.1); + cswitchValue[i]->setMaximum(175); + value=ValToTim(model.customSw[i].val1); + cswitchValue[i]->setSingleStep(0.1); + if (value>60) { + cswitchValue[i]->setSingleStep(1); + } else if (value>2) { + cswitchValue[i]->setSingleStep(0.5); + } + cswitchValue[i]->setValue(value); + break; + } + cswitchAnd[i]->setVisible(true); + populateSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw), POPULATE_AND_SWITCHES); + if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + cswitchDuration[i]->setVisible(true); + cswitchDuration[i]->setValue(model.customSw[i].duration/2.0); + cswitchDelay[i]->setVisible(true); + cswitchDelay[i]->setValue(model.customSw[i].delay/2.0); + } +} + +void CustomSwitchesPanel::update() +{ + lock = true; + for (int i=0; igetCapability(CustomSwitches); i++) { + populateCSWCB(csw[i], model.customSw[i].func); + setSwitchWidgetVisibility(i); + } + lock = false; +} + +void CustomSwitchesPanel::cswPaste() +{ + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + if (mimeData->hasFormat("application/x-companion9x-csw")) { + QByteArray cswData = mimeData->data("application/x-companion9x-csw"); + + CustomSwData *csw = &model.customSw[selectedSwitch]; + memcpy(csw, cswData.mid(0, sizeof(CustomSwData)).constData(), sizeof(CustomSwData)); + emit modified(); + updateSelectedSwitch(); + } +} + +void CustomSwitchesPanel::cswDelete() +{ + model.customSw[selectedSwitch].clear(); + emit modified(); + updateSelectedSwitch(); +} + +void CustomSwitchesPanel::cswCopy() +{ + QByteArray cswData; + cswData.append((char*)&model.customSw[selectedSwitch],sizeof(CustomSwData)); + QMimeData *mimeData = new QMimeData; + mimeData->setData("application/x-companion9x-csw", cswData); + QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); +} + +void CustomSwitchesPanel::updateSelectedSwitch() +{ + lock = true; + populateCSWCB(csw[selectedSwitch], model.customSw[selectedSwitch].func); + setSwitchWidgetVisibility(selectedSwitch); + lock = false; +} + +void CustomSwitchesPanel::cswCut() +{ + cswCopy(); + cswDelete(); +} + +// TODO make something generic here! +void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos) +{ + QLabel *label = (QLabel *)sender(); + selectedSwitch = label->property("index").toInt(); + + QPoint globalPos = label->mapToGlobal(pos); + + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + bool hasData = mimeData->hasFormat("application/x-companion9x-csw"); + + QMenu contextMenu; + contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(cswDelete()),tr("Delete")); + contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(cswCopy()),tr("Ctrl+C")); + contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(cswCut()),tr("Ctrl+X")); + contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(cswPaste()),tr("Ctrl+V"))->setEnabled(hasData); + + contextMenu.exec(globalPos); +} diff --git a/companion/src/modeledit/customswitches.h b/companion/src/modeledit/customswitches.h new file mode 100644 index 000000000..c00ad60b6 --- /dev/null +++ b/companion/src/modeledit/customswitches.h @@ -0,0 +1,42 @@ +#ifndef CUSTOMSWITCHES_H +#define CUSTOMSWITCHES_H + +#include "modelpanel.h" +#include +#include + +class CustomSwitchesPanel : public ModelPanel +{ + Q_OBJECT + + public: + CustomSwitchesPanel(QWidget *parent, ModelData & model); + virtual ~CustomSwitchesPanel(); + + virtual void update(); + + private slots: + void edited(); + void csw_customContextMenuRequested(QPoint pos); + void cswDelete(); + void cswCopy(); + void cswPaste(); + void cswCut(); + + private: + QComboBox * csw[C9X_NUM_CSW]; + QDoubleSpinBox * cswitchValue[C9X_NUM_CSW]; + QDoubleSpinBox * cswitchOffset[C9X_NUM_CSW]; + QComboBox * cswitchAnd[C9X_NUM_CSW]; + QDoubleSpinBox * cswitchDuration[C9X_NUM_CSW]; + QDoubleSpinBox * cswitchDelay[C9X_NUM_CSW]; + QComboBox * cswitchSource1[C9X_NUM_CSW]; + QComboBox * cswitchSource2[C9X_NUM_CSW]; + void setSwitchWidgetVisibility(int i); + int selectedSwitch; + + void updateSelectedSwitch(); + +}; + +#endif // CUSTOMSWITCHES_H diff --git a/companion/src/edge.cpp b/companion/src/modeledit/edge.cpp similarity index 100% rename from companion/src/edge.cpp rename to companion/src/modeledit/edge.cpp diff --git a/companion/src/edge.h b/companion/src/modeledit/edge.h similarity index 100% rename from companion/src/edge.h rename to companion/src/modeledit/edge.h diff --git a/companion/src/expodialog.cpp b/companion/src/modeledit/expodialog.cpp similarity index 100% rename from companion/src/expodialog.cpp rename to companion/src/modeledit/expodialog.cpp diff --git a/companion/src/expodialog.h b/companion/src/modeledit/expodialog.h similarity index 100% rename from companion/src/expodialog.h rename to companion/src/modeledit/expodialog.h diff --git a/companion/src/expodialog.ui b/companion/src/modeledit/expodialog.ui similarity index 100% rename from companion/src/expodialog.ui rename to companion/src/modeledit/expodialog.ui diff --git a/companion/src/modeledit/flightmode.ui b/companion/src/modeledit/flightmode.ui new file mode 100644 index 000000000..6ed3d8769 --- /dev/null +++ b/companion/src/modeledit/flightmode.ui @@ -0,0 +1,449 @@ + + + FlightMode + + + + 0 + 0 + 610 + 499 + + + + Form + + + + + + + + Fade In + + + + + + + 1 + + + + + + + 1 + + + + + + + Fade Out + + + + + + + 6 + + + + + + + Name + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Switch + + + + + + + + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + QSlider::TicksBothSides + + + 25 + + + + + + + Qt::Vertical + + + QSlider::TicksBothSides + + + 25 + + + + + + + Qt::Vertical + + + false + + + false + + + QSlider::TicksBothSides + + + 25 + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + QSlider::TicksBothSides + + + 25 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + trim1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Qt::AlignCenter + + + true + + + -896 + + + 896 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Qt::AlignCenter + + + true + + + -896 + + + 896 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + trim2 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + trim4 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + trim3 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Qt::AlignCenter + + + true + + + -896 + + + 896 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Qt::AlignCenter + + + true + + + -896 + + + 896 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + + + + + + + + + + + + + + + diff --git a/companion/src/modeledit/flightmodes.cpp b/companion/src/modeledit/flightmodes.cpp new file mode 100644 index 000000000..4475aaebc --- /dev/null +++ b/companion/src/modeledit/flightmodes.cpp @@ -0,0 +1,484 @@ +#include "flightmodes.h" +#include "ui_flightmode.h" +#include "firmwares/opentx/open9xeeprom.h" // TODO shouldn't be there +#include "helpers.h" +#include +#include + +FlightMode::FlightMode(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings): + ModelPanel(parent, model), + ui(new Ui::FlightMode), + generalSettings(generalSettings), + phaseIdx(phaseIdx), + phase(model.phaseData[phaseIdx]), + reCount(GetEepromInterface()->getCapability(RotaryEncoders)), + gvCount(((!GetEepromInterface()->getCapability(HasVariants)) || (GetCurrentFirmwareVariant() & GVARS_VARIANT)) ? + GetEepromInterface()->getCapability(Gvars) : 0) +{ + ui->setupUi(this); + + // Phase name + QRegExp rx(CHAR_FOR_NAMES_REGEX); + if (GetEepromInterface()->getCapability(FlightPhases)) { + ui->name->setValidator(new QRegExpValidator(rx, this)); + ui->name->setMaxLength(GetEepromInterface()->getCapability(FlightModesName)); + connect(ui->name, SIGNAL(editingFinished()), this, SLOT(phaseName_editingFinished())); + } + else { + ui->name->setDisabled(true); + } + + // Phase switch + if (phaseIdx > 0) { + populateSwitchCB(ui->swtch, phase.swtch); + connect(ui->swtch, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseSwitch_currentIndexChanged(int))); + } + else { + ui->swtch->hide(); + } + + // FadeIn / FadeOut + if (GetEepromInterface()->getCapability(FlightPhasesHaveFades)) { + int scale = GetEepromInterface()->getCapability(SlowScale); + int range = GetEepromInterface()->getCapability(SlowRange); + ui->fadeIn->setMaximum(float(range)/scale); + ui->fadeIn->setSingleStep(1.0/scale); + ui->fadeIn->setDecimals((scale==1 ? 0 :1) ); + connect(ui->fadeIn, SIGNAL(editingFinished()), this, SLOT(phaseFadeIn_editingFinished())); + ui->fadeOut->setMaximum(float(range)/scale); + ui->fadeOut->setSingleStep(1.0/scale); + ui->fadeOut->setDecimals((scale==1 ? 0 :1)); + connect(ui->fadeOut, SIGNAL(editingFinished()), this, SLOT(phaseFadeOut_editingFinished())); + } + else { + ui->fadeIn->setDisabled(true); + ui->fadeOut->setDisabled(true); + } + + // The trims + QString labels[] = { tr("Rud"), tr("Ele"), tr("Thr"), tr("Ail") }; // TODO is elsewhere for sure + + trimsLabel << ui->trim1Label << ui->trim2Label << ui->trim3Label << ui->trim4Label; + trimsUse << ui->trim1Use << ui->trim2Use << ui->trim3Use << ui->trim4Use; + trimsValue << ui->trim1Value << ui->trim2Value << ui->trim3Value << ui->trim4Value; + trimsSlider << ui->trim1Slider << ui->trim2Slider << ui->trim3Slider << ui->trim4Slider; + + for (int i=0; i<4; i++) { + trimsLabel[i]->setText(labels[CONVERT_MODE(i+1)-1]); + + if (phaseIdx > 0) { + trimsUse[i]->setProperty("index", i); + populateTrimUseCB(trimsUse[i], phaseIdx); + connect(trimsUse[i], SIGNAL(currentIndexChanged(int)), this, SLOT(phaseTrimUse_currentIndexChanged(int))); + } + else { + trimsUse[i]->hide(); + } + + trimsValue[i]->setProperty("index", i); + connect(trimsValue[i], SIGNAL(valueChanged(int)), this, SLOT(phaseTrim_valueChanged())); + + trimsSlider[i]->setProperty("index", i); + connect(trimsSlider[i], SIGNAL(valueChanged(int)), this, SLOT(phaseTrimSlider_valueChanged())); + } + + // Rotary encoders + if (reCount > 0) { + QGridLayout *reLayout = new QGridLayout(ui->reGB); + for (int i=0; ireGB); + label->setText(tr("Rotary Encoder %1").arg(i+1)); + reLayout->addWidget(label, i, 0, 1, 1); + if (phaseIdx > 0) { + // RE link to another RE + QComboBox *link = new QComboBox(ui->gvGB); + link->setProperty("index", i); + populateGvarUseCB(link, phaseIdx); + connect(link, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseREUse_currentIndexChanged(int))); + if (phase.rotaryEncoders[i] > 1024) { + link->setCurrentIndex(phase.rotaryEncoders[i] - 1024); + } + reLayout->addWidget(link, i, 1, 1, 1); + } + // RE value + reValues[i] = new QSpinBox(ui->reGB); + reValues[i]->setProperty("index", i); + reValues[i]->setMinimum(-1024); + reValues[i]->setMaximum(1024); + connect(reValues[i], SIGNAL(editingFinished()), this, SLOT(phaseREValue_editingFinished())); + reLayout->addWidget(reValues[i], i, 2, 1, 1); + } + } + else { + ui->reGB->hide(); + } + + // GVars + if (gvCount > 0) { + QGridLayout *gvLayout = new QGridLayout(ui->gvGB); + for (int i=0; igvGB); + label->setText(tr("GVAR%1").arg(i+1)); + gvLayout->addWidget(label, i, col++, 1, 1); +#if 0 + // TODO remove this capability? + // GVar source (er9x/ersky9x) + if (GetEepromInterface()->getCapability(GvarsHaveSources)) { + QComboBox *source = new QComboBox(ui->gvGB); + source->setProperty("index", i); + populateGvSourceCB(source, model.gvsource[i]); + // connect(source, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseGVSource_currentIndexChanged(int))); + gvLayout->addWidget(source, i, col++, 1, 1); + } +#endif + // GVar name + int nameLen = GetEepromInterface()->getCapability(GvarsName); + if (nameLen > 0) { + gvNames[i] = new QLineEdit(ui->gvGB); + gvNames[i]->setProperty("index", i); + gvNames[i]->setMaxLength(nameLen); + connect(gvNames[i], SIGNAL(editingFinished()), this, SLOT(GVName_editingFinished())); + gvLayout->addWidget(gvNames[i], i, col++, 1, 1); + } + if (phaseIdx > 0) { + // GVar link to another GVar + QComboBox *link = new QComboBox(ui->gvGB); + link->setProperty("index", i); + populateGvarUseCB(link, phaseIdx); + if (phase.gvars[i] > 1024) { + link->setCurrentIndex(phase.gvars[i] - 1024); + } + connect(link, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseGVUse_currentIndexChanged(int))); + gvLayout->addWidget(link, i, col++, 1, 1); + } + // GVar value + gvValues[i] = new QSpinBox(ui->gvGB); + gvValues[i]->setProperty("index", i); + connect(gvValues[i], SIGNAL(editingFinished()), this, SLOT(phaseGVValue_editingFinished())); + gvValues[i]->setMinimum(-1024); + gvValues[i]->setMaximum(1024); + gvLayout->addWidget(gvValues[i], i, col++, 1, 1); + } + } + else { + ui->gvGB->hide(); + } + + update(); +} + +FlightMode::~FlightMode() +{ + delete ui; +} + +void FlightMode::update() +{ + ui->name->setText(phase.name); + + int scale = GetEepromInterface()->getCapability(SlowScale); + ui->fadeIn->setValue(float(phase.fadeIn)/scale); + ui->fadeOut->setValue(float(phase.fadeOut)/scale); + + for (int i=0; i<4; i++) { + int trimsMax = GetEepromInterface()->getCapability(ExtendedTrims); + if (trimsMax == 0 || !model.extendedTrims) { + trimsMax = 125; + } + trimsSlider[i]->setRange(-trimsMax, +trimsMax); + trimsValue[i]->setRange(-trimsMax, +trimsMax); + int chn = CONVERT_MODE(i+1)-1; + if (chn == 2/*TODO constant*/ && generalSettings.throttleReversed) + trimsSlider[i]->setInvertedAppearance(true); + + trimUpdate(i); + } + + for (int i=0; isetText(model.gvars_names[i]); + if (phase.gvars[i] < 1024) { + gvValues[i]->setValue(phase.gvars[i]); + gvValues[i]->setDisabled(false); + } + else { + int idx = phase.gvars[i] - 1025; + if (idx >= i) idx++; + // TODO no!!!! + PhaseData *phasegvar = &model.phaseData[idx]; + gvValues[i]->setValue(phasegvar->gvars[i]); + gvValues[i]->setDisabled(true); + } + } + + for (int i=0; isetValue(phase.rotaryEncoders[i]); + reValues[i]->setDisabled(false); + } + else { + int idx = phase.rotaryEncoders[i] - 1025; + if (idx >= i) idx++; + // TODO no!!!! + PhaseData *phasere = &model.phaseData[idx]; + reValues[i]->setValue(phasere->rotaryEncoders[i]); + reValues[i]->setDisabled(true); + } + } +} + +void FlightMode::phaseName_editingFinished() +{ + QLineEdit *lineEdit = qobject_cast(sender()); + strcpy(phase.name, lineEdit->text().toAscii()); + emit modified(); + emit nameModified(); +} + +void FlightMode::phaseSwitch_currentIndexChanged(int index) +{ + QComboBox *comboBox = qobject_cast(sender()); + phase.swtch = RawSwitch(comboBox->itemData(index).toInt()); + emit modified(); +} + +void FlightMode::phaseFadeIn_editingFinished() +{ + QDoubleSpinBox *spinBox = qobject_cast(sender()); + int scale = GetEepromInterface()->getCapability(SlowScale); + phase.fadeIn = round(spinBox->value()*scale); + emit modified(); +} + +void FlightMode::phaseFadeOut_editingFinished() +{ + QDoubleSpinBox *spinBox = qobject_cast(sender()); + int scale = GetEepromInterface()->getCapability(SlowScale); + phase.fadeOut = round(spinBox->value()*scale); + emit modified(); +} + +void FlightMode::trimUpdate(unsigned int trim) +{ + lock = true; + int chn = CONVERT_MODE(trim+1)-1; + int value = phase.trim[chn]; + if (phaseIdx > 0 && phase.trimRef[chn] >= 0) { + trimsUse[trim]->setCurrentIndex(1 + phase.trimRef[chn] - (phase.trimRef[chn] >= phaseIdx ? 1 : 0)); + value = model.phaseData[model.getTrimFlightPhase(chn, phaseIdx)].trim[chn]; + trimsValue[trim]->setEnabled(false); + trimsSlider[trim]->setEnabled(false); + } + else { + if (phaseIdx > 0) trimsUse[trim]->setCurrentIndex(0); + trimsValue[trim]->setEnabled(true); + trimsSlider[trim]->setEnabled(true); + } + trimsSlider[trim]->setValue(value); + trimsValue[trim]->setValue(value); + lock = false; +} + +void FlightMode::phaseGVValue_editingFinished() +{ + if (!lock) { + QSpinBox *spinBox = qobject_cast(sender()); + int gvar = spinBox->property("index").toInt(); + phase.gvars[gvar] = spinBox->value(); + emit modified(); + } +} + +void FlightMode::GVName_editingFinished() +{ + if (!lock) { + QLineEdit *lineedit = qobject_cast(sender()); + int gvar = lineedit->property("index").toInt(); + memset(&model.gvars_names[gvar], 0, sizeof(model.gvars_names[gvar])); + strcpy(model.gvars_names[gvar], lineedit->text().toAscii()); + emit modified(); + } +} + +void FlightMode::GVSource_currentIndexChanged(int index) +{ + QComboBox *comboBox = qobject_cast(sender()); + int gvar = comboBox->property("index").toInt(); + model.gvsource[gvar] = index; + emit modified(); +} + +void FlightMode::phaseGVUse_currentIndexChanged(int index) +{ + if (!lock) { + lock = true; + QComboBox *comboBox = qobject_cast(sender()); + int gvar = comboBox->property("index").toInt(); + if (index == 0) { + int value = phase.gvars[gvar]; + if (value>1024) { + value=0; + } + gvValues[gvar]->setValue(value); + gvValues[gvar]->setEnabled(true); + phase.gvars[gvar]=value; + } + else { + phase.gvars[gvar] = 1024+index; + // TOTO it's wrong!!! + int value = model.phaseData[index + (index>phaseIdx ? 0 :-1)].gvars[gvar]; + gvValues[gvar]->setValue(value); + gvValues[gvar]->setDisabled(true); + } + emit modified(); + lock = false; + } +} + +void FlightMode::phaseREValue_editingFinished() +{ + if (!lock) { + QSpinBox *spinBox = qobject_cast(sender()); + int gvar = spinBox->property("index").toInt(); + phase.rotaryEncoders[gvar] = spinBox->value(); + emit modified(); + } +} + +void FlightMode::phaseREUse_currentIndexChanged(int index) +{ + if (!lock) { + lock = true; + QComboBox *comboBox = qobject_cast(sender()); + int re = comboBox->property("index").toInt(); + if (index == 0) { + // TODO no!!! + int value = phase.rotaryEncoders[re]; + if (value > 1024) { + value = 0; + } + reValues[re]->setValue(value); + reValues[re]->setEnabled(true); + phase.rotaryEncoders[re] = value; + } + else { + phase.rotaryEncoders[re] = 1024 + index; + int value = model.phaseData[index + (index>phaseIdx ? 0 :-1)].rotaryEncoders[re]; + reValues[re]->setValue(value); + reValues[re]->setDisabled(true) ; + } + lock = false; + emit modified(); + } +} + +void FlightMode::phaseTrimUse_currentIndexChanged(int index) +{ + if (!lock) { + QComboBox *comboBox = qobject_cast(sender()); + int trim = comboBox->property("index").toInt(); + int chn = CONVERT_MODE(trim+1)-1; + if (index == 0) { + phase.trim[chn] = model.phaseData[model.getTrimFlightPhase(chn, phaseIdx)].trim[chn]; + phase.trimRef[chn] = -1; + } + else { + phase.trim[chn] = 0; + phase.trimRef[chn] = index - 1 + (index > (int)phaseIdx ? 1 : 0); + } + + trimUpdate(trim); + emit modified(); + } +} + +void FlightMode::phaseTrim_valueChanged() +{ + if (!lock) { + QSpinBox *spinBox = qobject_cast(sender()); + int trim = spinBox->property("index").toInt(); + int chn = CONVERT_MODE(trim+1)-1; + int value = spinBox->value(); + phase.trim[chn] = value; + lock = true; + trimsSlider[trim]->setValue(value); + lock = false; + emit modified(); + } +} + +void FlightMode::phaseTrimSlider_valueChanged() +{ + if (!lock) { + QSlider *slider = qobject_cast(sender()); + int trim = slider->property("index").toInt(); + int chn = CONVERT_MODE(trim+1)-1; + int value = slider->value(); + phase.trim[chn] = value; + lock = true; + trimsValue[trim]->setValue(value); + lock = false; + emit modified(); + } +} + +/**********************************************************/ + +FlightModes::FlightModes(QWidget * parent, ModelData & model, GeneralSettings & generalSettings): + ModelPanel(parent, model), + modesCount(GetEepromInterface()->getCapability(FlightPhases)) +{ + QGridLayout * gridLayout = new QGridLayout(this); + tabWidget = new QTabWidget(this); + for (int i=0; isetProperty("index", i); + panels << tab; + connect(tab, SIGNAL(modified()), this, SLOT(onPhaseModified())); + connect(tab, SIGNAL(nameModified()), this, SLOT(onPhaseNameChanged())); + tabWidget->addTab(tab, getTabName(i)); + } + gridLayout->addWidget(tabWidget, 0, 0, 1, 1); + connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(on_tabWidget_currentChanged(int))); +} + +FlightModes::~FlightModes() +{ +} + +void FlightModes::onPhaseModified() +{ + emit modified(); +} + +QString FlightModes::getTabName(int index) +{ + QString result = tr("Flight Mode %1").arg(index); + const char *name = model.phaseData[index].name; + if (GetEepromInterface()->getCapability(FlightModesName) && strlen(name) > 0) { + result += tr(" (%1)").arg(name); + } + else if (index == 0) { + result += tr(" (default)"); + } + + return result; +} + +void FlightModes::onPhaseNameChanged() +{ + int index = sender()->property("index").toInt(); + tabWidget->setTabText(index, getTabName(index)); +} + +void FlightModes::update() +{ + on_tabWidget_currentChanged(tabWidget->currentIndex()); +} + +void FlightModes::on_tabWidget_currentChanged(int index) +{ + panels[index]->update(); +} diff --git a/companion/src/modeledit/flightmodes.h b/companion/src/modeledit/flightmodes.h new file mode 100644 index 000000000..0a09f279b --- /dev/null +++ b/companion/src/modeledit/flightmodes.h @@ -0,0 +1,86 @@ +#ifndef FLIGHTMODES_H +#define FLIGHTMODES_H + +#include "modelpanel.h" +#include +#include +#include +#include +#include + +namespace Ui { + class FlightMode; +} + +class FlightMode : public ModelPanel +{ + Q_OBJECT + + public: + FlightMode(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings); + virtual ~FlightMode(); + + virtual void update(); + + signals: + void nameModified(); + + private slots: + void phaseName_editingFinished(); + void phaseSwitch_currentIndexChanged(int index); + void phaseFadeIn_editingFinished(); + void phaseFadeOut_editingFinished(); + void phaseTrimUse_currentIndexChanged(int index); + void phaseTrim_valueChanged(); + void phaseTrimSlider_valueChanged(); + void GVName_editingFinished(); + void GVSource_currentIndexChanged(int index); + void phaseGVValue_editingFinished(); + void phaseGVUse_currentIndexChanged(int index); + void phaseREValue_editingFinished(); + void phaseREUse_currentIndexChanged(int index); + + private: + Ui::FlightMode *ui; + GeneralSettings & generalSettings; + int phaseIdx; + PhaseData & phase; + int reCount; + int gvCount; + QVector trimsLabel; + QLineEdit * gvNames[C9X_MAX_GVARS]; + QSpinBox * gvValues[C9X_MAX_GVARS]; + QSpinBox * reValues[C9X_MAX_ENCODERS]; + QVector trimsUse; + QVector trimsValue; + QVector trimsSlider; + + void trimUpdate(unsigned int trim); + +}; + +class FlightModes : public ModelPanel +{ + Q_OBJECT + + public: + FlightModes(QWidget *parent, ModelData & model, GeneralSettings & generalSettings); + virtual ~FlightModes(); + + virtual void update(); + + private slots: + void onPhaseModified(); + void onPhaseNameChanged(); + void on_tabWidget_currentChanged(int index); + + private: + int modesCount; + QTabWidget *tabWidget; + QString getTabName(int index); + QVector panels; + +}; + +#endif // FLIGHTMODES_H + diff --git a/companion/src/modeledit/heli.cpp b/companion/src/modeledit/heli.cpp new file mode 100644 index 000000000..6c584658a --- /dev/null +++ b/companion/src/modeledit/heli.cpp @@ -0,0 +1,49 @@ +#include "heli.h" +#include "ui_heli.h" +#include "helpers.h" + +HeliPanel::HeliPanel(QWidget *parent, ModelData & model): + ModelPanel(parent, model), + ui(new Ui::Heli) +{ + ui->setupUi(this); + + connect(ui->swashTypeCB, SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + connect(ui->swashCollectiveCB, SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + connect(ui->swashRingValSB, SIGNAL(editingFinished()), this, SLOT(edited())); + connect(ui->swashInvertELE, SIGNAL(stateChanged(int)), this, SLOT(edited())); + connect(ui->swashInvertAIL, SIGNAL(stateChanged(int)), this, SLOT(edited())); + connect(ui->swashInvertCOL, SIGNAL(stateChanged(int)), this, SLOT(edited())); +} + +HeliPanel::~HeliPanel() +{ + delete ui; +} + +void HeliPanel::update() +{ + lock = true; + + ui->swashTypeCB->setCurrentIndex(model.swashRingData.type); + populateSourceCB(ui->swashCollectiveCB, model.swashRingData.collectiveSource, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS); + ui->swashRingValSB->setValue(model.swashRingData.value); + ui->swashInvertELE->setChecked(model.swashRingData.invertELE); + ui->swashInvertAIL->setChecked(model.swashRingData.invertAIL); + ui->swashInvertCOL->setChecked(model.swashRingData.invertCOL); + + lock = false; +} + +void HeliPanel::edited() +{ + if (!lock) { + model.swashRingData.type = ui->swashTypeCB->currentIndex(); + model.swashRingData.collectiveSource = ui->swashCollectiveCB->itemData(ui->swashCollectiveCB->currentIndex()).toInt(); + model.swashRingData.value = ui->swashRingValSB->value(); + model.swashRingData.invertELE = ui->swashInvertELE->isChecked(); + model.swashRingData.invertAIL = ui->swashInvertAIL->isChecked(); + model.swashRingData.invertCOL = ui->swashInvertCOL->isChecked(); + emit modified(); + } +} diff --git a/companion/src/modeledit/heli.h b/companion/src/modeledit/heli.h new file mode 100644 index 000000000..7b5e3a73d --- /dev/null +++ b/companion/src/modeledit/heli.h @@ -0,0 +1,26 @@ +#ifndef HELI_H +#define HELI_H + +#include "modelpanel.h" + +namespace Ui { + class Heli; +} + +class HeliPanel : public ModelPanel +{ + Q_OBJECT + + public: + HeliPanel(QWidget *parent, ModelData & model); + ~HeliPanel(); + void update(); + + private slots: + void edited(); + + private: + Ui::Heli *ui; +}; + +#endif // HELI_H diff --git a/companion/src/modeledit/heli.ui b/companion/src/modeledit/heli.ui new file mode 100644 index 000000000..c9741fde9 --- /dev/null +++ b/companion/src/modeledit/heli.ui @@ -0,0 +1,141 @@ + + + Heli + + + + 0 + 0 + 795 + 307 + + + + Form + + + + 6 + + + + + + + Invert Elevator + + + + + + + Invert Aileron + + + + + + + Invert Collective + + + + + + + + + Invert + + + + + + + + Off + + + + + 120 + + + + + 120X + + + + + 140 + + + + + 90 + + + + + + + + Collective + + + + + + + + + + Swash Type + + + + + + + + + + 0 + + + 100 + + + 1 + + + 0 + + + + + + + Swash Ring + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp new file mode 100644 index 000000000..96967a5e8 --- /dev/null +++ b/companion/src/modeledit/inputs.cpp @@ -0,0 +1,486 @@ +#include "inputs.h" +#include +#include "expodialog.h" +#include "helpers.h" + +InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings): + ModelPanel(parent, model), + generalSettings(generalSettings), + expoInserted(false) +{ + QGridLayout * exposLayout = new QGridLayout(this); + + ExposlistWidget = new MixersList(this, true); + QPushButton * qbUp = new QPushButton(this); + QPushButton * qbDown = new QPushButton(this); + QPushButton * qbClear = new QPushButton(this); + + qbUp->setText(tr("Move Up")); + qbUp->setIcon(QIcon(":/images/moveup.png")); + qbUp->setShortcut(QKeySequence(tr("Ctrl+Up"))); + qbDown->setText(tr("Move Down")); + qbDown->setIcon(QIcon(":/images/movedown.png")); + qbDown->setShortcut(QKeySequence(tr("Ctrl+Down"))); + qbClear->setText(tr("Clear Expo Settings")); + qbClear->setIcon(QIcon(":/images/clear.png")); + + exposLayout->addWidget(ExposlistWidget,1,1,1,3); + exposLayout->addWidget(qbUp,2,1); + exposLayout->addWidget(qbClear,2,2); + exposLayout->addWidget(qbDown,2,3); + + connect(ExposlistWidget, SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(expolistWidget_customContextMenuRequested(QPoint))); + connect(ExposlistWidget, SIGNAL(doubleClicked(QModelIndex)),this,SLOT(expolistWidget_doubleClicked(QModelIndex))); + connect(ExposlistWidget, SIGNAL(mimeDropped(int,const QMimeData*,Qt::DropAction)),this,SLOT(mimeExpoDropped(int,const QMimeData*,Qt::DropAction))); + + connect(qbUp, SIGNAL(pressed()),SLOT(moveExpoUp())); + connect(qbDown, SIGNAL(pressed()),SLOT(moveExpoDown())); + connect(qbClear, SIGNAL(pressed()),SLOT(clearExpos())); + + connect(ExposlistWidget, SIGNAL(keyWasPressed(QKeyEvent*)), this, SLOT(expolistWidget_KeyPress(QKeyEvent*))); +} + +InputsPanel::~InputsPanel() +{ +} + +void InputsPanel::update() +{ + lock = true; + + // curDest -> destination channel + // i -> mixer number + QByteArray qba; + ExposlistWidget->clear(); + int curDest = -1; + + for(int i=0; imode==0) break; + QString str = ""; + while(curDest<(int)md->chn-1) { + curDest++; + str = getStickStr(curDest); + qba.clear(); + qba.append((quint8)-curDest-1); + QListWidgetItem *itm = new QListWidgetItem(str); + itm->setData(Qt::UserRole,qba); + ExposlistWidget->addItem(itm); + } + + if(curDest!=(int)md->chn) { + str = getStickStr(md->chn); + curDest = md->chn; + } else { + str = " "; + } + + switch (md->mode) { + case (1): str += " <-"; break; + case (2): str += " ->"; break; + default: str += " "; break; + }; + + str += tr("Weight") + getGVarString(md->weight).rightJustified(6, ' '); + if (!GetEepromInterface()->getCapability(ExpoIsCurve)) { + if (md->expo!=0) + str += " " + tr("Expo") + getGVarString(md->expo, true).rightJustified(7, ' '); + } else { + if (md->curveMode==0 && md->curveParam!=0) + str += " " + tr("Expo") + getGVarString(md->curveParam, true).rightJustified(7, ' '); + } + if (GetEepromInterface()->getCapability(FlightPhases)) { + if(md->phases) { + if (md->phases!=(unsigned int)(1<getCapability(FlightPhases))-1) { + int mask=1; + int first=0; + for (int i=0; igetCapability(FlightPhases);i++) { + if (!(md->phases & mask)) { + first++; + } + mask <<=1; + } + if (first>1) { + str += " " + tr("Flight modes") + QString("("); + } else { + str += " " + tr("Flight mode") + QString("("); + } + mask=1; + first=1; + for (int i=0; igetCapability(FlightPhases);i++) { + if (!(md->phases & mask)) { + if (!first) { + str += QString(", ")+ QString("%1").arg(getPhaseName(i+1, model.phaseData[i].name)); + } else { + str += QString("%1").arg(getPhaseName(i+1,model.phaseData[i].name)); + first=0; + } + } + mask <<=1; + } + str += QString(")"); + } else { + str += tr("DISABLED")+QString(" !!!"); + } + } + } + if (md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString()); + if (md->curveMode) + if (md->curveParam) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curveParam)); + if (GetEepromInterface()->getCapability(HasExpoNames)) { + QString ExpoName; + ExpoName.append(md->name); + if (!ExpoName.isEmpty()) { + str+=QString("(%1)").arg(ExpoName); + } + } + qba.clear(); + qba.append((quint8)i); + qba.append((const char*)md, sizeof(ExpoData)); + QListWidgetItem *itm = new QListWidgetItem(str); + itm->setData(Qt::UserRole,qba); // expo number + ExposlistWidget->addItem(itm); //(str); + } + + while(curDestsetData(Qt::UserRole,qba); // add new expo + ExposlistWidget->addItem(itm); + } + + lock = false; +} + + +bool InputsPanel::gm_insertExpo(int idx) +{ + if (idx<0 || idx>=C9X_MAX_EXPOS || model.expoData[C9X_MAX_EXPOS-1].mode > 0) { + QMessageBox::information(this, "companion9x", tr("Not enough available expos!")); + return false; + } + + int chn = model.expoData[idx].chn; + memmove(&model.expoData[idx+1],&model.expoData[idx], + (C9X_MAX_EXPOS-(idx+1))*sizeof(ExpoData) ); + memset(&model.expoData[idx],0,sizeof(ExpoData)); + model.expoData[idx].chn = chn; + model.expoData[idx].weight = 100; + model.expoData[idx].mode = 3 /* TODO enum */; + return true; +} + +void InputsPanel::gm_deleteExpo(int index) +{ + memmove(&model.expoData[index],&model.expoData[index+1], + (C9X_MAX_EXPOS-(index+1))*sizeof(ExpoData)); + memset(&model.expoData[C9X_MAX_EXPOS-1],0,sizeof(ExpoData)); +} + +void InputsPanel::gm_openExpo(int index) +{ + if(index<0 || index>=C9X_MAX_EXPOS) return; + + ExpoData mixd(model.expoData[index]); + emit modified(); + update(); + + ExpoDialog *g = new ExpoDialog(this, &mixd, generalSettings.stickMode); + if(g->exec()) { + model.expoData[index] = mixd; + emit modified(); + update(); + } else { + if (expoInserted) { + gm_deleteExpo(index); + } + expoInserted=false; + emit modified(); + update(); + } +} + +int InputsPanel::getExpoIndex(unsigned int dch) +{ + unsigned int i = 0; + while (model.expoData[i].chn<=dch && model.expoData[i].mode && i InputsPanel::createExpoListFromSelected() +{ + QList list; + foreach(QListWidgetItem *item, ExposlistWidget->selectedItems()) { + int idx= item->data(Qt::UserRole).toByteArray().at(0); + if(idx>=0 && idx list) +{ + for(int i=0; icount(); i++) { + int t = ExposlistWidget->item(i)->data(Qt::UserRole).toByteArray().at(0); + if(list.contains(t)) + ExposlistWidget->item(i)->setSelected(true); + } +} + + +void InputsPanel::exposDelete(bool ask) +{ + QMessageBox::StandardButton ret = QMessageBox::No; + + if(ask) + ret = QMessageBox::warning(this, "companion9x", + tr("Delete Selected Expos?"), + QMessageBox::Yes | QMessageBox::No); + + + if ((ret == QMessageBox::Yes) || (!ask)) { + exposDeleteList(createExpoListFromSelected()); + emit modified(); + update(); + } +} + +void InputsPanel::exposCut() +{ + exposCopy(); + exposDelete(false); +} + +void InputsPanel::exposCopy() +{ + QList list = createExpoListFromSelected(); + + QByteArray mxData; + foreach(int idx, list) { + mxData.append((char*)&model.expoData[idx],sizeof(ExpoData)); + } + + QMimeData *mimeData = new QMimeData; + mimeData->setData("application/x-companion9x-expo", mxData); + QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); +} + +void InputsPanel::mimeExpoDropped(int index, const QMimeData *data, Qt::DropAction /*action*/) +{ + int idx = ExposlistWidget->item(index > 0 ? index-1 : 0)->data(Qt::UserRole).toByteArray().at(0); + pasteExpoMimeData(data, idx); +} + +#include +#include +void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx) +{ + if (mimeData->hasFormat("application/x-companion9x-expo")) { + int idx; // mixer index + int dch; + + if (destIdx < 0) { + dch = -destIdx - 1; + idx = getExpoIndex(dch) - 1; //get expo index to insert + } else { + idx = destIdx; + dch = model.expoData[idx].chn; + } + + QByteArray mxData = mimeData->data("application/x-companion9x-expo"); + + int i = 0; + while (i < mxData.size()) { + idx++; + if (!gm_insertExpo(idx)) + break; + ExpoData *md = &model.expoData[idx]; + memcpy(md, mxData.mid(i, sizeof(ExpoData)).constData(), sizeof(ExpoData)); + md->chn = dch; + i += sizeof(ExpoData); + } + + emit modified(); + update(); + } +} + + +void InputsPanel::exposPaste() +{ + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + QListWidgetItem *item = ExposlistWidget->currentItem(); + if (item) + pasteExpoMimeData(mimeData, item->data(Qt::UserRole).toByteArray().at(0)); +} + +void InputsPanel::exposDuplicate() +{ + exposCopy(); + exposPaste(); +} + + +void InputsPanel::expoOpen(QListWidgetItem *item) +{ + if (!item) + item = ExposlistWidget->currentItem(); + + int idx = item->data(Qt::UserRole).toByteArray().at(0); + if (idx<0) { + int ch = -idx-1; + idx = getExpoIndex(ch); // get expo index to insert + if (!gm_insertExpo(idx)) + return; + model.expoData[idx].chn = ch; + expoInserted=true; + } else { + expoInserted=false; + } + gm_openExpo(idx); +} + +void InputsPanel::expoAdd() +{ + int index = ExposlistWidget->currentItem()->data(Qt::UserRole).toByteArray().at(0); + + if(index<0) { // if empty then return relevant index + expoOpen(); + } else { + index++; + if (!gm_insertExpo(index)) + return; + model.expoData[index].chn = model.expoData[index-1].chn; + } + gm_openExpo(index); +} + + +void InputsPanel::expolistWidget_customContextMenuRequested(QPoint pos) +{ + QPoint globalPos = ExposlistWidget->mapToGlobal(pos); + + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + bool hasData = mimeData->hasFormat("application/x-companion9x-expo"); + + QMenu contextMenu; + contextMenu.addAction(QIcon(":/images/add.png"), tr("&Add"),this,SLOT(expoAdd()),tr("Ctrl+A")); + contextMenu.addAction(QIcon(":/images/edit.png"), tr("&Edit"),this,SLOT(expoOpen()),tr("Enter")); + contextMenu.addSeparator(); + contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(exposDelete()),tr("Delete")); + contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(exposCopy()),tr("Ctrl+C")); + contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(exposCut()),tr("Ctrl+X")); + contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(exposPaste()),tr("Ctrl+V"))->setEnabled(hasData); + contextMenu.addAction(QIcon(":/images/duplicate.png"), tr("Du&plicate"),this,SLOT(exposDuplicate()),tr("Ctrl+U")); + contextMenu.addSeparator(); + contextMenu.addAction(QIcon(":/images/moveup.png"), tr("Move Up"),this,SLOT(moveExpoUp()),tr("Ctrl+Up")); + contextMenu.addAction(QIcon(":/images/movedown.png"), tr("Move Down"),this,SLOT(moveExpoDown()),tr("Ctrl+Down")); + + contextMenu.exec(globalPos); +} + + +void InputsPanel::expolistWidget_KeyPress(QKeyEvent *event) +{ + if(event->matches(QKeySequence::SelectAll)) expoAdd(); //Ctrl A + if(event->matches(QKeySequence::Delete)) exposDelete(); + if(event->matches(QKeySequence::Copy)) exposCopy(); + if(event->matches(QKeySequence::Cut)) exposCut(); + if(event->matches(QKeySequence::Paste)) exposPaste(); + if(event->matches(QKeySequence::Underline)) exposDuplicate(); + + if(event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) expoOpen(); + if(event->matches(QKeySequence::MoveToNextLine)) + ExposlistWidget->setCurrentRow(ExposlistWidget->currentRow()+1); + if(event->matches(QKeySequence::MoveToPreviousLine)) + ExposlistWidget->setCurrentRow(ExposlistWidget->currentRow()-1); +} + + +int InputsPanel::gm_moveExpo(int idx, bool dir) //true=inc=down false=dec=up +{ + if(idx>C9X_MAX_EXPOS || (idx==C9X_MAX_EXPOS && dir)) return idx; + + int tdx = dir ? idx+1 : idx-1; + ExpoData temp; + temp.clear(); + ExpoData &src=model.expoData[idx]; + ExpoData &tgt=model.expoData[tdx]; + if (!dir && tdx<0 && src.chn>0) { + src.chn--; + return idx; + } else if (!dir && tdx<0) { + return idx; + } + + if(memcmp(&src,&temp,sizeof(ExpoData))==0) return idx; + bool tgtempty=(memcmp(&tgt,&temp,sizeof(ExpoData))==0 ? 1:0); + if(tgt.chn!=src.chn || tgtempty) { + if ((dir) && (src.chn<(NUM_STICKS-1))) src.chn++; + if ((!dir) && (src.chn>0)) src.chn--; + return idx; + } + + //flip between idx and tgt + memcpy(&temp,&src,sizeof(ExpoData)); + memcpy(&src,&tgt,sizeof(ExpoData)); + memcpy(&tgt,&temp,sizeof(ExpoData)); + return tdx; +} + +void InputsPanel::moveExpoUp() +{ + QList list = createExpoListFromSelected(); + QList highlightList; + foreach(int idx, list) { + highlightList << gm_moveExpo(idx, false); + } + emit modified(); + update(); + setSelectedByExpoList(highlightList); +} + +void InputsPanel::moveExpoDown() +{ + QList list = createExpoListFromSelected(); + QList highlightList; + foreach(int idx, list) { + highlightList << gm_moveExpo(idx, true); + } + emit modified(); + update(); + setSelectedByExpoList(highlightList); +} + +void InputsPanel::expolistWidget_doubleClicked(QModelIndex index) +{ + expoOpen(ExposlistWidget->item(index.row())); +} + +void InputsPanel::exposDeleteList(QList list) +{ + qSort(list.begin(), list.end()); + + int iDec = 0; + foreach(int idx, list) { + gm_deleteExpo(idx-iDec); + iDec++; + } +} + +void InputsPanel::clearExpos() +{ + if (QMessageBox::question(this, tr("Clear Expos?"), tr("Really clear all the expos?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + model.clearInputs(); + emit modified(); + update(); + } +} diff --git a/companion/src/modeledit/inputs.h b/companion/src/modeledit/inputs.h new file mode 100644 index 000000000..d4e71ce5d --- /dev/null +++ b/companion/src/modeledit/inputs.h @@ -0,0 +1,50 @@ +#ifndef INPUTS_H +#define INPUTS_H + +#include "modelpanel.h" +#include "mixerslist.h" + +class InputsPanel : public ModelPanel +{ + Q_OBJECT + + public: + InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings); + virtual ~InputsPanel(); + + virtual void update(); + + private slots: + void clearExpos(); + void moveExpoUp(); + void moveExpoDown(); + void mimeExpoDropped(int index, const QMimeData *data, Qt::DropAction action); + void expolistWidget_customContextMenuRequested(QPoint pos); + void expolistWidget_doubleClicked(QModelIndex index); + void expolistWidget_KeyPress(QKeyEvent *event); + + private: + GeneralSettings & generalSettings; + bool expoInserted; + MixersList *ExposlistWidget; + + int getExpoIndex(unsigned int dch); + bool gm_insertExpo(int idx); + void gm_deleteExpo(int index); + void gm_openExpo(int index); + int gm_moveExpo(int idx, bool dir); + void exposDeleteList(QList list); + QList createExpoListFromSelected(); + void setSelectedByExpoList(QList list); + void exposDelete(bool ask=true); + void exposCut(); + void exposCopy(); + void exposPaste(); + void exposDuplicate(); + void expoOpen(QListWidgetItem *item = NULL); + void expoAdd(); + void pasteExpoMimeData(const QMimeData * mimeData, int destIdx); + +}; + +#endif // INPUTS_H diff --git a/companion/src/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp similarity index 100% rename from companion/src/mixerdialog.cpp rename to companion/src/modeledit/mixerdialog.cpp diff --git a/companion/src/mixerdialog.h b/companion/src/modeledit/mixerdialog.h similarity index 100% rename from companion/src/mixerdialog.h rename to companion/src/modeledit/mixerdialog.h diff --git a/companion/src/mixerdialog.ui b/companion/src/modeledit/mixerdialog.ui similarity index 100% rename from companion/src/mixerdialog.ui rename to companion/src/modeledit/mixerdialog.ui diff --git a/companion/src/mixerslist.cpp b/companion/src/modeledit/mixerslist.cpp similarity index 100% rename from companion/src/mixerslist.cpp rename to companion/src/modeledit/mixerslist.cpp diff --git a/companion/src/mixerslist.h b/companion/src/modeledit/mixerslist.h similarity index 100% rename from companion/src/mixerslist.h rename to companion/src/modeledit/mixerslist.h diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp new file mode 100644 index 000000000..695e75ff4 --- /dev/null +++ b/companion/src/modeledit/mixes.cpp @@ -0,0 +1,548 @@ +#include "mixes.h" +#include "helpers.h" +// #include +// #include "expodialog.h" + +MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings): + ModelPanel(parent, model), + generalSettings(generalSettings), + mixInserted(false) +{ + QGridLayout * mixesLayout = new QGridLayout(this); + + MixerlistWidget = new MixersList(this, false); // TODO enum + QPushButton * qbUp = new QPushButton(this); + QPushButton * qbDown = new QPushButton(this); + QPushButton * qbClear = new QPushButton(this); + + qbUp->setText(tr("Move Up")); + qbUp->setIcon(QIcon(":/images/moveup.png")); + qbUp->setShortcut(QKeySequence(tr("Ctrl+Up"))); + qbDown->setText(tr("Move Down")); + qbDown->setIcon(QIcon(":/images/movedown.png")); + qbDown->setShortcut(QKeySequence(tr("Ctrl+Down"))); + qbClear->setText(tr("Clear Mixes")); + qbClear->setIcon(QIcon(":/images/clear.png")); + + mixesLayout->addWidget(MixerlistWidget,1,1,1,3); + mixesLayout->addWidget(qbUp,2,1); + mixesLayout->addWidget(qbClear,2,2); + mixesLayout->addWidget(qbDown,2,3); + + connect(MixerlistWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(mixerlistWidget_customContextMenuRequested(QPoint))); + connect(MixerlistWidget,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(mixerlistWidget_doubleClicked(QModelIndex))); + connect(MixerlistWidget,SIGNAL(mimeDropped(int,const QMimeData*,Qt::DropAction)),this,SLOT(mimeMixerDropped(int,const QMimeData*,Qt::DropAction))); + + connect(qbUp,SIGNAL(pressed()),SLOT(moveMixUp())); + connect(qbDown,SIGNAL(pressed()),SLOT(moveMixDown())); + connect(qbClear,SIGNAL(pressed()),SLOT(clearMixes())); + + connect(MixerlistWidget,SIGNAL(keyWasPressed(QKeyEvent*)), this, SLOT(mixerlistWidget_KeyPress(QKeyEvent*))); +} + +MixesPanel::~MixesPanel() +{ +} + +void MixesPanel::update() +{ + // curDest -> destination channel4 + // i -> mixer number + QByteArray qba; + MixerlistWidget->clear(); + unsigned int curDest = 0; + int i; + unsigned int outputs = GetEepromInterface()->getCapability(Outputs); + int showNames = false; // TODO in a menu ui->showNames_Ckb->isChecked(); + for(i=0; igetCapability(Mixes); i++) { + MixData *md = &model.mixData[i]; + if ((md->destCh==0) || (md->destCh>outputs+(unsigned int)GetEepromInterface()->getCapability(ExtraChannels))) continue; + QString str = ""; + while(curDest<(md->destCh-1)) { + curDest++; + if (curDest > outputs) { + str = tr("X%1 ").arg(curDest-outputs); + } else { + str = tr("CH%1%2").arg(curDest/10).arg(curDest%10); + if (GetEepromInterface()->getCapability(HasChNames) && showNames) { + QString name=model.limitData[curDest-1].name; + if (!name.isEmpty()) { + name.append(" "); + str=name.left(6); + } + } + } + qba.clear(); + qba.append((quint8)-curDest); + QListWidgetItem *itm = new QListWidgetItem(str); + itm->setData(Qt::UserRole,qba); + MixerlistWidget->addItem(itm); + } + + if (md->destCh > outputs) { + str = tr("X%1 ").arg(md->destCh-outputs); + } else { + str = tr("CH%1%2").arg(md->destCh/10).arg(md->destCh%10); + str.append(" "); + if (GetEepromInterface()->getCapability(HasChNames) && showNames) { + QString name=model.limitData[md->destCh-1].name; + if (!name.isEmpty()) { + name.append(" "); + str=name.left(6); + } + } + } + if (curDest != md->destCh) { + curDest = md->destCh; + } else { + str.fill(' '); + } + + switch(md->mltpx) { + case (1): str += " *"; break; + case (2): str += " R"; break; + default: str += " "; break; + }; + + str += " " + getGVarString(md->weight, true).rightJustified(6, ' '); + str += md->srcRaw.toString(); + unsigned int fpCount = GetEepromInterface()->getCapability(FlightPhases); + if (GetEepromInterface()->getCapability(FlightPhases)) { + if(md->phases) { + if (md->phases!=(unsigned int)(1<phases & mask)) { + first++; + } + mask <<=1; + } + if (first>1) { + str += " " + tr("Flight modes") + QString("("); + } else { + str += " " + tr("Flight mode") + QString("("); + } + mask=1; + first=1; + for (unsigned int i=0; iphases & mask)) { + if (!first) { + str += QString(", ")+ QString("%1").arg(getPhaseName(i+1, model.phaseData[i].name)); + } + else { + str += QString("%1").arg(getPhaseName(i+1,model.phaseData[i].name)); + first=0; + } + } + mask <<=1; + } + str += QString(")"); + } else { + str += tr("DISABLED")+QString(" !!!"); + } + } + } + if(md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString()); + if(md->carryTrim>0) { + str += " " +tr("No Trim"); + } else if (md->carryTrim<0) { + str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(); + } + if(md->noExpo) { + str += " " +tr("No DR/Expo"); + } + if (GetEepromInterface()->getCapability(MixFmTrim) && md->enableFmTrim==1) { + if (md->sOffset) str += " " + tr("FMTrim") + QString("(%1%)").arg(md->sOffset); + } else { + if (md->sOffset) str += " " + tr("Offset") + getGVarString(md->sOffset); + } + if (md->differential) str += " " + tr("Diff") + getGVarString(md->differential); + if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve)); + int scale=GetEepromInterface()->getCapability(SlowScale); + if (scale==0) + scale=1; + if (md->delayDown || md->delayUp) + str += tr(" Delay(u%1:d%2)").arg((double)md->delayUp/scale).arg((double)md->delayDown/scale); + if (md->speedDown || md->speedUp) + str += tr(" Slow(u%1:d%2)").arg((double)md->speedUp/scale).arg((double)md->speedDown/scale); + if (md->mixWarn) str += tr(" Warn(%1)").arg(md->mixWarn); + if (GetEepromInterface()->getCapability(HasMixerNames)) { + QString MixerName; + MixerName.append(md->name); + if (!MixerName.isEmpty()) { + str+=QString("(%1)").arg(MixerName); + } + } + qba.clear(); + qba.append((quint8)i); + qba.append((const char*)md, sizeof(MixData)); + QListWidgetItem *itm = new QListWidgetItem(str); + itm->setData(Qt::UserRole,qba); // mix number + MixerlistWidget->addItem(itm);//(str); + } + + while(curDestgetCapability(ExtraChannels)) { + curDest++; + QString str; + + if (curDest > outputs) { + str = tr("X%1 ").arg(curDest-outputs); + } else { + str = tr("CH%1%2").arg(curDest/10).arg(curDest%10); + if (GetEepromInterface()->getCapability(HasChNames) && showNames) { + QString name=model.limitData[curDest-1].name; + if (!name.isEmpty()) { + name.append(" "); + str=name.left(6); + } + } + } + qba.clear(); + qba.append((quint8)-curDest); + QListWidgetItem *itm = new QListWidgetItem(str); + itm->setData(Qt::UserRole,qba); // add new mixer + MixerlistWidget->addItem(itm); + } +} + + +bool MixesPanel::gm_insertMix(int idx) +{ + if (idx<0 || idx>=GetEepromInterface()->getCapability(Mixes) || model.mixData[GetEepromInterface()->getCapability(Mixes)-1].destCh > 0) { + QMessageBox::information(this, "companion9x", tr("Not enough available mixers!")); + return false; + } + + int i = model.mixData[idx].destCh; + memmove(&model.mixData[idx+1],&model.mixData[idx], + (GetEepromInterface()->getCapability(Mixes)-(idx+1))*sizeof(MixData) ); + memset(&model.mixData[idx],0,sizeof(MixData)); + model.mixData[idx].srcRaw = RawSource(SOURCE_TYPE_NONE); + model.mixData[idx].destCh = i; + model.mixData[idx].weight = 100; + return true; +} + +void MixesPanel::gm_deleteMix(int index) +{ + memmove(&model.mixData[index],&model.mixData[index+1], + (GetEepromInterface()->getCapability(Mixes)-(index+1))*sizeof(MixData)); + memset(&model.mixData[GetEepromInterface()->getCapability(Mixes)-1],0,sizeof(MixData)); +} + +void MixesPanel::gm_openMix(int index) +{ + if(index<0 || index>=GetEepromInterface()->getCapability(Mixes)) return; + + MixData mixd(model.mixData[index]); + emit modified(); + update(); + + MixerDialog *g = new MixerDialog(this, &mixd, generalSettings.stickMode); + if(g->exec()) { + model.mixData[index] = mixd; + emit modified(); + update(); + } else { + if (mixInserted) { + gm_deleteMix(index); + } + mixInserted=false; + emit modified(); + update(); + } +} + +int MixesPanel::getMixerIndex(unsigned int dch) +{ + int i = 0; + while ((model.mixData[i].destCh<=dch) && (model.mixData[i].destCh) && (igetCapability(Mixes))) i++; + if(i==GetEepromInterface()->getCapability(Mixes)) return -1; + return i; +} + +void MixesPanel::mixerlistWidget_doubleClicked(QModelIndex index) +{ + int idx= MixerlistWidget->item(index.row())->data(Qt::UserRole).toByteArray().at(0); + if (idx<0) { + int i = -idx; + idx = getMixerIndex(i); //get mixer index to insert + if (!gm_insertMix(idx)) + return; + model.mixData[idx].destCh = i; + mixInserted=true; + } else { + mixInserted=false; + } + gm_openMix(idx); +} + +void MixesPanel::mixersDeleteList(QList list) +{ + qSort(list.begin(), list.end()); + + int iDec = 0; + foreach(int idx, list) { + gm_deleteMix(idx-iDec); + iDec++; + } +} + +QList MixesPanel::createMixListFromSelected() +{ + QList list; + foreach(QListWidgetItem *item, MixerlistWidget->selectedItems()) { + int idx= item->data(Qt::UserRole).toByteArray().at(0); + if(idx>=0 && idxgetCapability(Mixes)) list << idx; + } + return list; +} + +// TODO duplicated code +void MixesPanel::setSelectedByMixList(QList list) +{ + for(int i=0; icount(); i++) { + int t = MixerlistWidget->item(i)->data(Qt::UserRole).toByteArray().at(0); + if(list.contains(t)) + MixerlistWidget->item(i)->setSelected(true); + } +} + + +void MixesPanel::mixersDelete(bool ask) +{ + QMessageBox::StandardButton ret = QMessageBox::No; + + if(ask) + ret = QMessageBox::warning(this, "companion9x", + tr("Delete Selected Mixes?"), + QMessageBox::Yes | QMessageBox::No); + + + if ((ret == QMessageBox::Yes) || (!ask)) { + mixersDeleteList(createMixListFromSelected()); + emit modified(); + update(); + } +} + +void MixesPanel::mixersCut() +{ + mixersCopy(); + mixersDelete(false); +} + +void MixesPanel::mixersCopy() +{ + + QList list = createMixListFromSelected(); + + QByteArray mxData; + foreach(int idx, list) { + mxData.append((char*)&model.mixData[idx],sizeof(MixData)); + } + + QMimeData *mimeData = new QMimeData; + mimeData->setData("application/x-companion9x-mix", mxData); + QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); +} + +void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx) +{ + if(mimeData->hasFormat("application/x-companion9x-mix")) { + int idx; // mixer index + int dch; + + if(destIdx<0) { + dch = -destIdx; + idx = getMixerIndex(dch) - 1; //get mixer index to insert + } else { + idx = destIdx; + dch = model.mixData[idx].destCh; + } + + QByteArray mxData = mimeData->data("application/x-companion9x-mix"); + + int i = 0; + while(igetCapability(Mixes)) break; + + if (!gm_insertMix(idx)) + break; + MixData *md = &model.mixData[idx]; + memcpy(md,mxData.mid(i,sizeof(MixData)).constData(),sizeof(MixData)); + md->destCh = dch; + i += sizeof(MixData); + } + + emit modified(); + update(); + } +} + + +void MixesPanel::mixersPaste() +{ + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + QListWidgetItem *item = MixerlistWidget->currentItem(); + if (item) + pasteMixerMimeData(mimeData, item->data(Qt::UserRole).toByteArray().at(0)); +} + +void MixesPanel::mixersDuplicate() +{ + mixersCopy(); + mixersPaste(); +} + +void MixesPanel::mixerOpen() +{ + int idx = MixerlistWidget->currentItem()->data(Qt::UserRole).toByteArray().at(0); + if(idx<0) { + int i = -idx; + idx = getMixerIndex(i); //get mixer index to insert + if (!gm_insertMix(idx)) + return; + model.mixData[idx].destCh = i; + mixInserted=true; + } else { + mixInserted=false; + } + + gm_openMix(idx); +} + +void MixesPanel::mixerAdd() +{ + if (!MixerlistWidget->currentItem()) + return; + int index = MixerlistWidget->currentItem()->data(Qt::UserRole).toByteArray().at(0); + + if(index<0) { // if empty then return relavent index + int i = -index; + index = getMixerIndex(i); //get mixer index to insert + if (!gm_insertMix(index)) + return; + model.mixData[index].destCh = i; + mixInserted=true; + } else { + index++; + if (!gm_insertMix(index)) + return; + model.mixData[index].destCh = model.mixData[index-1].destCh; + mixInserted=true; + } + gm_openMix(index); +} + +void MixesPanel::mixerlistWidget_customContextMenuRequested(QPoint pos) +{ + QPoint globalPos = MixerlistWidget->mapToGlobal(pos); + + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + bool hasData = mimeData->hasFormat("application/x-companion9x-mix"); + + QMenu contextMenu; + contextMenu.addAction(QIcon(":/images/add.png"), tr("&Add"),this,SLOT(mixerAdd()),tr("Ctrl+A")); + contextMenu.addAction(QIcon(":/images/edit.png"), tr("&Edit"),this,SLOT(mixerOpen()),tr("Enter")); + contextMenu.addSeparator(); + contextMenu.addAction(QIcon(":/images/clear.png"), tr("&Delete"),this,SLOT(mixersDelete()),tr("Delete")); + contextMenu.addAction(QIcon(":/images/copy.png"), tr("&Copy"),this,SLOT(mixersCopy()),tr("Ctrl+C")); + contextMenu.addAction(QIcon(":/images/cut.png"), tr("&Cut"),this,SLOT(mixersCut()),tr("Ctrl+X")); + contextMenu.addAction(QIcon(":/images/paste.png"), tr("&Paste"),this,SLOT(mixersPaste()),tr("Ctrl+V"))->setEnabled(hasData); + contextMenu.addAction(QIcon(":/images/duplicate.png"), tr("Du&plicate"),this,SLOT(mixersDuplicate()),tr("Ctrl+U")); + contextMenu.addSeparator(); + contextMenu.addAction(QIcon(":/images/moveup.png"), tr("Move Up"),this,SLOT(moveMixUp()),tr("Ctrl+Up")); + contextMenu.addAction(QIcon(":/images/movedown.png"), tr("Move Down"),this,SLOT(moveMixDown()),tr("Ctrl+Down")); + + contextMenu.exec(globalPos); +} + +void MixesPanel::mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction /*action*/) +{ + int idx= MixerlistWidget->item(index > 0 ? index-1 : 0)->data(Qt::UserRole).toByteArray().at(0); + pasteMixerMimeData(data, idx); +} + +void MixesPanel::mixesEdited() +{ + emit modified(); +} + +void MixesPanel::mixerlistWidget_KeyPress(QKeyEvent *event) +{ + if(event->matches(QKeySequence::SelectAll)) mixerAdd(); //Ctrl A + if(event->matches(QKeySequence::Delete)) mixersDelete(); + if(event->matches(QKeySequence::Copy)) mixersCopy(); + if(event->matches(QKeySequence::Cut)) mixersCut(); + if(event->matches(QKeySequence::Paste)) mixersPaste(); + if(event->matches(QKeySequence::Underline)) mixersDuplicate(); + + if(event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) mixerOpen(); + if(event->matches(QKeySequence::MoveToNextLine)) + MixerlistWidget->setCurrentRow(MixerlistWidget->currentRow()+1); + if(event->matches(QKeySequence::MoveToPreviousLine)) + MixerlistWidget->setCurrentRow(MixerlistWidget->currentRow()-1); +} + +int MixesPanel::gm_moveMix(int idx, bool dir) //true=inc=down false=dec=up +{ + if(idx>GetEepromInterface()->getCapability(Mixes) || (idx==0 && !dir) || (idx==GetEepromInterface()->getCapability(Mixes) && dir)) return idx; + + int tdx = dir ? idx+1 : idx-1; + MixData &src=model.mixData[idx]; + MixData &tgt=model.mixData[tdx]; + + unsigned int outputs = GetEepromInterface()->getCapability(Outputs); + if((src.destCh==0) || (src.destCh>outputs) || (tgt.destCh>outputs)) return idx; + + if (tgt.destCh!=src.destCh) { + if ((dir) && (src.destCh0)) src.destCh--; + return idx; + } + + //flip between idx and tgt + MixData temp; + memcpy(&temp,&src,sizeof(MixData)); + memcpy(&src,&tgt,sizeof(MixData)); + memcpy(&tgt,&temp,sizeof(MixData)); + return tdx; +} + +void MixesPanel::moveMixUp() +{ + QList list = createMixListFromSelected(); + QList highlightList; + foreach(int idx, list) { + highlightList << gm_moveMix(idx, false); + } + emit modified(); + update(); + setSelectedByMixList(highlightList); +} + +void MixesPanel::moveMixDown() +{ + QList list = createMixListFromSelected(); + QList highlightList; + foreach(int idx, list) { + highlightList << gm_moveMix(idx, true); + } + emit modified(); + update(); + setSelectedByMixList(highlightList); +} + +void MixesPanel::clearMixes() +{ + if (QMessageBox::question(this, tr("Clear Mixes?"), tr("Really clear all the mixes?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + model.clearMixes(); + emit modified(); + update(); + } +} diff --git a/companion/src/modeledit/mixes.h b/companion/src/modeledit/mixes.h new file mode 100644 index 000000000..5e5dc4e80 --- /dev/null +++ b/companion/src/modeledit/mixes.h @@ -0,0 +1,56 @@ +#ifndef MIXES_H +#define MIXES_H + +#include "modelpanel.h" +#include "mixerslist.h" +#include "mixerdialog.h" + +class MixesPanel : public ModelPanel +{ + Q_OBJECT + + public: + MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings); + virtual ~MixesPanel(); + + virtual void update(); + + private slots: + // TODO all slots? + void clearMixes(); + void mixersDelete(bool ask=true); + void mixersCut(); + void mixersCopy(); + void mixersPaste(); + void mixersDuplicate(); + void mixerOpen(); + void mixerAdd(); + void moveMixUp(); + void moveMixDown(); + + void mixerlistWidget_customContextMenuRequested(QPoint pos); + void mixerlistWidget_doubleClicked(QModelIndex index); + void mixerlistWidget_KeyPress(QKeyEvent *event); + + void mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction action); + void pasteMixerMimeData(const QMimeData * mimeData, int destIdx); + + void mixesEdited(); + + private: + GeneralSettings & generalSettings; + MixersList *MixerlistWidget; + bool mixInserted; + + int getMixerIndex(unsigned int dch); + bool gm_insertMix(int idx); + void gm_deleteMix(int index); + void gm_openMix(int index); + int gm_moveMix(int idx, bool dir); + void mixersDeleteList(QList list); + QList createMixListFromSelected(); + void setSelectedByMixList(QList list); + +}; + +#endif // MIXES_H diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp new file mode 100644 index 000000000..fcdc68108 --- /dev/null +++ b/companion/src/modeledit/modeledit.cpp @@ -0,0 +1,130 @@ +#include "modeledit.h" +#include "ui_modeledit.h" +#include "setup.h" +#include "heli.h" +#include "flightmodes.h" +#include "inputs.h" +#include "mixes.h" +#include "channels.h" +#include "curves.h" +#include "customswitches.h" +#include "customfunctions.h" +#include "telemetry.h" +#include + +ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool isNew, QWidget *parent) : + QDialog(parent), + ui(new Ui::ModelEdit), + modelId(modelId), + model(radioData.models[modelId]), + generalSettings(generalSettings) +{ + ui->setupUi(this); + addTab(new Setup(this, model), tr("Setup")); + addTab(new HeliPanel(this, model), tr("Heli")); + addTab(new FlightModes(this, model, radioData.generalSettings), tr("Flight Modes")); + addTab(new InputsPanel(this, model, radioData.generalSettings), tr("Inputs")); + addTab(new MixesPanel(this, model, radioData.generalSettings), tr("Mixes")); + addTab(new Channels(this, model), tr("Channels")); + addTab(new CustomSwitchesPanel(this, model), tr("Custom Switches")); + if (GetEepromInterface()->getCapability(CustomFunctions)) + addTab(new CustomFunctionsPanel(this, model, radioData.generalSettings), tr("Assignable Functions")); + addTab(new Curves(this, model), tr("Curves")); + // TODO remove this capability if (!GetEepromInterface()->getCapability(FSSwitch)) + if (GetEepromInterface()->getCapability(Telemetry) & TM_HASTELEMETRY) + addTab(new TelemetryPanel(this, model), tr("Telemetry")); +} + +ModelEdit::~ModelEdit() +{ + delete ui; +} + +class VerticalScrollArea : public QScrollArea +{ + public: + VerticalScrollArea(QWidget * parent, ModelPanel * panel); + + protected: + virtual bool eventFilter(QObject *o, QEvent *e); + + private: + ModelPanel * panel; + QWidget * parent; +}; + +VerticalScrollArea::VerticalScrollArea(QWidget * parent, ModelPanel * panel): + QScrollArea(parent), + panel(panel), + parent(parent) +{ + setWidgetResizable(true); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setWidget(panel); + panel->installEventFilter(this); +} + +bool VerticalScrollArea::eventFilter(QObject *o, QEvent *e) +{ + if (o == panel && e->type() == QEvent::Resize) { + setMinimumWidth(panel->minimumSizeHint().width() + verticalScrollBar()->width()); + } + return false; +} + +void ModelEdit::addTab(ModelPanel *panel, QString text) +{ + panels << panel; + QWidget * widget = new QWidget(ui->tabWidget); + QVBoxLayout *baseLayout = new QVBoxLayout(widget); + VerticalScrollArea * area = new VerticalScrollArea(widget, panel); + baseLayout->addWidget(area); + ui->tabWidget->addTab(widget, text); + connect(panel, SIGNAL(modified()), this, SLOT(onTabModified())); +} + +void ModelEdit::onTabModified() +{ + emit modified(); +} + +void ModelEdit::on_tabWidget_currentChanged(int index) +{ + panels[index]->update(); +} + +void ModelEdit::on_pushButton_clicked() +{ + launchSimulation(); +} + +// TODO merge both +#include "simulatordialog.h" +#include "xsimulatordialog.h" + +void ModelEdit::launchSimulation() +{ + if (GetEepromInterface()->getSimulator()) { + RadioData *simuData = new RadioData(); + simuData->generalSettings = generalSettings; + simuData->models[modelId] = model; + if (GetEepromInterface()->getCapability(SimulatorType)) { + xsimulatorDialog sd(this); + sd.loadParams(*simuData, modelId); + sd.exec(); + } + else { + simulatorDialog sd(this); + sd.loadParams(*simuData, modelId); + sd.exec(); + } + delete simuData; + } + else { + QMessageBox::warning(NULL, + QObject::tr("Warning"), + QObject::tr("Simulator for this firmware is not yet available")); + } +} + + diff --git a/companion/src/modeledit/modeledit.h b/companion/src/modeledit/modeledit.h new file mode 100644 index 000000000..4208a7190 --- /dev/null +++ b/companion/src/modeledit/modeledit.h @@ -0,0 +1,39 @@ +#ifndef MODELEDIT_H +#define MODELEDIT_H + +#include +#include "modelpanel.h" + +namespace Ui { + class ModelEdit; +} + +class ModelEdit : public QDialog +{ + Q_OBJECT + + public: + explicit ModelEdit(RadioData & radioData, int modelId , bool openWizard =false, bool inNew =false, QWidget *parent = 0); + ~ModelEdit(); + + signals: + void modified(); + + private slots: + void onTabModified(); + void on_pushButton_clicked(); + void on_tabWidget_currentChanged(int index); + + private: + Ui::ModelEdit *ui; + int modelId; + ModelData & model; + GeneralSettings & generalSettings; + QVector panels; + + void addTab(ModelPanel *panel, QString text); + void launchSimulation(); + +}; + +#endif // MODELEDIT_H diff --git a/companion/src/modeledit/modeledit.ui b/companion/src/modeledit/modeledit.ui new file mode 100644 index 000000000..a4ac2fa1e --- /dev/null +++ b/companion/src/modeledit/modeledit.ui @@ -0,0 +1,67 @@ + + + ModelEdit + + + + 0 + 0 + 339 + 385 + + + + + 0 + 0 + + + + Dialog + + + + :/icon.png:/icon.png + + + true + + + + + + QLayout::SetMinimumSize + + + + + true + + + QTabWidget::North + + + -1 + + + + + + + Simulate + + + + :/images/simulate.png:/images/simulate.png + + + + + + + + + + + + diff --git a/companion/src/modeledit/modelpanel.cpp b/companion/src/modeledit/modelpanel.cpp new file mode 100644 index 000000000..b4c257aba --- /dev/null +++ b/companion/src/modeledit/modelpanel.cpp @@ -0,0 +1,30 @@ +#include "modelpanel.h" +#include + +ModelPanel::ModelPanel(QWidget * parent, ModelData & model): + QWidget(parent), + model(model), + lock(false) +{ +} + +ModelPanel::~ModelPanel() +{ +} + +void ModelPanel::update() +{ +} + +void ModelPanel::addLabel(QGridLayout * gridLayout, QString text, int col) +{ + QLabel *label = new QLabel(this); + label->setFrameShape(QFrame::Panel); + label->setFrameShadow(QFrame::Raised); + label->setMidLineWidth(0); + label->setAlignment(Qt::AlignCenter); + label->setMargin(3); + label->setText(text); + gridLayout->addWidget(label, 0, col, 1, 1); +} + diff --git a/companion/src/modeledit/modelpanel.h b/companion/src/modeledit/modelpanel.h new file mode 100644 index 000000000..8e37010dd --- /dev/null +++ b/companion/src/modeledit/modelpanel.h @@ -0,0 +1,29 @@ +#ifndef MODELPANEL_H +#define MODELPANEL_H + +#include +#include +#include "eeprominterface.h" + +class ModelPanel : public QWidget +{ + Q_OBJECT + + public: + ModelPanel(QWidget *parent, ModelData & model); + virtual ~ModelPanel(); + + signals: + void modified(); + + public slots: + virtual void update(); + + protected: + ModelData & model; + bool lock; + void addLabel(QGridLayout * gridLayout, QString text, int col); + +}; + +#endif // CHANNELS_H diff --git a/companion/src/node.cpp b/companion/src/modeledit/node.cpp similarity index 74% rename from companion/src/node.cpp rename to companion/src/modeledit/node.cpp index 66fa209b1..b421490f9 100644 --- a/companion/src/node.cpp +++ b/companion/src/modeledit/node.cpp @@ -46,32 +46,28 @@ #include "edge.h" #include "node.h" -#include "modeledit.h" -Node::Node(QSpinBox *sb,QSpinBox *sbx) +Node::Node(): + minX(-100), + maxX(+100) { - setFlag(ItemIsMovable); - setFlag(ItemSendsGeometryChanges); - setCacheMode(DeviceCoordinateCache); - setZValue(-1); - nodecolor = QColor(Qt::yellow); - qsb = sb; - qsbx = sbx; - bPressed = false; - centerX = true; - centerY = true; - fixedX = false; - fixedY = false; - ballSize = DEFAULT_BALL_SIZE; - minX=-100; - maxX=100; - + setFlag(ItemIsMovable); + setFlag(ItemSendsGeometryChanges); + setCacheMode(DeviceCoordinateCache); + setZValue(-1); + nodecolor = QColor(Qt::yellow); + bPressed = false; + centerX = true; + centerY = true; + fixedX = false; + fixedY = false; + ballSize = DEFAULT_BALL_SIZE; } void Node::addEdge(Edge *edge) { - edgeList << edge; - edge->adjust(); + edgeList << edge; + edge->adjust(); } void Node::stepToCenter(qreal step) @@ -105,7 +101,7 @@ void Node::stepToCenter(qreal step) } -void Node::setColor(QColor color) +void Node::setColor(const QColor & color) { nodecolor=color; } @@ -190,26 +186,23 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value) if(fixedY) newPos.setY(y());//make sure x doesn't change newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));// bound X newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));// bound Y - if (qsb) { - ModelEdit* modeledit = qobject_cast(qsb->parent()->parent()->parent()->parent()->parent()->parent()->parent()); - modeledit->redrawCurve = false; - qsb->setValue(100+(rect.top()-y())*200/rect.height()); - if (qsbx && !getFixedX()) { - int newX = -100 + ( (newPos.x()-rect.left()) * 200) / rect.width(); - if (newX < minX) newX = minX; - if (newX > maxX) newX = maxX; - newPos.setX(((newX+100)*rect.width()/200+rect.left())); - qsbx->setValue(newX); - } - modeledit->redrawCurve = true; + + int newX = -100 + ( (newPos.x()-rect.left()) * 200) / rect.width(); + int newY = 100+(rect.top()-y())*200/rect.height(); + if (newX < minX) newX = minX; + if (newX > maxX) newX = maxX; + + if (!getFixedX()) { + newPos.setX(((newX+100)*rect.width()/200+rect.left())); } + + emit moved(newX, newY); return newPos; } break; case ItemPositionHasChanged: - foreach (Edge *edge, edgeList) - edge->adjust(); + edge->adjust(); break; default: break; @@ -222,25 +215,19 @@ void Node::mousePressEvent(QGraphicsSceneMouseEvent *event) { update(); bPressed = true; - if(qsb) qsb->setFocus(); QGraphicsItem::mousePressEvent(event); + emit focus(); } void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { update(); bPressed = false; - if(scene()) { - if(qsb) { - qsb->clearFocus(); - ModelEdit* modeledit = qobject_cast(qsb->parent()->parent()->parent()->parent()->parent()->parent()->parent()); - QGraphicsItem::mouseReleaseEvent(event); - modeledit->drawCurve(); - } else { - QGraphicsItem::mouseReleaseEvent(event); - } - //need to tell SB that it needs to write the value - } else { + if (scene()) { + QGraphicsItem::mouseReleaseEvent(event); + emit unfocus(); + } + else { QGraphicsItem::mouseReleaseEvent(event); } } diff --git a/companion/src/node.h b/companion/src/modeledit/node.h similarity index 91% rename from companion/src/node.h rename to companion/src/modeledit/node.h index 7d33f111f..9bc699cb6 100644 --- a/companion/src/node.h +++ b/companion/src/modeledit/node.h @@ -52,11 +52,12 @@ QT_BEGIN_NAMESPACE class QGraphicsSceneMouseEvent; QT_END_NAMESPACE -class Node : public QGraphicsItem +class Node : public QGraphicsObject { + Q_OBJECT -public: - Node(QSpinBox *sb = 0, QSpinBox *sbx = 0); + public: + Node(); void addEdge(Edge *edge); QList edges() const; @@ -80,16 +81,19 @@ public: bool getFixedY() {return fixedY;} void setMinX(int val) {minX = val;}; void setMaxX(int val) {maxX = val;}; - void setColor(QColor color); + void setColor(const QColor & color); -protected: - QVariant itemChange(GraphicsItemChange change, const QVariant &value); + signals: + void moved(int x, int y); + void focus(); + void unfocus(); + protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); -private: - + private: bool bPressed; bool centerX; bool centerY; @@ -98,8 +102,6 @@ private: int ballSize; int minX; int maxX; - QSpinBox *qsb; - QSpinBox *qsbx; QList edgeList; QPointF newPos; QColor nodecolor; diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp new file mode 100644 index 000000000..68ea23242 --- /dev/null +++ b/companion/src/modeledit/setup.cpp @@ -0,0 +1,1492 @@ +#include "setup.h" +#include "ui_setup.h" +#include "helpers.h" + +Setup::Setup(QWidget *parent, ModelData & model): + ModelPanel(parent, model), + ui(new Ui::Setup) +{ + ui->setupUi(this); + tabModelEditSetup(); +} + +Setup::~Setup() +{ + delete ui; +} + +void Setup::tabModelEditSetup() +{ + lock = true; + //name + QLabel * pmsl[] = {ui->swwarn_label, ui->swwarn0_label, ui->swwarn4_label, NULL}; + QCheckBox * pmchkb[] = {ui->swwarn1_ChkB,ui->swwarn2_ChkB,ui->swwarn3_ChkB,ui->swwarn5_ChkB,ui->swwarn6_ChkB, NULL}; + QSlider * tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, NULL}; + QSlider * fssld1[] = { ui->fsm1SL_1, ui->fsm1SL_2,ui->fsm1SL_3,ui->fsm1SL_4,ui->fsm1SL_5,ui->fsm1SL_6,ui->fsm1SL_7,ui->fsm1SL_8, + ui->fsm1SL_9, ui->fsm1SL_10,ui->fsm1SL_11,ui->fsm1SL_12,ui->fsm1SL_13,ui->fsm1SL_14,ui->fsm1SL_15,ui->fsm1SL_16, NULL }; + QSlider * fssld2[] = { ui->fsm2SL_1, ui->fsm2SL_2,ui->fsm2SL_3,ui->fsm2SL_4,ui->fsm2SL_5,ui->fsm2SL_6,ui->fsm2SL_7,ui->fsm2SL_8, + ui->fsm2SL_9, ui->fsm2SL_10,ui->fsm2SL_11,ui->fsm2SL_12,ui->fsm2SL_13,ui->fsm2SL_14,ui->fsm2SL_15,ui->fsm2SL_16, NULL }; + QSpinBox * fssb1[] = { ui->fsm1SB_1, ui->fsm1SB_2,ui->fsm1SB_3,ui->fsm1SB_4,ui->fsm1SB_5,ui->fsm1SB_6,ui->fsm1SB_7,ui->fsm1SB_8, + ui->fsm1SB_9, ui->fsm1SB_10,ui->fsm1SB_11,ui->fsm1SB_12,ui->fsm1SB_13,ui->fsm1SB_14,ui->fsm1SB_15,ui->fsm1SB_16, NULL }; + QSpinBox * fssb2[] = { ui->fsm2SB_1, ui->fsm2SB_2,ui->fsm2SB_3,ui->fsm2SB_4,ui->fsm2SB_5,ui->fsm2SB_6,ui->fsm2SB_7,ui->fsm2SB_8, + ui->fsm2SB_9, ui->fsm2SB_10,ui->fsm2SB_11,ui->fsm2SB_12,ui->fsm2SB_13,ui->fsm2SB_14,ui->fsm2SB_15,ui->fsm2SB_16, NULL }; + if (IS_TARANIS(GetEepromInterface()->getBoard())) { + ui->modelNameLE->setMaxLength(12); + } else { + ui->modelNameLE->setMaxLength(10); + } + ui->modelNameLE->setText(model.name); + + if (GetEepromInterface()->getCapability(NumModules)<2) { + ui->rf2_GB->hide(); + } + + if (!GetEepromInterface()->getCapability(HasFailsafe)) { + ui->FSGB_1->hide(); + ui->FSGB_2->hide(); + ui->ModelSetupTab->setTabEnabled(1,0); + } else { + if (GetEepromInterface()->getCapability(HasFailsafe)<32) { + ui->FSGB_2->hide(); + } + + for (int i=0; fssld1[i]; i++) { + fssld1[i]->setValue(model.moduleData[0].failsafeChannels[i]); + fssld2[i]->setValue(model.moduleData[1].failsafeChannels[i]); + fssb1[i]->setValue(model.moduleData[0].failsafeChannels[i]); + fssb2[i]->setValue(model.moduleData[1].failsafeChannels[i]); + connect(fssld1[i],SIGNAL(valueChanged(int)),this,SLOT(fssldValueChanged())); + connect(fssld2[i],SIGNAL(valueChanged(int)),this,SLOT(fssldValueChanged())); + connect(fssb1[i],SIGNAL(valueChanged(int)),this,SLOT(fssbValueChanged())); + connect(fssb2[i],SIGNAL(valueChanged(int)),this,SLOT(fssbValueChanged())); + connect(fssld1[i],SIGNAL(sliderReleased()),this,SLOT(fssldEdited())); + connect(fssld2[i],SIGNAL(sliderReleased()),this,SLOT(fssldEdited())); + connect(fssb1[i],SIGNAL(editingFinished()),this,SLOT(fssbEdited())); + connect(fssb2[i],SIGNAL(editingFinished()),this,SLOT(fssbEdited())); + } + } + + //timer1 mode direction value + populateTimerSwitchCB(ui->timer1ModeCB,model.timers[0].mode,GetEepromInterface()->getCapability(TimerTriggerB)); + int min = model.timers[0].val/60; + int sec = model.timers[0].val%60; + ui->timer1ValTE->setTime(QTime(0,min,sec)); + ui->timer1DirCB->setCurrentIndex(model.timers[0].dir); + if (!GetEepromInterface()->getCapability(ModelVoice)) { + ui->modelVoice_SB->hide(); + ui->modelVoice_label->hide(); + } else { + ui->modelVoice_SB->setValue(model.modelVoice+260); + } + if (!GetEepromInterface()->getCapability(PerModelThrottleInvert)) { + ui->label_thrrev->hide(); + ui->thrrevChkB->hide(); + } + else { + ui->thrrevChkB->setChecked(model.throttleReversed); + } + if (!GetEepromInterface()->getCapability(ModelImage)) { + ui->modelImage_CB->hide(); + ui->modelImage_label->hide(); + ui->modelImage_image->hide(); + } else { + + QStringList items; + items.append(""); + QSettings settings("companion9x", "companion9x"); + QString path=settings.value("sdPath", ".").toString(); + path.append("/BMP/"); + QDir qd(path); + int vml= GetEepromInterface()->getCapability(VoicesMaxLength)+4; + if (qd.exists()) { + QStringList filters; + filters << "*.bmp" << "*.bmp"; + foreach ( QString file, qd.entryList(filters, QDir::Files) ) { + QFileInfo fi(file); + QString temp=fi.completeBaseName(); + if (!items.contains(temp) && temp.length()<=vml) { + items.append(temp); + } + } + } + if (!items.contains(model.bitmap)) { + items.append(model.bitmap); + } + items.sort(); + ui->modelImage_CB->clear(); + foreach ( QString file, items ) { + ui->modelImage_CB->addItem(file); + if (file==model.bitmap) { + ui->modelImage_CB->setCurrentIndex(ui->modelImage_CB->count()-1); + QString fileName=path; + fileName.append(model.bitmap); + fileName.append(".bmp"); + QImage image(fileName); + if (image.isNull()) { + fileName=path; + fileName.append(model.bitmap); + fileName.append(".BMP"); + image.load(fileName); + } + if (!image.isNull()) { + ui->modelImage_image->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));; + } + } + } + + } + + if (!GetEepromInterface()->getCapability(pmSwitchMask)) { + for (int i=0; pmsl[i]; i++) { + pmsl[i]->hide(); + } + for (int i=0; pmchkb[i]; i++) { + pmchkb[i]->hide(); + } + ui->tswwarn0_CB->hide(); + for (int i=0; tpmsld[i]; i++) { + tpmsld[i]->hide(); + } + ui->swwarn0_line->hide(); + ui->swwarn0_line->hide(); + ui->swwarn0_CB->hide(); + ui->swwarn4_CB->hide(); + ui->swwarn_line0->hide(); + ui->swwarn_line1->hide(); + ui->swwarn_line2->hide(); + ui->swwarn_line3->hide(); + ui->swwarn_line4->hide(); + ui->swwarn_line5->hide(); + ui->tswwarn0_label->hide(); + ui->tswwarn1_label->hide(); + ui->tswwarn2_label->hide(); + ui->tswwarn3_label->hide(); + ui->tswwarn4_label->hide(); + ui->tswwarn5_label->hide(); + ui->tswwarn6_label->hide(); + ui->tswwarn7_label->hide(); + } else { + if (GetEepromInterface()->getCapability(Pots)==3) { + ui->swwarn0_CB->setCurrentIndex(model.switchWarningStates & 0x01); + ui->swwarn1_ChkB->setChecked(checkbit(model.switchWarningStates, 1)); + ui->swwarn2_ChkB->setChecked(checkbit(model.switchWarningStates, 2)); + ui->swwarn3_ChkB->setChecked(checkbit(model.switchWarningStates, 3)); + ui->swwarn4_CB->setCurrentIndex((model.switchWarningStates & 0x30)>>4); + ui->swwarn5_ChkB->setChecked(checkbit(model.switchWarningStates, 6)); + ui->swwarn6_ChkB->setChecked(checkbit(model.switchWarningStates, 7)); + for (int i=0; pmchkb[i]; i++) { + connect(pmchkb[i], SIGNAL(stateChanged(int)),this,SLOT(startupSwitchEdited())); + } + connect(ui->swwarn0_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(startupSwitchEdited())); + connect(ui->swwarn4_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(startupSwitchEdited())); + } else { + ui->tswwarn0_CB->setCurrentIndex(model.switchWarningStates & 0x01); + uint16_t switchstate=(model.switchWarningStates>>1); + ui->chkSA->setValue(switchstate & 0x3); + switchstate >>= 2; + ui->chkSB->setValue(switchstate & 0x3); + switchstate >>= 2; + ui->chkSC->setValue(switchstate & 0x3); + switchstate >>= 2; + ui->chkSD->setValue(switchstate & 0x3); + switchstate >>= 2; + ui->chkSE->setValue(switchstate & 0x3); + switchstate >>= 2; + ui->chkSF->setValue((switchstate & 0x3)/2); + switchstate >>= 2; + ui->chkSG->setValue(switchstate & 0x3); + connect(ui->tswwarn0_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(startupSwitchEdited())); + for (int i=0; tpmsld[i]; i++) { + connect(tpmsld[i], SIGNAL(valueChanged(int)),this,SLOT(startupSwitchEdited())); + } + } + } + int ppmmax=GetEepromInterface()->getCapability(PPMFrameLength); + if (ppmmax>0) { + ui->ppmFrameLengthDSB->setMaximum(ppmmax); + } + if (!GetEepromInterface()->getCapability(InstantTrimSW)) { + ui->instantTrim_label->hide(); + ui->instantTrim_CB->setDisabled(true); + ui->instantTrim_CB->hide(); + } + else { + int found=false; + for (int i=0; i< C9X_MAX_CUSTOM_FUNCTIONS; i++) { + if (model.funcSw[i].func==FuncInstantTrim) { + populateSwitchCB(ui->instantTrim_CB,model.funcSw[i].swtch,POPULATE_MSWITCHES & POPULATE_ONOFF); + found=true; + break; + } + } + if (found==false) { + populateSwitchCB(ui->instantTrim_CB,RawSwitch(),POPULATE_MSWITCHES & POPULATE_ONOFF); + } + } + if (GetEepromInterface()->getCapability(NoTimerDirs)) { + ui->timer1DirCB->hide(); + ui->timer2DirCB->hide(); + } + if (GetEepromInterface()->getCapability(NoThrExpo)) { + ui->label_thrExpo->hide(); + ui->thrExpoChkB->hide(); + } + if (!(GetEepromInterface()->getCapability(ExtendedTrims)>0)) { + ui->extendedTrimsChkB->hide(); + ui->extendedTrims_label->hide(); + } else { + ui->extendedTrimsChkB->setChecked(model.extendedTrims); + } + if (!GetEepromInterface()->getCapability(HasTTrace)) { + ui->label_ttrace->hide(); + ui->ttraceCB->hide(); + } else { + populateTTraceCB(ui->ttraceCB,model.thrTraceSrc); + } + if (GetEepromInterface()->getCapability(RotaryEncoders)==0) { + ui->bcREaChkB->hide(); + ui->bcREbChkB->hide(); + } + if (GetEepromInterface()->getCapability(Pots)==3) { + ui->tswwarn0_CB->hide(); + ui->tswwarn0_label->hide(); + ui->tswwarn1_label->hide(); + ui->tswwarn2_label->hide(); + ui->tswwarn3_label->hide(); + ui->tswwarn4_label->hide(); + ui->tswwarn5_label->hide(); + ui->tswwarn6_label->hide(); + ui->tswwarn7_label->hide(); + ui->chkSA->hide(); + ui->chkSB->hide(); + ui->chkSC->hide(); + ui->chkSD->hide(); + ui->chkSE->hide(); + ui->chkSF->hide(); + ui->chkSG->hide(); + this->layout()->removeItem(ui->TaranisSwitchStartup); + ui->bcP4ChkB->hide(); + } else { + ui->swwarn0_CB->hide(); + ui->swwarn0_label->hide(); + ui->swwarn0_line->hide(); + ui->swwarn1_ChkB->hide(); + ui->swwarn1_line->hide(); + ui->swwarn2_ChkB->hide(); + ui->swwarn3_ChkB->hide(); + ui->swwarn4_CB->hide(); + ui->swwarn4_label->hide(); + ui->swwarn5_ChkB->hide(); + ui->swwarn6_ChkB->hide(); + ui->swwarn_line0->hide(); + ui->swwarn_line1->hide(); + ui->swwarn_line2->hide(); + ui->swwarn_line3->hide(); + ui->swwarn_line4->hide(); + ui->swwarn_line5->hide(); + this->layout()->removeItem(ui->StockSwitchStartup); + ui->bcP1ChkB->setText(tr("S1")); + ui->bcP2ChkB->setText(tr("S2")); + ui->bcP3ChkB->setText(tr("LS")); + } + + if (!GetEepromInterface()->getCapability(PerModelThrottleWarning)) { + ui->thrwarnChkB->setDisabled(true); + ui->thrwarnChkB->hide(); + ui->thrwarnLabel->hide(); + } + else { + ui->thrwarnChkB->setChecked(model.disableThrottleWarning); + } + if (!GetEepromInterface()->getCapability(TimerTriggerB)) { + ui->timer1ModeBCB->hide(); + ui->timer1ModeB_label->hide(); + ui->timer2ModeBCB->hide(); + ui->timer2ModeB_label->hide(); + } else { + populateTimerSwitchBCB(ui->timer1ModeBCB,model.timers[0].modeB,GetEepromInterface()->getCapability(TimerTriggerB)); + populateTimerSwitchBCB(ui->timer2ModeBCB,model.timers[1].modeB,GetEepromInterface()->getCapability(TimerTriggerB)); + } + + int index=0; + int selindex; + int selindex2; + ui->protocolCB->clear(); + for (int i=0; iisAvailable((Protocol)i)) { + ui->protocolCB->addItem(getProtocolStr(i), (QVariant)i); + if (model.moduleData[0].protocol == i) { + selindex = index; + } + index++; + } + } + if (GetEepromInterface()->getCapability(NumModules)>1) { + index=0; + ui->protocolCB_2->clear(); + for (int i=0; iisAvailable((Protocol)i, 1)) { + ui->protocolCB_2->addItem(getProtocolStr(i), (QVariant)i); + if (model.moduleData[1].protocol == i) { + selindex2 = index; + } + index++; + } + } + } + if (GetEepromInterface()->getCapability(ModelTrainerEnable)) { + if (!(model.trainerMode||model.traineron)) { + ui->protocolCB_3->setCurrentIndex(0); + ui->label_PPM_3->hide(); + ui->ppmDelaySB_3->hide(); + ui->label_PPMCH_3->hide(); + ui->label_pulsePol_3->hide(); + ui->pulsePolCB_3->hide(); + ui->numChannelsSB_3->hide(); + ui->label_ppmFrameLength_3->hide(); + ui->ppmFrameLengthDSB_3->hide(); + ui->label_numChannelsStart_3->hide(); + ui->numChannelsStart_3->hide(); + } else { + ui->protocolCB_3->setCurrentIndex(1); + ui->label_PPM_3->show(); + ui->ppmDelaySB_3->show(); + ui->label_PPMCH_3->show(); + ui->label_pulsePol_3->show(); + ui->pulsePolCB_3->show(); + ui->numChannelsSB_3->show(); + ui->label_ppmFrameLength_3->show(); + ui->ppmFrameLengthDSB_3->show(); + ui->label_numChannelsStart_3->show(); + ui->numChannelsStart_3->show(); + } + on_protocolCB_3_currentIndexChanged(model.traineron||model.trainerMode); + } else { + ui->rf3_GB->hide(); + } + + ui->label_PPM->hide(); + ui->ppmDelaySB->hide(); + ui->label_PPMCH->hide(); + ui->label_pulsePol->hide(); + ui->pulsePolCB->hide(); + ui->numChannelsSB->hide(); + ui->label_ppmFrameLength->hide(); + ui->ppmFrameLengthDSB->hide(); + ui->label_DSM->hide(); + ui->DSM_Type->hide(); + ui->label_PXX->hide(); + ui->pxxRxNum->hide(); + ui->label_numChannelsStart->hide(); + ui->numChannelsStart->hide(); + ui->pxxRxNum->setEnabled(false); + ui->protocolCB->setCurrentIndex(selindex); + on_protocolCB_currentIndexChanged(selindex); + if (GetEepromInterface()->getCapability(NumModules)>1) { + ui->label_PPM_2->hide(); + ui->ppmDelaySB_2->hide(); + ui->label_PPMCH_2->hide(); + ui->label_pulsePol_2->hide(); + ui->pulsePolCB_2->hide(); + ui->numChannelsSB_2->hide(); + ui->label_ppmFrameLength_2->hide(); + ui->ppmFrameLengthDSB_2->hide(); + ui->label_DSM_2->hide(); + ui->DSM_Type_2->hide(); + ui->label_PXX_2->hide(); + ui->pxxRxNum_2->hide(); + ui->label_numChannelsStart_2->hide(); + ui->numChannelsStart_2->hide(); + ui->pxxRxNum_2->setEnabled(false); + ui->protocolCB_2->setCurrentIndex(selindex2); + on_protocolCB_2_currentIndexChanged(selindex2); + } + + //timer2 mode direction value + if (GetEepromInterface()->getCapability(Timers)<2) { + ui->timer2DirCB->hide(); + ui->timer2ValTE->hide(); + ui->timer2DirCB->hide(); + ui->timer2ModeCB->hide(); + ui->timer2ModeBCB->hide(); + ui->timer2ModeB_label->hide(); + ui->label_timer2->hide(); + } else { + populateTimerSwitchCB(ui->timer2ModeCB,model.timers[1].mode,GetEepromInterface()->getCapability(TimerTriggerB)); + min = model.timers[1].val/60; + sec = model.timers[1].val%60; + ui->timer2ValTE->setTime(QTime(0,min,sec)); + ui->timer2DirCB->setCurrentIndex(model.timers[1].dir); + } + if (!GetEepromInterface()->getCapability(PermTimers)) { + ui->timer1Perm->hide(); + ui->timer2Perm->hide(); + ui->timer1PermValue->hide(); + ui->timer2PermValue->hide(); + } else { + int sign=1; + int pvalue=model.timers[0].pvalue; + if (pvalue<0) { + pvalue=-pvalue; + sign=-1; + } + int hours=pvalue/3600; + pvalue-=hours*3600; + int minutes = pvalue/60; + int seconds = pvalue%60; + ui->timer1PermValue->setText(QString(" %1(%2:%3:%4)").arg(sign<0 ? "-" :" ").arg(hours,2,10,QLatin1Char('0')).arg(minutes,2,10,QLatin1Char('0')).arg(seconds,2,10,QLatin1Char('0'))); + // QString QString::arg ( int a, int fieldWidth = 0, int base = 10, const QChar & fillChar = QLatin1Char( ' ' ) ) const + sign=1; + pvalue=model.timers[1].pvalue; + if (pvalue<0) { + pvalue=-pvalue; + sign=-1; + } + hours=pvalue/3600; + pvalue-=hours*3600; + minutes = pvalue/60; + seconds = pvalue%60; + ui->timer2PermValue->setText(QString(" %1(%2:%3:%4)").arg(sign<0 ? "-" :" ").arg(hours,2,10,QLatin1Char('0')).arg(minutes,2,10,QLatin1Char('0')).arg(seconds,2,10,QLatin1Char('0'))); + ui->timer1Perm->setChecked(model.timers[0].persistent); + ui->timer2Perm->setChecked(model.timers[1].persistent); + } + if (!GetEepromInterface()->getCapability(minuteBeep)) { + ui->timer1Minute->hide(); + ui->timer2Minute->hide(); + } else { + ui->timer1Minute->setChecked(model.timers[0].minuteBeep); + ui->timer2Minute->setChecked(model.timers[1].minuteBeep); + } + + if (!GetEepromInterface()->getCapability(countdownBeep)) { + ui->timer1CountDownBeep->hide(); + ui->timer2CountDownBeep->hide(); + } else { + ui->timer1CountDownBeep->setChecked(model.timers[0].countdownBeep); + ui->timer2CountDownBeep->setChecked(model.timers[1].countdownBeep); + } + + //trim inc, thro trim, thro expo, instatrim + ui->trimIncCB->setCurrentIndex(model.trimInc); + ui->thrExpoChkB->setChecked(model.thrExpo); + ui->thrTrimChkB->setChecked(model.thrTrim); + + //center beep + ui->bcRUDChkB->setChecked(model.beepANACenter & BC_BIT_RUD); + ui->bcELEChkB->setChecked(model.beepANACenter & BC_BIT_ELE); + ui->bcTHRChkB->setChecked(model.beepANACenter & BC_BIT_THR); + ui->bcAILChkB->setChecked(model.beepANACenter & BC_BIT_AIL); + ui->bcP1ChkB->setChecked(model.beepANACenter & BC_BIT_P1); + ui->bcP2ChkB->setChecked(model.beepANACenter & BC_BIT_P2); + ui->bcP3ChkB->setChecked(model.beepANACenter & BC_BIT_P3); + ui->bcP4ChkB->setChecked(model.beepANACenter & BC_BIT_P4); + ui->bcREaChkB->setChecked(model.beepANACenter & BC_BIT_REA); + ui->bcREbChkB->setChecked(model.beepANACenter & BC_BIT_REB); + + // PPM settings fields + ui->ppmDelaySB->setEnabled(model.moduleData[0].protocol == PPM); + ui->pulsePolCB->setCurrentIndex(model.moduleData[0].ppmPulsePol); + ui->ppmDelaySB->setEnabled(model.moduleData[0].protocol == PPM); + ui->ppmDelaySB->setValue(model.moduleData[0].ppmDelay); + // TODO? ui->numChannelsSB->setEnabled(model.moduleData[0].protocol == PPM); + + ui->extendedLimitsChkB->setChecked(model.extendedLimits); + ui->T2ThrTrgChkB->setChecked(model.t2throttle); + if (!GetEepromInterface()->getCapability(Timer2ThrTrig)) { + ui->T2ThrTrg->hide(); + ui->T2ThrTrgChkB->hide(); + } + ui->ppmFrameLengthDSB->setValue(22.5+((double)model.moduleData[0].ppmFrameLength)*0.5); + if (!GetEepromInterface()->getCapability(PPMExtCtrl)) { + ui->ppmFrameLengthDSB->hide(); + ui->label_ppmFrameLength->hide(); + } + switch (model.moduleData[0].protocol) { + case PXX_DJT: + case PXX_XJT_X16: + case PXX_XJT_D8: + case PXX_XJT_LR12: + ui->pxxRxNum->setMinimum(0); + ui->pxxRxNum->setValue((model.modelId)); + break; + case DSM2: + if (!GetEepromInterface()->getCapability(DSM2Indexes)) { + ui->pxxRxNum->setValue(1); + } + else { + ui->pxxRxNum->setMinimum(0); + ui->pxxRxNum->setValue((model.modelId)); + } + ui->numChannelsSB->setValue(8); + break; + default: + ui->label_DSM->hide(); + ui->DSM_Type->hide(); + ui->DSM_Type->setEnabled(false); + ui->label_PXX->hide(); + ui->pxxRxNum->hide(); + ui->pxxRxNum->setEnabled(false); + ui->numChannelsSB->setValue(model.moduleData[0].channelsCount); + break; + } + lock = false; +} + +void Setup::on_protocolCB_currentIndexChanged(int index) +{ + Protocol protocol = (Protocol)ui->protocolCB->itemData(index).toInt(); + + if (!lock) { + model.moduleData[0].protocol = protocol; + emit modified(); + } + + if (protocol==PXX_XJT_D8 || protocol==OFF) { + ui->FSGB_1->hide(); + } else { + ui->fsm1CB->setCurrentIndex(model.moduleData[0].failsafeMode); + on_fsm1CB_currentIndexChanged(model.moduleData[0].failsafeMode); + ui->FSGB_1->show(); + } + + ui->ppmDelaySB->setEnabled(!protocol); + ui->numChannelsSB->setEnabled(!protocol); + + if (GetEepromInterface()->getCapability(HasPPMStart)) { + ui->numChannelsSB->setSingleStep(1); + } else { + ui->numChannelsSB->setSingleStep(2); + } + + switch (protocol) { + case OFF: + ui->label_PPM->hide(); + ui->ppmDelaySB->hide(); + ui->label_PPMCH->hide(); + ui->label_pulsePol->hide(); + ui->pulsePolCB->hide(); + ui->numChannelsSB->hide(); + ui->label_ppmFrameLength->hide(); + ui->ppmFrameLengthDSB->hide(); + ui->label_DSM->hide(); + ui->DSM_Type->hide(); + ui->label_PXX->hide(); + ui->pxxRxNum->hide(); + ui->label_numChannelsStart->hide(); + ui->numChannelsStart->hide(); + break; + case PXX_XJT_X16: + case PXX_XJT_D8: + case PXX_XJT_LR12: + case PXX_DJT: + ui->label_PPM->hide(); + ui->ppmDelaySB->hide(); + ui->ppmDelaySB->setEnabled(false); + ui->label_PPMCH->show(); + ui->label_pulsePol->hide(); + ui->pulsePolCB->hide(); + ui->numChannelsSB->show(); + ui->numChannelsSB->setEnabled(true); + ui->label_ppmFrameLength->hide(); + ui->ppmFrameLengthDSB->hide(); + ui->ppmFrameLengthDSB->setEnabled(false); + ui->label_DSM->hide(); + ui->DSM_Type->hide(); + ui->DSM_Type->setEnabled(false); + ui->label_PXX->show(); + ui->pxxRxNum->setMinimum(0); + ui->pxxRxNum->show(); + ui->pxxRxNum->setEnabled(true); + ui->pxxRxNum->setValue((model.moduleData[0].channelsCount-8)/2+1); + ui->label_numChannelsStart->show(); + ui->numChannelsStart->show(); + ui->numChannelsStart->setValue(model.moduleData[0].channelsStart+1); + ui->numChannelsSB->setMinimum(model.moduleData[0].channelsStart+4); + ui->numChannelsSB->setValue(model.moduleData[0].channelsStart+model.moduleData[0].channelsCount); + break; + case LP45: + case DSM2: + case DSMX: + ui->label_pulsePol->hide(); + ui->pulsePolCB->hide(); + ui->label_PPM->hide(); + ui->ppmDelaySB->hide(); + ui->ppmDelaySB->setEnabled(false); + ui->label_PPMCH->hide(); + ui->label_numChannelsStart->hide(); + ui->numChannelsStart->hide(); + ui->numChannelsSB->hide(); + ui->numChannelsSB->setEnabled(false); + ui->label_ppmFrameLength->hide(); + ui->ppmFrameLengthDSB->hide(); + ui->ppmFrameLengthDSB->setEnabled(false); + if (!GetEepromInterface()->getCapability(DSM2Indexes)) { + ui->label_PXX->hide(); + ui->pxxRxNum->hide(); + ui->pxxRxNum->setEnabled(false); + } + else { + ui->pxxRxNum->setMinimum(0); + ui->pxxRxNum->setValue(model.modelId); + ui->label_PXX->show(); + ui->pxxRxNum->show(); + ui->pxxRxNum->setEnabled(true); + } + ui->DSM_Type->setEnabled(false); + ui->label_DSM->hide(); + ui->DSM_Type->hide(); + break; + default: + if (GetEepromInterface()->getCapability(HasPPMStart)) { + ui->label_numChannelsStart->show(); + ui->numChannelsStart->show(); + } + else { + ui->label_numChannelsStart->hide(); + ui->numChannelsStart->hide(); + } + ui->numChannelsStart->setValue(model.moduleData[0].channelsStart+1); + ui->numChannelsSB->setMinimum(model.moduleData[0].channelsStart+4); + ui->numChannelsSB->setValue(model.moduleData[0].channelsStart + model.moduleData[0].channelsCount); + ui->label_pulsePol->show(); + ui->pulsePolCB->show(); + ui->label_DSM->hide(); + ui->DSM_Type->hide(); + ui->DSM_Type->setEnabled(false); + ui->label_PXX->hide(); + ui->pxxRxNum->hide(); + ui->pxxRxNum->setEnabled(false); + ui->label_PPM->show(); + ui->ppmDelaySB->show(); + ui->ppmDelaySB->setEnabled(true); + ui->label_PPMCH->show(); + ui->numChannelsSB->show(); + ui->numChannelsSB->setEnabled(true); + ui->ppmFrameLengthDSB->setEnabled(true); + ui->ppmFrameLengthDSB->setMinimum(model.moduleData[0].channelsCount*(model.extendedLimits ? 2.250 :2)+3.5); + if (GetEepromInterface()->getCapability(PPMExtCtrl)) { + ui->ppmFrameLengthDSB->show(); + ui->label_ppmFrameLength->show(); + } + + break; + } +} + +void Setup::on_protocolCB_2_currentIndexChanged(int index) +{ + Protocol protocol = (Protocol)ui->protocolCB_2->itemData(index).toInt(); + + if (!lock) { + model.moduleData[1].protocol = protocol; + emit modified(); + } + + if (protocol==PXX_XJT_X16 || protocol==PXX_XJT_LR12) { + ui->FSGB_2->show(); + ui->fsm2CB->setCurrentIndex(model.moduleData[1].failsafeMode); + on_fsm2CB_currentIndexChanged(model.moduleData[1].failsafeMode); + } + else { + ui->FSGB_2->hide(); + } + + ui->ppmDelaySB_2->setEnabled(!protocol); + ui->numChannelsSB_2->setEnabled(!protocol); + + if (GetEepromInterface()->getCapability(HasPPMStart)) { + ui->numChannelsSB_2->setSingleStep(1); + } else { + ui->numChannelsSB_2->setSingleStep(2); + } + + switch (protocol) { + case OFF: + ui->label_PPM_2->hide(); + ui->ppmDelaySB_2->hide(); + ui->label_PPMCH_2->hide(); + ui->label_pulsePol_2->hide(); + ui->pulsePolCB_2->hide(); + ui->numChannelsSB_2->hide(); + ui->label_ppmFrameLength_2->hide(); + ui->ppmFrameLengthDSB_2->hide(); + ui->label_DSM_2->hide(); + ui->DSM_Type_2->hide(); + ui->label_PXX_2->hide(); + ui->pxxRxNum_2->hide(); + ui->label_numChannelsStart_2->hide(); + ui->numChannelsStart_2->hide(); + break; + case PXX_XJT_X16: + case PXX_XJT_D8: + case PXX_XJT_LR12: + case PXX_DJT: + ui->label_PPM_2->hide(); + ui->ppmDelaySB_2->hide(); + ui->ppmDelaySB_2->setEnabled(false); + ui->label_PPMCH_2->show(); + ui->label_pulsePol_2->hide(); + ui->pulsePolCB_2->hide(); + ui->numChannelsSB_2->show(); + ui->numChannelsSB_2->setEnabled(true); + ui->label_ppmFrameLength_2->hide(); + ui->ppmFrameLengthDSB_2->hide(); + ui->ppmFrameLengthDSB_2->setEnabled(false); + ui->label_DSM_2->hide(); + ui->DSM_Type_2->hide(); + ui->DSM_Type_2->setEnabled(false); + ui->label_PXX_2->show(); + ui->pxxRxNum_2->setMinimum(0); + ui->pxxRxNum_2->show(); + ui->pxxRxNum_2->setEnabled(true); + ui->pxxRxNum_2->setValue(model.modelId); + ui->label_numChannelsStart_2->show(); + ui->numChannelsStart_2->show(); + ui->numChannelsStart_2->setValue(model.moduleData[1].channelsStart+1); + ui->numChannelsSB_2->setMinimum(model.moduleData[1].channelsStart+4); + ui->numChannelsSB_2->setValue(model.moduleData[1].channelsStart+model.moduleData[1].channelsCount); + break; + case LP45: + case DSM2: + case DSMX: + ui->label_pulsePol_2->hide(); + ui->pulsePolCB_2->hide(); + ui->label_PPM_2->hide(); + ui->ppmDelaySB_2->hide(); + ui->ppmDelaySB_2->setEnabled(false); + ui->label_PPMCH_2->hide(); + ui->numChannelsSB_2->hide(); + ui->numChannelsSB_2->setEnabled(false); + ui->label_ppmFrameLength_2->hide(); + ui->ppmFrameLengthDSB_2->hide(); + ui->ppmFrameLengthDSB_2->setEnabled(false); + if (!GetEepromInterface()->getCapability(DSM2Indexes)) { + ui->label_PXX_2->hide(); + ui->pxxRxNum_2->hide(); + ui->pxxRxNum_2->setEnabled(false); + } else { + ui->pxxRxNum_2->setMinimum(0); + ui->pxxRxNum_2->setValue(model.modelId); + ui->label_PXX_2->show(); + ui->pxxRxNum_2->show(); + ui->pxxRxNum_2->setEnabled(true); + } + ui->DSM_Type_2->setEnabled(false); + ui->label_DSM_2->hide(); + ui->DSM_Type_2->hide(); + break; + default: + if (GetEepromInterface()->getCapability(HasPPMStart)) { + ui->label_numChannelsStart_2->show(); + ui->numChannelsStart_2->show(); + } else { + ui->label_numChannelsStart_2->hide(); + ui->numChannelsStart_2->hide(); + } + ui->numChannelsStart_2->setValue(model.moduleData[1].channelsStart+1); + ui->numChannelsSB_2->setMinimum(model.moduleData[1].channelsStart+4); + ui->numChannelsSB_2->setValue(model.moduleData[1].channelsStart+model.moduleData[1].channelsCount); + ui->label_pulsePol_2->show(); + ui->pulsePolCB_2->show(); + ui->pulsePolCB_2->setCurrentIndex(model.moduleData[1].ppmPulsePol); + ui->label_DSM_2->hide(); + ui->DSM_Type_2->hide(); + ui->DSM_Type_2->setEnabled(false); + ui->label_PXX_2->hide(); + ui->pxxRxNum_2->hide(); + ui->pxxRxNum_2->setEnabled(false); + ui->label_PPM_2->show(); + ui->ppmDelaySB_2->show(); + ui->ppmDelaySB_2->setEnabled(true); + ui->ppmDelaySB_2->setValue(model.moduleData[1].ppmDelay); + ui->label_PPMCH_2->show(); + ui->numChannelsSB_2->show(); + ui->numChannelsSB_2->setEnabled(true); + ui->ppmFrameLengthDSB_2->setEnabled(true); + ui->ppmFrameLengthDSB_2->setMinimum(model.moduleData[1].channelsCount*(model.extendedLimits ? 2.250 :2)+3.5); + if (GetEepromInterface()->getCapability(PPMExtCtrl)) { + ui->ppmFrameLengthDSB_2->show(); + ui->label_ppmFrameLength_2->show(); + ui->ppmFrameLengthDSB_2->setValue(model.moduleData[1].ppmFrameLength/2.0+22.5); + } + break; + } +} + +void Setup::on_protocolCB_3_currentIndexChanged(int index) +{ + Protocol protocol = (Protocol)ui->protocolCB_3->currentIndex(); + + if (!lock) { + model.moduleData[2].protocol = protocol; + model.trainerMode = ui->protocolCB_3->currentIndex(); + emit modified(); + } + + switch (index) { + case 0: + ui->label_PPM_3->hide(); + ui->ppmDelaySB_3->hide(); + ui->label_PPMCH_3->hide(); + ui->label_pulsePol_3->hide(); + ui->pulsePolCB_3->hide(); + ui->numChannelsSB_3->hide(); + ui->label_ppmFrameLength_3->hide(); + ui->ppmFrameLengthDSB_3->hide(); + ui->label_numChannelsStart_3->hide(); + ui->numChannelsStart_3->hide(); + break; + default: + ui->label_PPM_3->show(); + ui->ppmDelaySB_3->show(); + ui->label_PPMCH_3->show(); + ui->label_pulsePol_3->show(); + ui->pulsePolCB_3->show(); + ui->numChannelsSB_3->show(); + ui->label_ppmFrameLength_3->show(); + ui->ppmFrameLengthDSB_3->show(); + ui->label_numChannelsStart_3->show(); + ui->numChannelsStart_3->show(); + ui->numChannelsStart_3->setValue(model.moduleData[2].channelsStart+1); + ui->numChannelsSB_3->setMinimum(model.moduleData[2].channelsStart+4); + ui->numChannelsSB_3->setValue(model.moduleData[2].channelsStart+model.moduleData[2].channelsCount); + ui->pulsePolCB_3->setCurrentIndex(model.moduleData[2].ppmPulsePol); + ui->ppmDelaySB_3->setValue(model.moduleData[2].ppmDelay); + ui->ppmFrameLengthDSB_3->setMinimum(model.moduleData[2].channelsCount*(model.extendedLimits ? 2.250 :2)+3.5); + if (GetEepromInterface()->getCapability(PPMExtCtrl)) { + ui->ppmFrameLengthDSB_3->show(); + ui->label_ppmFrameLength_3->show(); + ui->ppmFrameLengthDSB_3->setValue(model.moduleData[2].ppmFrameLength/2.0+22.5); + } + break; + } +} + +void Setup::on_T2ThrTrgChkB_toggled(bool checked) +{ + model.t2throttle = checked; + emit modified(); +} + +void Setup::on_extendedLimitsChkB_toggled(bool checked) +{ + model.extendedLimits = checked; + emit modified(); +} + +void Setup::on_thrwarnChkB_toggled(bool checked) +{ + model.disableThrottleWarning = checked; + emit modified(); +} + +void Setup::on_thrrevChkB_toggled(bool checked) +{ + model.throttleReversed = checked; + emit modified(); +} + +void Setup::on_extendedTrimsChkB_toggled(bool checked) +{ + model.extendedTrims = checked; + emit modified(); +} + +void Setup::on_fsm1CB_currentIndexChanged(int index) +{ + QSpinBox * fssb[] = { ui->fsm1SB_1, ui->fsm1SB_2,ui->fsm1SB_3,ui->fsm1SB_4,ui->fsm1SB_5,ui->fsm1SB_6,ui->fsm1SB_7,ui->fsm1SB_8, + ui->fsm1SB_9, ui->fsm1SB_10,ui->fsm1SB_11,ui->fsm1SB_12,ui->fsm1SB_13,ui->fsm1SB_14,ui->fsm1SB_15,ui->fsm1SB_16, NULL }; + QSlider * fssld[] = { ui->fsm1SL_1, ui->fsm1SL_2,ui->fsm1SL_3,ui->fsm1SL_4,ui->fsm1SL_5,ui->fsm1SL_6,ui->fsm1SL_7,ui->fsm1SL_8, + ui->fsm1SL_9, ui->fsm1SL_10,ui->fsm1SL_11,ui->fsm1SL_12,ui->fsm1SL_13,ui->fsm1SL_14,ui->fsm1SL_15,ui->fsm1SL_16, NULL }; + model.moduleData[0].failsafeMode=index; + for (int i=0; fssb[i]; i++) { + if (index==1) { + fssb[i]->setEnabled(true); + fssld[i]->setEnabled(true); + } else { + fssb[i]->setDisabled(true); + fssld[i]->setDisabled(true); + } + } + emit modified(); +} + +void Setup::on_fsm2CB_currentIndexChanged(int index) +{ + QSpinBox * fssb[] = { ui->fsm2SB_1, ui->fsm2SB_2,ui->fsm2SB_3,ui->fsm2SB_4,ui->fsm2SB_5,ui->fsm2SB_6,ui->fsm2SB_7,ui->fsm2SB_8, + ui->fsm2SB_9, ui->fsm2SB_10,ui->fsm2SB_11,ui->fsm2SB_12,ui->fsm2SB_13,ui->fsm2SB_14,ui->fsm2SB_15,ui->fsm2SB_16, NULL }; + QSlider * fssld[] = { ui->fsm2SL_1, ui->fsm2SL_2,ui->fsm2SL_3,ui->fsm2SL_4,ui->fsm2SL_5,ui->fsm2SL_6,ui->fsm2SL_7,ui->fsm2SL_8, + ui->fsm2SL_9, ui->fsm2SL_10,ui->fsm2SL_11,ui->fsm2SL_12,ui->fsm2SL_13,ui->fsm2SL_14,ui->fsm2SL_15,ui->fsm2SL_16, NULL }; + model.moduleData[1].failsafeMode=index; + for (int i=0; fssb[i]; i++) { + if (index==1) { + fssb[i]->setEnabled(true); + fssld[i]->setEnabled(true); + } else { + fssb[i]->setDisabled(true); + fssld[i]->setDisabled(true); + } + } + emit modified(); +} + +void Setup::fssldValueChanged() +{ + if (!lock) { + lock = true; + QSpinBox * fssb1[] = { ui->fsm1SB_1, ui->fsm1SB_2,ui->fsm1SB_3,ui->fsm1SB_4,ui->fsm1SB_5,ui->fsm1SB_6,ui->fsm1SB_7,ui->fsm1SB_8, + ui->fsm1SB_9, ui->fsm1SB_10,ui->fsm1SB_11,ui->fsm1SB_12,ui->fsm1SB_13,ui->fsm1SB_14,ui->fsm1SB_15,ui->fsm1SB_16, NULL }; + QSpinBox * fssb2[] = { ui->fsm2SB_1, ui->fsm2SB_2,ui->fsm2SB_3,ui->fsm2SB_4,ui->fsm2SB_5,ui->fsm2SB_6,ui->fsm2SB_7,ui->fsm2SB_8, + ui->fsm2SB_9, ui->fsm2SB_10,ui->fsm2SB_11,ui->fsm2SB_12,ui->fsm2SB_13,ui->fsm2SB_14,ui->fsm2SB_15,ui->fsm2SB_16, NULL }; + QSlider *sl = qobject_cast(sender()); + int fsId=sl->objectName().mid(sl->objectName().lastIndexOf("_")+1).toInt()-1; + int moduleid=sl->objectName().mid(3,1).toInt(); + if (moduleid==1) { + fssb1[fsId]->setValue(sl->value()); + } else { + fssb2[fsId]->setValue(sl->value()); + } + lock = false; + } +} + +void Setup::fssbValueChanged() +{ + if (!lock) { + lock = true; + QSlider * fssld1[] = { ui->fsm1SL_1, ui->fsm1SL_2,ui->fsm1SL_3,ui->fsm1SL_4,ui->fsm1SL_5,ui->fsm1SL_6,ui->fsm1SL_7,ui->fsm1SL_8, + ui->fsm1SL_9, ui->fsm1SL_10,ui->fsm1SL_11,ui->fsm1SL_12,ui->fsm1SL_13,ui->fsm1SL_14,ui->fsm1SL_15,ui->fsm1SL_16, NULL }; + QSlider * fssld2[] = { ui->fsm2SL_1, ui->fsm2SL_2,ui->fsm2SL_3,ui->fsm2SL_4,ui->fsm2SL_5,ui->fsm2SL_6,ui->fsm2SL_7,ui->fsm2SL_8, + ui->fsm2SL_9, ui->fsm2SL_10,ui->fsm2SL_11,ui->fsm2SL_12,ui->fsm2SL_13,ui->fsm2SL_14,ui->fsm2SL_15,ui->fsm2SL_16, NULL }; + QSpinBox *sb = qobject_cast(sender()); + int fsId=sb->objectName().mid(sb->objectName().lastIndexOf("_")+1).toInt()-1; + int moduleid=sb->objectName().mid(3,1).toInt(); + if (moduleid==1) { + fssld1[fsId]->setValue(sb->value()); + } else { + fssld2[fsId]->setValue(sb->value()); + } + lock = false; + } +} + +void Setup::fssldEdited() +{ + QSlider *sl = qobject_cast(sender()); + int fsId=sl->objectName().mid(sl->objectName().lastIndexOf("_")+1).toInt()-1; + int moduleid=sl->objectName().mid(3,1).toInt(); + if (moduleid==1) { + model.moduleData[0].failsafeChannels[fsId]=sl->value(); + } else { + model.moduleData[1].failsafeChannels[fsId]=sl->value(); + } + emit modified(); +} + +void Setup::fssbEdited() +{ + QSpinBox *sb = qobject_cast(sender()); + int fsId=sb->objectName().mid(sb->objectName().lastIndexOf("_")+1).toInt()-1; + int moduleid=sb->objectName().mid(3,1).toInt(); + if (moduleid==1) { + model.moduleData[0].failsafeChannels[fsId]=sb->value(); + } else { + model.moduleData[1].failsafeChannels[fsId]=sb->value(); + } + emit modified(); +} + + + +void Setup::on_modelVoice_SB_editingFinished() +{ + model.modelVoice=ui->modelVoice_SB->value()-260; + emit modified(); +} + +void Setup::on_timer1Perm_toggled(bool checked) +{ + model.timers[0].persistent=checked; + emit modified(); +} + +void Setup::on_timer2Perm_toggled(bool checked) +{ + model.timers[1].persistent=checked; + emit modified(); +} + +void Setup::on_timer1Minute_toggled(bool checked) +{ + model.timers[0].minuteBeep=checked; + emit modified(); +} + +void Setup::on_timer2Minute_toggled(bool checked) +{ + model.timers[1].minuteBeep=checked; + emit modified(); +} + +void Setup::on_timer1CountDownBeep_toggled(bool checked) +{ + model.timers[0].countdownBeep=checked; + emit modified(); +} + +void Setup::on_timer2CountDownBeep_toggled(bool checked) +{ + model.timers[1].countdownBeep=checked; + emit modified(); +} + +void Setup::on_timer1ModeCB_currentIndexChanged(int index) +{ + model.timers[0].mode = TimerMode(ui->timer1ModeCB->itemData(index).toInt()); + emit modified(); +} + +void Setup::on_timer1DirCB_currentIndexChanged(int index) +{ + model.timers[0].dir = index; + emit modified(); +} + +void Setup::on_timer1ValTE_editingFinished() +{ + model.timers[0].val = ui->timer1ValTE->time().minute()*60 + ui->timer1ValTE->time().second(); + emit modified(); +} + +void Setup::on_timer1ModeBCB_currentIndexChanged(int index) +{ + model.timers[0].modeB = ui->timer1ModeBCB->itemData(index).toInt(); + emit modified(); +} + +void Setup::on_timer2ModeCB_currentIndexChanged(int index) +{ + model.timers[1].mode = TimerMode(ui->timer2ModeCB->itemData(index).toInt()); + emit modified(); +} + +void Setup::on_timer2DirCB_currentIndexChanged(int index) +{ + model.timers[1].dir = index; + emit modified(); +} + +void Setup::on_timer2ValTE_editingFinished() +{ + model.timers[1].val = ui->timer2ValTE->time().minute()*60 + ui->timer2ValTE->time().second(); + emit modified(); +} + +void Setup::on_timer2ModeBCB_currentIndexChanged(int index) +{ + model.timers[1].modeB = ui->timer2ModeBCB->itemData(index).toInt(); + emit modified(); +} + +void Setup::on_trimIncCB_currentIndexChanged(int index) +{ + model.trimInc = index; + emit modified(); +} + +void Setup::on_ttraceCB_currentIndexChanged(int index) +{ + model.thrTraceSrc = index; + emit modified(); +} + +void Setup::on_pulsePolCB_currentIndexChanged(int index) +{ + model.moduleData[0].ppmPulsePol = index; + emit modified(); +} + +void Setup::on_pulsePolCB_2_currentIndexChanged(int index) +{ + model.moduleData[1].ppmPulsePol = index; + emit modified(); +} + +void Setup::on_pulsePolCB_3_currentIndexChanged(int index) +{ + model.moduleData[2].ppmPulsePol = index; + emit modified(); +} + +void Setup::on_numChannelsSB_editingFinished() +{ + // TODO only accept valid values + model.moduleData[0].channelsCount = 1+ui->numChannelsSB->value()-ui->numChannelsStart->value(); + ui->ppmFrameLengthDSB->setMinimum(model.moduleData[0].channelsCount*(model.extendedLimits ? 2.250 :2)+3.5); + emit modified(); +} + +void Setup::on_numChannelsSB_2_editingFinished() +{ + // TODO only accept valid values + model.moduleData[1].channelsCount = 1+ui->numChannelsSB_2->value()-ui->numChannelsStart_2->value(); + ui->ppmFrameLengthDSB_2->setMinimum(model.moduleData[1].channelsCount*(model.extendedLimits ? 2.250 :2.0)+3.5); + emit modified(); +} + +void Setup::on_numChannelsSB_3_editingFinished() +{ + // TODO only accept valid values + model.moduleData[2].channelsCount = 1+ui->numChannelsSB_3->value()-ui->numChannelsStart_3->value(); + ui->ppmFrameLengthDSB_3->setMinimum(model.moduleData[2].channelsCount*(model.extendedLimits ? 2.250 :2)+3.5); + emit modified(); +} + +void Setup::on_numChannelsStart_editingFinished() +{ + // TODO only accept valid values + model.moduleData[0].channelsStart = ui->numChannelsStart->value()-1; + ui->numChannelsSB->setMinimum(model.moduleData[0].channelsStart+4); + ui->numChannelsSB->setValue(model.moduleData[0].channelsStart+model.moduleData[0].channelsCount); + emit modified(); +} + +void Setup::on_numChannelsStart_2_editingFinished() +{ + // TODO only accept valid values + model.moduleData[1].channelsStart = ui->numChannelsStart_2->value()-1; + ui->numChannelsSB_2->setMinimum(model.moduleData[1].channelsStart+4); + ui->numChannelsSB_2->setValue(model.moduleData[1].channelsStart+model.moduleData[1].channelsCount); + emit modified(); +} + +void Setup::on_numChannelsStart_3_editingFinished() +{ + // TODO only accept valid values + model.moduleData[2].channelsStart = ui->numChannelsStart_3->value()-1; + ui->numChannelsSB_3->setMinimum(model.moduleData[2].channelsStart+4); + ui->numChannelsSB_3->setValue(model.moduleData[2].channelsStart+model.moduleData[2].channelsCount); + emit modified(); +} + +void Setup::on_ppmDelaySB_editingFinished() +{ + if (!lock) { + // TODO only accept valid values + model.moduleData[0].ppmDelay = ui->ppmDelaySB->value(); + emit modified(); + } +} + +void Setup::on_ppmDelaySB_2_editingFinished() +{ + if (!lock) { + // TODO only accept valid values + model.moduleData[1].ppmDelay = ui->ppmDelaySB_2->value(); + emit modified(); + } +} + +void Setup::on_ppmDelaySB_3_editingFinished() +{ + if (!lock) { + // TODO only accept valid values + model.moduleData[2].ppmDelay = ui->ppmDelaySB_3->value(); + emit modified(); + } +} + +void Setup::on_DSM_Type_currentIndexChanged(int index) +{ + if (!lock) { + // model.moduleData[0].channelsCount = (index*2)+8; + emit modified(); + } +} + +void Setup::on_DSM_Type_2_currentIndexChanged(int index) +{ + if (!lock) { + // model.moduleData[1].channelsCount = (index*2)+8; + emit modified(); + } +} + +void Setup::on_pxxRxNum_editingFinished() +{ + if (!lock) { + if (!GetEepromInterface()->getCapability(DSM2Indexes)) { + // model.moduleData[0].channelsCount = (ui->pxxRxNum->value()-1)*2+8; + } + else { + model.modelId = ui->pxxRxNum->value(); + } + emit modified(); + } +} + +void Setup::on_pxxRxNum_2_editingFinished() +{ + if (!lock) { + /* if (!GetEepromInterface()->getCapability(DSM2Indexes)) { + model.moduleData[1].channelsCount = (ui->pxxRxNum_2->value()-1)*2+8; + } */ + emit modified(); + } +} + +void Setup::on_ppmFrameLengthDSB_editingFinished() +{ + model.moduleData[0].ppmFrameLength = (ui->ppmFrameLengthDSB->value()-22.5)/0.5; + emit modified(); +} + +void Setup::on_ppmFrameLengthDSB_2_editingFinished() +{ + model.moduleData[1].ppmFrameLength = (ui->ppmFrameLengthDSB_2->value()-22.5)/0.5; + emit modified(); +} + +void Setup::on_ppmFrameLengthDSB_3_editingFinished() +{ + model.moduleData[2].ppmFrameLength = (ui->ppmFrameLengthDSB_3->value()-22.5)/0.5; + emit modified(); +} + +void Setup::on_instantTrim_CB_currentIndexChanged(int index) +{ + if (!lock) { + bool found=false; + for (int i=0; i< C9X_MAX_CUSTOM_FUNCTIONS; i++) { + if (model.funcSw[i].func==FuncInstantTrim) { + model.funcSw[i].swtch = RawSwitch(ui->instantTrim_CB->itemData(ui->instantTrim_CB->currentIndex()).toInt()); + found=true; + } + } + if (found==false) { + for (int i=0; i< C9X_MAX_CUSTOM_FUNCTIONS; i++) { + if (model.funcSw[i].swtch==RawSwitch()) { + model.funcSw[i].swtch = RawSwitch(ui->instantTrim_CB->itemData(ui->instantTrim_CB->currentIndex()).toInt()); + model.funcSw[i].func = FuncInstantTrim; + break; + } + } + } + emit modified(); + } +} + +void Setup::on_modelNameLE_editingFinished() +{ + int length=ui->modelNameLE->maxLength(); + strncpy(model.name, ui->modelNameLE->text().toAscii(), length); + emit modified(); +} + +void Setup::on_modelImage_CB_currentIndexChanged(int index) +{ + if (!lock) { + strncpy(model.bitmap, ui->modelImage_CB->currentText().toAscii(), GetEepromInterface()->getCapability(VoicesMaxLength)); + QSettings settings("companion9x", "companion9x"); + QString path=settings.value("sdPath", ".").toString(); + path.append("/BMP/"); + QDir qd(path); + if (qd.exists()) { + QString fileName=path; + fileName.append(model.bitmap); + fileName.append(".bmp"); + QImage image(fileName); + if (image.isNull()) { + fileName=path; + fileName.append(model.bitmap); + fileName.append(".BMP"); + image.load(fileName); + } + if (!image.isNull()) { + ui->modelImage_image->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));; + } + else { + ui->modelImage_image->clear(); + } + } + else { + ui->modelImage_image->clear(); + } + emit modified(); + } +} + +void Setup::startupSwitchEdited() +{ + if (GetEepromInterface()->getCapability(Pots)==3) { + uint8_t i= 0; + i|=(uint8_t)ui->swwarn0_CB->currentIndex(); + if (i==1) { + ui->swwarn1_ChkB->setDisabled(true) ; + ui->swwarn2_ChkB->setDisabled(true) ; + ui->swwarn3_ChkB->setDisabled(true) ; + ui->swwarn4_CB->setDisabled(true) ; + ui->swwarn5_ChkB->setDisabled(true) ; + ui->swwarn6_ChkB->setDisabled(true) ; + } + else { + ui->swwarn1_ChkB->setEnabled(true) ; + ui->swwarn2_ChkB->setEnabled(true) ; + ui->swwarn3_ChkB->setEnabled(true) ; + ui->swwarn4_CB->setEnabled(true) ; + ui->swwarn5_ChkB->setEnabled(true) ; + ui->swwarn6_ChkB->setEnabled(true) ; + i|=(ui->swwarn1_ChkB->isChecked() ? 1 : 0)<<1; + i|=(ui->swwarn2_ChkB->isChecked() ? 1 : 0)<<2; + i|=(ui->swwarn3_ChkB->isChecked() ? 1 : 0)<<3; + i|=((uint8_t)ui->swwarn4_CB->currentIndex() & 0x03)<<4; + i|=(ui->swwarn5_ChkB->isChecked() ? 1 : 0)<<6; + i|=(ui->swwarn6_ChkB->isChecked() ? 1 : 0)<<7; + } + model.switchWarningStates=i; + } + else { + uint16_t i= 0; + i|=(uint16_t)ui->tswwarn0_CB->currentIndex(); + if (i==1) { + ui->chkSA->setDisabled(true); + ui->chkSB->setDisabled(true); + ui->chkSC->setDisabled(true); + ui->chkSD->setDisabled(true); + ui->chkSE->setDisabled(true); + ui->chkSF->setDisabled(true); + ui->chkSG->setDisabled(true); + } + else { + ui->chkSA->setEnabled(true); + ui->chkSB->setEnabled(true); + ui->chkSC->setEnabled(true); + ui->chkSD->setEnabled(true); + ui->chkSE->setEnabled(true); + ui->chkSF->setEnabled(true); + ui->chkSG->setEnabled(true); + i|=(((uint16_t)ui->chkSA->value())<<1); + i|=(((uint16_t)ui->chkSB->value())<<3); + i|=(((uint16_t)ui->chkSC->value())<<5); + i|=(((uint16_t)ui->chkSD->value())<<7); + i|=(((uint16_t)ui->chkSE->value())<<9); + i|=(((uint16_t)ui->chkSF->value())<<12); + i|=(((uint16_t)ui->chkSG->value())<<13); + } + model.switchWarningStates=i; + } + emit modified(); +} + +void Setup::on_thrTrimChkB_toggled(bool checked) +{ + model.thrTrim = checked; + emit modified(); +} + +void Setup::on_thrExpoChkB_toggled(bool checked) +{ + model.thrExpo = checked; + emit modified(); +} + +void Setup::on_bcRUDChkB_toggled(bool checked) +{ + if(checked) { + model.beepANACenter |= BC_BIT_RUD; + } else { + model.beepANACenter &= ~BC_BIT_RUD; + } + emit modified(); +} + +void Setup::on_bcELEChkB_toggled(bool checked) +{ + if(checked) { + model.beepANACenter |= BC_BIT_ELE; + } else { + model.beepANACenter &= ~BC_BIT_ELE; + } + emit modified(); +} + +void Setup::on_bcTHRChkB_toggled(bool checked) +{ + if(checked) { + model.beepANACenter |= BC_BIT_THR; + } else { + model.beepANACenter &= ~BC_BIT_THR; + } + emit modified(); +} + +void Setup::on_bcAILChkB_toggled(bool checked) +{ + if(checked) { + model.beepANACenter |= BC_BIT_AIL; + } else { + model.beepANACenter &= ~BC_BIT_AIL; + } + emit modified(); +} + +void Setup::on_bcP1ChkB_toggled(bool checked) +{ + if(checked) { + model.beepANACenter |= BC_BIT_P1; + } else { + model.beepANACenter &= ~BC_BIT_P1; + } + emit modified(); +} + +void Setup::on_bcP2ChkB_toggled(bool checked) +{ + if(checked) { + model.beepANACenter |= BC_BIT_P2; + } else { + model.beepANACenter &= ~BC_BIT_P2; + } + emit modified(); +} + +void Setup::on_bcP3ChkB_toggled(bool checked) +{ + if(checked) { + model.beepANACenter |= BC_BIT_P3; + } else { + model.beepANACenter &= ~BC_BIT_P3; + } + emit modified(); +} + +void Setup::on_bcP4ChkB_toggled(bool checked) +{ + if(checked) { + model.beepANACenter |= BC_BIT_P4; + } else { + model.beepANACenter &= ~BC_BIT_P4; + } + emit modified(); +} + +void Setup::on_bcREaChkB_toggled(bool checked) +{ + if(checked) { + model.beepANACenter |= BC_BIT_REA; + } else { + model.beepANACenter &= ~BC_BIT_REA; + } + emit modified(); +} + +void Setup::on_bcREbChkB_toggled(bool checked) +{ + if(checked) { + model.beepANACenter |= BC_BIT_REB; + } else { + model.beepANACenter &= ~BC_BIT_REB; + } + emit modified(); +} + diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h new file mode 100644 index 000000000..87b3cc843 --- /dev/null +++ b/companion/src/modeledit/setup.h @@ -0,0 +1,96 @@ +#ifndef SETUP_H +#define SETUP_H + +#include "modelpanel.h" + +namespace Ui { + class Setup; +} + +class Setup : public ModelPanel +{ + Q_OBJECT + + public: + Setup(QWidget *parent, ModelData & model); + virtual ~Setup(); + + private slots: + void on_protocolCB_currentIndexChanged(int index); + void on_protocolCB_2_currentIndexChanged(int index); + void on_protocolCB_3_currentIndexChanged(int index); + void on_fsm1CB_currentIndexChanged(int index); + void on_fsm2CB_currentIndexChanged(int index); + void on_modelVoice_SB_editingFinished(); + void on_T2ThrTrgChkB_toggled(bool checked); + void on_ttraceCB_currentIndexChanged(int index); + void on_instantTrim_CB_currentIndexChanged(int index); + void on_thrExpoChkB_toggled(bool checked); + void on_thrTrimChkB_toggled(bool checked); + void on_extendedLimitsChkB_toggled(bool checked); + void on_extendedTrimsChkB_toggled(bool checked); + void on_thrwarnChkB_toggled(bool checked); + void on_thrrevChkB_toggled(bool checked); + void on_timer1Perm_toggled(bool checked); + void on_timer2Perm_toggled(bool checked); + void on_timer1Minute_toggled(bool checked); + void on_timer2Minute_toggled(bool checked); + void on_timer1CountDownBeep_toggled(bool checked); + void on_timer2CountDownBeep_toggled(bool checked); + void fssldEdited(); + void fssbEdited(); + void fssldValueChanged(); + void fssbValueChanged(); + void on_ppmDelaySB_editingFinished(); + void on_ppmDelaySB_2_editingFinished(); + void on_ppmDelaySB_3_editingFinished(); + void on_numChannelsSB_editingFinished(); + void on_numChannelsSB_2_editingFinished(); + void on_numChannelsSB_3_editingFinished(); + void on_numChannelsStart_editingFinished(); + void on_numChannelsStart_2_editingFinished(); + void on_numChannelsStart_3_editingFinished(); +// void void ModelEdit::on_numChannelsStart_3_editingFinished(); + void on_pulsePolCB_currentIndexChanged(int index); + void on_pulsePolCB_2_currentIndexChanged(int index); + void on_pulsePolCB_3_currentIndexChanged(int index); + void on_ppmFrameLengthDSB_editingFinished(); + void on_ppmFrameLengthDSB_2_editingFinished(); + void on_ppmFrameLengthDSB_3_editingFinished(); + void on_DSM_Type_currentIndexChanged(int index); + void on_DSM_Type_2_currentIndexChanged(int index); + void on_pxxRxNum_editingFinished(); + void on_pxxRxNum_2_editingFinished(); + + // TODO void on_trimSWCB_currentIndexChanged(int index); + void on_trimIncCB_currentIndexChanged(int index); + void on_timer1DirCB_currentIndexChanged(int index); + void on_timer1ModeCB_currentIndexChanged(int index); + void on_timer1ValTE_editingFinished(); + void on_timer1ModeBCB_currentIndexChanged(int index); + void on_timer2DirCB_currentIndexChanged(int index); + void on_timer2ModeCB_currentIndexChanged(int index); + void on_timer2ValTE_editingFinished(); + void on_timer2ModeBCB_currentIndexChanged(int index); + void on_modelNameLE_editingFinished(); + void on_modelImage_CB_currentIndexChanged(int index); + + void on_bcRUDChkB_toggled(bool checked); + void on_bcELEChkB_toggled(bool checked); + void on_bcTHRChkB_toggled(bool checked); + void on_bcAILChkB_toggled(bool checked); + void on_bcP1ChkB_toggled(bool checked); + void on_bcP2ChkB_toggled(bool checked); + void on_bcP3ChkB_toggled(bool checked); + void on_bcP4ChkB_toggled(bool checked); + void on_bcREaChkB_toggled(bool checked); + void on_bcREbChkB_toggled(bool checked); + + void startupSwitchEdited(); + + private: + Ui::Setup *ui; + void tabModelEditSetup(); +}; + +#endif // SETUP_H diff --git a/companion/src/modeledit/setup.ui b/companion/src/modeledit/setup.ui new file mode 100644 index 000000000..94dbaadfb --- /dev/null +++ b/companion/src/modeledit/setup.ui @@ -0,0 +1,3759 @@ + + + Setup + + + Qt::NonModal + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + Form + + + + + + true + + + + 0 + 0 + + + + 0 + + + true + + + false + + + + + 0 + 0 + + + + ModelSetup + + + + + + Timer2 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Disable Throttle Warning + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + Extended Limits + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Throttle Trim + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Throttle Source + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + + + + Center beep + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Trim Increment + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + Exponential + + + + + Extra Fine + + + + + Fine + + + + + Medium + + + + + Coarse + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Switch startup Warning + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0 + + + 6 + + + + + + 0 + 0 + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + 3POS + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Check + + + Qt::AlignCenter + + + + + + + Qt::LeftToRight + + + THR + + + + + + + + ON + + + + + OFF + + + + + + + + Qt::LeftToRight + + + RUD + + + + + + + Qt::LeftToRight + + + ELE + + + + + + + Qt::LeftToRight + + + AIL + + + + + + + Qt::LeftToRight + + + GEA + + + + + + + true + + + + ID0 + + + + + ID1 + + + + + ID2 + + + + + + + + + 0 + 0 + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + Qt::Vertical + + + + + + + + + QLayout::SetMinimumSize + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + ON + + + + + OFF + + + + + + + + + 0 + 0 + + + + SB + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + SD + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + SA + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Check + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + 16777215 + 50 + + + + 0 + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + 16777215 + 50 + + + + 0 + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + SC + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + 16777215 + 50 + + + + 0 + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + SG + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + SE + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + 16777215 + 50 + + + + 0 + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + 16777215 + 50 + + + + 0 + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + SF + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + 16777215 + 50 + + + + 0 + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + 16777215 + 50 + + + + 0 + + + 1 + + + 1 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + + + + REa + + + + + + + RUD + + + + + + + ELE + + + + + + + THR + + + + + + + AIL + + + + + + + P1 + + + + + + + P2 + + + + + + + P3 + + + + + + + REb + + + + + + + RS + + + + + + + + + + + + + + + + Throttle2Trig + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 16777215 + 16777215 + + + + + + + + + 0 + 0 + + + + + + + + + + + Instant Trim + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + Extended Trims + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + + + + + + Reverse Throttle Operation + + + + + + + Reverse throttle operation. +If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well. + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 0 + + + + + + + + + + + + + + + Master + + + + + Slave + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + usec + + + 100 + + + 800 + + + 50 + + + 300 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + PPM delay + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Pulse Shift (polarity) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Trainer Mode + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + mSec + + + 1 + + + 12.500000000000000 + + + 32.500000000000000 + + + 0.500000000000000 + + + 22.500000000000000 + + + + + + + + 0 + 0 + + + + + Negative + + + + + Positive + + + + + + + + PPM Frame Length + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + font-weight:bold; + + + Master/Trainer Port + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + ch + + + 1 + + + 16 + + + 2 + + + 8 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + ch + + + 1 + + + 32 + + + 1 + + + 8 + + + + + + + + 0 + 0 + + + + Channels + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Start + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + + + PPM delay + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Polarity + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + Negative + + + + + Positive + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + usec + + + 100 + + + 800 + + + 50 + + + 300 + + + + + + + + 0 + 0 + + + + PPM Frame Length + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + mSec + + + 1 + + + 12.500000000000000 + + + 32.500000000000000 + + + 0.500000000000000 + + + 22.500000000000000 + + + + + + + + 0 + 0 + + + + + + + 1 + + + 125 + + + 1 + + + 1 + + + + + + + Qt::Horizontal + + + + 5 + 20 + + + + + + + + + 0 + 0 + + + + DSM Type + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + LP4/LP5 + + + + + DSM2only + + + + + DSM2/DSMX + + + + + + + + + 0 + 0 + + + + RX Number + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + PPM + + + + + Silver A + + + + + Silver B + + + + + Silver C + + + + + Trac 09 + + + + + + + + font-weight: bold; + + + RF Module 1 + + + + + + + + 0 + 0 + + + + Protocol + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 0 + + + + + + + + + + Start + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + ch + + + 1 + + + 32 + + + 1 + + + 1 + + + + + + + + 0 + 0 + + + + Channels + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + ch + + + 1 + + + 16 + + + 2 + + + 8 + + + + + + + + + + + + + + + + + + PPM delay + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + usec + + + 100 + + + 800 + + + 50 + + + 300 + + + + + + + + 0 + 0 + + + + + Negative + + + + + Positive + + + + + + + + + 0 + 0 + + + + Polarity + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + RX Number + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + 1 + + + 125 + + + 1 + + + 1 + + + + + + + + 0 + 0 + + + + DSM Type + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + LP4/LP5 + + + + + DSM2only + + + + + DSM2/DSMX + + + + + + + + font-weight:bold; + + + RF Module 2 + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 0 + + + + + + + + + 0 + 0 + + + + PPM Frame Length + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + mSec + + + 1 + + + 12.500000000000000 + + + 32.500000000000000 + + + 0.500000000000000 + + + 22.500000000000000 + + + + + + + Qt::Horizontal + + + + 5 + 20 + + + + + + + + + PPM + + + + + Silver A + + + + + Silver B + + + + + Silver C + + + + + Trac 09 + + + + + + + + + 0 + 0 + + + + Protocol + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + Start + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + ch + + + 1 + + + 32 + + + 1 + + + 1 + + + + + + + + 0 + 0 + + + + Channels + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + ch + + + 1 + + + 16 + + + 2 + + + 8 + + + + + + + + + + + + + + Throttle Expo + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Model Name + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Timer1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 2 + + + + + true + + + QDateTimeEdit::MinuteSection + + + mm:ss + + + + + + + + Count Down + + + + + Count Up + + + + + + + + + + + + 0 + 0 + + + + TriggerB + + + + + + + + + + Persistent + + + + + + + (00:00:00) + + + + + + + MinuteBeep + + + + + + + CountDownBeep + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 2 + + + + + true + + + QDateTimeEdit::MinuteSection + + + mm:ss + + + + + + + + Count Down + + + + + Count Up + + + + + + + + + + + + 0 + 0 + + + + TriggerB + + + + + + + + + + Persistent + + + + + + + (00:00:00) + + + + + + + MinuteBeep + + + + + + + CountDownBeep + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + 10 + + + + + + + Model Voice + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + 260 + + + 511 + + + 1 + + + 260 + + + + + + + Model Image + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 64 + 32 + + + + + 64 + 32 + + + + QFrame::Panel + + + QFrame::Raised + + + + + + true + + + + + + + + + + + + + Failsafe + + + + + + External module + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH12 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH01 + + + + + + + CH04 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH10 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + CH02 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH11 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH03 + + + + + + + CH09 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + CH05 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + CH06 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + CH07 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH08 + + + + + + + Qt::Vertical + + + + + + + CH13 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + CH14 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + CH15 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + CH16 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + true + + + -100 + + + 100 + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + + + Failsafe Mode + + + + + + + + Hold + + + + + Custom + + + + + No Pulses + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 1 + + + + + + + + Internal Module + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + CH14 + + + + + + + CH09 + + + + + + + CH02 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH01 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH04 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH12 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH10 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH03 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH11 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + CH05 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + CH06 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + CH07 + + + + + + + CH08 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + CH13 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + CH15 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + CH16 + + + + + + + -100 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + -100 + + + 100 + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + + + Failsafe Mode + + + + + + + + Hold + + + + + Custom + + + + + No Pulses + + + + + + + + + + + + + + + + + + diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp new file mode 100644 index 000000000..22db68ae4 --- /dev/null +++ b/companion/src/modeledit/telemetry.cpp @@ -0,0 +1,939 @@ +#include "telemetry.h" +#include "ui_telemetry.h" +#include "ui_telemetry_analog.h" +#include "helpers.h" + +TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog): + QWidget(parent), + ui(new Ui::TelemetryAnalog), + analog(analog), + lock(false) +{ + ui->setupUi(this); + + float ratio; + + if (analog.type==0 || analog.type==1 || analog.type==2) { + ratio = (analog.ratio<RatioSB->setDecimals(1); + ui->RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); + } + else { + ratio = analog.ratio<RatioSB->setDecimals(0); + ui->RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); + } + ui->RatioSB->setValue(ratio); + + update(); + + ui->UnitCB->setCurrentIndex(analog.type); + ui->alarm1LevelCB->setCurrentIndex(analog.alarms[0].level); + ui->alarm1GreaterCB->setCurrentIndex(analog.alarms[0].greater); + ui->alarm2LevelCB->setCurrentIndex(analog.alarms[1].level); + ui->alarm2GreaterCB->setCurrentIndex(analog.alarms[1].greater); + + if (!(GetEepromInterface()->getCapability(Telemetry) & TM_HASOFFSET)) { + ui->CalibSB->hide(); + ui->CalibLabel->hide(); + } + else { + ui->label_Max->setText(tr("Range")); + } +} + +void TelemetryAnalog::update() +{ + float ratio, alarm1value, alarm2value; + if (analog.ratio==0) { + ui->alarm1ValueSB->setMinimum(0); + ui->alarm1ValueSB->setMaximum(0); + ui->alarm2ValueSB->setMinimum(0); + ui->alarm2ValueSB->setMaximum(0); + ui->CalibSB->setMinimum(0); + ui->CalibSB->setMaximum(0); + ui->CalibSB->setValue(0); + ui->alarm1ValueSB->setValue(0); + ui->alarm2ValueSB->setValue(0); + return; + } + + if (analog.type==0 || analog.type==1 || analog.type==2) { + ratio=(analog.ratio<alarm1ValueSB->setDecimals(2); + ui->alarm1ValueSB->setSingleStep(ratio/255.0); + ui->alarm2ValueSB->setDecimals(2); + ui->alarm2ValueSB->setSingleStep(ratio/255.0); + ui->alarm1ValueSB->setMinimum((analog.ratio*1.0*analog.offset)/2550.0); + ui->alarm1ValueSB->setMaximum(ratio+(analog.ratio*1.0*analog.offset)/2550.0); + ui->alarm2ValueSB->setMinimum((analog.offset*1.0*analog.ratio)/2550.0); + ui->alarm2ValueSB->setMaximum(ratio+(analog.offset*1.0*analog.ratio)/2550.0); + } + else { + ratio=analog.ratio<alarm1ValueSB->setDecimals(2); + ui->alarm1ValueSB->setSingleStep(ratio/255.0); + ui->alarm2ValueSB->setDecimals(2); + ui->alarm2ValueSB->setSingleStep(ratio/255.0); + ui->alarm1ValueSB->setMinimum((analog.offset*1.0*analog.ratio)/255.0); + ui->alarm1ValueSB->setMaximum(ratio+(analog.offset*1.0*analog.ratio)/255.0); + ui->alarm2ValueSB->setMinimum((analog.offset*1.0*analog.ratio)/255.0); + ui->alarm2ValueSB->setMaximum(ratio+(analog.offset*1.0*analog.ratio)/255.0); + } + ui->CalibSB->setDecimals(2); + ui->CalibSB->setMaximum((ratio*127)/255.0); + ui->CalibSB->setMinimum((-ratio*128)/255.0); + ui->CalibSB->setSingleStep(ratio/255.0); + ui->CalibSB->setValue((analog.offset*ratio)/255); + alarm1value=ratio*(analog.alarms[0].value/255.0+analog.offset/255.0); + alarm2value=ratio*(analog.alarms[1].value/255.0+analog.offset/255.0);; + ui->alarm1ValueSB->setValue(alarm1value); + ui->alarm2ValueSB->setValue(alarm2value); +} + +void TelemetryAnalog::on_UnitCB_currentIndexChanged(int index) +{ + float ratio; + analog.type=index; + switch (index) { + case 0: + case 1: + case 2: + ui->RatioSB->setDecimals(1); + ui->RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); + ratio=(analog.ratio<RatioSB->setDecimals(0); + ui->RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier)); + ratio=(analog.ratio<RatioSB->setValue(ratio); + update(); + emit modified(); +} + +void TelemetryAnalog::on_RatioSB_valueChanged() +{ + if (!lock) { + if (analog.type==0 || analog.type==1 || analog.type==2) { + analog.multiplier = findmult(ui->RatioSB->value(), 25.5); + float singlestep =(1<RatioSB->setSingleStep(singlestep); + ui->RatioSB->setValue(round(ui->RatioSB->value()/singlestep)*singlestep); + lock=false; + } + else { + analog.multiplier = findmult(ui->RatioSB->value(), 255); + float singlestep =(1<RatioSB->setSingleStep(singlestep); + ui->RatioSB->setValue(round(ui->RatioSB->value()/singlestep)*singlestep); + lock = false; + } + emit modified(); + } +} + +void TelemetryAnalog::on_RatioSB_editingFinished() +{ + float ratio, calib, alarm1value,alarm2value; + if (lock) return; + if (analog.type==0 || analog.type==1 || analog.type==2) { + analog.multiplier = findmult(ui->RatioSB->value(), 25.5); + ui->CalibSB->setSingleStep((1<alarm1ValueSB->setSingleStep((1<alarm2ValueSB->setSingleStep((1<RatioSB->value()*10))/(1 <RatioSB->value(), 255); + ui->CalibSB->setSingleStep(1<alarm1ValueSB->setSingleStep(1<alarm2ValueSB->setSingleStep(1<RatioSB->value()/(1 << analog.multiplier)); + } + ui->CalibSB->setMaximum((ui->RatioSB->value()*127)/255); + ui->CalibSB->setMinimum((ui->RatioSB->value()*-128)/255); + ui->alarm1ValueSB->setMaximum(ui->RatioSB->value()); + ui->alarm2ValueSB->setMaximum(ui->RatioSB->value()); + repaint(); + ratio=analog.ratio * (1 << analog.multiplier); + calib=ui->CalibSB->value(); + alarm1value=ui->alarm1ValueSB->value(); + alarm2value=ui->alarm2ValueSB->value(); + if (analog.type==0) { + calib*=10; + alarm1value*=10; + alarm2value*=10; + } + if (calib>0) { + if (calib>((ratio*127)/255)) { + analog.offset=127; + } else { + analog.offset=round(calib*255/ratio); + } + } + if (calib<0) { + if (calib<((ratio*-128)/255)) { + analog.offset=-128; + } else { + analog.offset=round(calib*255/ratio); + } + } + analog.alarms[0].value=round((alarm1value*255-analog.offset*(analog.ratio<CalibSB->value()/ratio)); + calib=ratio*analog.offset/255.0; + alarm1value=ui->alarm1ValueSB->value(); + alarm2value=ui->alarm2ValueSB->value(); + if (alarm1value(ratio+calib)) { + alarm1value=ratio+calib; + } + if (alarm2value(ratio+calib)) { + alarm2value=ratio+calib; + } + analog.alarms[0].value=round(((alarm1value-calib)*255)/ratio); + analog.alarms[1].value=round(((alarm2value-calib)*255)/ratio); + } else { + analog.offset=0; + analog.alarms[0].value=0; + analog.alarms[1].value=0; + } + update(); + // TODO ? telBarUpdate(); + emit modified(); +} + +void TelemetryAnalog::on_alarm1LevelCB_currentIndexChanged(int index) +{ + analog.alarms[0].level = index; + emit modified(); +} + + +void TelemetryAnalog::on_alarm1GreaterCB_currentIndexChanged(int index) +{ + analog.alarms[0].greater = index; + emit modified(); +} + +void TelemetryAnalog::on_alarm1ValueSB_editingFinished() +{ + float ratio, calib, alarm1value; + ratio=analog.ratio<alarm1ValueSB->value(); + if (analog.type==0) { + ratio/=10; + } + if (alarm1value<((calib*ratio)/255)) { + analog.alarms[0].value=0; + } else if (alarm1value>(ratio+(calib*ratio)/255)) { + analog.alarms[0].value=255; + } else { + analog.alarms[0].value = round((alarm1value-((calib*ratio)/255))/ratio*255); + } + update(); + emit modified(); +} + +void TelemetryAnalog::on_alarm2LevelCB_currentIndexChanged(int index) +{ + analog.alarms[1].level = index; + emit modified(); +} + +void TelemetryAnalog::on_alarm2GreaterCB_currentIndexChanged(int index) +{ + analog.alarms[1].greater = index; + emit modified(); +} + +void TelemetryAnalog::on_alarm2ValueSB_editingFinished() +{ + float ratio, calib, alarm2value; + ratio = analog.ratio<alarm2ValueSB->value(); + if (analog.type==0) { + ratio/=10; + } + if (alarm2value<((calib*ratio)/255)) { + analog.alarms[1].value=0; + } else if (alarm2value>(ratio+(calib*ratio)/255)) { + analog.alarms[1].value=255; + } else { + analog.alarms[1].value = round((alarm2value-((calib*ratio)/255))/ratio*255); + } + update(); + emit modified(); +} + +TelemetryAnalog::~TelemetryAnalog() +{ + delete ui; +} + +/******************************************************/ + +TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model): + ModelPanel(parent, model), + ui(new Ui::Telemetry) +{ + ui->setupUi(this); + + analogs[0] = new TelemetryAnalog(this, model.frsky.channels[0]); + ui->A1Layout->addWidget(analogs[0]); + connect(analogs[0], SIGNAL(modified()), this, SLOT(onAnalogModified())); + analogs[1] = new TelemetryAnalog(this, model.frsky.channels[1]); + ui->A2Layout->addWidget(analogs[1]); + connect(analogs[1], SIGNAL(modified()), this, SLOT(onAnalogModified())); + + QGroupBox* barsgb[3] = { ui->CS1Bars, ui->CS2Bars, ui->CS3Bars }; + QGroupBox* numsgb[3] = { ui->CS1Nums, ui->CS2Nums, ui->CS3Nums }; + + QComboBox* barscb[12] = { ui->telBarCS1B1_CB, ui->telBarCS1B2_CB, ui->telBarCS1B3_CB, ui->telBarCS1B4_CB, + ui->telBarCS2B1_CB, ui->telBarCS2B2_CB, ui->telBarCS2B3_CB, ui->telBarCS2B4_CB, + ui->telBarCS3B1_CB, ui->telBarCS3B2_CB, ui->telBarCS3B3_CB, ui->telBarCS3B4_CB}; + QDoubleSpinBox* minSB[12] = { ui->telMinCS1SB1, ui->telMinCS1SB2, ui->telMinCS1SB3, ui->telMinCS1SB4, + ui->telMinCS2SB1, ui->telMinCS2SB2, ui->telMinCS2SB3, ui->telMinCS2SB4, + ui->telMinCS3SB1, ui->telMinCS3SB2, ui->telMinCS3SB3, ui->telMinCS3SB4}; + QDoubleSpinBox* maxSB[12] = { ui->telMaxCS1SB1, ui->telMaxCS1SB2, ui->telMaxCS1SB3, ui->telMaxCS1SB4, + ui->telMaxCS2SB1, ui->telMaxCS2SB2, ui->telMaxCS2SB3, ui->telMaxCS2SB4, + ui->telMaxCS3SB1, ui->telMaxCS3SB2, ui->telMaxCS3SB3, ui->telMaxCS3SB4}; + QComboBox* tmp[36] = { ui->telemetryCS1F1_CB, ui->telemetryCS1F2_CB, ui->telemetryCS1F3_CB, ui->telemetryCS1F4_CB, ui->telemetryCS1F5_CB, ui->telemetryCS1F6_CB, ui->telemetryCS1F7_CB, ui->telemetryCS1F8_CB, ui->telemetryCS1F9_CB, ui->telemetryCS1F10_CB, ui->telemetryCS1F11_CB, ui->telemetryCS1F12_CB, + ui->telemetryCS2F1_CB, ui->telemetryCS2F2_CB, ui->telemetryCS2F3_CB, ui->telemetryCS2F4_CB, ui->telemetryCS2F5_CB, ui->telemetryCS2F6_CB, ui->telemetryCS2F7_CB, ui->telemetryCS2F8_CB, ui->telemetryCS2F9_CB, ui->telemetryCS2F10_CB, ui->telemetryCS2F11_CB, ui->telemetryCS2F12_CB, + ui->telemetryCS3F1_CB, ui->telemetryCS3F2_CB, ui->telemetryCS3F3_CB, ui->telemetryCS3F4_CB, ui->telemetryCS3F5_CB, ui->telemetryCS3F6_CB, ui->telemetryCS3F7_CB, ui->telemetryCS3F8_CB, ui->telemetryCS3F9_CB, ui->telemetryCS3F10_CB, ui->telemetryCS3F11_CB, ui->telemetryCS3F12_CB}; + + memcpy(barsGB, barsgb, sizeof(barsGB)); + memcpy(numsGB, numsgb, sizeof(numsGB)); + memcpy(barsCB, barscb, sizeof(barsCB)); + memcpy(this->maxSB, maxSB, sizeof(this->maxSB)); + memcpy(this->minSB, minSB, sizeof(this->minSB)); + memcpy(csf, tmp, sizeof(csf)); + + setup(); +} + +TelemetryPanel::~TelemetryPanel() +{ + delete ui; +} + +void TelemetryPanel::setup() +{ + QSettings settings("companion9x", "companion9x"); + QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); + + lock=true; + ui->telemetryCSType1->setCurrentIndex(model.frsky.screens[0].type); + ui->telemetryCSType2->setCurrentIndex(model.frsky.screens[1].type); + ui->telemetryCSType3->setCurrentIndex(model.frsky.screens[2].type); + + for (int i=0; i<3; i++) { + bool isNum = (model.frsky.screens[i].type==0); + barsGB[i]->setVisible(!isNum); + numsGB[i]->setVisible(isNum); + } + + connect(ui->telemetryCSType1,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int))); + connect(ui->telemetryCSType2,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int))); + connect(ui->telemetryCSType3,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int))); + + //frsky Settings + if (!GetEepromInterface()->getCapability(TelemetryRSSIModel) ) { + ui->RSSIGB->hide(); + } + ui->rssiAlarm1SB->setValue(model.frsky.rssiAlarms[0].value); + ui->rssiAlarm2SB->setValue(model.frsky.rssiAlarms[1].value); + ui->rssiAlarm1CB->setCurrentIndex(model.frsky.rssiAlarms[0].level); + ui->rssiAlarm2CB->setCurrentIndex(model.frsky.rssiAlarms[1].level); + + if (!GetEepromInterface()->getCapability(HasAltitudeSel)) { + ui->AltitudeGPS_ChkB->hide(); + } else { + ui->AltitudeGPS_ChkB->setChecked(model.frsky.FrSkyGpsAlt); + } + int varioCap=GetEepromInterface()->getCapability(HasVario); + // if (IS_TARANIS(GetEepromInterface()->getBoard())) { + if (false) { + ui->AltitudeToolbar_ChkB->setChecked(model.frsky.altitudeDisplayed); + } else { + ui->AltitudeToolbar_ChkB->hide(); + } + if (!varioCap) { + ui->varioLimitMax_DSB->hide(); + ui->varioLimitMinOff_ChkB->hide(); + ui->varioLimitMin_DSB->hide(); + ui->varioLimitCenterMin_DSB->hide(); + ui->varioLimitCenterMax_DSB->hide(); + ui->varioLimit_label->hide(); + ui->VarioLabel_1->hide(); + ui->VarioLabel_2->hide(); + ui->VarioLabel_3->hide(); + ui->VarioLabel_4->hide(); + ui->varioSourceCB->hide(); + ui->varioSource_label->hide(); + } else { + if (!GetEepromInterface()->getCapability(HasVarioSink)) { + ui->varioLimitMinOff_ChkB->hide(); + ui->varioLimitMin_DSB->hide(); + ui->varioLimitCenterMin_DSB->hide(); + ui->VarioLabel_1->hide(); + ui->VarioLabel_2->hide(); + } + ui->varioLimitMin_DSB->setValue(model.frsky.varioMin-10); + ui->varioLimitMax_DSB->setValue(model.frsky.varioMax+10); + ui->varioLimitCenterMax_DSB->setValue((model.frsky.varioCenterMax/10.0)+0.5); + ui->varioSourceCB->setCurrentIndex(model.frsky.varioSource); + if (model.frsky.varioCenterMin==-16) { + ui->varioLimitMinOff_ChkB->setChecked(true); + ui->varioLimitCenterMin_DSB->setValue(-2.0); + ui->varioLimitCenterMin_DSB->setDisabled(true); + } else { + ui->varioLimitMinOff_ChkB->setChecked(false); + ui->varioLimitCenterMin_DSB->setValue((model.frsky.varioCenterMin/10.0)-0.5); + } + int mask=1; + for (int i=0; i< ui->varioSourceCB->count(); i++) { + if (!(varioCap&mask)) { + QModelIndex index = ui->varioSourceCB->model()->index(i, 0); + QVariant v(0); + ui->varioSourceCB->model()->setData(index, v, Qt::UserRole - 1); + } + mask <<=1; + } + } + + if (!(GetEepromInterface()->getCapability(HasAltitudeSel)||GetEepromInterface()->getCapability(HasVario))) { + ui->altimetryGB->hide(); + } + if (GetEepromInterface()->getCapability(NoTelemetryProtocol)) { + model.frsky.usrProto=1; + ui->frskyProtoCB->setDisabled(true); + } else { + ui->frskyProtoCB->setEnabled(true); + } + + if (GetEepromInterface()->getCapability(TelemetryCSFields)==0) { + ui->groupBox_5->hide(); + } else { + if (GetEepromInterface()->getCapability(TelemetryCSFields)==8) { + ui->tabCsView->removeTab(1); + ui->tabCsView->removeTab(2); + } + if (GetEepromInterface()->getCapability(TelemetryCSFields)==16) { + ui->tabCsView->removeTab(2); + } + int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields); + if (cols==0) cols=2; + for (int screen=0; screen<(GetEepromInterface()->getCapability(TelemetryCSFields)/(4*cols)); screen++) { + for (int c=0; chide(); + } + } + } + } + + if (!GetEepromInterface()->getCapability(TelemetryUnits)) { + ui->frskyUnitsCB->setDisabled(true); + int index=0; + if (firmware_id.contains("imperial")) { + index=1; + } + ui->frskyUnitsCB->setCurrentIndex(index); + } + if ((GetEepromInterface()->getCapability(Telemetry)&TM_HASWSHH)) { + ui->frskyProtoCB->addItem(tr("Winged Shadow How High")); + } else { + ui->frskyProtoCB->addItem(tr("Winged Shadow How High (not supported)")); + } + + ui->frskyProtoCB->setCurrentIndex(model.frsky.usrProto); + ui->frskyUnitsCB->setCurrentIndex(model.frsky.imperial); + ui->frskyBladesCB->setCurrentIndex(model.frsky.blades); + ui->frskyCurrentCB->setCurrentIndex(model.frsky.currentSource); + ui->frskyVoltCB->setCurrentIndex(model.frsky.voltsSource); + + for (int screen=0; screen<2;screen++) { + for (int rows=0; rows<4; rows++) { + for (int cols=0; cols<3; cols++) { + int index=screen*12+cols*4+rows; + populateCustomScreenFieldCB(csf[index], model.frsky.screens[screen].body.lines[rows].source[cols], (rows<4), model.frsky.usrProto); + } + } + } + + for (int j=0; j<12; j++) { + int screen = j/4; + int field = j%4; + populateCustomScreenFieldCB(barsCB[j], model.frsky.screens[screen].body.bars[field].source, false, model.frsky.usrProto); + switch (model.frsky.screens[screen].body.bars[field].source-1) { + case TELEMETRY_SOURCE_TX_BATT: + case TELEMETRY_SOURCE_A1: + case TELEMETRY_SOURCE_A1_MIN: + case TELEMETRY_SOURCE_A2: + case TELEMETRY_SOURCE_A2_MIN: + case TELEMETRY_SOURCE_CELLS_SUM: + case TELEMETRY_SOURCE_VFAS: + case TELEMETRY_SOURCE_CURRENT_MAX: + case TELEMETRY_SOURCE_CURRENT: + minSB[j]->setDecimals(1); + maxSB[j]->setDecimals(1); + break; + case TELEMETRY_SOURCE_CELL: + minSB[j]->setDecimals(2); + maxSB[j]->setDecimals(2); + break; + default: + minSB[j]->setDecimals(0); + maxSB[j]->setDecimals(0); + } + minSB[j]->setMinimum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 0, &model.frsky)); + minSB[j]->setMaximum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 255, &model.frsky)); + minSB[j]->setSingleStep(getBarStep(model.frsky.screens[screen].body.bars[field].source)); + minSB[j]->setValue(getBarValue(model.frsky.screens[screen].body.bars[field].source, model.frsky.screens[screen].body.bars[field].barMin, &model.frsky)); + maxSB[j]->setMinimum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 0, &model.frsky)); + maxSB[j]->setMaximum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 255, &model.frsky)); + maxSB[j]->setSingleStep(getBarStep(model.frsky.screens[screen].body.bars[field].source)); + maxSB[j]->setValue(getBarValue(model.frsky.screens[screen].body.bars[field].source, (255-model.frsky.screens[screen].body.bars[field].barMax), &model.frsky)); + + if (model.frsky.screens[screen].body.bars[field].source==0 || model.frsky.screens[screen].type==0) { + minSB[j]->setDisabled(true); + maxSB[j]->setDisabled(true); + } + connect(barsCB[j],SIGNAL(currentIndexChanged(int)),this,SLOT(telBarCBcurrentIndexChanged(int))); + connect(maxSB[j],SIGNAL(editingFinished()),this,SLOT(telMaxSBeditingFinished())); + connect(minSB[j],SIGNAL(editingFinished()),this,SLOT(telMinSBeditingFinished())); + } + lock=false; +} + +void TelemetryPanel::onAnalogModified() +{ + emit modified(); +} + +void TelemetryPanel::on_frskyUnitsCB_currentIndexChanged(int index) +{ + model.frsky.imperial=index; + emit modified(); +} + +void TelemetryPanel::on_frskyBladesCB_currentIndexChanged(int index) +{ + model.frsky.blades=index; + emit modified(); +} + +void TelemetryPanel::on_frskyCurrentCB_currentIndexChanged(int index) +{ + model.frsky.currentSource=index; + emit modified(); +} + +void TelemetryPanel::on_frskyVoltCB_currentIndexChanged(int index) +{ + model.frsky.voltsSource=index; + emit modified(); +} + +void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index) +{ + if (lock) return; + int bindex[12]; + lock=true; + for (int i=0; i<12; i++) { + bindex[i]=barsCB[i]->currentIndex(); + model.frsky.usrProto=index; + populateCustomScreenFieldCB(barsCB[i], bindex[i], false, model.frsky.usrProto); + } + if (!GetEepromInterface()->getCapability(TelemetryCSFields)) { + ui->groupBox_5->hide(); + } else { + for (int screen=0; screen<2;screen++) { + for (int rows=0; rows<4; rows++) { + for (int cols=0; cols<3; cols++) { + int index=screen*12+cols*4+rows; + populateCustomScreenFieldCB(csf[index], model.frsky.screens[screen].body.lines[rows].source[cols], (rows<4), model.frsky.usrProto); + } + } + } + } + lock=false; + if (index==0) { + for (int i=0; i<12; i++) { + if (bindex[i]>2) { + barsCB[i]->setCurrentIndex(0); + } else { + barsCB[i]->setCurrentIndex(bindex[i]); + } + } + } else if (index==2) { + for (int i=0; i<12; i++) { + if (bindex[i]>3) { + barsCB[i]->setCurrentIndex(0); + } else { + barsCB[i]->setCurrentIndex(bindex[i]); + } + } + } else { + for (int i=0; i<12; i++) { + barsCB[i]->setCurrentIndex(bindex[i]); + } + } + emit modified(); +} + +void TelemetryPanel::on_rssiAlarm1CB_currentIndexChanged(int index) { + if (lock) return; + model.frsky.rssiAlarms[0].level=index; + emit modified(); +} + +void TelemetryPanel::on_rssiAlarm2CB_currentIndexChanged(int index) { + if (lock) return; + model.frsky.rssiAlarms[1].level=index; + emit modified(); +} + +void TelemetryPanel::on_rssiAlarm1SB_editingFinished() +{ + if (lock) return; + model.frsky.rssiAlarms[0].value=(ui->rssiAlarm1SB->value()); + emit modified(); +} + +void TelemetryPanel::on_rssiAlarm2SB_editingFinished() +{ + if (lock) return; + model.frsky.rssiAlarms[1].value=(ui->rssiAlarm2SB->value()); + emit modified(); +} + +void TelemetryPanel::on_AltitudeGPS_ChkB_toggled(bool checked) +{ + if (lock) return; + model.frsky.FrSkyGpsAlt = checked; + emit modified(); + //AltitudeGPS_CB +} + +void TelemetryPanel::on_AltitudeToolbar_ChkB_toggled(bool checked) +{ + model.frsky.altitudeDisplayed = checked; + emit modified(); +} + +void TelemetryPanel::on_varioSourceCB_currentIndexChanged(int index) +{ + if (lock) return; + model.frsky.varioSource = index; + emit modified(); +} + +void TelemetryPanel::on_varioLimitMin_DSB_editingFinished() +{ + if (lock) return; + model.frsky.varioMin= round(ui->varioLimitMin_DSB->value()+10); + emit modified(); +} + +void TelemetryPanel::on_varioLimitMax_DSB_editingFinished() +{ + if (lock) return; + model.frsky.varioMax= round(ui->varioLimitMax_DSB->value()-10); + emit modified(); +} + +void TelemetryPanel::on_varioLimitCenterMin_DSB_editingFinished() +{ + if (lock) return; + if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) { + ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value()); + } + model.frsky.varioCenterMin= round((ui->varioLimitCenterMin_DSB->value()+0.5)*10); + emit modified(); +} + +void TelemetryPanel::on_varioLimitMinOff_ChkB_toggled(bool checked) +{ + if (lock) return; + model.frsky.varioCenterMin = -16; + if (!checked) { + lock=true; + ui->varioLimitCenterMin_DSB->setValue(-2.0); + ui->varioLimitCenterMin_DSB->setEnabled(true); + lock=false; + } else { + ui->varioLimitCenterMin_DSB->setValue(-2.0); + ui->varioLimitCenterMin_DSB->setDisabled(true); + } + emit modified(); +} + +void TelemetryPanel::on_varioLimitCenterMax_DSB_editingFinished() +{ + if (lock) return; + if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) { + ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value()); + } + model.frsky.varioCenterMax= round((ui->varioLimitCenterMax_DSB->value()-0.5)*10); + emit modified(); +} + +void TelemetryPanel::telBarUpdate() +{ + int index; + lock=true; + for (int i=0; i<12; i++) { + int screen=i/4; + index=barsCB[i]->currentIndex(); + if (index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1_MIN || index==TELEMETRY_SOURCE_A2_MIN) { + minSB[i]->setMinimum(getBarValue(index, 0, &model.frsky)); + minSB[i]->setMaximum(getBarValue(index, 255, &model.frsky)); + minSB[i]->setSingleStep(getBarStep(index)); + maxSB[i]->setMinimum(getBarValue(index, 0, &model.frsky)); + maxSB[i]->setMaximum(getBarValue(index, 255, &model.frsky)); + maxSB[i]->setSingleStep(getBarStep(index)); + minSB[i]->setValue(getBarValue(index, model.frsky.screens[screen].body.bars[i%4].barMin, &model.frsky)); + maxSB[i]->setValue(getBarValue(index, 255-model.frsky.screens[screen].body.bars[i%4].barMax, &model.frsky)); + } + } + lock=false; +} + +void TelemetryPanel::ScreenTypeCBcurrentIndexChanged(int index) +{ + if (lock) return; + + QComboBox *comboBox = qobject_cast(sender()); + int screen = comboBox->objectName().right(1).toInt() -1; + lock=true; + model.frsky.screens[screen].type=index; + + for (int i=0; i<3; i++) { + bool isNum = (model.frsky.screens[i].type==0); + barsGB[i]->setVisible(!isNum); + numsGB[i]->setVisible(isNum); + } + + lock=false; + emit modified(); +} + +void TelemetryPanel::telBarCBcurrentIndexChanged(int index) +{ + if (lock) return; + QComboBox *comboBox = qobject_cast(sender()); + int screenId = comboBox->objectName().mid(8,1).toInt() - 1; + int barId = comboBox->objectName().mid(10,1).toInt() - 1; + int bar=barId+screenId*4; + model.frsky.screens[screenId].body.bars[barId].source=index; + lock=true; + if (index==0) { + model.frsky.screens[screenId].body.bars[barId].barMin=0; + model.frsky.screens[screenId].body.bars[barId].barMax=0; + minSB[bar]->setDisabled(true); + maxSB[bar]->setDisabled(true); + } else { + minSB[bar]->setEnabled(true); + maxSB[bar]->setEnabled(true); + } + switch (index-1) { + case TELEMETRY_SOURCE_TX_BATT: + case TELEMETRY_SOURCE_A1: + case TELEMETRY_SOURCE_A1_MIN: + case TELEMETRY_SOURCE_A2: + case TELEMETRY_SOURCE_A2_MIN: + case TELEMETRY_SOURCE_CELLS_SUM: + case TELEMETRY_SOURCE_VFAS: + case TELEMETRY_SOURCE_CURRENT_MAX: + case TELEMETRY_SOURCE_CURRENT: + minSB[bar]->setDecimals(1); + maxSB[bar]->setDecimals(1); + break; + case TELEMETRY_SOURCE_CELL: + minSB[bar]->setDecimals(2); + maxSB[bar]->setDecimals(2); + break; + default: + minSB[bar]->setDecimals(0); + maxSB[bar]->setDecimals(0); + } + minSB[bar]->setMinimum(getBarValue(index, 0, &model.frsky)); + minSB[bar]->setMaximum(getBarValue(index, 255, &model.frsky)); + minSB[bar]->setSingleStep(getBarStep(index)); + maxSB[bar]->setMinimum(getBarValue(index, 0, &model.frsky)); + maxSB[bar]->setMaximum(getBarValue(index, 255, &model.frsky)); + maxSB[bar]->setSingleStep(getBarStep(index)); + minSB[bar]->setValue(getBarValue(index, model.frsky.screens[screenId].body.bars[barId].barMin, &model.frsky)); + maxSB[bar]->setValue(getBarValue(index, 255-model.frsky.screens[screenId].body.bars[barId].barMax, &model.frsky)); + lock=false; + emit modified(); +} + +void TelemetryPanel::telMinSBeditingFinished() +{ + if (lock) return; + QDoubleSpinBox *spinBox = qobject_cast(sender()); + int screenId = spinBox->objectName().mid(8,1).toInt() - 1; + int barId = spinBox->objectName().right(1).toInt() - 1; + int minId = barId+screenId*4; + lock=true; + if (model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1 || model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1_MIN) { + model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-analogs[0]->ui->CalibSB->value())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source)); + } else if (model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2 || model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2_MIN) { + model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-analogs[1]->ui->CalibSB->value())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source)); + } else { + model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-getBarValue(model.frsky.screens[screenId].body.bars[barId].source, 0, &model.frsky))/getBarStep(model.frsky.screens[screenId].body.bars[barId].source)); + } + spinBox->setValue(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, model.frsky.screens[screenId].body.bars[barId].barMin, &model.frsky)); + if (maxSB[minId]->value()value()) { + model.frsky.screens[screenId].body.bars[minId].barMax=(255-model.frsky.screens[screenId].body.bars[barId].barMin+1); + maxSB[minId]->setValue(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, 255-model.frsky.screens[screenId].body.bars[barId].barMax, &model.frsky)); + } + maxSB[minId]->setMinimum(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, (model.frsky.screens[screenId].body.bars[barId].barMin+1), &model.frsky)); + lock=false; + emit modified(); +} + +void TelemetryPanel::telMaxSBeditingFinished() +{ + if (lock) return; + QDoubleSpinBox *spinBox = qobject_cast(sender()); + int screenId = spinBox->objectName().mid(8,1).toInt() - 1; + int barId = spinBox->objectName().right(1).toInt() - 1; + lock=true; + if (model.frsky.screens[screenId].body.bars[barId].source==5) { + model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[0]->ui->CalibSB->value())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source))); + } else if (model.frsky.screens[screenId].body.bars[barId].source==6) { + model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[1]->ui->CalibSB->value())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source))); + } else { + model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-getBarValue(model.frsky.screens[screenId].body.bars[barId].source, 0, &model.frsky))/getBarStep(model.frsky.screens[screenId].body.bars[barId].source) )); + } + spinBox->setValue(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, (255-model.frsky.screens[screenId].body.bars[barId].barMax), &model.frsky)); + lock=false; + emit modified(); +} + +void TelemetryPanel::customFieldEdited() +{ + if (!lock) { + lock = true; + + int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields); + if (cols==0) cols=2; + + for (int i=0; igetCapability(TelemetryCSFields); i++) { + int screen=i/(4*cols); + int r=((i%(4*cols))%4); + int c=((i%(4*cols))/4); + if (model.frsky.screens[screen].type==0) { + model.frsky.screens[screen].body.lines[r].source[c]=csf[i]->currentIndex(); + } + } + emit modified(); + + lock = false; + } +} + +float TelemetryPanel::getBarStep(int barId) +{ + switch (barId-1) { + case TELEMETRY_SOURCE_TX_BATT: + return 0.1; + break; + case TELEMETRY_SOURCE_TIMER1: + case TELEMETRY_SOURCE_TIMER2: + return 3; + break; + case TELEMETRY_SOURCE_A1: + case TELEMETRY_SOURCE_A1_MIN: + return (analogs[0]->ui->RatioSB->value()/255); + break; + case TELEMETRY_SOURCE_A2: + case TELEMETRY_SOURCE_A2_MIN: + return (analogs[1]->ui->RatioSB->value()/255); + break; + case TELEMETRY_SOURCE_ALT: + case TELEMETRY_SOURCE_GPS_ALT: + case TELEMETRY_SOURCE_ALT_MAX: + case TELEMETRY_SOURCE_ALT_MIN: + return 8; + break; + case TELEMETRY_SOURCE_RPM: + case TELEMETRY_SOURCE_RPM_MAX: + return 50; + break; + case TELEMETRY_SOURCE_CELLS_SUM: + case TELEMETRY_SOURCE_VFAS: + return 0.1; + break; + case TELEMETRY_SOURCE_CELL: + return 0.02; + break; + case TELEMETRY_SOURCE_HDG: + return 2; + break; + case TELEMETRY_SOURCE_DIST: + case TELEMETRY_SOURCE_DIST_MAX: + return 8; + break; + case TELEMETRY_SOURCE_CURRENT_MAX: + case TELEMETRY_SOURCE_CURRENT: + return 0.5; + break; + case TELEMETRY_SOURCE_POWER: + return 5; + break; + case TELEMETRY_SOURCE_CONSUMPTION: + return 20; + break; + case TELEMETRY_SOURCE_SPEED: + case TELEMETRY_SOURCE_SPEED_MAX: + if (model.frsky.imperial==1) { + return 1; + } else { + return 1.852; + } + break; + default: + return 1; + break; + } +} diff --git a/companion/src/modeledit/telemetry.h b/companion/src/modeledit/telemetry.h new file mode 100644 index 000000000..6984a9f51 --- /dev/null +++ b/companion/src/modeledit/telemetry.h @@ -0,0 +1,98 @@ +#ifndef TELEMETRY_H +#define TELEMETRY_H + +#include "modelpanel.h" +#include +#include +#include + +namespace Ui { + class TelemetryAnalog; + class Telemetry; +} + +class TelemetryAnalog : public QWidget +{ + Q_OBJECT + + friend class TelemetryPanel; + + public: + TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog); + virtual ~TelemetryAnalog(); + + signals: + void modified(); + + private slots: + void on_UnitCB_currentIndexChanged(int index); + void on_RatioSB_editingFinished(); + void on_RatioSB_valueChanged(); + void on_CalibSB_editingFinished(); + void on_alarm1LevelCB_currentIndexChanged(int index); + void on_alarm1GreaterCB_currentIndexChanged(int index); + void on_alarm1ValueSB_editingFinished(); + void on_alarm2LevelCB_currentIndexChanged(int index); + void on_alarm2GreaterCB_currentIndexChanged(int index); + void on_alarm2ValueSB_editingFinished(); + + private: + Ui::TelemetryAnalog *ui; + FrSkyChannelData & analog; + bool lock; + + void update(); +}; + +class TelemetryPanel : public ModelPanel +{ + Q_OBJECT + + public: + TelemetryPanel(QWidget *parent, ModelData & model); + virtual ~TelemetryPanel(); + + signals: + void modified(); + + private slots: + void onAnalogModified(); + void on_frskyProtoCB_currentIndexChanged(int index); + void on_frskyUnitsCB_currentIndexChanged(int index); + void on_frskyBladesCB_currentIndexChanged(int index); + void on_frskyCurrentCB_currentIndexChanged(int index); + void on_frskyVoltCB_currentIndexChanged(int index); + void on_AltitudeToolbar_ChkB_toggled(bool checked); + void on_rssiAlarm1CB_currentIndexChanged(int index); + void on_rssiAlarm2CB_currentIndexChanged(int index); + void on_rssiAlarm1SB_editingFinished(); + void on_rssiAlarm2SB_editingFinished(); + void on_AltitudeGPS_ChkB_toggled(bool checked); + void on_varioSourceCB_currentIndexChanged(int index); + void on_varioLimitMin_DSB_editingFinished(); + void on_varioLimitMax_DSB_editingFinished(); + void on_varioLimitCenterMin_DSB_editingFinished(); + void on_varioLimitMinOff_ChkB_toggled(bool checked); + void on_varioLimitCenterMax_DSB_editingFinished(); + void telBarCBcurrentIndexChanged(int index); + void ScreenTypeCBcurrentIndexChanged(int index); + void telMaxSBeditingFinished(); + void telMinSBeditingFinished(); + void customFieldEdited(); + + private: + Ui::Telemetry *ui; + TelemetryAnalog * analogs[2]; + QGroupBox* barsGB[3]; + QGroupBox* numsGB[3]; + QComboBox* barsCB[12]; + QDoubleSpinBox* minSB[12]; + QDoubleSpinBox* maxSB[12]; + QComboBox* csf[36]; + + void setup(); + float getBarStep(int barId); + void telBarUpdate(); +}; + +#endif // TELEMETRY_H diff --git a/companion/src/modeledit/telemetry.ui b/companion/src/modeledit/telemetry.ui new file mode 100644 index 000000000..704eab921 --- /dev/null +++ b/companion/src/modeledit/telemetry.ui @@ -0,0 +1,2013 @@ + + + Telemetry + + + + 0 + 0 + 738 + 507 + + + + Form + + + + + + QLayout::SetMinimumSize + + + + + + 0 + 0 + + + + true + + + + + + A1 + + + false + + + + 1 + + + 1 + + + + + + + + A2 + + + + 1 + + + 1 + + + + + + + + + 0 + 0 + + + + RSSI + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + Alarm 1 + + + + + + + + 0 + 0 + + + + + ---- + + + + + Yellow + + + + + Orange + + + + + Red + + + + + + + + true + + + + 0 + 0 + + + + + + + 20 + + + 80 + + + 1 + + + 50 + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Alarm 2 + + + + + + + + 0 + 0 + + + + + ---- + + + + + Yellow + + + + + Orange + + + + + Red + + + + + + + + true + + + + 0 + 0 + + + + + + + 20 + + + 80 + + + 1 + + + 50 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + QLayout::SetMinimumSize + + + + + + 0 + 0 + + + + Serial Protocol + + + + 1 + + + 1 + + + + + + + + 0 + 0 + + + + Volt source + + + + + + + + 0 + 0 + + + + + Metric + + + + + Imperial + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Current source + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + Protocol + + + + + + + + 0 + 0 + + + + + NONE + + + + + A1 + + + + + A2 + + + + + FAS + + + + + + + + + 0 + 0 + + + + + None + + + + + FrSky Sensor Hub + + + + + + + + + 0 + 0 + + + + + A1 + + + + + A2 + + + + + FAS + + + + + CEL + + + + + + + + + 0 + 0 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Units + + + + + + + + 0 + 0 + + + + Blades + + + + + + + + + + + + + 0 + 0 + + + + Altimetry / Vario + + + + 1 + + + 1 + + + + + + + + 0 + 0 + + + + + Alti + + + + + Alti+ + + + + + Vario + + + + + A1 + + + + + A2 + + + + + + + + + + + 0 + 0 + + + + Sink Max + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + 1 + + + -2.000000000000000 + + + 0.000000000000000 + + + 0.100000000000000 + + + -0.500000000000000 + + + + + + + + 0 + 0 + + + + 1 + + + -1.000000000000000 + + + 2.000000000000000 + + + 0.100000000000000 + + + 0.500000000000000 + + + + + + + + 0 + 0 + + + + 0 + + + 3.000000000000000 + + + 17.000000000000000 + + + 10.000000000000000 + + + + + + + + 0 + 0 + + + + 0 + + + -17.000000000000000 + + + -3.000000000000000 + + + -10.000000000000000 + + + + + + + + 0 + 0 + + + + Off + + + + + + + + 0 + 0 + + + + Climb Max + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Sink Min + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Climb Min + + + Qt::AlignCenter + + + + + + + + + Vario source + + + + + + + Vario limits + + + + + + + + + + 0 + 0 + + + + Use GPS as altitude source + + + + + + + + 0 + 0 + + + + Display altitude in toolbar + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + + + + 1 + + + 1 + + + + + + 0 + 0 + + + + 0 + + + + Telemetry screen 1 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Custom Screen Type + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + + Nums + + + + + Bars + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + Source + + + Qt::AlignCenter + + + + + + + Min + + + Qt::AlignCenter + + + + + + + Gauge + + + Qt::AlignCenter + + + + + + + Max + + + Qt::AlignCenter + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 1 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 2 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 3 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 4 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + + Telemetry screen 2 + + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + Source + + + Qt::AlignCenter + + + + + + + Min + + + Qt::AlignCenter + + + + + + + Gauge + + + Qt::AlignCenter + + + + + + + Max + + + Qt::AlignCenter + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 1 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 2 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 3 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 4 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + + + + 0 + 0 + + + + Custom Screen Type + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + + Nums + + + + + Bars + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Telemetry screen 3 + + + + + + + + + 0 + 0 + + + + Custom Screen Type + + + + + + + + 0 + 0 + + + + + 90 + 0 + + + + + Nums + + + + + Bars + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + Source + + + Qt::AlignCenter + + + + + + + Min + + + Qt::AlignCenter + + + + + + + Gauge + + + Qt::AlignCenter + + + + + + + Max + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 1 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 2 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 3 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + 0 + + + + + + + false + + + Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),) + + + + QFrame::Panel + + + QFrame::Raised + + + Gauge 4 + + + Qt::AlignCenter + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + diff --git a/companion/src/modeledit/telemetry_analog.ui b/companion/src/modeledit/telemetry_analog.ui new file mode 100644 index 000000000..30a3615c0 --- /dev/null +++ b/companion/src/modeledit/telemetry_analog.ui @@ -0,0 +1,324 @@ + + + TelemetryAnalog + + + + 0 + 0 + 291 + 118 + + + + Form + + + + + + + + + 0 + 0 + + + + Unit + + + + + + + + 0 + 0 + + + + Max Value + + + + + + + + 0 + 0 + + + + Alarm 1 + + + + + + + + 0 + 0 + + + + + ---- + + + + + Yellow + + + + + Orange + + + + + Red + + + + + + + + + 0 + 0 + + + + + < + + + + + > + + + + + + + + + 0 + 0 + + + + Alarm 2 + + + + + + + + 0 + 0 + + + + + ---- + + + + + Yellow + + + + + Orange + + + + + Red + + + + + + + + + 0 + 0 + + + + + < + + + + + > + + + + + + + + + 0 + 0 + + + + Min Value + + + + + + + true + + + + 0 + 0 + + + + 0 + + + 255.000000000000000 + + + + + + + + 0 + 0 + + + + 2 + + + -12.800000000000001 + + + 12.699999999999999 + + + 0.100000000000000 + + + + + + + true + + + + 0 + 0 + + + + 0 + + + 255.000000000000000 + + + + + + + true + + + + 0 + 0 + + + + 0 + + + 255.000000000000000 + + + + + + + + 0 + 0 + + + + + Volts (V) + + + + + Amps (A) + + + + + Speed (m/s or ft/s) + + + + + Raw (-) + + + + + Speed (km/h or miles/h) + + + + + Meters (m or ft) + + + + + Temp (°) + + + + + Fuel (%) + + + + + mAmps (mA) + + + + + + + + + + + diff --git a/companion/src/modeledit/templates.cpp b/companion/src/modeledit/templates.cpp new file mode 100644 index 000000000..c45b920bf --- /dev/null +++ b/companion/src/modeledit/templates.cpp @@ -0,0 +1,852 @@ +#include "templates.h" +#include +#include + +Templates::Templates(QWidget * parent, ModelData & model): + QWidget(parent), + model(model) +{ + QGridLayout * gridLayout = new QGridLayout(this); + QListWidget * templateList = new QListWidget(this); + gridLayout->addWidget(templateList, 0, 0, 1, 1); + + templateList->addItem(tr("Simple 4-CH")); + templateList->addItem(tr("T-Cut")); + templateList->addItem(tr("Sticky T-Cut")); + templateList->addItem(tr("V-Tail")); + templateList->addItem(tr("Elevon\\Delta")); + templateList->addItem(tr("Heli Setup")); + templateList->addItem(tr("Heli Setup with gyro gain control")); + templateList->addItem(tr("Gyro gain control")); + templateList->addItem(tr("Heli Setup (Futaba's channel assignment style)")); + templateList->addItem(tr("Heli Setup with gyro gain control (Futaba's channel assignment style)")); + templateList->addItem(tr("Gyro gain control (Futaba's channel assignment style)")); + templateList->addItem(tr("Servo Test")); + templateList->addItem(tr("MultiCopter")); + templateList->addItem(tr("Use Model Config Wizard")); + + connect(templateList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(doubleClicked(QModelIndex))); +} + +Templates::~Templates() +{ +} + +void Templates::setSwitch(unsigned int idx, unsigned int func, int v1, int v2) +{ + g_model.customSw[idx-1].func = func; + g_model.customSw[idx-1].val1 = v1; + g_model.customSw[idx-1].val2 = v2; +} + +void Templates::onDoubleClicked(QModelIndex index) +{ + QString text = ui->templateList->item(index.row())->text(); + if (index.row()==13) { + uint64_t result=0xffffffff; + modelConfigDialog *mcw = new modelConfigDialog(radioData, &result, this); + mcw->exec(); + if (result!=0xffffffff) { + applyNumericTemplate(result); + updateSettings(); + tabMixes(); + } + } else { + int res = QMessageBox::question(this,tr("Apply Template?"),tr("Apply template \"%1\"?").arg(text),QMessageBox::Yes | QMessageBox::No); + if(res!=QMessageBox::Yes) return; + applyTemplate(index.row()); + updateSettings(); + tabMixes(); + } +} + +void Templates::applyNumericTemplate(uint64_t tpl) +{ + clearCurves(); + clearExpos(false); + clearMixes(false); + int8_t heli_ar1[] = {-100, -20, 30, 70, 90}; + int8_t heli_ar2[] = {80, 70, 60, 70, 100}; + int8_t heli_ar3[] = {100, 90, 80, 90, 100}; + int8_t heli_ar4[] = {-30, -15, 0, 50, 100}; + int8_t heli_ar5[] = {-100, -50, 0, 50, 100}; + bool rx[10]; + for (int i=0; i<10 ; i++) { + rx[i]=false; + } + int thrsw=GetEepromInterface()->getCapability(GetThrSwitch); + MixData *md = &model.mixData[0]; + uint8_t spo2ch=(tpl & 0x0F); + tpl>>=4; + uint8_t spo1ch=(tpl & 0x0F); + tpl>>=4; + uint8_t fla2ch=(tpl & 0x0F); + tpl>>=4; + uint8_t fla1ch=(tpl & 0x0F); + tpl>>=4; + uint8_t rud2ch=(tpl & 0x0F); + tpl>>=4; + uint8_t ele2ch=(tpl & 0x0F); + tpl>>=4; + uint8_t ail2ch=(tpl & 0x0F); + tpl>>=4; + uint8_t chstyle=(tpl & 0x03); + tpl>>=2; + uint8_t gyro=(tpl & 0x03); + tpl>>=2; + uint8_t tailtype=(tpl & 0x03); + tpl>>=2; + uint8_t swashtype=(tpl & 0x07); + tpl>>=3; + uint8_t ruddertype=(tpl & 0x03); + tpl>>=2; + uint8_t spoilertype=(tpl & 0x3); + tpl>>=2; + uint8_t flaptype=(tpl & 0x03); + tpl>>=2; + uint8_t ailerontype=(tpl & 0x03); + tpl>>=2; + uint8_t enginetype=(tpl & 0x03); + tpl>>=2; + uint8_t modeltype=(tpl & 0x03); + + #define ICC(x) icc[(x)-1] + uint8_t icc[4] = {0}; + for(uint8_t i=1; i<=4; i++) //generate inverse array + for(uint8_t j=1; j<=4; j++) if(CC(i)==j) icc[j-1]=i; + + int ailerons; + int flaps; + int throttle; + int spoilers; + int elevators; + int rudders; + int sign; + uint8_t rxch; + switch (modeltype) { + case 0: + ailerons=ailerontype; + flaps=flaptype; + throttle=1; + switch (tailtype) { + case 0: + case 1: + rudders=1; + elevators=1; + break; + case 2: + rudders=1; + elevators=2; + break; + } + rxch=ICC(STK_RUD); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); + if (tailtype==1) { + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); + } + rx[rxch-1]=true; + rxch=ICC(STK_ELE); + if (tailtype==1) { + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); + } + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); + rx[rxch-1]=true; + rxch=ICC(STK_THR); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("THR").toAscii().data(),6); + rx[rxch-1]=true; + if (ail2ch > 0) { + rx[ail2ch-1]=true; + } + if (ele2ch > 0) { + rx[ele2ch-1]=true; + } + if (fla1ch > 0) { + rx[fla1ch-1]=true; + } + if (fla2ch > 0) { + rx[fla2ch-1]=true; + } + if (ailerons>0) { + rxch=ICC(STK_AIL); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); + rx[rxch-1]=true; + } + if (ailerons>1) { + if (ail2ch==0) { + for (int j=0; j<10 ; j++) { + if (!rx[j]) { + md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6); + rx[j]=true; + break; + } + } + } else { + md=setDest(ail2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6); + } + } + if (elevators>1) { + if (ele2ch==0) { + for (int j=0; j<10 ; j++) { + if (!rx[j]) { + md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();;strncpy(md->name, tr("ELE2").toAscii().data(),6); + rx[j]=true; + break; + } + } + }else{ + md=setDest(ele2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();;strncpy(md->name, tr("ELE2").toAscii().data(),6); + } + } + if (flaps>0) { + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->speedUp=4; md->speedDown=4; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->speedUp=4; md->speedDown=4; + } + sign=-1; + for (uint8_t i=0; i< flaps; i++) { + sign*=-1; + int index; + if (i==0) { + index=fla1ch; + } else { + index=fla2ch; + } + if (index==0) { + for (int j=0; j<10 ; j++) { + if (!rx[j]) { + md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); + rx[j]=true; + break; + } + } + } else { + md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); + } + } + break; + case 1: + setCurve(CURVE5(1),heli_ar1); + setCurve(CURVE5(2),heli_ar2); + setCurve(CURVE5(3),heli_ar3); + setCurve(CURVE5(4),heli_ar4); + setCurve(CURVE5(5),heli_ar5); + setCurve(CURVE5(6),heli_ar5); + switch (swashtype) { + case 0: + model.swashRingData.type = HELI_SWASH_TYPE_90; + break; + case 1: + model.swashRingData.type = HELI_SWASH_TYPE_120; + break; + case 2: + model.swashRingData.type = HELI_SWASH_TYPE_120X; + break; + case 3: + model.swashRingData.type = HELI_SWASH_TYPE_140; + break; + case 4: + model.swashRingData.type = HELI_SWASH_TYPE_NONE; + break; + } + model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); + + if (chstyle==0) { + if (swashtype!=4) { + md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); + md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6); + } else { + md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); + md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6); + } + md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + switch (gyro) { + case 1: + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); + break; + case 2: + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); + break; + } + } else { + if (swashtype!=4) { + md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); + md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6); + } else { + md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); + md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight= 100; md->swtch=RawSwitch();strncpy(md->name, tr("PITCH").toAscii().data(),6); + } + md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + switch (gyro) { + case 1: + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); + break; + case 2: + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100;strncpy(md->name, tr("GYRO").toAscii().data(),6); + break; + } + } + // collective + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; + break; + case 2: + ailerons=ailerontype; + flaps=flaptype; + spoilers=spoilertype; + throttle=enginetype; + switch (tailtype) { + case 0: + case 1: + rudders=1; + elevators=1; + break; + case 2: + rudders=1; + elevators=2; + break; + } + if (throttle==1) { + rxch=ICC(STK_THR); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("THR").toAscii().data(),6); + rx[rxch-1]=true; + } + rxch=ICC(STK_RUD); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); + if (tailtype==1) { + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); + } + rx[rxch-1]=true; + rxch=ICC(STK_ELE); + if (tailtype==1) { + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); + } + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); + rx[rxch-1]=true; + if (ail2ch > 0) { + rx[ail2ch-1]=true; + } + if (ele2ch > 0) { + rx[ele2ch-1]=true; + } + if (fla1ch > 0) { + rx[fla1ch-1]=true; + } + if (fla2ch > 0) { + rx[fla2ch-1]=true; + } + if (spo1ch > 0) { + rx[spo1ch-1]=true; + } + if (spo2ch > 0) { + rx[spo2ch-1]=true; + } + + if (ailerons>0) { + rxch=ICC(STK_AIL); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); + rx[rxch-1]=true; + } + if (ailerons>1) { + if (ail2ch==0) { + for (int j=0; j<10 ; j++) { + if (!rx[j]) { + md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6); + rx[j]=true; + break; + } + } + } else { + md=setDest(ail2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL2").toAscii().data(),6); + } + } + if (elevators>1) { + if (ele2ch==0) { + for (int j=0; j<10 ; j++) { + if (!rx[j]) { + md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE2").toAscii().data(),6); + rx[j]=true; + break; + } + } + } else { + md=setDest(ele2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE2").toAscii().data(),6); + } + } + if (flaps>0) { + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6);md->speedUp=4; md->speedDown=4; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6);md->speedUp=4; md->speedDown=4; + } + sign=-1; + for (uint8_t i=0; i< flaps; i++) { + sign*=-1; + int index; + if (i==0) { + index=fla1ch; + } else { + index=fla2ch; + } + if (index==0) { + for (int j=0; j<10 ; j++) { + if (!rx[j]) { + md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); + rx[j]=true; + break; + } + } + } else { + md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); + } + } + if (spoilers>0) { + md=setDest(12); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA);strncpy(md->name, tr("SPOIL").toAscii().data(),6); md->speedUp=4;;md->speedDown=4; + md=setDest(12); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA);strncpy(md->name, tr("SPOIL").toAscii().data(),6);md->speedUp=4;md->speedDown=4; + } + sign=-1; + for (uint8_t i=0; i< spoilers; i++) { + sign*=-1; + int index; + if (i==0) { + index=spo1ch; + } else { + index=spo2ch; + } + if (index==0) { + for (int j=0; j<10 ; j++) { + if (!rx[j]) { + md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 11); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("SPOIL%1").arg(i+1).toAscii().data(),6); + rx[j]=true; + break; + } + } + } else { + md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 11); md->weight=100*sign; md->sOffset=0; md->swtch=RawSwitch();strncpy(md->name, tr("SPOIL%1").arg(i+1).toAscii().data(),6); + } + } + break; + case 3: + flaps=flaptype; + throttle=enginetype; + rudders=ruddertype; + if (throttle==1) { + rxch=ICC(STK_THR); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("THR").toAscii().data(),6); + rx[rxch-1]=true; + } + rxch=ICC(STK_ELE); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("ELE").toAscii().data(),6); + rx[rxch-1]=true; + rxch=ICC(STK_AIL); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("AIL").toAscii().data(),6); + rx[rxch-1]=true; + if (rudders>0) { + rxch=ICC(STK_RUD); + md=setDest(rxch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD").toAscii().data(),6); + rx[rxch-1]=true; + } + if (rud2ch > 0) { + rx[rud2ch-1]=true; + } + if (fla1ch > 0) { + rx[fla1ch-1]=true; + } + if (fla2ch > 0) { + rx[fla2ch-1]=true; + } + if (rudders>1) { + if (rud2ch==0) { + for (int j=0; j<10 ; j++) { + if (!rx[j]) { + md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD2").toAscii().data(),6); + rx[j]=true; + break; + } + } + } else { + md=setDest(rud2ch); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=-100; md->swtch=RawSwitch();strncpy(md->name, tr("RUD2").toAscii().data(),6); + } + } + if (flaps>0) { + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->sOffset=0; md->speedUp=4; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_AIL);strncpy(md->name, tr("FLAPS").toAscii().data(),6); md->sOffset=0; md->speedUp=4; + } + sign=-1; + for (uint8_t i=0; i< flaps; i++) { + sign*=-1; + int index; + if (i==0) { + index=fla1ch; + } else { + index=fla2ch; + } + if (index==0) { + for (int j=0; j<10 ; j++) { + if (!rx[j]) { + md=setDest(j+1); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->speedUp=4; md->speedDown=4; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); + rx[j]=true; + break; + } + } + } else { + md=setDest(index); md->srcRaw=RawSource(SOURCE_TYPE_CH, 10); md->weight=100*sign; md->sOffset=0; md->speedUp=4; md->speedDown=4; md->swtch=RawSwitch();strncpy(md->name, tr("FLAP%1").arg(i+1).toAscii().data(),6); + } + } + break; + } + updateHeliTab(); + updateCurvesTab(); + if (modeltype==1 && swashtype!=4) { + ui->tabWidget->setCurrentIndex(1); + } else { + ui->tabWidget->setCurrentIndex(4); + } + resizeEvent(); +} + +void Templates::applyTemplate(uint8_t idx) +{ + int8_t heli_ar1[] = {-100, -20, 30, 70, 90}; + int8_t heli_ar2[] = {80, 70, 60, 70, 100}; + int8_t heli_ar3[] = {100, 90, 80, 90, 100}; + int8_t heli_ar4[] = {-30, -15, 0, 50, 100}; + int8_t heli_ar5[] = {-100, -50, 0, 50, 100}; + + int thrsw=GetEepromInterface()->getCapability(GetThrSwitch); + MixData *md = &model.mixData[0]; + + //CC(STK) -> vSTK + //ICC(vSTK) -> STK + #define ICC(x) icc[(x)-1] + uint8_t icc[4] = {0}; + for(uint8_t i=1; i<=4; i++) //generate inverse array + for(uint8_t j=1; j<=4; j++) if(CC(i)==j) icc[j-1]=i; + + + uint8_t j = 0; + + //Simple 4-Ch + if(idx==j++) { + if (md->destCh) + clearMixes(); + md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch(); + } + + //T-Cut + if(idx==j++) { + md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + } + + //sticky t-cut + if(idx==j++) { + md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 12); md->mltpx=MLTPX_REP; + md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_CH, 13); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP; + md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + setSwitch(0xB, CS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99); + setSwitch(0xC, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0); + updateSwitchesTab(); + } + + //V-Tail + if(idx==j++) { + clearMixes(); + md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch(); + } + + //Elevon\\Delta + if(idx==j++) { + clearMixes(); + md=setDest(ICC(STK_THR)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_RUD)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_ELE)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-100; md->swtch=RawSwitch(); + md=setDest(ICC(STK_AIL)); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=100; md->swtch=RawSwitch(); + } + + //Heli Setup + if(idx==j++) { + clearMixes(); //This time we want a clean slate + clearCurves(); + + // Set up Mixes + // 3 cyclic channels + md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch(); + + // rudder + md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); + + // throttle + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + + // gyro gain + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); + + // collective + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; + + model.swashRingData.type = HELI_SWASH_TYPE_120; + model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); + + // set up Curves + setCurve(CURVE5(1),heli_ar1); + setCurve(CURVE5(2),heli_ar2); + setCurve(CURVE5(3),heli_ar3); + setCurve(CURVE5(4),heli_ar4); + setCurve(CURVE5(5),heli_ar5); + setCurve(CURVE5(6),heli_ar5); + + // make sure curves are redrawn + updateHeliTab(); + updateCurvesTab(); + resizeEvent(); + } + + //Heli Setup gyro gain control + if(idx==j++) { + clearMixes(); //This time we want a clean slate + clearCurves(); + + // Set up Mixes + // 3 cyclic channels + md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch(); + + // rudder + md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); + + // throttle + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + + // gyro gain + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100; + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100; + + // collective + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; + + model.swashRingData.type = HELI_SWASH_TYPE_120; + model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); + + // set up Curves + setCurve(CURVE5(1),heli_ar1); + setCurve(CURVE5(2),heli_ar2); + setCurve(CURVE5(3),heli_ar3); + setCurve(CURVE5(4),heli_ar4); + setCurve(CURVE5(5),heli_ar5); + setCurve(CURVE5(6),heli_ar5); + + // make sure curves are redrawn + updateHeliTab(); + updateCurvesTab(); + resizeEvent(); + } + + // gyro gain control + if(idx==j++) { + int res = QMessageBox::question(this,tr("Clear Mixes?"),tr("Really clear existing mixes on CH6?"),QMessageBox::Yes | QMessageBox::No); + if(res!=QMessageBox::Yes) return; + // first clear mix on ch6 + bool found=true; + while (found) { + found=false; + for (int i=0; i< GetEepromInterface()->getCapability(Mixes); i++) { + if (model.mixData[i].destCh==6) { + gm_deleteMix(i); + found=true; + break; + } + } + } + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100; + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100; + } + + //Heli Setup futaba style + if(idx==j++) { + clearMixes(); //This time we want a clean slate + clearCurves(); + + // Set up Mixes + // 3 cyclic channels + md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch(); + + // rudder + md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); + + // throttle + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + + // gyro gain + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); + + // collective + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; + + model.swashRingData.type = HELI_SWASH_TYPE_120; + model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); + + // set up Curves + setCurve(CURVE5(1),heli_ar1); + setCurve(CURVE5(2),heli_ar2); + setCurve(CURVE5(3),heli_ar3); + setCurve(CURVE5(4),heli_ar4); + setCurve(CURVE5(5),heli_ar5); + setCurve(CURVE5(6),heli_ar5); + + // make sure curves are redrawn + updateHeliTab(); + updateCurvesTab(); + resizeEvent(); + } + + // Heli setup futaba style with gyro gain control + if(idx==j++) { + clearMixes(); //This time we want a clean slate + clearCurves(); + + // Set up Mixes + // 3 cyclic channels + md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 1); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 0); md->weight= 100; md->swtch=RawSwitch(); + md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_CYC, 2); md->weight= 100; md->swtch=RawSwitch(); + + // rudder + md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); + + // throttle + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(1); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(2); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; + + // gyro gain + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100; + + // collective + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID0); md->curve=CV(4); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID1); md->curve=CV(5); md->carryTrim=TRIM_OFF; + md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_ID2); md->curve=CV(6); md->carryTrim=TRIM_OFF; + + model.swashRingData.type = HELI_SWASH_TYPE_120; + model.swashRingData.collectiveSource = RawSource(SOURCE_TYPE_CH, 10); + + // set up Curves + setCurve(CURVE5(1),heli_ar1); + setCurve(CURVE5(2),heli_ar2); + setCurve(CURVE5(3),heli_ar3); + setCurve(CURVE5(4),heli_ar4); + setCurve(CURVE5(5),heli_ar5); + setCurve(CURVE5(6),heli_ar5); + + // make sure curves are redrawn + updateHeliTab(); + updateCurvesTab(); + resizeEvent(); + } + + // gyro gain control futaba style + if(idx==j++) { + int res = QMessageBox::question(this,tr("Clear Mixes?"),tr("Really clear existing mixes on CH5?"),QMessageBox::Yes | QMessageBox::No); + if(res!=QMessageBox::Yes) return; + // first clear mix on ch6 + bool found=true; + while (found) { + found=false; + for (int i=0; i< GetEepromInterface()->getCapability(Mixes); i++) { + if (model.mixData[i].destCh==5) { + gm_deleteMix(i); + found=true; + break; + } + } + } + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight= 50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,-DSW_GEA); md->sOffset=100; + md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,DSW_GEA); md->sOffset=100; + } + + //Servo Test + if(idx==j++) { + md=setDest(15); md->srcRaw=RawSource(SOURCE_TYPE_CH, 15); md->weight= 100; md->speedUp = 8; md->speedDown = 8; md->swtch=RawSwitch(); + md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_CUSTOM_SWITCH, 0); md->weight= 110; md->swtch=RawSwitch(); + md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP; + md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP; + setSwitch(1, CS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue()); + setSwitch(2, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105); + setSwitch(3, CS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105); + + // redraw switches tab + updateSwitchesTab(); + } + + //MultiCopter + if(idx==j++) { + if (md->destCh) + clearMixes(); + md=setDest(1); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 3); md->weight=50; md->swtch=RawSwitch(); //CH1 AIL + md=setDest(2); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 1); md->weight=-50; md->swtch=RawSwitch(); //CH2 ELE + md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(); //CH3 THR + md=setDest(4); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 0); md->weight=100; md->swtch=RawSwitch(); //CH4 RUD + } +} + +MixData* Templates::setDest(uint8_t dch) +{ + uint8_t i = 0; + while ((g_model.mixData[i].destCh<=dch) && (g_model.mixData[i].destCh) && (igetCapability(Mixes))) i++; + if(i==GetEepromInterface()->getCapability(Mixes)) return &g_model.mixData[0]; + + memmove(&g_model.mixData[i+1],&g_model.mixData[i], + (GetEepromInterface()->getCapability(Mixes)-(i+1))*sizeof(MixData) ); + memset(&g_model.mixData[i],0,sizeof(MixData)); + g_model.mixData[i].destCh = dch; + return &g_model.mixData[i]; +} diff --git a/companion/src/modeledit/templates.h b/companion/src/modeledit/templates.h new file mode 100644 index 000000000..2f485f41e --- /dev/null +++ b/companion/src/modeledit/templates.h @@ -0,0 +1,23 @@ +#ifndef TEMPLATES_H +#define TEMPLATES_H + +#include +#include "eeprominterface.h" + +class Templates : public QWidget +{ + Q_OBJECT + + public: + Templates(QWidget *parent, ModelData & model); + ~Templates(); + + private slots: + void onDoubleClicked(QModelIndex index); + + private: + void applyNumericTemplate(uint64_t tpl); + ModelData & model; +}; + +#endif // TEMPLATES_H diff --git a/companion/src/modelslist.cpp b/companion/src/modelslist.cpp index e63959491..756e3ffaf 100644 --- a/companion/src/modelslist.cpp +++ b/companion/src/modelslist.cpp @@ -51,7 +51,7 @@ public: } bool general_settings; uint8_t models_count; - uint8_t models[C9XMAX_MODELS]; + uint8_t models[C9X_MAX_MODELS]; }; ModelsListWidget::ModelsListWidget(QWidget *parent): diff --git a/companion/src/modelslist.h b/companion/src/modelslist.h index 02e1f6f73..8d6e73e83 100644 --- a/companion/src/modelslist.h +++ b/companion/src/modelslist.h @@ -48,7 +48,7 @@ struct CurrentSelection { QListWidgetItem *current_item; - bool selected[C9XMAX_MODELS+1]; + bool selected[C9X_MAX_MODELS+1]; }; class ModelsListWidget : public QListWidget diff --git a/companion/src/printdialog.cpp b/companion/src/printdialog.cpp index 6a287179e..36b0422c4 100644 --- a/companion/src/printdialog.cpp +++ b/companion/src/printdialog.cpp @@ -157,7 +157,7 @@ QString printDialog::printPhases() if ((GetCurrentFirmwareVariant() & GVARS_VARIANT ) || (!GetEepromInterface()->getCapability(HasVariants) && GetEepromInterface()->getCapability(Gvars))) { if (GetEepromInterface()->getCapability(GvarsFlightPhases)) { gvars=1; - gvarnum=GetEepromInterface()->getCapability(GvarsNum); + gvarnum=GetEepromInterface()->getCapability(Gvars); } } @@ -787,7 +787,7 @@ void printDialog::printGvars() int gvarnum=0; if ((GetCurrentFirmwareVariant() & GVARS_VARIANT ) || (!GetEepromInterface()->getCapability(HasVariants) && GetEepromInterface()->getCapability(Gvars))) { gvars=1; - gvarnum=GetEepromInterface()->getCapability(GvarsNum); + gvarnum=GetEepromInterface()->getCapability(Gvars); } if (!GetEepromInterface()->getCapability(GvarsFlightPhases) && (gvars==1 && GetEepromInterface()->getCapability(Gvars))) { QString str = "
"; diff --git a/companion/src/simulatordialog.h b/companion/src/simulatordialog.h index b50629a7a..65edcb9e5 100644 --- a/companion/src/simulatordialog.h +++ b/companion/src/simulatordialog.h @@ -2,7 +2,7 @@ #define SIMULATORDIALOG_H #include -#include "node.h" +#include "modeledit/node.h" #include "eeprominterface.h" #ifdef JOYSTICKS #include "joystick.h" diff --git a/companion/src/xmlinterface.cpp b/companion/src/xmlinterface.cpp index 67d8be5ce..e7bd91683 100644 --- a/companion/src/xmlinterface.cpp +++ b/companion/src/xmlinterface.cpp @@ -195,7 +195,7 @@ bool XmlInterface::save(RadioData &radioData) // the models models xml_models; models::model_sequence & model_sequence (xml_models.model()); - for (int i=0; i -#include "node.h" +#include "modeledit/node.h" #include "eeprominterface.h" #ifdef JOYSTICKS #include "joystick.h"