1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

OP-1674 Add frequency display and limiting values - Allow channel 250.

This commit is contained in:
Laurent Lalanne 2015-01-11 19:39:53 +01:00
parent c8c3a46735
commit ada09a8aaa
3 changed files with 143 additions and 45 deletions

View File

@ -97,6 +97,11 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget
// Connect the selection changed signals.
connect(m_oplink->PPMOnly, SIGNAL(toggled(bool)), this, SLOT(ppmOnlyChanged()));
connect(m_oplink->MinimumChannel, SIGNAL(valueChanged(int)), this, SLOT(minChannelChanged()));
connect(m_oplink->MaximumChannel, SIGNAL(valueChanged(int)), this, SLOT(maxChannelChanged()));
m_oplink->MinimumChannel->setKeyboardTracking(false);
m_oplink->MaximumChannel->setKeyboardTracking(false);
// Request and update of the setting object.
settingsUpdated = false;
@ -318,6 +323,52 @@ void ConfigPipXtremeWidget::ppmOnlyChanged()
m_oplink->ComSpeed->setEnabled(!is_ppm_only);
}
void ConfigPipXtremeWidget::minChannelChanged()
{
ChannelChanged(false);
}
void ConfigPipXtremeWidget::maxChannelChanged()
{
ChannelChanged(true);
}
void ConfigPipXtremeWidget::ChannelChanged(bool isMax)
{
int minChannel = m_oplink->MinimumChannel->value();
int maxChannel = m_oplink->MaximumChannel->value();
int minimalChannelRange = 10;
if ((maxChannel - minChannel) < minimalChannelRange) {
if (isMax) {
minChannel = maxChannel - minimalChannelRange;
} else {
maxChannel = minChannel + minimalChannelRange;
}
if (maxChannel > 250) {
maxChannel = 250;
minChannel = 250 - minimalChannelRange;
}
if (minChannel < 0) {
minChannel = 0;
maxChannel = minimalChannelRange;
}
}
m_oplink->MaximumChannel->setValue(maxChannel);
m_oplink->MinimumChannel->setValue(minChannel);
// Calculate and Display frequency in Mhz
float minFrequency = 430 + (minChannel * 0.040);
float maxFrequency = 430 + (maxChannel * 0.040);
m_oplink->MinFreq->setText(QString::number(minFrequency, 'f', 3) + "Mhz");
m_oplink->MaxFreq->setText(QString::number(maxFrequency, 'f', 3) + "Mhz");
}
/**
@}
@}

View File

@ -62,6 +62,9 @@ private slots:
void disconnected();
void bind();
void ppmOnlyChanged();
void minChannelChanged();
void maxChannelChanged();
void ChannelChanged(bool isMax);
};
#endif // CONFIGTXPIDWIDGET_H

View File

@ -49,8 +49,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>810</width>
<height>575</height>
<width>835</width>
<height>545</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
@ -72,14 +72,14 @@
<string>Configuration</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="3">
<item row="4" column="4">
<widget class="QComboBox" name="ComSpeed">
<property name="statusTip">
<string>Com speed in bps.</string>
</property>
</widget>
</item>
<item row="4" column="2">
<item row="4" column="3">
<widget class="QLabel" name="ComSpeedLabel">
<property name="font">
<font>
@ -95,7 +95,7 @@
</property>
</widget>
</item>
<item row="9" column="2">
<item row="9" column="3">
<widget class="QLabel" name="VCPPortLabel">
<property name="font">
<font>
@ -111,7 +111,7 @@
</property>
</widget>
</item>
<item row="7" column="3">
<item row="7" column="4">
<widget class="QComboBox" name="FlexiPort">
<property name="maximumSize">
<size>
@ -124,7 +124,7 @@
</property>
</widget>
</item>
<item row="6" column="2">
<item row="6" column="3">
<widget class="QLabel" name="MainPortLabel">
<property name="font">
<font>
@ -140,7 +140,7 @@
</property>
</widget>
</item>
<item row="6" column="3">
<item row="6" column="4">
<widget class="QComboBox" name="MainPort">
<property name="maximumSize">
<size>
@ -153,7 +153,20 @@
</property>
</widget>
</item>
<item row="0" column="3">
<item row="9" column="4">
<widget class="QComboBox" name="VCPPort">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Choose the function for the USB virtual com port</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QComboBox" name="MaxRFTxPower">
<property name="maximumSize">
<size>
@ -172,7 +185,7 @@
</property>
</widget>
</item>
<item row="0" column="2">
<item row="0" column="3">
<widget class="QLabel" name="MaxRFTxPowerLabel">
<property name="font">
<font>
@ -188,20 +201,10 @@
</property>
</widget>
</item>
<item row="9" column="3">
<widget class="QComboBox" name="VCPPort">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Choose the function for the USB virtual com port</string>
</property>
</widget>
<item row="10" column="4">
<widget class="QComboBox" name="FlexiIOPort"/>
</item>
<item row="10" column="2">
<item row="10" column="3">
<widget class="QLabel" name="FlexiIOPortLabel">
<property name="font">
<font>
@ -217,10 +220,29 @@
</property>
</widget>
</item>
<item row="10" column="3">
<widget class="QComboBox" name="FlexiIOPort"/>
<item row="6" column="1">
<widget class="QSpinBox" name="MaximumChannel">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="toolTip">
<string>Channel 0 is 430 MHz, channel 250 is 440 MHz, and the channel spacing is 40 KHz.</string>
</property>
<property name="maximum">
<number>250</number>
</property>
</widget>
</item>
<item row="7" column="2">
<item row="7" column="3">
<widget class="QLabel" name="FlexiPortLabel">
<property name="font">
<font>
@ -252,22 +274,6 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="MaximumChannel">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="toolTip">
<string>Channel 0 is 430 MHz, channel 249 is 440 MHz, and the channel spacing is 40 KHz.</string>
</property>
<property name="maximum">
<number>249</number>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="MinimumChannelLabel">
<property name="font">
@ -286,6 +292,12 @@
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="MinimumChannel">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>50</weight>
@ -293,10 +305,10 @@
</font>
</property>
<property name="toolTip">
<string>Channel 0 is 430 MHz, channel 249 is 440 MHz, and the channel spacing is 40 KHz.</string>
<string>Channel 0 is 430 MHz, channel 250 is 440 MHz, and the channel spacing is 40 KHz.</string>
</property>
<property name="maximum">
<number>249</number>
<number>250</number>
</property>
</widget>
</item>
@ -318,6 +330,12 @@
</item>
<item row="9" column="1">
<widget class="QSpinBox" name="ChannelSet">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>50</weight>
@ -328,7 +346,7 @@
<string>Sets the random sequence of channels to use for frequency hopping.</string>
</property>
<property name="maximum">
<number>249</number>
<number>250</number>
</property>
</widget>
</item>
@ -396,6 +414,32 @@
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="MaxFreq">
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>440.000Mhz</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="MinFreq">
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>430.000Mhz</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>