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; unsigned int thrTraceSrc;
int8_t traineron; // 0 disable trainer, 1 allow trainer int8_t traineron; // 0 disable trainer, 1 allow trainer
int8_t t2throttle; // Start timer2 using throttle int8_t t2throttle; // Start timer2 using throttle
unsigned int modelId; unsigned int modelId;
unsigned int switchWarningStates; unsigned int switchWarningStates;
unsigned int nSwToWarn;
unsigned int nPotsToWarn;
int potPosition[C9X_NUM_POTS];
bool displayText;
// TODO structure // TODO structure
char gvars_names[C9X_MAX_GVARS][6+1]; char gvars_names[C9X_MAX_GVARS][6+1];
bool gvars_popups[C9X_MAX_GVARS]; bool gvars_popups[C9X_MAX_GVARS];
@@ -1008,6 +1012,8 @@ enum Capability {
CSFunc, CSFunc,
LCDWidth, LCDWidth,
GetThrSwitch, GetThrSwitch,
HasDisplayText,
PotWarnings,
VirtualInputs, VirtualInputs,
LuaInputs, LuaInputs,
LimitsPer1000, LimitsPer1000,
@@ -1856,7 +1856,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new BoolField<1>(modelData.disableThrottleWarning)); internalField.Append(new BoolField<1>(modelData.disableThrottleWarning));
if (IS_TARANIS(board) || (IS_ARM(board) && version >= 216)) if (IS_TARANIS(board) || (IS_ARM(board) && version >= 216))
internalField.Append(new SpareBitsField<1>()); internalField.Append(new BoolField<1>(modelData.displayText));
else else
internalField.Append(new BoolField<1>(modelData.moduleData[0].ppmPulsePol)); 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)); 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) { if (IS_TARANIS(board) && version < 215) {
internalField.Append(new CharField<10>(modelData.bitmap)); 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)) { if (IS_TARANIS(board)) {
for (int i=0; i<MAX_CURVES(board, version); i++) { for (int i=0; i<MAX_CURVES(board, version); i++) {
internalField.Append(new ZCharField<6>(modelData.curves[i].name)); 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>()); internalField.Append(new SpareBitsField<720>());
// TODO char inputNames[MAX_INPUTS][4]; // TODO char inputNames[MAX_INPUTS][4];
internalField.Append(new SpareBitsField<1024>()); 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) ; return (IS_TARANIS(board) ? 212 : 128) ;
case GetThrSwitch: case GetThrSwitch:
return (IS_TARANIS(board) ? DSW_SF1 : DSW_THR) ; 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 VirtualInputs:
case LuaInputs: case LuaInputs:
case LimitsPer1000: case LimitsPer1000:
+47 -16
View File
@@ -399,6 +399,10 @@ Setup::Setup(QWidget *parent, ModelData & model):
ui->imagePreview->hide(); ui->imagePreview->hide();
} }
if (!GetEepromInterface()->getCapability(HasDisplayText)) {
ui->displayText->hide();
}
// Beep Center checkboxes // Beep Center checkboxes
int analogs = 4 + GetEepromInterface()->getCapability(Pots); int analogs = 4 + GetEepromInterface()->getCapability(Pots);
for (int i=0; i<analogs+GetEepromInterface()->getCapability(RotaryEncoders); i++) { for (int i=0; i<analogs+GetEepromInterface()->getCapability(RotaryEncoders); i++) {
@@ -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)); ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, analogs+GetEepromInterface()->getCapability(RotaryEncoders));
// Startup switches warnings // 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++) { for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) {
QLabel * label = new QLabel(); QLabel * label = new QLabel();
QSlider * slider = new QSlider(); QSlider * slider = new QSlider();
QCheckBox * cb = new QCheckBox();
slider->setProperty("index", i+1); slider->setProperty("index", i+1);
slider->setOrientation(Qt::Vertical); slider->setOrientation(Qt::Vertical);
slider->setMinimum(0); slider->setMinimum(0);
@@ -435,10 +438,17 @@ Setup::Setup(QWidget *parent, ModelData & model):
label->setText(switches9X[i]); label->setText(switches9X[i]);
slider->setMaximum(i==0 ? 2 : 1); slider->setMaximum(i==0 ? 2 : 1);
} }
cb->setProperty("index", i+1);
ui->switchesStartupLayout->addWidget(label, 0, i+1); ui->switchesStartupLayout->addWidget(label, 0, i+1);
ui->switchesStartupLayout->setAlignment(label, Qt::AlignCenter);
ui->switchesStartupLayout->addWidget(slider, 1, i+1); 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(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int)));
connect(cb, SIGNAL(toggled(bool)), this, SLOT(startupSwitchToggled(bool)));
startupSwitchesSliders << slider; startupSwitchesSliders << slider;
startupSwitchesCheckboxes << cb;
} }
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, GetEepromInterface()->getCapability(Switches)); 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->throttleTrim->setChecked(model.thrTrim);
ui->extendedLimits->setChecked(model.extendedLimits); ui->extendedLimits->setChecked(model.extendedLimits);
ui->extendedTrims->setChecked(model.extendedTrims); ui->extendedTrims->setChecked(model.extendedTrims);
ui->displayText->setChecked(model.displayText);
updateBeepCenter(); updateBeepCenter();
updateStartupSwitches(); updateStartupSwitches();
@@ -563,13 +574,14 @@ void Setup::updateStartupSwitches()
lock = true; lock = true;
unsigned int switchStates = model.switchWarningStates; unsigned int switchStates = model.switchWarningStates;
bool enabled = !(switchStates & 0x01); bool enabled;
ui->switchesStartupWarning->setCurrentIndex(switchStates & 0x01);
switchStates >>= 1;
for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) { for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) {
QSlider * slider = startupSwitchesSliders[i]; QSlider * slider = startupSwitchesSliders[i];
QCheckBox * cb = startupSwitchesCheckboxes[i];
enabled = !(model.nSwToWarn & (1 << i));
slider->setEnabled(enabled); slider->setEnabled(enabled);
cb->setChecked(enabled);
if (IS_TARANIS(GetEepromInterface()->getBoard())) { if (IS_TARANIS(GetEepromInterface()->getBoard())) {
slider->setValue(i==5 ? (switchStates & 0x3)/2 : switchStates & 0x3); slider->setValue(i==5 ? (switchStates & 0x3)/2 : switchStates & 0x3);
switchStates >>= 2; switchStates >>= 2;
@@ -590,24 +602,24 @@ void Setup::startupSwitchEdited(int value)
unsigned int mask; unsigned int mask;
int index = sender()->property("index").toInt(); int index = sender()->property("index").toInt();
if (index == 0) { if (IS_TARANIS(GetEepromInterface()->getBoard())) {
mask = 0x01; if (index == 6) {
} shift = (index - 1)*2;
else if (IS_TARANIS(GetEepromInterface()->getBoard())) { mask = 0x02 << shift;
if (index == 6) shift++;
mask = 0x02 << (index*2 - 1); }
else { else {
shift = index*2 - 1; shift = (index - 1)*2;
mask = 0x03 << shift; mask = 0x03 << shift;
} }
} }
else { else {
if (index == 1) { if (index == 1) {
shift = 1; mask = 0x03;
mask = 0x03 << shift;
} }
else { else {
mask = 0x01 << (index+1); shift = index;
mask = 0x01 << shift;
} }
} }
@@ -615,7 +627,7 @@ void Setup::startupSwitchEdited(int value)
if (value) { if (value) {
if (shift == 0) { if (shift == 0) {
model.switchWarningStates |= mask; model.switchWarningStates |= value;
} }
else { else {
model.switchWarningStates |= (value << shift); 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) void Setup::on_throttleTrim_toggled(bool checked)
{ {
model.thrTrim = checked; model.thrTrim = checked;
+3
View File
@@ -83,15 +83,18 @@ class Setup : public ModelPanel
void on_extendedTrims_toggled(bool checked); void on_extendedTrims_toggled(bool checked);
void on_throttleWarning_toggled(bool checked); void on_throttleWarning_toggled(bool checked);
void on_throttleReverse_toggled(bool checked); void on_throttleReverse_toggled(bool checked);
void on_displayText_toggled(bool checked);
void on_image_currentIndexChanged(int index); void on_image_currentIndexChanged(int index);
void on_trimIncrement_currentIndexChanged(int index); void on_trimIncrement_currentIndexChanged(int index);
void onBeepCenterToggled(bool checked); void onBeepCenterToggled(bool checked);
void startupSwitchEdited(int value); void startupSwitchEdited(int value);
void startupSwitchToggled(bool checked);
void onChildModified(); void onChildModified();
private: private:
Ui::Setup *ui; Ui::Setup *ui;
QVector<QSlider *> startupSwitchesSliders; QVector<QSlider *> startupSwitchesSliders;
QVector<QCheckBox *> startupSwitchesCheckboxes;
QVector<QCheckBox *> centerBeepCheckboxes; QVector<QCheckBox *> centerBeepCheckboxes;
ModulePanel * modules[C9X_NUM_MODULES+1]; ModulePanel * modules[C9X_NUM_MODULES+1];
TimerPanel * timers[C9X_MAX_TIMERS]; TimerPanel * timers[C9X_MAX_TIMERS];
+40 -50
View File
@@ -65,7 +65,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Switch startup Warning</string> <string>Switch Warnings</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -95,55 +95,6 @@
</property> </property>
</widget> </widget>
</item> </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"> <item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_37" columnstretch="0,0,0,0,0,0"> <layout class="QGridLayout" name="gridLayout_37" columnstretch="0,0,0,0,0,0">
<item row="0" column="3"> <item row="0" column="3">
@@ -288,6 +239,29 @@
</property> </property>
</widget> </widget>
</item> </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> </layout>
</item> </item>
<item row="3" column="1"> <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> </item>
</layout> </layout>
</item> </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> </layout>
</item> </item>
<item> <item>