New switch warnings and displayText in companion. Import/export conversions not done yet

This commit is contained in:
Andre Bernet
2014-01-20 19:26:30 +01:00
parent 0b2b9ea1c3
commit b38d278c75
6 changed files with 118 additions and 68 deletions
+7 -1
View File
@@ -856,8 +856,12 @@ class ModelData {
unsigned int thrTraceSrc;
int8_t traineron; // 0 disable trainer, 1 allow trainer
int8_t t2throttle; // Start timer2 using throttle
unsigned int modelId;
unsigned int modelId;
unsigned int switchWarningStates;
unsigned int nSwToWarn;
unsigned int nPotsToWarn;
int potPosition[C9X_NUM_POTS];
bool displayText;
// TODO structure
char gvars_names[C9X_MAX_GVARS][6+1];
bool gvars_popups[C9X_MAX_GVARS];
@@ -1008,6 +1012,8 @@ enum Capability {
CSFunc,
LCDWidth,
GetThrSwitch,
HasDisplayText,
PotWarnings,
VirtualInputs,
LuaInputs,
LimitsPer1000,
@@ -1856,7 +1856,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new BoolField<1>(modelData.disableThrottleWarning));
if (IS_TARANIS(board) || (IS_ARM(board) && version >= 216))
internalField.Append(new SpareBitsField<1>());
internalField.Append(new BoolField<1>(modelData.displayText));
else
internalField.Append(new BoolField<1>(modelData.moduleData[0].ppmPulsePol));
@@ -1927,6 +1927,10 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new MavlinkField(modelData.mavlink, board, version));
}
if (!IS_ARM(board) && (version >= 216)) {
internalField.Append(new UnsignedField<8>(modelData.nSwToWarn));
}
if (IS_TARANIS(board) && version < 215) {
internalField.Append(new CharField<10>(modelData.bitmap));
}
@@ -1953,6 +1957,14 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
}
}
if (IS_ARM(board) && version >= 216) {
internalField.Append(new UnsignedField<8>(modelData.nSwToWarn));
internalField.Append(new UnsignedField<8>(modelData.nPotsToWarn));
for (int i=0; i < GetEepromInterface()->getCapability(PotWarnings); i++) {
internalField.Append(new SignedField<8>(modelData.potPosition[i]));
}
}
if (IS_TARANIS(board)) {
for (int i=0; i<MAX_CURVES(board, version); i++) {
internalField.Append(new ZCharField<6>(modelData.curves[i].name));
@@ -1964,6 +1976,11 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new SpareBitsField<720>());
// TODO char inputNames[MAX_INPUTS][4];
internalField.Append(new SpareBitsField<1024>());
internalField.Append(new UnsignedField<8>(modelData.nSwToWarn));
internalField.Append(new UnsignedField<8>(modelData.nPotsToWarn));
for (int i=0; i < GetEepromInterface()->getCapability(PotWarnings); i++) {
internalField.Append(new SignedField<8>(modelData.potPosition[i]));
}
}
}
@@ -695,6 +695,9 @@ int Open9xInterface::getCapability(const Capability capability)
return (IS_TARANIS(board) ? 212 : 128) ;
case GetThrSwitch:
return (IS_TARANIS(board) ? DSW_SF1 : DSW_THR) ;
case PotWarnings:
return (IS_TARANIS(board) ? 4 : IS_ARM(board) ? 3 : 0);
case HasDisplayText:
case VirtualInputs:
case LuaInputs:
case LimitsPer1000:
+47 -16
View File
@@ -398,6 +398,10 @@ Setup::Setup(QWidget *parent, ModelData & model):
ui->modelImage_label->hide();
ui->imagePreview->hide();
}
if (!GetEepromInterface()->getCapability(HasDisplayText)) {
ui->displayText->hide();
}
// Beep Center checkboxes
int analogs = 4 + GetEepromInterface()->getCapability(Pots);
@@ -412,11 +416,10 @@ Setup::Setup(QWidget *parent, ModelData & model):
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();
QCheckBox * cb = new QCheckBox();
slider->setProperty("index", i+1);
slider->setOrientation(Qt::Vertical);
slider->setMinimum(0);
@@ -435,10 +438,17 @@ Setup::Setup(QWidget *parent, ModelData & model):
label->setText(switches9X[i]);
slider->setMaximum(i==0 ? 2 : 1);
}
cb->setProperty("index", i+1);
ui->switchesStartupLayout->addWidget(label, 0, i+1);
ui->switchesStartupLayout->setAlignment(label, Qt::AlignCenter);
ui->switchesStartupLayout->addWidget(slider, 1, i+1);
ui->switchesStartupLayout->setAlignment(slider, Qt::AlignCenter);
ui->switchesStartupLayout->addWidget(cb, 2, i+1);
ui->switchesStartupLayout->setAlignment(cb, Qt::AlignCenter);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int)));
connect(cb, SIGNAL(toggled(bool)), this, SLOT(startupSwitchToggled(bool)));
startupSwitchesSliders << slider;
startupSwitchesCheckboxes << cb;
}
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, GetEepromInterface()->getCapability(Switches));
@@ -539,6 +549,7 @@ void Setup::update()
ui->throttleTrim->setChecked(model.thrTrim);
ui->extendedLimits->setChecked(model.extendedLimits);
ui->extendedTrims->setChecked(model.extendedTrims);
ui->displayText->setChecked(model.displayText);
updateBeepCenter();
updateStartupSwitches();
@@ -563,13 +574,14 @@ void Setup::updateStartupSwitches()
lock = true;
unsigned int switchStates = model.switchWarningStates;
bool enabled = !(switchStates & 0x01);
ui->switchesStartupWarning->setCurrentIndex(switchStates & 0x01);
switchStates >>= 1;
bool enabled;
for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) {
QSlider * slider = startupSwitchesSliders[i];
QCheckBox * cb = startupSwitchesCheckboxes[i];
enabled = !(model.nSwToWarn & (1 << i));
slider->setEnabled(enabled);
cb->setChecked(enabled);
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
slider->setValue(i==5 ? (switchStates & 0x3)/2 : switchStates & 0x3);
switchStates >>= 2;
@@ -590,24 +602,24 @@ void Setup::startupSwitchEdited(int value)
unsigned int mask;
int index = sender()->property("index").toInt();
if (index == 0) {
mask = 0x01;
}
else if (IS_TARANIS(GetEepromInterface()->getBoard())) {
if (index == 6)
mask = 0x02 << (index*2 - 1);
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
if (index == 6) {
shift = (index - 1)*2;
mask = 0x02 << shift;
shift++;
}
else {
shift = index*2 - 1;
shift = (index - 1)*2;
mask = 0x03 << shift;
}
}
else {
if (index == 1) {
shift = 1;
mask = 0x03 << shift;
mask = 0x03;
}
else {
mask = 0x01 << (index+1);
shift = index;
mask = 0x01 << shift;
}
}
@@ -615,7 +627,7 @@ void Setup::startupSwitchEdited(int value)
if (value) {
if (shift == 0) {
model.switchWarningStates |= mask;
model.switchWarningStates |= value;
}
else {
model.switchWarningStates |= (value << shift);
@@ -627,6 +639,25 @@ void Setup::startupSwitchEdited(int value)
}
}
void Setup::startupSwitchToggled(bool checked)
{
int index = sender()->property("index").toInt()-1;
if (checked)
model.nSwToWarn &= ~(1 << index);
else
model.nSwToWarn |= (1 << index);
updateStartupSwitches();
emit modified();
}
void Setup::on_displayText_toggled(bool checked)
{
model.displayText = checked;
emit modified();
}
void Setup::on_throttleTrim_toggled(bool checked)
{
model.thrTrim = checked;
+3
View File
@@ -83,15 +83,18 @@ class Setup : public ModelPanel
void on_extendedTrims_toggled(bool checked);
void on_throttleWarning_toggled(bool checked);
void on_throttleReverse_toggled(bool checked);
void on_displayText_toggled(bool checked);
void on_image_currentIndexChanged(int index);
void on_trimIncrement_currentIndexChanged(int index);
void onBeepCenterToggled(bool checked);
void startupSwitchEdited(int value);
void startupSwitchToggled(bool checked);
void onChildModified();
private:
Ui::Setup *ui;
QVector<QSlider *> startupSwitchesSliders;
QVector<QCheckBox *> startupSwitchesCheckboxes;
QVector<QCheckBox *> centerBeepCheckboxes;
ModulePanel * modules[C9X_NUM_MODULES+1];
TimerPanel * timers[C9X_MAX_TIMERS];
+40 -50
View File
@@ -65,7 +65,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Switch startup Warning</string>
<string>Switch Warnings</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -95,55 +95,6 @@
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QGridLayout" name="switchesStartupLayout" rowstretch="0,0" columnstretch="0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QComboBox" name="switchesStartupWarning">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>ON</string>
</property>
</item>
<item>
<property name="text">
<string>OFF</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="switchesStartupWarning_Label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Check</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_37" columnstretch="0,0,0,0,0,0">
<item row="0" column="3">
@@ -288,6 +239,29 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="displayText">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Display Checklist</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="1">
@@ -353,6 +327,22 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
</item>
</layout>
</item>
<item row="5" column="1">
<layout class="QGridLayout" name="switchesStartupLayout" rowstretch="0" columnstretch="0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
</layout>
</item>
</layout>
</item>
<item>