EEPROM 'next' support. A lot of corrections.

This commit is contained in:
Bertrand Songis
2014-01-13 19:09:05 +01:00
parent 0b387a2467
commit cedddfe8d2
20 changed files with 419 additions and 434 deletions
+2 -1
View File
@@ -281,7 +281,8 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
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) {
}
else if (index>=FuncAdjustGV1 && index<=FuncAdjustGVLast) {
if (modified) model.funcSw[i].adjustMode = fswtchGVmode[i]->currentIndex();
widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE;
if (model.funcSw[i].adjustMode==0) {
+70 -147
View File
@@ -15,109 +15,47 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
setWindowTitle(tr("DEST -> %1").arg(getStickStr(ed->chn)));
QRegExp rx(CHAR_FOR_NAMES_REGEX);
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
if (gvars==0) {
ui->expoGV->setDisabled(true);
ui->weightGV->setDisabled(true);
ui->expoCurveGV->setDisabled(true);
/* TODO
if (ed->expo>100) {
ed->expo=0;
}
*/
if (ed->weight>100 || ed->weight<-100) {
ed->weight=100;
}
/* TODO
if (ed->curveParam>100 || ed->curveParam<-100) {
ed->curveParam=0;
}
*/
}
// TODO populateGVCB(ui->expoCB, ed->expo);
populateGVCB(ui->weightCB, ed->weight);
// TODO populateGVCB(ui->expoCurveCB, ed->curveParam);
ui->weightSB->setMinimum(0);
ui->weightSB->setMaximum(100);
if (ed->weight>100 || ed->weight<0) {
ui->weightGV->setChecked(true);
ui->weightSB->hide();
ui->weightCB->show();
} else {
ui->weightGV->setChecked(false);
ui->weightSB->setValue(ed->weight);
ui->weightSB->show();
ui->weightCB->hide();
}
/* TODO
ui->expoSB->setMinimum(-100);
ui->expoSB->setMaximum(100);
if (ed->expo>100 || ed->expo<-100) {
ui->expoGV->setChecked(true);
ui->expoSB->hide();
ui->expoCB->show();
}
else {
ui->expoGV->setChecked(false);
ui->expoSB->setValue(ed->expo);
ui->expoSB->show();
ui->expoCB->hide();
}
ui->expoCurveSB->setMinimum(-100);
ui->expoCurveSB->setMaximum(100);
if (ed->curveParam>100 || ed->curveParam<-100) {
ui->expoCurveGV->setChecked(true);
ui->expoCurveSB->hide();
ui->expoCurveCB->show();
}
else {
ui->expoCurveGV->setChecked(false);
ui->expoCurveSB->setValue(ed->curveParam);
ui->expoCurveSB->show();
ui->expoCurveCB->hide();
}
*/
} else {
gvars=1;
}
else {
// TODO ui->expoGV->hide();
ui->weightGV->hide();
// TODO ui->expoCurveGV->hide();
// TODO ui->expoSB->setMinimum(-100);
// TODO ui->expoSB->setMaximum(100);
// TODO ui->expoSB->setValue(ed->expo);
// TODO ui->expoCurveSB->setMinimum(-100);
// TODO ui->expoCurveSB->setMaximum(100);
// TODO ui->expoCurveSB->setValue(ed->curveParam);
ui->weightSB->setMinimum(0);
ui->weightSB->setMaximum(100);
if (gvars==0) {
ui->weightGV->setDisabled(true);
ui->curveGVarCB->hide();
if ((ed->curve.type == CurveReference::CURVE_REF_EXPO || ed->curve.type == CurveReference::CURVE_REF_DIFF) && ed->curve.value > 100) {
ed->curve.value = 0;
}
if (ed->weight>100 || ed->weight<-100) {
ed->weight = 100;
}
}
populateGVCB(ui->weightCB, ed->weight);
ui->weightSB->setMinimum(0);
ui->weightSB->setMaximum(100);
if (ed->weight>100 || ed->weight<0) {
ui->weightGV->setChecked(true);
ui->weightSB->hide();
ui->weightCB->show();
} else {
ui->weightGV->setChecked(false);
ui->weightSB->setValue(ed->weight);
ui->weightSB->show();
ui->weightCB->hide();
}
populateSwitchCB(ui->switchesCB,ed->swtch);
/* if (ed->curveMode==0) {
populateExpoCurvesCB(ui->curvesCB,0); // TODO capacity for er9x
}
else {
populateExpoCurvesCB(ui->curvesCB,ed->curveParam); // TODO capacity for er9x
}
*/
populateCurveReference(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, 0);
ui->modeCB->setCurrentIndex(ed->mode-1);
ui->label_expo->hide();
// TODO ui->expoCB->hide();
// TODO ui->expoGV->hide();
// TODO ui->expoSB->hide();
if (!GetEepromInterface()->getCapability(FlightPhases)) {
ui->label_phases->hide();
@@ -138,6 +76,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
cb_fp[i]->hide();
}
}
int expolength=GetEepromInterface()->getCapability(HasExpoNames);
if (!expolength) {
ui->label_name->hide();
@@ -145,21 +84,25 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
} else {
ui->expoName->setMaxLength(expolength);
}
ui->expoName->setValidator(new QRegExpValidator(rx, this));
ui->expoName->setText(ed->name);
valuesChanged();
connect(ui->expoName,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->expoCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->expoSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->expoCurveCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->expoCurveSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->curveTypeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curveGVarCB,SIGNAL(stateChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curveValueCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curveValueSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curvesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->modeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->expoGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->expoCurveGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
for (int i=0; i<9; i++) {
connect(cb_fp[i],SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
@@ -186,63 +129,43 @@ void ExpoDialog::changeEvent(QEvent *e)
void ExpoDialog::widgetChanged()
{
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
gvars=1;
}
if (gvars==1) {
if (ui->expoCurveGV->isChecked()) {
ui->expoCurveCB->show();
ui->expoCurveSB->hide();
} else {
ui->expoCurveCB->hide();
ui->expoCurveSB->show();
}
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
} else {
ui->weightCB->hide();
ui->weightSB->show();
}
}
valuesChanged();
QTimer::singleShot(0, this, SLOT(shrink()));
// TODO so many times duplicated :(
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
gvars=1;
}
/* TODO if (gvars==1) {
if (ui->expoCurveGV->isChecked()) {
ui->expoCurveCB->show();
ui->expoCurveSB->hide();
} else {
ui->expoCurveCB->hide();
ui->expoCurveSB->show();
}
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
} else {
ui->weightCB->hide();
ui->weightSB->show();
}
} */
valuesChanged();
QTimer::singleShot(0, this, SLOT(shrink()));
}
void ExpoDialog::valuesChanged()
{
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
if (ui->curvesCB->currentIndex()==0) {
// TODO ed->curveMode = 0;
ui->expoCurveGV->show();
if (ui->expoCurveGV->isChecked()) {
ui->expoCurveCB->show();
ui->expoCurveSB->hide();
// TODO ed->curveParam = ui->expoCurveCB->itemData(ui->expoCurveCB->currentIndex()).toInt();
}
else {
ui->expoCurveCB->hide();
ui->expoCurveSB->show();
// TODO ed->curveParam = ui->expoCurveSB->value();
}
// TODO ed->expo = ed->curveParam;
}
else {
// TODO ed->curveMode = 1;
// TODO ed->curveParam = ui->curvesCB->currentIndex();
// TODO ed->expo = 0;
ui->expoCurveCB->hide();
ui->expoCurveSB->hide();
ui->expoCurveGV->hide();
}
retrieveCurveReference(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, 0);
if (ui->weightGV->isChecked()) {
ed->weight = ui->weightCB->itemData(ui->weightCB->currentIndex()).toInt();
} else {
+10 -10
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>370</width>
<height>289</height>
<height>291</height>
</rect>
</property>
<property name="sizePolicy">
@@ -26,7 +26,7 @@
<string/>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<iconset>
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
@@ -308,14 +308,14 @@ If blank then the expo is considered to be &quot;ON&quot; all the time.</string>
<item row="5" column="0">
<widget class="QLabel" name="label_curves">
<property name="text">
<string>Curve/Exponential</string>
<string>Curve</string>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,0,1">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,1,0">
<item>
<widget class="QComboBox" name="curvesCB">
<widget class="QComboBox" name="curveTypeCB">
<property name="toolTip">
<string/>
</property>
@@ -325,22 +325,22 @@ If blank then the expo is considered to be &quot;ON&quot; all the time.</string>
</widget>
</item>
<item>
<widget class="QCheckBox" name="expoCurveGV">
<widget class="QCheckBox" name="curveGVarCB">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="expoCurveSB"/>
</item>
<item>
<widget class="QComboBox" name="expoCurveCB">
<widget class="QComboBox" name="curveValueCB">
<property name="whatsThis">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="curveValueSB"/>
</item>
</layout>
</item>
<item row="6" column="0">
+1 -1
View File
@@ -82,7 +82,7 @@ void InputsPanel::update()
default: str += " "; break;
};
str += tr("Weight") + getGVarString(md->weight).rightJustified(6, ' ');
str += tr("Weight(%1)").arg(getGVarString(md->weight));
QString curveStr = md->curve.toString();
if (!curveStr.isEmpty()) {
+75 -84
View File
@@ -6,7 +6,8 @@
MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
QDialog(parent),
ui(new Ui::MixerDialog),
md(mixdata)
md(mixdata),
lock(false)
{
ui->setupUi(this);
QRegExp rx(CHAR_FOR_NAMES_REGEX);
@@ -22,63 +23,51 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
ui->sourceCB->removeItem(0);
int limit=GetEepromInterface()->getCapability(OffsetWeight);
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
if (gvars==0) {
ui->offsetGV->setDisabled(true);
ui->weightGV->setDisabled(true);
if (md->weight>limit || md->weight<-limit) {
md->weight=100;
}
if (md->sOffset>limit || md->sOffset<-limit) {
md->sOffset=0;
}
}
populateGVCB(ui->offsetCB,md->sOffset);
populateGVCB(ui->weightCB,md->weight);
ui->weightSB->setMinimum(-limit);
ui->weightSB->setMaximum(limit);
} else {
gvars=1;
}
if (gvars==0) {
ui->offsetGV->setDisabled(true);
ui->weightGV->setDisabled(true);
if (md->weight>limit || md->weight<-limit) {
ui->weightGV->setChecked(true);
ui->weightSB->hide();
ui->weightCB->show();
} else {
ui->weightGV->setChecked(false);
ui->weightSB->setValue(md->weight);
ui->weightSB->show();
ui->weightCB->hide();
md->weight=100;
}
ui->offsetSB->setMinimum(-limit);
ui->offsetSB->setMaximum(limit);
if (md->sOffset>limit || md->sOffset<-limit) {
ui->offsetGV->setChecked(true);
ui->offsetSB->hide();
ui->offsetCB->show();
}
else {
ui->offsetGV->setChecked(false);
ui->offsetSB->setValue(md->sOffset);
ui->offsetSB->show();
ui->offsetCB->hide();
md->sOffset=0;
}
}
else {
ui->offsetGV->hide();
ui->weightGV->hide();
ui->offsetSB->setMinimum(-limit);
ui->offsetSB->setMaximum(limit);
ui->offsetSB->setValue(md->sOffset);
ui->weightSB->setMinimum(-limit);
ui->weightSB->setMaximum(limit);
populateGVCB(ui->offsetCB,md->sOffset);
populateGVCB(ui->weightCB,md->weight);
ui->weightSB->setMinimum(-limit);
ui->weightSB->setMaximum(limit);
if (md->weight>limit || md->weight<-limit) {
ui->weightGV->setChecked(true);
ui->weightSB->hide();
ui->weightCB->show();
} else {
ui->weightGV->setChecked(false);
ui->weightSB->setValue(md->weight);
ui->weightSB->show();
ui->weightCB->hide();
}
ui->offsetSB->setMinimum(-limit);
ui->offsetSB->setMaximum(limit);
if (md->sOffset>limit || md->sOffset<-limit) {
ui->offsetGV->setChecked(true);
ui->offsetSB->hide();
ui->offsetCB->show();
}
else {
ui->offsetGV->setChecked(false);
ui->offsetSB->setValue(md->sOffset);
ui->offsetSB->show();
ui->offsetCB->hide();
}
populateCurveReference(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve, 0);
@@ -197,38 +186,43 @@ void MixerDialog::changeEvent(QEvent *e)
void MixerDialog::widgetChanged()
{
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
int gvars=0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
gvars=1;
}
if (gvars==1) {
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
} else {
ui->weightCB->hide();
ui->weightSB->show();
}
if (ui->offsetGV->isChecked()) {
ui->offsetCB->show();
ui->offsetSB->hide();
} else {
ui->offsetCB->hide();
ui->offsetSB->show();
}
}
valuesChanged();
QTimer::singleShot(0, this, SLOT(shrink()));
int gvars = 0;
if (GetEepromInterface()->getCapability(HasVariants)) {
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars = 1;
}
}
else {
gvars = 1;
}
if (gvars == 1) {
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
}
else {
ui->weightCB->hide();
ui->weightSB->show();
}
if (ui->offsetGV->isChecked()) {
ui->offsetCB->show();
ui->offsetSB->hide();
}
else {
ui->offsetCB->hide();
ui->offsetSB->show();
}
}
valuesChanged();
QTimer::singleShot(0, this, SLOT(shrink()));
}
void MixerDialog::valuesChanged()
{
if (!lock) {
lock = true;
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt());
if ((ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt()-65536)<4) {
@@ -256,13 +250,7 @@ void MixerDialog::valuesChanged()
md->carryTrim = -(ui->trimCB->currentIndex()-1);
md->noExpo = ui->MixDR_CB->checkState() ? 0 : 1;
// TODO md->curve = ui->curvesCB->currentIndex()-(numcurves)*GetEepromInterface()->getCapability(HasNegCurves);
// TODO if (ui->differentialGV->isChecked()) {
// TODO md->differential = ui->differentialCB->itemData(ui->differentialCB->currentIndex()).toInt();
// TODO } else {
// TODO md->differential = ui->differentialSB->value();
// TODO }
// populateCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueCB, CurveReference & curve, unsigned int flags)
retrieveCurveReference(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve, 0);
md->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
md->mixWarn = ui->warningCB->currentIndex();
@@ -286,6 +274,9 @@ void MixerDialog::valuesChanged()
md->phases<<=1;
}
md->phases>>=1;
lock = false;
}
}
void MixerDialog::shrink() {
+1
View File
@@ -26,6 +26,7 @@ private slots:
private:
Ui::MixerDialog *ui;
MixData *md;
bool lock;
};
#endif // MIXERDIALOG_H
+5 -10
View File
@@ -104,8 +104,9 @@ void MixesPanel::update()
default: str += " "; break;
};
str += " " + getGVarString(md->weight, true).rightJustified(6, ' ');
str += md->srcRaw.toString();
str += " " + tr("Weight(%1)").arg(getGVarString(md->weight, true));
unsigned int fpCount = GetEepromInterface()->getCapability(FlightPhases);
if (GetEepromInterface()->getCapability(FlightPhases)) {
if(md->phases) {
@@ -149,16 +150,10 @@ void MixesPanel::update()
} else if (md->carryTrim<0) {
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString();
}
if(md->noExpo) {
str += " " +tr("No DR/Expo");
}
if (md->sOffset) str += " " + tr("Offset") + getGVarString(md->sOffset);
QString curveStr = md->curve.toString();
if (!curveStr.isEmpty()) {
str += " " + curveStr;
}
if (md->noExpo) str += " " + tr("No DR/Expo");
if (md->sOffset) str += " " + tr("Offset(%1)").arg(getGVarString(md->sOffset));
if (md->curve.value) str += " " + md->curve.toString();
int scale=GetEepromInterface()->getCapability(SlowScale);
if (scale==0)
+138 -115
View File
@@ -101,11 +101,14 @@ ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module
moduleIdx(moduleIdx),
ui(new Ui::Module)
{
lock = true;
ui->setupUi(this);
QString label;
if (moduleIdx < 0) {
label = tr("Trainer Module");
ui->trainerMode->setCurrentIndex(model.trainerMode);
}
else {
ui->label_trainerMode->hide();
@@ -122,6 +125,7 @@ ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module
for (int i=0; i<PROTO_LAST; i++) {
if (GetEepromInterface()->isAvailable((Protocol)i, moduleIdx)) {
ui->protocol->addItem(getProtocolStr(i), (QVariant)i);
if (i == module.protocol) ui->protocol->setCurrentIndex(ui->protocol->count()-1);
}
}
@@ -143,6 +147,8 @@ ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onFailsafeChannelChanged(int)));
}
}
lock = false;
}
ModulePanel::~ModulePanel()
@@ -150,38 +156,46 @@ ModulePanel::~ModulePanel()
delete ui;
}
#define MASK_CHANNELS_COUNT 1
#define MASK_RX_NUMBER 2
#define MASK_CHANNELS_RANGE 4
#define MASK_PPM_FIELDS 8
#define MASK_FAILSAFES 16
#define MASK_PROTOCOL 1
#define MASK_CHANNELS_COUNT 2
#define MASK_RX_NUMBER 4
#define MASK_CHANNELS_RANGE 8
#define MASK_PPM_FIELDS 16
#define MASK_FAILSAFES 32
void ModulePanel::update()
{
unsigned int mask = 0;
Protocol protocol = (Protocol)module.protocol;
switch (protocol) {
case OFF:
break;
case PXX_XJT_X16:
case PXX_XJT_D8:
case PXX_XJT_LR12:
case PXX_DJT:
mask |= MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT | MASK_RX_NUMBER;
if (protocol==PXX_XJT_X16) mask |= MASK_FAILSAFES;
break;
case LP45:
case DSM2:
case DSMX:
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER;
module.channelsCount = 8;
break;
default:
mask |= MASK_PPM_FIELDS | MASK_CHANNELS_RANGE| MASK_CHANNELS_COUNT;
break;
if (moduleIdx >= 0 || model.trainerMode != 0) {
mask |= MASK_PROTOCOL;
switch (protocol) {
case OFF:
break;
case PXX_XJT_X16:
case PXX_XJT_D8:
case PXX_XJT_LR12:
case PXX_DJT:
mask |= MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT | MASK_RX_NUMBER;
if (protocol==PXX_XJT_X16) mask |= MASK_FAILSAFES;
break;
case LP45:
case DSM2:
case DSMX:
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER;
module.channelsCount = 8;
break;
default:
mask |= MASK_PPM_FIELDS | MASK_CHANNELS_RANGE| MASK_CHANNELS_COUNT;
break;
}
}
ui->label_protocol->setVisible(mask & MASK_PROTOCOL);
ui->protocol->setVisible(mask & MASK_PROTOCOL);
ui->label_rxNumber->setVisible(mask & MASK_PROTOCOL);
ui->rxNumber->setVisible(mask & MASK_PROTOCOL);
ui->rxNumber->setEnabled(mask & MASK_RX_NUMBER);
ui->rxNumber->setValue(model.modelId);
ui->label_channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
@@ -220,6 +234,15 @@ void ModulePanel::update()
}
}
void ModulePanel::on_trainerMode_currentIndexChanged(int index)
{
if (!lock) {
model.trainerMode = index;
update();
emit modified();
}
}
void ModulePanel::on_protocol_currentIndexChanged(int index)
{
if (!lock) {
@@ -302,6 +325,8 @@ Setup::Setup(QWidget *parent, ModelData & model):
ModelPanel(parent, model),
ui(new Ui::Setup)
{
lock = true;
memset(modules, 0, sizeof(modules));
ui->setupUi(this);
@@ -325,101 +350,99 @@ Setup::Setup(QWidget *parent, ModelData & model):
ui->modulesLayout->addWidget(modules[C9X_NUM_MODULES]);
}
if (!GetEepromInterface()->getCapability(ModelImage)) {
ui->image->hide();
ui->modelImage_label->hide();
ui->imagePreview->hide();
if (GetEepromInterface()->getCapability(ModelImage)) {
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();
foreach ( QString file, items ) {
ui->image->addItem(file);
if (file == model.bitmap) {
ui->image->setCurrentIndex(ui->image->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->imagePreview->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));;
}
}
}
}
else {
ui->image->hide();
ui->modelImage_label->hide();
ui->imagePreview->hide();
}
// Beep Center checkboxes
int analogs = 4 + GetEepromInterface()->getCapability(Pots);
for (int i=0; i<analogs+GetEepromInterface()->getCapability(RotaryEncoders); i++) {
QCheckBox * checkbox = new QCheckBox(this);
checkbox->setProperty("index", i);
checkbox->setText(i<analogs ? AnalogString(i) : RotaryEncoderString(i-analogs));
ui->centerBeepLayout->addWidget(checkbox, 0, i+1);
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
centerBeepCheckboxes << checkbox;
}
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, analogs+GetEepromInterface()->getCapability(RotaryEncoders));
// Startup switches warnings
ui->switchesStartupWarning->setProperty("index", 0);
connect(ui->switchesStartupWarning, SIGNAL(currentIndexChanged(int)), this, SLOT(startupSwitchEdited(int)));
for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) {
QLabel * label = new QLabel();
QSlider * slider = new QSlider();
slider->setProperty("index", i+1);
slider->setOrientation(Qt::Vertical);
slider->setMinimum(0);
slider->setSingleStep(1);
slider->setPageStep(1);
slider->setInvertedAppearance(true);
slider->setTickPosition(QSlider::TicksBothSides);
slider->setTickInterval(1);
slider->setMinimumSize(QSize(30, 50));
slider->setMaximumSize(QSize(50, 50));
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
label->setText(switchesX9D[i]);
slider->setMaximum(i==5 ? 1 : 2);
}
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->image->clear();
foreach ( QString file, items ) {
ui->image->addItem(file);
if (file==model.bitmap) {
ui->image->setCurrentIndex(ui->image->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->imagePreview->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));;
}
}
}
label->setText(switches9X[i]);
slider->setMaximum(i==0 ? 2 : 1);
}
ui->switchesStartupLayout->addWidget(label, 0, i+1);
ui->switchesStartupLayout->addWidget(slider, 1, i+1);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int)));
startupSwitchesSliders << slider;
}
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, GetEepromInterface()->getCapability(Switches));
// Beep Center checkboxes
int analogs = 4 + GetEepromInterface()->getCapability(Pots);
for (int i=0; i<analogs+GetEepromInterface()->getCapability(RotaryEncoders); i++) {
QCheckBox * checkbox = new QCheckBox(this);
checkbox->setProperty("index", i);
checkbox->setText(i<analogs ? AnalogString(i) : RotaryEncoderString(i-analogs));
ui->centerBeepLayout->addWidget(checkbox, 0, i+1);
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
centerBeepCheckboxes << checkbox;
}
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, analogs+GetEepromInterface()->getCapability(RotaryEncoders));
// Startup switches warnings
ui->switchesStartupWarning->setProperty("index", 0);
connect(ui->switchesStartupWarning, SIGNAL(currentIndexChanged(int)), this, SLOT(startupSwitchEdited(int)));
for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) {
QLabel * label = new QLabel();
QSlider * slider = new QSlider();
slider->setProperty("index", i+1);
slider->setOrientation(Qt::Vertical);
slider->setMinimum(0);
slider->setSingleStep(1);
slider->setPageStep(1);
slider->setInvertedAppearance(true);
slider->setTickPosition(QSlider::TicksBothSides);
slider->setTickInterval(1);
slider->setMinimumSize(QSize(30, 50));
slider->setMaximumSize(QSize(50, 50));
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
label->setText(switchesX9D[i]);
slider->setMaximum(i==5 ? 1 : 2);
}
else {
label->setText(switches9X[i]);
slider->setMaximum(i==0 ? 2 : 1);
}
ui->switchesStartupLayout->addWidget(label, 0, i+1);
ui->switchesStartupLayout->addWidget(slider, 1, i+1);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int)));
startupSwitchesSliders << slider;
}
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, GetEepromInterface()->getCapability(Switches));
lock = false;
lock = false;
}
Setup::~Setup()
+1
View File
@@ -46,6 +46,7 @@ class ModulePanel : public ModelPanel
virtual void update();
private slots:
void on_trainerMode_currentIndexChanged(int index);
void on_protocol_currentIndexChanged(int index);
void on_ppmDelay_editingFinished();
void on_channelsCount_editingFinished();