void ModelData::clear() { memset(this, 0, sizeof(ModelData)); moduleData[0].channelsCount = 8; moduleData[1].channelsStart = 0; moduleData[1].channelsCount = 8; moduleData[0].ppmDelay = 300; moduleData[1].ppmDelay = 300; moduleData[2].ppmDelay = 300; int board = GetEepromInterface()->getBoard(); if (IS_TARANIS(board)) { moduleData[0].protocol=PXX_XJT_X16; moduleData[1].protocol=OFF; } else { moduleData[0].protocol=PPM; moduleData[1].protocol=OFF; } for (int i=0; i<C9X_MAX_FLIGHT_MODES; i++) { flightModeData[i].clear(); } clearInputs(); clearMixes(); for (int i=0; i<C9X_NUM_CHNOUT; i++) limitData[i].clear(); for (int i=0; i<NUM_STICKS; i++) expoData[i].clear(); for (int i=0; i<C9X_NUM_CSW; i++) customSw[i].clear(); for (int i=0; i<C9X_MAX_CUSTOM_FUNCTIONS; i++) funcSw[i].clear(); for (int i=0; i<C9X_MAX_CURVES; i++) curves[i].clear(5); for (int i=0; i<2; i++) timers[i].clear(); swashRingData.clear(); frsky.clear(); }
MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): ModelPanel(parent, model, generalSettings, firmware), mixInserted(false), highlightedSource(0), modelPrinter(firmware, generalSettings, model) { 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(CompanionIcon("moveup.png")); qbUp->setShortcut(QKeySequence(tr("Ctrl+Up"))); qbDown->setText(tr("Move Down")); qbDown->setIcon(CompanionIcon("movedown.png")); qbDown->setShortcut(QKeySequence(tr("Ctrl+Down"))); qbClear->setText(tr("Clear Mixes")); qbClear->setIcon(CompanionIcon("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*))); }
void applyTemplate(uint8_t idx) { MixData *md; //CC(STK) -> vSTK //ICC(vSTK) -> STK #define ICC(x) icc[(x)-1] uint8_t icc[4] = {0}; for (uint8_t i=0; i<4; i++) { //generate inverse array for(uint8_t j=0; j<4; j++) if(CC(i+1)==j+MIXSRC_Rud) icc[j]=i; } switch (idx) { case TMPL_CLEAR_MIXES: case TMPL_SIMPLE_4CH: case TMPL_HELI_SETUP: clearMixes(); break; } switch (idx) { // Simple 4-Ch case TMPL_SIMPLE_4CH: defaultInputs(); setDest(ICC(STK_RUD), TMPL_INPUT(STK_RUD)); setDest(ICC(STK_ELE), TMPL_INPUT(STK_ELE)); setDest(ICC(STK_THR), TMPL_INPUT(STK_THR)); setDest(ICC(STK_AIL), TMPL_INPUT(STK_AIL)); break; // Sticky-T-Cut case TMPL_STI_THR_CUT: md=setDest(ICC(STK_THR), MIXSRC_MAX); mixSetWeight(md, -100); md->swtch=SWSRC_SWC; md->mltpx=MLTPX_REP; md=setDest(13, MIXSRC_CH14); // md->weight= 100; done by setDest anyway md=setDest(13, MIXSRC_MAX); mixSetWeight(md, -100); md->swtch=SWSRC_SWB; md->mltpx=MLTPX_REP; md=setDest(13, MIXSRC_MAX); /* md->weight= 100;*/ md->swtch=SWSRC_THR; md->mltpx=MLTPX_REP; setLogicalSwitch(11, LS_FUNC_VNEG, STK_THR, -99); setLogicalSwitch(12, LS_FUNC_VPOS, MIXSRC_CH14, 0); break; // V-Tail case TMPL_V_TAIL: defaultInputs(); setDest(ICC(STK_RUD), TMPL_INPUT(STK_RUD), true); md=setDest(ICC(STK_RUD), TMPL_INPUT(STK_ELE)); mixSetWeight(md, -100); setDest(ICC(STK_ELE), TMPL_INPUT(STK_RUD), true); setDest(ICC(STK_ELE), TMPL_INPUT(STK_ELE)); break; // Elevon\\Delta case TMPL_ELEVON_DELTA: defaultInputs(); setDest(ICC(STK_ELE), MIXSRC_Ele, true); setDest(ICC(STK_ELE), MIXSRC_Ail); setDest(ICC(STK_AIL), MIXSRC_Ele, true); md=setDest(ICC(STK_AIL), MIXSRC_Ail); mixSetWeight(md, -100); break; // eCCPM case TMPL_ECCPM: md=setDest(ICC(STK_ELE), MIXSRC_Ele, true); md->weight= 72; md=setDest(ICC(STK_ELE), MIXSRC_Thr); md->weight= 55; md=setDest(ICC(STK_AIL), MIXSRC_Ele, true); mixSetWeight(md, -36); md=setDest(ICC(STK_AIL), MIXSRC_Ail); md->weight= 62; md=setDest(ICC(STK_AIL), MIXSRC_Thr); md->weight= 55; md=setDest(5, MIXSRC_Ele, true); mixSetWeight(md, -36); md=setDest(5, MIXSRC_Ail); mixSetWeight(md, -62); md=setDest(5, MIXSRC_Thr); md->weight= 55; break; // Heli Setup case TMPL_HELI_SETUP: clearCurves(); //Set up Mixes // 3 cyclic channels md=setDest(0, MIXSRC_CYC1); // md->weight=100; md=setDest(1, MIXSRC_CYC2); // md->weight=100; md=setDest(2, MIXSRC_CYC3); // md->weight=100; // rudder md=setDest(3, MIXSRC_Rud); // md->weight=100; // throttle #if defined(PCBTARANIS) // TODO #else md=setDest(4, MIXSRC_Thr); md->swtch=SWSRC_ID0; mixSetCurve(md, 0); md->carryTrim=TRIM_OFF; md=setDest(4, MIXSRC_Thr); md->swtch=SWSRC_ID1; mixSetCurve(md, 1); md->carryTrim=TRIM_OFF; md=setDest(4, MIXSRC_Thr); md->swtch=SWSRC_ID2; mixSetCurve(md, 2); md->carryTrim=TRIM_OFF; #endif md=setDest(4, MIXSRC_MAX); mixSetWeight(md, -100); md->swtch=SWSRC_THR; md->mltpx=MLTPX_REP; // gyro gain md=setDest(5, MIXSRC_MAX); md->weight= 30; md->swtch=-SWSRC_GEA; md=setDest(5, MIXSRC_MAX); mixSetWeight(md, -30); md->swtch= SWSRC_GEA; // collective #if defined(PCBTARANIS) // TODO #else md=setDest(10, MIXSRC_Thr); /*md->weight= 100;*/ md->swtch=SWSRC_ID0; mixSetCurve(md, 3); md->carryTrim=TRIM_OFF; md=setDest(10, MIXSRC_Thr); /*md->weight= 100;*/ md->swtch=SWSRC_ID1; mixSetCurve(md, 4); md->carryTrim=TRIM_OFF; md=setDest(10, MIXSRC_Thr); /*md->weight= 100;*/ md->swtch=SWSRC_ID2; mixSetCurve(md, 5); md->carryTrim=TRIM_OFF; #endif g_model.swashR.collectiveSource = MIXSRC_CH11; g_model.swashR.type = SWASH_TYPE_120; // curves setCurve(0, heli_ar1); setCurve(1, heli_ar2); setCurve(2, heli_ar3); setCurve(3, heli_ar4); setCurve(4, heli_ar5); setCurve(5, heli_ar5); break; // Servo Test case TMPL_SERVO_TEST: md=setDest(NUM_CHNOUT-1, MIXSRC_SW1, true); md->weight=110; md->mltpx=MLTPX_ADD; md->delayUp = 6; md->delayDown = 6; md->speedUp = 8; md->speedDown = 8; setLogicalSwitch(1, LS_FUNC_VNEG, MIXSRC_LAST_CH, 0); break; default: break; } eeDirty(EE_MODEL); }
void applyTemplate(uint8_t idx) #endif { 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; #ifndef NO_TEMPLATES uint8_t j = 0; //Simple 4-Ch if(idx==j++) { #endif clearMixes(); md=setDest(ICC(STK_RUD)); md->srcRaw=CM(STK_RUD); md=setDest(ICC(STK_ELE)); md->srcRaw=CM(STK_ELE); md=setDest(ICC(STK_THR)); md->srcRaw=CM(STK_THR); md=setDest(ICC(STK_AIL)); md->srcRaw=CM(STK_AIL); #ifndef NO_TEMPLATES } //T-Cut if(idx==j++) { md=setDest(ICC(STK_THR)); md->srcRaw=MIX_MAX; md->weight=-100; md->swtch=DSW_THR; md->mltpx=MLTPX_REP; } //sticky t-cut if(idx==j++) { md=setDest(ICC(STK_THR)); md->srcRaw=MIX_MAX; md->weight=-100; md->swtch=DSW_SWC; md->mltpx=MLTPX_REP; md=setDest(14); md->srcRaw=CH(14); md=setDest(14); md->srcRaw=MIX_MAX; md->weight=-100; md->swtch=DSW_SWB; md->mltpx=MLTPX_REP; md=setDest(14); md->srcRaw=MIX_MAX; md->swtch=DSW_THR; md->mltpx=MLTPX_REP; setSwitch(0xB,CS_VNEG, CM(STK_THR), -99); setSwitch(0xC,CS_VPOS, CH(14), 0); } //V-Tail if(idx==j++) { clearMixes(); md=setDest(ICC(STK_RUD)); md->srcRaw=CM(STK_RUD); md=setDest(ICC(STK_RUD)); md->srcRaw=CM(STK_ELE); md->weight=-100; md=setDest(ICC(STK_ELE)); md->srcRaw=CM(STK_RUD); md=setDest(ICC(STK_ELE)); md->srcRaw=CM(STK_ELE); } //Elevon\\Delta if(idx==j++) { clearMixes(); md=setDest(ICC(STK_ELE)); md->srcRaw=CM(STK_ELE); md=setDest(ICC(STK_ELE)); md->srcRaw=CM(STK_AIL); md=setDest(ICC(STK_AIL)); md->srcRaw=CM(STK_ELE); md=setDest(ICC(STK_AIL)); md->srcRaw=CM(STK_AIL); md->weight=-100; } //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=MIX_CYC1; md=setDest(2); md->srcRaw=MIX_CYC2; md=setDest(3); md->srcRaw=MIX_CYC3; //rudder md=setDest(4); md->srcRaw=CM(STK_RUD); //Throttle md=setDest(5); md->srcRaw=CM(STK_THR); md->swtch= DSW_ID0; md->curve=CV(1); md->carryTrim=TRIM_OFF; md=setDest(5); md->srcRaw=CM(STK_THR); md->swtch= DSW_ID1; md->curve=CV(2); md->carryTrim=TRIM_OFF; md=setDest(5); md->srcRaw=CM(STK_THR); md->swtch= DSW_ID2; md->curve=CV(3); md->carryTrim=TRIM_OFF; md=setDest(5); md->srcRaw=MIX_MAX; md->weight=-100; md->swtch= DSW_THR; md->mltpx=MLTPX_REP; //gyro gain md=setDest(6); md->srcRaw=MIX_FULL; md->weight=30; md->swtch=-DSW_GEA; //collective md=setDest(11); md->srcRaw=CM(STK_THR); md->weight=70; md->swtch= DSW_ID0; md->curve=CV(4); md->carryTrim=TRIM_OFF; md=setDest(11); md->srcRaw=CM(STK_THR); md->weight=70; md->swtch= DSW_ID1; md->curve=CV(5); md->carryTrim=TRIM_OFF; md=setDest(11); md->srcRaw=CM(STK_THR); md->weight=70; md->swtch= DSW_ID2; md->curve=CV(6); md->carryTrim=TRIM_OFF; g_model.swashType = SWASH_TYPE_120; g_model.swashCollectiveSource = CH(11); //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); } //Gyro Gain if(idx==j++) { md=setDest(6); md->srcRaw=STK_P2; md->weight= 50; md->swtch=-DSW_GEA; md->sOffset=100; md=setDest(6); md->srcRaw=STK_P2; md->weight=-50; md->swtch= DSW_GEA; md->sOffset=100; } //Servo Test if(idx==j++) { md=setDest(15); md->srcRaw=CH(16); md->speedUp = 8; md->speedDown = 8; md=setDest(16); md->srcRaw=MIX_FULL; md->weight= 110; md->swtch=DSW_SW1; md=setDest(16); md->srcRaw=MIX_MAX; md->weight=-110; md->swtch=DSW_SW2; md->mltpx=MLTPX_REP; md=setDest(16); md->srcRaw=MIX_MAX; md->weight= 110; md->swtch=DSW_SW3; md->mltpx=MLTPX_REP; setSwitch(1,CS_LESS,CH(15),CH(16)); setSwitch(2,CS_VPOS,CH(15), 105); setSwitch(3,CS_VNEG,CH(15), -105); } STORE_MODELVARS; eeWaitComplete() ; #endif }