Pot warning UI in companion
This commit is contained in:
@@ -1053,7 +1053,6 @@ enum Capability {
|
||||
LCDWidth,
|
||||
GetThrSwitch,
|
||||
HasDisplayText,
|
||||
PotWarnings,
|
||||
VirtualInputs,
|
||||
LuaInputs,
|
||||
LimitsPer1000,
|
||||
|
||||
@@ -1970,7 +1970,7 @@ 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++) {
|
||||
for (int i=0; i < GetEepromInterface()->getCapability(Pots); i++) {
|
||||
internalField.Append(new SignedField<8>(modelData.potPosition[i]));
|
||||
}
|
||||
}
|
||||
@@ -1988,7 +1988,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
|
||||
internalField.Append(new ZCharField<4>(modelData.inputNames[i]));
|
||||
internalField.Append(new UnsignedField<8>(modelData.nSwToWarn));
|
||||
internalField.Append(new UnsignedField<8>(modelData.nPotsToWarn));
|
||||
for (int i=0; i < GetEepromInterface()->getCapability(PotWarnings); i++) {
|
||||
for (int i=0; i < GetEepromInterface()->getCapability(Pots); i++) {
|
||||
internalField.Append(new SignedField<8>(modelData.potPosition[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,8 +671,6 @@ 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:
|
||||
return IS_TARANIS(board) ? 32 : 0;
|
||||
|
||||
@@ -409,13 +409,12 @@ Setup::Setup(QWidget *parent, ModelData & model):
|
||||
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
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) {
|
||||
QLabel * label = new QLabel();
|
||||
QSlider * slider = new QSlider();
|
||||
QCheckBox * cb = new QCheckBox();
|
||||
QLabel * label = new QLabel(this);
|
||||
QSlider * slider = new QSlider(this);
|
||||
QCheckBox * cb = new QCheckBox(this);
|
||||
slider->setProperty("index", i+1);
|
||||
slider->setOrientation(Qt::Vertical);
|
||||
slider->setMinimum(0);
|
||||
@@ -441,13 +440,28 @@ Setup::Setup(QWidget *parent, ModelData & model):
|
||||
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)));
|
||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(on_startupSwitchEdited(int)));
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(on_startupSwitchToggled(bool)));
|
||||
startupSwitchesSliders << slider;
|
||||
startupSwitchesCheckboxes << cb;
|
||||
}
|
||||
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, GetEepromInterface()->getCapability(Switches));
|
||||
|
||||
// Pot warnings
|
||||
if(IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(Pots); i++) {
|
||||
QCheckBox * cb = new QCheckBox(this);
|
||||
cb->setProperty("index", i+1);
|
||||
cb->setText(AnalogString(i+4));
|
||||
ui->potWarningLayout->addWidget(cb, 0, i+1);
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(on_potWarningToggled(bool)));
|
||||
potWarningCheckboxes << cb;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui->label_potWarning->hide();
|
||||
ui->potWarningMode->hide();
|
||||
}
|
||||
lock = false;
|
||||
}
|
||||
|
||||
@@ -549,6 +563,7 @@ void Setup::update()
|
||||
|
||||
updateBeepCenter();
|
||||
updateStartupSwitches();
|
||||
updatePotWarnings();
|
||||
|
||||
for (int i=0; i<C9X_MAX_TIMERS; i++)
|
||||
timers[i]->update();
|
||||
@@ -591,7 +606,7 @@ void Setup::updateStartupSwitches()
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void Setup::startupSwitchEdited(int value)
|
||||
void Setup::on_startupSwitchEdited(int value)
|
||||
{
|
||||
if (!lock) {
|
||||
int shift = 0;
|
||||
@@ -635,16 +650,61 @@ void Setup::startupSwitchEdited(int value)
|
||||
}
|
||||
}
|
||||
|
||||
void Setup::startupSwitchToggled(bool checked)
|
||||
void Setup::on_startupSwitchToggled(bool checked)
|
||||
{
|
||||
int index = sender()->property("index").toInt()-1;
|
||||
if (!lock) {
|
||||
int index = sender()->property("index").toInt()-1;
|
||||
|
||||
if (checked)
|
||||
model.nSwToWarn &= ~(1 << index);
|
||||
else
|
||||
model.nSwToWarn |= (1 << index);
|
||||
if (checked)
|
||||
model.nSwToWarn &= ~(1 << index);
|
||||
else
|
||||
model.nSwToWarn |= (1 << index);
|
||||
|
||||
updateStartupSwitches();
|
||||
updateStartupSwitches();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void Setup::updatePotWarnings()
|
||||
{
|
||||
lock = true;
|
||||
int mode = model.nPotsToWarn >> 6;
|
||||
ui->potWarningMode->setCurrentIndex(mode);
|
||||
|
||||
if (mode == 0)
|
||||
model.nPotsToWarn = 0x3F;
|
||||
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(Pots); i++) {
|
||||
bool enabled = !(model.nPotsToWarn & (1 << i));
|
||||
|
||||
potWarningCheckboxes[i]->setChecked(enabled);
|
||||
potWarningCheckboxes[i]->setDisabled(mode == 0);
|
||||
}
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void Setup::on_potWarningToggled(bool checked)
|
||||
{
|
||||
if (!lock) {
|
||||
int index = sender()->property("index").toInt()-1;
|
||||
|
||||
if(checked)
|
||||
model.nPotsToWarn &= ~(1 << index);
|
||||
else
|
||||
model.nPotsToWarn |= (1 << index);
|
||||
|
||||
updatePotWarnings();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void Setup::on_potWarningMode_currentIndexChanged(int index)
|
||||
{
|
||||
int mask = 0xC0;
|
||||
model.nPotsToWarn = model.nPotsToWarn & ~mask;
|
||||
model.nPotsToWarn = model.nPotsToWarn | ((index << 6) & mask);
|
||||
|
||||
updatePotWarnings();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QCheckBox>
|
||||
#include <QSlider>
|
||||
#include <QSpinBox>
|
||||
#include <QLabel>
|
||||
|
||||
namespace Ui {
|
||||
class Setup;
|
||||
@@ -87,18 +88,22 @@ class Setup : public ModelPanel
|
||||
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 on_startupSwitchEdited(int value);
|
||||
void on_startupSwitchToggled(bool checked);
|
||||
void on_potWarningToggled(bool checked);
|
||||
void on_potWarningMode_currentIndexChanged(int index);
|
||||
void onChildModified();
|
||||
|
||||
private:
|
||||
Ui::Setup *ui;
|
||||
QVector<QSlider *> startupSwitchesSliders;
|
||||
QVector<QCheckBox *> startupSwitchesCheckboxes;
|
||||
QVector<QCheckBox *> potWarningCheckboxes;
|
||||
QVector<QCheckBox *> centerBeepCheckboxes;
|
||||
ModulePanel * modules[C9X_NUM_MODULES+1];
|
||||
TimerPanel * timers[C9X_MAX_TIMERS];
|
||||
void updateStartupSwitches();
|
||||
void updatePotWarnings();
|
||||
void updateBeepCenter();
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>782</width>
|
||||
<height>334</height>
|
||||
<width>787</width>
|
||||
<height>727</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -16,85 +16,6 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Model Name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_timer2">
|
||||
<property name="text">
|
||||
<string>Timer2</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Timer1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_ttrace">
|
||||
<property name="text">
|
||||
<string>Throttle Source</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="swwarn_label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Switch Warnings</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Center beep</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<layout class="QGridLayout" name="centerBeepLayout"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Trim Increment</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_37" columnstretch="0,0,0,0,0,0">
|
||||
<item row="0" column="3">
|
||||
@@ -182,6 +103,85 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Model Name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_timer2">
|
||||
<property name="text">
|
||||
<string>Timer2</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Timer1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_ttrace">
|
||||
<property name="text">
|
||||
<string>Throttle Source</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="swwarn_label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Switch Warnings</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Center beep</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QGridLayout" name="centerBeepLayout"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Trim Increment</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
@@ -343,6 +343,42 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_potWarning">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pot Warnings</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<layout class="QGridLayout" name="potWarningLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="potWarningMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Manual</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Auto</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user