Merge pull request #1020 from opentx/dvogonen/add_companion_selectable_functions_993
Dvogonen/add companion selectable functions 993
This commit is contained in:
@@ -71,6 +71,7 @@
|
||||
<file>images/wizard/models.png</file>
|
||||
<file>images/wizard/multirotor.png</file>
|
||||
<file>images/wizard/rudder.png</file>
|
||||
<file>images/wizard/options.png</file>
|
||||
<file>images/wizard/simpletail.png</file>
|
||||
<file>images/wizard/tail.png</file>
|
||||
<file>images/wizard/tails.png</file>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
@@ -67,35 +67,60 @@ void WizMix::addMix(ModelData &model, Input input, int weight, int channel, int
|
||||
}
|
||||
else if (input==FLAPS_INPUT){
|
||||
// There ought to be some kind of constants for switches somewhere...
|
||||
maxMixSwitch((char *)"Flaps Up", model.mixData[mixIndex++], channel+1, isTaranis ? 1 :-3 , weight); //SA-UP or ELE-UP
|
||||
maxMixSwitch((char *)"Flaps Down", model.mixData[mixIndex++], channel+1, isTaranis ? 3 : 3 , -weight); //SA-DOWN or ELE-DOWN
|
||||
maxMixSwitch((char *)"Flaps Up", model.mixData[mixIndex++], channel+1, isTaranis ? 1 :-3 , weight); //Taranis SA-UP, 9X ELE-UP
|
||||
maxMixSwitch((char *)"Flaps Down", model.mixData[mixIndex++], channel+1, isTaranis ? 3 : 3 , -weight); //Taranis SA-DOWN, 9X ELE-DOWN
|
||||
|
||||
}
|
||||
else if (input==AIRBRAKES_INPUT){
|
||||
maxMixSwitch((char *)"Airbrk Off", model.mixData[mixIndex++], channel+1, isTaranis ? 13 :-2 , -weight); //SE-UP or RUD-UP
|
||||
maxMixSwitch((char *)"Airbrk On", model.mixData[mixIndex++], channel+1, isTaranis ? 15 : 2 , weight); //SE-DOWN or RUD-DOWN
|
||||
maxMixSwitch((char *)"Airbrk Off", model.mixData[mixIndex++], channel+1, isTaranis ? 13 :-2 , -weight); //Taranis SE-UP, 9X RUD-UP
|
||||
maxMixSwitch((char *)"Airbrk On", model.mixData[mixIndex++], channel+1, isTaranis ? 15 : 2 , weight); //Tatanis SE-DOWN, 9X RUD-DOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WizMix::operator ModelData()
|
||||
{
|
||||
int throttleChannel = -1;
|
||||
bool isTaranis = IS_TARANIS(GetEepromInterface()->getBoard());
|
||||
|
||||
ModelData model;
|
||||
model.used = true;
|
||||
model.modelId = modelId;
|
||||
model.setDefaultInputs(settings);
|
||||
|
||||
int mixIndex = 0;
|
||||
int switchIndex = 0;
|
||||
int timerIndex = 0;
|
||||
|
||||
// Safe copy model name
|
||||
strncpy(model.name, name, WIZ_MODEL_NAME_LENGTH);
|
||||
model.name[WIZ_MODEL_NAME_LENGTH] = 0;
|
||||
|
||||
int mixIndex = 0;
|
||||
// Add the channel mixes
|
||||
for (int i=0; i<WIZ_MAX_CHANNELS; i++ )
|
||||
{
|
||||
Channel ch = channel[i];
|
||||
if (ch.input1 == THROTTLE_INPUT || ch.input2 == THROTTLE_INPUT)
|
||||
throttleChannel = i;
|
||||
|
||||
addMix(model, ch.input1, ch.weight1, i, mixIndex);
|
||||
addMix(model, ch.input2, ch.weight2, i, mixIndex);
|
||||
}
|
||||
|
||||
// Add the Throttle Cut option
|
||||
if( options[THROTTLE_CUT_OPTION] && throttleChannel >=0 ){
|
||||
model.funcSw[switchIndex].swtch.type = SWITCH_TYPE_SWITCH;
|
||||
model.funcSw[switchIndex].swtch.index = isTaranis ? 16 : 1; // Taranis SF-UP, 9X THR-UP
|
||||
model.funcSw[switchIndex].enabled = 1;
|
||||
model.funcSw[switchIndex].func = (AssignFunc)throttleChannel;
|
||||
}
|
||||
|
||||
// Add the Throttle Timer option
|
||||
if (options[THROTTLE_TIMER_OPTION] && throttleChannel >=0 ){
|
||||
model.timers[timerIndex].mode.type = SWITCH_TYPE_SWITCH;
|
||||
model.timers[timerIndex].mode.index = isTaranis ? -16 : -1; // Taranis !SF-UP, 9X THR-DOWN
|
||||
timerIndex++;
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "eeprominterface.h"
|
||||
|
||||
#define WIZ_MAX_CHANNELS 8
|
||||
|
||||
#define WIZ_MAX_OPTIONS 2
|
||||
// TODO use a constant common to the whole companion
|
||||
// TODO when in the wizard use the getCapacity(...) to know how long the name can be
|
||||
#define WIZ_MODEL_NAME_LENGTH 12
|
||||
@@ -40,6 +40,11 @@ enum Vehicle {
|
||||
HELICOPTER
|
||||
};
|
||||
|
||||
enum Options {
|
||||
THROTTLE_CUT_OPTION,
|
||||
THROTTLE_TIMER_OPTION
|
||||
};
|
||||
|
||||
enum WizardPage {
|
||||
Page_None = -1,
|
||||
Page_Models,
|
||||
@@ -60,6 +65,7 @@ enum WizardPage {
|
||||
Page_Fblheli,
|
||||
Page_Helictrl,
|
||||
Page_Multirotor,
|
||||
Page_Options,
|
||||
Page_Conclusion
|
||||
};
|
||||
|
||||
@@ -86,6 +92,7 @@ class WizMix
|
||||
const GeneralSettings & settings;
|
||||
Vehicle vehicle;
|
||||
Channel channel[WIZ_MAX_CHANNELS];
|
||||
bool options[WIZ_MAX_OPTIONS];
|
||||
|
||||
WizMix(const GeneralSettings & settings, const unsigned int modelId);
|
||||
operator ModelData();
|
||||
|
||||
@@ -32,17 +32,18 @@ WizardDialog::WizardDialog(const GeneralSettings & settings, unsigned int modelI
|
||||
setPage(Page_Flaps, new FlapsPage(this, "flaps",tr("Flaps"),tr("Has your model got flaps?"), Page_Airbrakes));
|
||||
setPage(Page_Airbrakes, new AirbrakesPage(this, "airbrakes",tr("Airbrakes"),tr("Has your model got airbrakes?"), Page_Tails));
|
||||
setPage(Page_Bank, new BankPage(this, "bank",tr("Flying-wing / Delta-wing"),tr("Are the elevons controlled by servos connected to separate channels or by a single servo channel?"), Page_Rudder));
|
||||
setPage(Page_Rudder, new RudderPage(this, "rudder",tr("Rudder"),tr("Does your model have a rudder?"), Page_Conclusion));
|
||||
setPage(Page_Rudder, new RudderPage(this, "rudder",tr("Rudder"),tr("Does your model have a rudder?"), Page_Options));
|
||||
setPage(Page_Tails, new TailSelectionPage(this, "tails",tr("Tail Type"),tr("Select which type of tail your model is equiped with.")));
|
||||
setPage(Page_Tail, new TailPage(this, "tail",tr("Tail"),tr("Select channels for tail control."), Page_Conclusion));
|
||||
setPage(Page_Vtail, new VTailPage(this, "vtail",tr("V-Tail"),tr("Select channels for tail control."), Page_Conclusion));
|
||||
setPage(Page_Simpletail, new SimpleTailPage(this, "simpletail",tr("Tail"),tr("Select elevator channel."), Page_Conclusion));
|
||||
setPage(Page_Tail, new TailPage(this, "tail",tr("Tail"),tr("Select channels for tail control."), Page_Options));
|
||||
setPage(Page_Vtail, new VTailPage(this, "vtail",tr("V-Tail"),tr("Select channels for tail control."), Page_Options));
|
||||
setPage(Page_Simpletail, new SimpleTailPage(this, "simpletail",tr("Tail"),tr("Select elevator channel."), Page_Options));
|
||||
setPage(Page_Cyclic, new CyclicPage(this, "cyclic",tr("Cyclic"),tr("Which type of swash control is installed in your helicopter?"), Page_Gyro));
|
||||
setPage(Page_Gyro, new GyroPage(this, "gyro",tr("Tail Gyro"),tr("Has your helicopter got an adjustable gyro for the tail?"), Page_Flybar));
|
||||
setPage(Page_Flybar, new FlybarSelectionPage(this, "flybar",tr("Rotor Type"),tr("Has your helicopter got a flybar?")));
|
||||
setPage(Page_Fblheli, new FblPage(this, "fblheli",tr("Helicopter"),tr("Select the controls for your helicopter"), Page_Conclusion));
|
||||
setPage(Page_Helictrl, new HeliPage(this, "helictrl",tr("Helicopter"),tr("Select the controls for your helicopter"), Page_Conclusion));
|
||||
setPage(Page_Multirotor, new MultirotorPage(this, "multirotor",tr("Multirotor"),tr("Select the control channels for your multirotor"), Page_Conclusion));
|
||||
setPage(Page_Fblheli, new FblPage(this, "fblheli",tr("Helicopter"),tr("Select the controls for your helicopter"), Page_Options));
|
||||
setPage(Page_Helictrl, new HeliPage(this, "helictrl",tr("Helicopter"),tr("Select the controls for your helicopter"), Page_Options));
|
||||
setPage(Page_Multirotor, new MultirotorPage(this, "multirotor",tr("Multirotor"),tr("Select the control channels for your multirotor"), Page_Options));
|
||||
setPage(Page_Options, new OptionsPage(this, "options",tr("Model Options"),tr("Select additional options"), Page_Conclusion));
|
||||
setPage(Page_Conclusion, new ConclusionPage(this, "conclusion",tr("Save Changes"),tr(
|
||||
"Manually check the direction of each control surface and reverse any channels that make controls move in the wrong direction. "
|
||||
"Remove the propeller/propellers before you try to control your model for the first time.<br>"
|
||||
@@ -117,6 +118,8 @@ void WizardDialog::showHelp()
|
||||
"Yaw - Spektrum: CH4, Futaba: CH4<br>"
|
||||
"Pitch - Spektrum: CH3, Futaba: CH2<br>"
|
||||
"Roll - Spektrum: CH2, Futaba: CH1"); break;
|
||||
case Page_Options:
|
||||
message = tr("TBD."); break;
|
||||
case Page_Conclusion:
|
||||
message = tr("TBD."); break;
|
||||
default:
|
||||
@@ -832,6 +835,27 @@ bool MultirotorPage::validatePage() {
|
||||
bookChannel(rollCB, AILERONS_INPUT, 100 ));
|
||||
}
|
||||
|
||||
OptionsPage::OptionsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage)
|
||||
: StandardPage(Page_Options, dlg, image, title, text, nextPage)
|
||||
{
|
||||
throttleCutRB = new QCheckBox(tr("Throttle Cut"));
|
||||
throttleTimerRB = new QCheckBox(tr("Throttle Timer"));
|
||||
|
||||
QLayout *l = layout();
|
||||
l->addWidget(throttleCutRB);
|
||||
l->addWidget(throttleTimerRB);
|
||||
}
|
||||
|
||||
void OptionsPage::initializePage(){
|
||||
StandardPage::initializePage();
|
||||
}
|
||||
|
||||
bool OptionsPage::validatePage(){
|
||||
wizDlg->mix.options[THROTTLE_CUT_OPTION] = throttleCutRB->isChecked();
|
||||
wizDlg->mix.options[THROTTLE_TIMER_OPTION] = throttleTimerRB->isChecked();
|
||||
return true;
|
||||
}
|
||||
|
||||
ConclusionPage::ConclusionPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage)
|
||||
: StandardPage(Page_Conclusion, dlg, image, title, text, nextPage)
|
||||
{
|
||||
@@ -840,8 +864,8 @@ ConclusionPage::ConclusionPage(WizardDialog *dlg, QString image, QString title,
|
||||
registerField("evaluate.proceed*", proceedCB);
|
||||
|
||||
QLayout *l = layout();
|
||||
l->addWidget(proceedCB);
|
||||
l->addWidget(textLabel);
|
||||
l->addWidget(proceedCB);
|
||||
}
|
||||
|
||||
void ConclusionPage::initializePage(){
|
||||
@@ -898,6 +922,16 @@ QString WizardPrinter::print()
|
||||
QString str;
|
||||
str = QString(tr("Model Name: ")) + mix->name + "\n";
|
||||
str += QString(tr("Model Type: ")) + vehicleName(mix->vehicle) + "\n";
|
||||
|
||||
str += QString(tr("Options: ["));
|
||||
for (int i=0; i<WIZ_MAX_OPTIONS; i++){
|
||||
if (mix->options[i])
|
||||
str += "X";
|
||||
else
|
||||
str += "-";
|
||||
}
|
||||
str += QString(tr("]")) + "\n";
|
||||
|
||||
for (int i=0; i<WIZ_MAX_CHANNELS; i++){
|
||||
if (mix->channel[i].page != Page_None) {
|
||||
Channel ch = mix->channel[i];
|
||||
|
||||
@@ -333,6 +333,18 @@ private:
|
||||
QComboBox *rollCB;
|
||||
};
|
||||
|
||||
class OptionsPage: public StandardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OptionsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
|
||||
void initializePage();
|
||||
bool validatePage();
|
||||
private:
|
||||
QCheckBox *throttleCutRB;
|
||||
QCheckBox *throttleTimerRB;
|
||||
};
|
||||
|
||||
class ConclusionPage: public StandardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Reference in New Issue
Block a user