From ada09a8aaa0a5e79fc5467b26ba6d30f49e24a95 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 11 Jan 2015 19:39:53 +0100 Subject: [PATCH 1/4] OP-1674 Add frequency display and limiting values - Allow channel 250. --- .../plugins/config/configpipxtremewidget.cpp | 51 +++++++ .../plugins/config/configpipxtremewidget.h | 3 + .../src/plugins/config/pipxtreme.ui | 134 ++++++++++++------ 3 files changed, 143 insertions(+), 45 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp index 6595b6366..60073eb7a 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp @@ -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"); +} + /** @} @} diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h index 986f7c7bd..1d38183e1 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h @@ -62,6 +62,9 @@ private slots: void disconnected(); void bind(); void ppmOnlyChanged(); + void minChannelChanged(); + void maxChannelChanged(); + void ChannelChanged(bool isMax); }; #endif // CONFIGTXPIDWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui index baa3482c2..e9393331f 100644 --- a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui +++ b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui @@ -49,8 +49,8 @@ 0 0 - 810 - 575 + 835 + 545 @@ -72,14 +72,14 @@ Configuration - + Com speed in bps. - + @@ -95,7 +95,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -124,7 +124,7 @@ - + @@ -140,7 +140,7 @@ - + @@ -153,7 +153,20 @@ - + + + + + 16777215 + 16777215 + + + + Choose the function for the USB virtual com port + + + + @@ -172,7 +185,7 @@ - + @@ -188,20 +201,10 @@ - - - - - 16777215 - 16777215 - - - - Choose the function for the USB virtual com port - - + + - + @@ -217,10 +220,29 @@ - - + + + + + 60 + 16777215 + + + + + 50 + false + + + + Channel 0 is 430 MHz, channel 250 is 440 MHz, and the channel spacing is 40 KHz. + + + 250 + + - + @@ -252,22 +274,6 @@ - - - - - 50 - false - - - - Channel 0 is 430 MHz, channel 249 is 440 MHz, and the channel spacing is 40 KHz. - - - 249 - - - @@ -286,6 +292,12 @@ + + + 60 + 16777215 + + 50 @@ -293,10 +305,10 @@ - Channel 0 is 430 MHz, channel 249 is 440 MHz, and the channel spacing is 40 KHz. + Channel 0 is 430 MHz, channel 250 is 440 MHz, and the channel spacing is 40 KHz. - 249 + 250 @@ -318,6 +330,12 @@ + + + 60 + 16777215 + + 50 @@ -328,7 +346,7 @@ Sets the random sequence of channels to use for frequency hopping. - 249 + 250 @@ -396,6 +414,32 @@ + + + + + 105 + 16777215 + + + + 440.000Mhz + + + + + + + + 105 + 16777215 + + + + 430.000Mhz + + + From 4c27a78072796de17cfce0d005b31457312862bd Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Mon, 12 Jan 2015 12:57:01 +0100 Subject: [PATCH 2/4] OP-1674 Allow channel 250 --- flight/pios/common/pios_rfm22b.c | 6 +++--- flight/pios/inc/pios_rfm22b_priv.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flight/pios/common/pios_rfm22b.c b/flight/pios/common/pios_rfm22b.c index 203fe1179..aa6525f8b 100644 --- a/flight/pios/common/pios_rfm22b.c +++ b/flight/pios/common/pios_rfm22b.c @@ -167,7 +167,7 @@ static const uint8_t channel_list[] = { 217, 27, 87, 122, 125, 135, 148, 178, 71, 206, 57, 141, 35, 30, 246, 159, 16, 32, 15, 229, 20, 12, 223, 150, 101, 79, 56, 102, 111, 174, 236, 137, 143, 52, 225, 64, 224, 112, 168, 243, 130, 108, 202, 123, 146, 228, 75, 46, 153, 7, 192, 175, 151, 222, 59, 82, 90, 1, 65, 109, 44, 165, 84, 43, 36, 128, 196, 67, 80, - 136, 86, 70, 234, 66, 185, 10, 164, 177, 116, 50, 107, 183, 215, 212, 60, 227, 133, 120, 14 + 136, 86, 70, 234, 66, 185, 10, 164, 177, 116, 50, 107, 183, 215, 212, 60, 227, 133, 120, 14, 250 }; /* Local function forwared declarations */ @@ -558,7 +558,7 @@ void PIOS_RFM22B_SetTxPower(uint32_t rfm22b_id, enum rfm22b_tx_power tx_pwr) /** * Sets the range and number of channels to use for the radio. - * The channels are 0 to 255 divided across the 430-440 MHz range. + * The channels are 0 to 250 divided across the 430-440 MHz range. * The number of channels configured will be spread across the selected channel range. * The channel spacing is 10MHz / 250 = 40kHz * @@ -1618,7 +1618,7 @@ static void rfm22_setNominalCarrierFrequency(struct pios_rfm22b_dev *rfm22b_dev, { // Set the frequency channels to start at 430MHz uint32_t frequency_hz = RFM22B_NOMINAL_CARRIER_FREQUENCY; - // The step size is 10MHz / 250 channels = 40khz, and the step size is specified in 10khz increments. + // The step size is 10MHz / 250 = 40khz, and the step size is specified in 10khz increments. uint8_t freq_hop_step_size = 4; // holds the hbsel (1 or 2) diff --git a/flight/pios/inc/pios_rfm22b_priv.h b/flight/pios/inc/pios_rfm22b_priv.h index bacc2dcda..4ad3c816d 100644 --- a/flight/pios/inc/pios_rfm22b_priv.h +++ b/flight/pios/inc/pios_rfm22b_priv.h @@ -40,7 +40,7 @@ // ************************************ #define RFM22B_MAX_PACKET_LEN 64 -#define RFM22B_NUM_CHANNELS 250 +#define RFM22B_NUM_CHANNELS 251 // 0 (432Mhz) to 250 (440Mhz) = 251 channels // ************************************ From c506fc93d6da7359237d868cd01484e77b248578 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 22 Jan 2015 19:49:06 +0100 Subject: [PATCH 3/4] OP-1674 Revert changes from previous commit in flight side, keep comments changes --- flight/pios/common/pios_rfm22b.c | 2 +- flight/pios/inc/pios_rfm22b_priv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flight/pios/common/pios_rfm22b.c b/flight/pios/common/pios_rfm22b.c index aa6525f8b..4aed541ed 100644 --- a/flight/pios/common/pios_rfm22b.c +++ b/flight/pios/common/pios_rfm22b.c @@ -167,7 +167,7 @@ static const uint8_t channel_list[] = { 217, 27, 87, 122, 125, 135, 148, 178, 71, 206, 57, 141, 35, 30, 246, 159, 16, 32, 15, 229, 20, 12, 223, 150, 101, 79, 56, 102, 111, 174, 236, 137, 143, 52, 225, 64, 224, 112, 168, 243, 130, 108, 202, 123, 146, 228, 75, 46, 153, 7, 192, 175, 151, 222, 59, 82, 90, 1, 65, 109, 44, 165, 84, 43, 36, 128, 196, 67, 80, - 136, 86, 70, 234, 66, 185, 10, 164, 177, 116, 50, 107, 183, 215, 212, 60, 227, 133, 120, 14, 250 + 136, 86, 70, 234, 66, 185, 10, 164, 177, 116, 50, 107, 183, 215, 212, 60, 227, 133, 120, 14 }; /* Local function forwared declarations */ diff --git a/flight/pios/inc/pios_rfm22b_priv.h b/flight/pios/inc/pios_rfm22b_priv.h index 4ad3c816d..bacc2dcda 100644 --- a/flight/pios/inc/pios_rfm22b_priv.h +++ b/flight/pios/inc/pios_rfm22b_priv.h @@ -40,7 +40,7 @@ // ************************************ #define RFM22B_MAX_PACKET_LEN 64 -#define RFM22B_NUM_CHANNELS 251 // 0 (432Mhz) to 250 (440Mhz) = 251 channels +#define RFM22B_NUM_CHANNELS 250 // ************************************ From 8f0c0407fb8e60d8c5538b85783d461e0a23b820 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 22 Jan 2015 23:56:20 +0100 Subject: [PATCH 4/4] OP-1674 Changes from review : added constants and set limits - UI changes, Freq close to channel number. --- .../plugins/config/configpipxtremewidget.cpp | 41 ++++--- .../plugins/config/configpipxtremewidget.h | 2 +- .../src/plugins/config/pipxtreme.ui | 113 +++++++++--------- 3 files changed, 83 insertions(+), 73 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp index 60073eb7a..684f32b78 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp @@ -32,6 +32,12 @@ #include #include +// Channel range and Frequency display +static const int MAX_CHANNEL_NUM = 250; +static const int MIN_CHANNEL_RANGE = 10; +static const float FIRST_FREQUENCY = 430.000; +static const float FREQUENCY_STEP = 0.040; + ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget(parent) { m_oplink = new Ui_OPLinkWidget(); @@ -103,6 +109,9 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget m_oplink->MinimumChannel->setKeyboardTracking(false); m_oplink->MaximumChannel->setKeyboardTracking(false); + m_oplink->MaximumChannel->setMaximum(MAX_CHANNEL_NUM); + m_oplink->MinimumChannel->setMaximum(MAX_CHANNEL_NUM - MIN_CHANNEL_RANGE); + // Request and update of the setting object. settingsUpdated = false; autoLoadWidgets(); @@ -325,48 +334,46 @@ void ConfigPipXtremeWidget::ppmOnlyChanged() void ConfigPipXtremeWidget::minChannelChanged() { - ChannelChanged(false); + channelChanged(false); } void ConfigPipXtremeWidget::maxChannelChanged() { - ChannelChanged(true); + channelChanged(true); } -void ConfigPipXtremeWidget::ChannelChanged(bool isMax) +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 ((maxChannel - minChannel) < MIN_CHANNEL_RANGE) { if (isMax) { - minChannel = maxChannel - minimalChannelRange; + minChannel = maxChannel - MIN_CHANNEL_RANGE; } else { - maxChannel = minChannel + minimalChannelRange; + maxChannel = minChannel + MIN_CHANNEL_RANGE; } - if (maxChannel > 250) { - maxChannel = 250; - minChannel = 250 - minimalChannelRange; + if (maxChannel > MAX_CHANNEL_NUM) { + maxChannel = MAX_CHANNEL_NUM; + minChannel = MAX_CHANNEL_NUM - MIN_CHANNEL_RANGE; } if (minChannel < 0) { minChannel = 0; - maxChannel = minimalChannelRange; + maxChannel = MIN_CHANNEL_RANGE; } } 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); + // Calculate and Display frequency in MHz + float minFrequency = FIRST_FREQUENCY + (minChannel * FREQUENCY_STEP); + float maxFrequency = FIRST_FREQUENCY + (maxChannel * FREQUENCY_STEP); - m_oplink->MinFreq->setText(QString::number(minFrequency, 'f', 3) + "Mhz"); - m_oplink->MaxFreq->setText(QString::number(maxFrequency, 'f', 3) + "Mhz"); + m_oplink->MinFreq->setText("(" + QString::number(minFrequency, 'f', 3) + " MHz)"); + m_oplink->MaxFreq->setText("(" + QString::number(maxFrequency, 'f', 3) + " MHz)"); } /** diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h index 1d38183e1..bd2ebd0bf 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.h @@ -64,7 +64,7 @@ private slots: void ppmOnlyChanged(); void minChannelChanged(); void maxChannelChanged(); - void ChannelChanged(bool isMax); + void channelChanged(bool isMax); }; #endif // CONFIGTXPIDWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui index e9393331f..9cbe0265c 100644 --- a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui +++ b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui @@ -6,7 +6,7 @@ 0 0 - 834 + 971 652 @@ -49,8 +49,8 @@ 0 0 - 835 - 545 + 949 + 558 @@ -350,54 +350,6 @@ - - - - - 50 - false - - - - Only PPM packets will be transmitted. - - - PPM Only - - - - - - - - 50 - false - - - - If selected, data will only be transmitted from the coordinator to the Rx modem. - - - One-Way - - - - - - - - 50 - false - - - - PPM packets will be received by this modem. Must be selected if Coordinator modem is configured for PPM. - - - PPM - - - @@ -418,12 +370,12 @@ - 105 + 110 16777215 - 440.000Mhz + 440.000 (MHz) @@ -431,12 +383,63 @@ - 105 + 110 16777215 - 430.000Mhz + 430.000 (MHz) + + + + + + + + 50 + false + + + + false + + + If selected, data will only be transmitted from the coordinator to the Rx modem. + + + One-Way + + + + + + + + 50 + false + + + + Only PPM packets will be transmitted. + + + PPM Only + + + + + + + + 50 + false + + + + PPM packets will be received by this modem. Must be selected if Coordinator modem is configured for PPM. + + + PPM