diff --git a/companion/src/modeledit/CMakeLists.txt b/companion/src/modeledit/CMakeLists.txt index 6c0ca893b..a69127b31 100644 --- a/companion/src/modeledit/CMakeLists.txt +++ b/companion/src/modeledit/CMakeLists.txt @@ -23,7 +23,6 @@ set(modeledit_SRCS channels.cpp logicalswitches.cpp customfunctions.cpp - # templates.cpp mixerslistwidget.cpp # node.cpp ## node and edge are built in common lib because also used by simulator # edge.cpp ## commenting them here avoids a "duplicate target" warning eg. from ninja @@ -36,7 +35,6 @@ set(modeledit_HDRS channels.h logicalswitches.h customfunctions.h - # templates.h mixerslistwidget.h # node.h ) diff --git a/companion/src/modeledit/templates.cpp b/companion/src/modeledit/templates.cpp deleted file mode 100644 index 00c63d4f0..000000000 --- a/companion/src/modeledit/templates.cpp +++ /dev/null @@ -1,896 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "templates.h" - -#define CHANNEL_ORDER(x) generalSettings.getDefaultStick(x) -#define CC(x) (CHANNEL_ORDER(x)) //need to invert this to work with dest -// TODO ICC is GeneralSettings::getDefaultChannel(unsigned int stick) - -void ModelEdit::setCurve(uint8_t c, int8_t ar[]) -{ - int len=sizeof(ar)/sizeof(int8_t); - - if (firmware->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]; - } - } - } -} - -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.logicalSw[idx-1].func = func; - g_model.logicalSw[idx-1].val1 = v1; - g_model.logicalSw[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=firmware->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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA);strncpy(md->name, tr("GYRO").toAscii().data(),6); - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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=firmware->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(Board::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(Board::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(Board::SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP; - md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - setSwitch(0xB, LS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99); - setSwitch(0xC, LS_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); - - // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); md->sOffset=100; - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); md->sOffset=100; - - // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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< firmware->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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); md->sOffset=100; - md=setDest(6); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-30; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); - - // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_ID2); md->curve=CV(3); md->carryTrim=TRIM_OFF; - md=setDest(3); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(Board::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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); md->sOffset=100; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_GEA); md->sOffset=100; - - // collective - md=setDest(11); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 2); md->weight=100; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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< firmware->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(Board::SWITCH_TYPE_SWITCH,-Board::SWITCH_GEA); md->sOffset=100; - md=setDest(5); md->srcRaw=RawSource(SOURCE_TYPE_STICK, 5); md->weight=-50; md->swtch=RawSwitch(Board::SWITCH_TYPE_SWITCH,Board::SWITCH_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(Board::SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP; - md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(Board::SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP; - setSwitch(1, LS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue()); - setSwitch(2, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105); - setSwitch(3, LS_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==firmware->getCapability(Mixes)) return &g_model.mixData[0]; - - memmove(&g_model.mixData[i+1],&g_model.mixData[i], - (firmware->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 deleted file mode 100644 index a3e1af8fd..000000000 --- a/companion/src/modeledit/templates.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#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/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index f3fe9bbaa..aac4399b9 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -150,12 +150,6 @@ if(RAMBACKUP) set(SRC ${SRC} storage/rambackup.cpp storage/rlc.cpp) endif() -if(TEMPLATES) - add_definitions(-DTEMPLATES) - set(SRC ${SRC} templates.cpp) - set(GUI_SRC ${GUI_SRC} model_templates.cpp) -endif() - if(NOT LUA STREQUAL NO) add_definitions(-DLUA) if(LUA_COMPILER) diff --git a/radio/src/gui/128x64/menus.h b/radio/src/gui/128x64/menus.h index 407b7dfd3..e51504314 100644 --- a/radio/src/gui/128x64/menus.h +++ b/radio/src/gui/128x64/menus.h @@ -121,7 +121,6 @@ enum MenuModelIndexes { #endif CASE_FRSKY(MENU_MODEL_TELEMETRY_FRSKY) MENU_MODEL_DISPLAY, - CASE_TEMPLATES(MENU_MODEL_TEMPLATES) MENU_MODEL_PAGES_COUNT }; @@ -161,7 +160,6 @@ static const MenuHandlerFunc menuTabModel[] PROGMEM = { #endif CASE_FRSKY(menuModelTelemetryFrsky) menuModelDisplay, - CASE_TEMPLATES(menuModelTemplates) }; void menuStatisticsView(event_t event); diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index ccee9f60a..cc6df41fe 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -347,12 +347,6 @@ void defaultInputs() } #endif -#if defined(TEMPLATES) -inline void applyDefaultTemplate() -{ - applyTemplate(TMPL_SIMPLE_4CH); // calls storageDirty internally -} -#else void applyDefaultTemplate() { #if defined(VIRTUAL_INPUTS) @@ -372,7 +366,6 @@ void applyDefaultTemplate() #endif } } -#endif #if defined(CPUARM) && defined(EEPROM) void checkModelIdUnique(uint8_t index, uint8_t module) diff --git a/radio/src/opentx.h b/radio/src/opentx.h index dc6f766a5..e7c1aaa1e 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -147,12 +147,6 @@ #define CASE_HELI(x) #endif -#if defined(TEMPLATES) - #define CASE_TEMPLATES(x) x, -#else - #define CASE_TEMPLATES(x) -#endif - #if defined(FLIGHT_MODES) #define CASE_FLIGHT_MODES(x) x, #else @@ -443,9 +437,6 @@ typedef struct { #include "strhelpers.h" #include "gui.h" -#if defined(TEMPLATES) - #include "templates.h" -#endif #if !defined(SIMU) #define assert(x) diff --git a/radio/src/templates.cpp b/radio/src/templates.cpp deleted file mode 100644 index a13b3a673..000000000 --- a/radio/src/templates.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -/* - * - * ============================================================ - * Templates file - * - * eccpm - * crow - * throttle cut - * flaperon - * elevon - * v-tail - * throttle hold - * Aileron Differential - * Spoilers - * Snap Roll - * ELE->Flap - * Flap->ELE - * - */ - -#include "opentx.h" - - #pragma message("Templates are not implemented on this board") - -MixData* setDest(uint8_t dch, uint8_t src, bool clear=false) -{ - uint8_t i = 0; - MixData * mix; - - while (1) { - mix = mixAddress(i); - if (mix->srcRaw && mix->destCh <= dch) { - if (clear && mix->destCh == dch) { - deleteExpoMix(0, i); - } - else { - if (++i==MAX_MIXERS) { - // TODO should return null pointer but needs to be tested then - mix = mixAddress(0); - break; - } - } - } - else { - break; - } - } - - memmove(mix+1, mix, (MAX_MIXERS-(i+1))*sizeof(MixData) ); - memclear(mix, sizeof(MixData)); - mix->destCh = dch; - mix->srcRaw = src; - mix->weight = 100; - return mix; -} - -void mixSetWeight(MixData* md, int8_t weight) -{ - u_int8int16_t tmp; - tmp.word=weight; - MD_UNION_TO_WEIGHT(tmp,md); - // MD_SETWEIGHT(md,weight); doesn't matter here in code cost compiler optimizes this anyway -} - -#if defined(PCBTARANIS) - #define TMPL_INPUT(x) (MIXSRC_FIRST_INPUT+channel_order(x)-1) -#else - #define clearInputs() - #define defaultInputs() - #define TMPL_INPUT(x) (MIXSRC_Rud+x-1) -#endif - -void clearMixes() -{ - memset(g_model.mixData, 0, sizeof(g_model.mixData)); // clear all mixes -} - -void clearCurves() -{ - memclear(g_model.curves, sizeof(g_model.curves) + sizeof(g_model.points)); // clear all curves -} - -void setCurve(uint8_t c, const pm_int8_t ar[]) -{ - int8_t * cv = curveAddress(c); - for (uint8_t i=0; i<5; i++) { - cv[i] = pgm_read_byte(&ar[i]); - } -} - -void setLogicalSwitch(uint8_t idx, uint8_t func, int8_t v1, int8_t v2) -{ - LogicalSwitchData *cs = lswAddress(idx-1); - cs->func = func; - cs->v1 = v1; - cs->v2 = v2; -} - -const pm_int8_t heli_ar1[] PROGMEM = {-100, 20, 30, 70, 90}; -const pm_int8_t heli_ar2[] PROGMEM = {80, 70, 60, 70, 100}; -const pm_int8_t heli_ar3[] PROGMEM = {100, 90, 80, 90, 100}; -const pm_int8_t heli_ar4[] PROGMEM = {-30, -15, 0, 50, 100}; -const pm_int8_t heli_ar5[] PROGMEM = {-100, -50, 0, 50, 100}; - -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: -#if defined(HELI) && defined(CURVES) - case TMPL_HELI_SETUP: -#endif - 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; - -#if defined(HELI) && defined(CURVES) - // 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; -#endif - - // Servo Test - case TMPL_SERVO_TEST: - md=setDest(MAX_OUTPUT_CHANNELS-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; - - } - - storageDirty(EE_MODEL); -} diff --git a/radio/src/templates.h b/radio/src/templates.h deleted file mode 100644 index 2fe5a34fa..000000000 --- a/radio/src/templates.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) OpenTX - * - * Based on code named - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -/* - * ============================================================ - * Templates file - * - * eccpm - * crow - * throttle cut - * flaperon - * elevon - * v-tail - * throttle hold - * Aileron Differential - * Spoilers - * Snap Roll - * ELE->Flap - * Flap->ELE - * - */ - -#ifndef _TEMPLATES_H_ -#define _TEMPLATES_H_ - -#include - -#define STK_RUD 1 -#define STK_ELE 2 -#define STK_THR 3 -#define STK_AIL 4 -#define STK_P1 5 -#define STK_P2 6 -#define STK_P3 7 - -#define CV(x) (CURVE_BASE+(x)-1) -#define CC(x) (MIXSRC_Rud - 1 + channel_order(x)) // need to invert this to work with dest - -#if defined(PCBTARANIS) - #define mixSetCurve(mix, idx) mix->curve.type=CURVE_REF_CUSTOM; mix->curve.value=idx -#else - #define mixSetCurve(mix, idx) mix->curveMode=MODE_CURVE; mix->curveParam=CURVE_BASE+idx -#endif - -enum Templates { - TMPL_CLEAR_MIXES, - TMPL_SIMPLE_4CH, - TMPL_STI_THR_CUT, - TMPL_V_TAIL, - TMPL_ELEVON_DELTA, - TMPL_ECCPM, -#if defined(HELI) && defined(CURVES) - TMPL_HELI_SETUP, -#endif - TMPL_SERVO_TEST, - TMPL_COUNT -}; - -void clearMixes(); -void clearCurves(); -void applyTemplate(uint8_t idx); - -#endif // _TEMPLATES_H_ - - diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 251a4d3f6..4d6a55491 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -70,9 +70,6 @@ const pm_char STR_OPEN9X[] PROGMEM = ISTR(AMPSRC) ISTR(VARIOSRC) ISTR(VTELEMSCREENTYPE) -#if defined(TEMPLATES) - ISTR(VTEMPLATES) -#endif #if defined(HELI) ISTR(VSWASHTYPE) #endif @@ -340,9 +337,6 @@ const pm_char STR_MENUTELEMETRY[] PROGMEM = TR_MENUTELEMETRY; const pm_char STR_LIMIT[] PROGMEM = TR_LIMIT; #endif -#if defined(TEMPLATES) -const pm_char STR_MENUTEMPLATES[] PROGMEM = TR_MENUTEMPLATES; -#endif const pm_char STR_MENUSTAT[] PROGMEM = TR_MENUSTAT; const pm_char STR_MENUDEBUG[] PROGMEM = TR_MENUDEBUG; diff --git a/radio/src/translations.h b/radio/src/translations.h index cf8bd26cc..9a0e57672 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -163,12 +163,7 @@ extern const pm_char STR_OPEN9X[]; #define OFS_VARIOSRC (OFS_AMPSRC + sizeof(TR_AMPSRC)) #define OFS_VSCREEN (OFS_VARIOSRC + sizeof(TR_VARIOSRC)) #define OFS_VTEMPLATES (OFS_VSCREEN + sizeof(TR_VTELEMSCREENTYPE)) -#if defined(TEMPLATES) - #define TR_VTEMPLATES TR_TEMPLATE_CLEAR_MIXES TR_TEMPLATE_SIMPLE_4CH TR_TEMPLATE_STICKY_TCUT TR_TEMPLATE_VTAIL TR_TEMPLATE_DELTA TR_TEMPLATE_ECCPM TR_TEMPLATE_HELI TR_TEMPLATE_SERVO_TEST - #define OFS_VSWASHTYPE (OFS_VTEMPLATES + sizeof(TR_VTEMPLATES)) -#else #define OFS_VSWASHTYPE (OFS_VTEMPLATES) -#endif #if defined(HELI) #define OFS_VKEYS (OFS_VSWASHTYPE + sizeof(TR_VSWASHTYPE)) #else @@ -264,9 +259,6 @@ extern const pm_char STR_OPEN9X[]; #define STR_VTELEMSCREENTYPE (STR_OPEN9X + OFS_VSCREEN) #define STR_TELEMCHNS (STR_OPEN9X + OFS_TELEMCHNS) -#if defined(TEMPLATES) - #define STR_VTEMPLATES (STR_OPEN9X + OFS_VTEMPLATES) -#endif #if defined(HELI) #define STR_VSWASHTYPE (STR_OPEN9X + OFS_VSWASHTYPE)