diff --git a/doc/img/FreqDisplay_plugin.png b/doc/img/FreqDisplay_plugin.png index ca8b18db9..723da67da 100644 Binary files a/doc/img/FreqDisplay_plugin.png and b/doc/img/FreqDisplay_plugin.png differ diff --git a/plugins/feature/freqdisplay/freqdisplaygui.cpp b/plugins/feature/freqdisplay/freqdisplaygui.cpp index d5e5e4850..40be5ae3a 100644 --- a/plugins/feature/freqdisplay/freqdisplaygui.cpp +++ b/plugins/feature/freqdisplay/freqdisplaygui.cpp @@ -269,6 +269,7 @@ void FreqDisplayGUI::displaySettings() } ui->displayMode->setCurrentIndex(static_cast(m_settings.m_displayMode)); ui->speech->setChecked(m_settings.m_speechEnabled); + ui->activeOnly->setChecked(m_settings.m_activeOnly); ui->transparentBackground->setChecked(m_settings.m_transparentBackground); ui->frequencyUnits->setCurrentIndex(static_cast(m_settings.m_frequencyUnits)); ui->showUnits->setChecked(m_settings.m_showUnits); @@ -471,6 +472,22 @@ void FreqDisplayGUI::updateFrequencyText() const auto& selectedChannel = m_availableChannels.at(channelListIndex); const FreqDisplaySettings::DisplayMode mode = m_settings.m_displayMode; + if (m_settings.m_activeOnly) + { + // Only display frequency if channel is unmuted and squelch open + // If not, we clear the frequency display + int squelchValue; + int audioMuteValue; + bool hasSquelch = ChannelWebAPIUtils::getChannelReportValue(selectedChannel.m_superIndex, selectedChannel.m_index, "squelch", squelchValue); + bool hasAudioMute = ChannelWebAPIUtils::getChannelSetting(selectedChannel.m_superIndex, selectedChannel.m_index, "audioMute", audioMuteValue); + if ((hasSquelch && !squelchValue) || (hasAudioMute && audioMuteValue)) + { + setLabelText(tr("")); + updateFrequencyFont(); + return; + } + } + // --- Frequency --- QString freqText; if (mode == FreqDisplaySettings::Frequency || mode == FreqDisplaySettings::Both) @@ -484,11 +501,9 @@ void FreqDisplayGUI::updateFrequencyText() updateFrequencyFont(); return; } - if (!ChannelWebAPIUtils::getFrequencyOffset(selectedChannel.m_superIndex, selectedChannel.m_index, offsetHz)) - { - setLabelText(tr("Offset unavailable")); - updateFrequencyFont(); - return; + // Not all channels have an offset + if (!ChannelWebAPIUtils::getFrequencyOffset(selectedChannel.m_superIndex, selectedChannel.m_index, offsetHz)) { + offsetHz = 0; } const qint64 absoluteFrequency = qRound64(centerFrequencyHz) + static_cast(offsetHz); @@ -864,6 +879,12 @@ QString FreqDisplayGUI::formatFrequency(qint64 frequencyHz) const } } +void FreqDisplayGUI::on_activeOnly_toggled(bool checked) +{ + m_settings.m_activeOnly = checked; + applySetting("activeOnly"); +} + void FreqDisplayGUI::on_transparentBackground_toggled(bool checked) { m_settings.m_transparentBackground = checked; @@ -920,6 +941,7 @@ void FreqDisplayGUI::makeUIConnections() connect(ui->displayMode, qOverload(&QComboBox::currentIndexChanged), this, &FreqDisplayGUI::on_displayMode_currentIndexChanged); connect(ui->speech, &ButtonSwitch::toggled, this, &FreqDisplayGUI::on_speech_toggled); connect(ui->fontFamily, &QFontComboBox::currentFontChanged, this, &FreqDisplayGUI::on_fontFamily_currentFontChanged); + connect(ui->activeOnly, &ButtonSwitch::toggled, this, &FreqDisplayGUI::on_activeOnly_toggled); connect(ui->transparentBackground, &ButtonSwitch::toggled, this, &FreqDisplayGUI::on_transparentBackground_toggled); connect(ui->frequencyUnits, qOverload(&QComboBox::currentIndexChanged), this, &FreqDisplayGUI::on_frequencyUnits_currentIndexChanged); connect(ui->showUnits, &ButtonSwitch::toggled, this, &FreqDisplayGUI::on_showUnits_toggled); diff --git a/plugins/feature/freqdisplay/freqdisplaygui.h b/plugins/feature/freqdisplay/freqdisplaygui.h index dcc2f7ed2..b1f82c35e 100644 --- a/plugins/feature/freqdisplay/freqdisplaygui.h +++ b/plugins/feature/freqdisplay/freqdisplaygui.h @@ -127,8 +127,8 @@ private: static QString textForSpeech(const QString& displayText); #endif - static constexpr const char* m_rxTxChannelKinds = "RT"; - static constexpr int m_pollIntervalMs = 1000; + static constexpr const char* m_rxTxChannelKinds = "RTM"; + static constexpr int m_pollIntervalMs = 250; static constexpr int m_minimumFrequencyFontPointSize = 10; /// Reference point size used when probing text metrics in updateFrequencyFont(). /// Large enough that integer rounding in QFontMetrics is negligible. @@ -170,6 +170,7 @@ private slots: void on_displayMode_currentIndexChanged(int index); void on_speech_toggled(bool checked); void on_fontFamily_currentFontChanged(const QFont& font); + void on_activeOnly_toggled(bool checked); void on_transparentBackground_toggled(bool checked); void on_frequencyUnits_currentIndexChanged(int index); void on_showUnits_toggled(bool checked); diff --git a/plugins/feature/freqdisplay/freqdisplaygui.ui b/plugins/feature/freqdisplay/freqdisplaygui.ui index 94c880f2a..c686d71ce 100644 --- a/plugins/feature/freqdisplay/freqdisplaygui.ui +++ b/plugins/feature/freqdisplay/freqdisplaygui.ui @@ -107,6 +107,16 @@ + + + + When checked, display frequency / power only when channel is active (unmuted and squelch open) + + + A + + + diff --git a/plugins/feature/freqdisplay/freqdisplaysettings.cpp b/plugins/feature/freqdisplay/freqdisplaysettings.cpp index 4331d178e..0083c415a 100644 --- a/plugins/feature/freqdisplay/freqdisplaysettings.cpp +++ b/plugins/feature/freqdisplay/freqdisplaysettings.cpp @@ -52,6 +52,7 @@ void FreqDisplaySettings::resetToDefaults() m_reverseAPIPort = 8888; m_reverseAPIFeatureSetIndex = 0; m_reverseAPIFeatureIndex = 0; + m_activeOnly = false; } QByteArray FreqDisplaySettings::serialize() const @@ -82,6 +83,7 @@ QByteArray FreqDisplaySettings::serialize() const s.writeU32(20, m_reverseAPIPort); s.writeU32(21, m_reverseAPIFeatureSetIndex); s.writeU32(22, m_reverseAPIFeatureIndex); + s.writeBool(23, m_activeOnly); return s.final(); } @@ -144,6 +146,8 @@ bool FreqDisplaySettings::deserialize(const QByteArray& data) d.readU32(22, &utmp, 0); m_reverseAPIFeatureIndex = utmp > 99 ? 99 : utmp; + d.readBool(23, &m_activeOnly); + return true; } else @@ -218,4 +222,7 @@ void FreqDisplaySettings::applySettings(const QStringList& settingsKeys, const F if (settingsKeys.contains("reverseAPIFeatureIndex")) { m_reverseAPIFeatureIndex = settings.m_reverseAPIFeatureIndex; } + if (settingsKeys.contains("activeOnly")) { + m_activeOnly = settings.m_activeOnly; + } } diff --git a/plugins/feature/freqdisplay/freqdisplaysettings.h b/plugins/feature/freqdisplay/freqdisplaysettings.h index 95119dc24..a257dc730 100644 --- a/plugins/feature/freqdisplay/freqdisplaysettings.h +++ b/plugins/feature/freqdisplay/freqdisplaysettings.h @@ -63,6 +63,7 @@ struct FreqDisplaySettings uint16_t m_reverseAPIPort; uint16_t m_reverseAPIFeatureSetIndex; uint16_t m_reverseAPIFeatureIndex; + bool m_activeOnly; //!< Only display frequency/power for channels that are active (unmuted and squelch open) FreqDisplaySettings(); ~FreqDisplaySettings() = default; diff --git a/plugins/feature/freqdisplay/readme.md b/plugins/feature/freqdisplay/readme.md index b1759dce8..d2ca6f031 100644 --- a/plugins/feature/freqdisplay/readme.md +++ b/plugins/feature/freqdisplay/readme.md @@ -24,7 +24,13 @@ Choose the text to display: * Power - displays the selected channel's (1) power in dB. * Frequency & Power - displays the selected channel's (1) centre frequency in Hz and power in dB. -

3: T - Transparent

+

3: A - Active Only

+ +When active only is checked, the frequency / power will only be displayed for a channel if the channel is "active", which means its audio is unmuted and squelch is open. +If not active, the frequency / power text will be cleared. +When active only is unchecked, frequency / power will be displayed and spoken, regardless of the channel's audio mute or squelch. + +

4: T - Transparent

When Transparent mode is checked, only the centre frequency and/or power will be displayed with a transparent background, so it can be overlaid on other windows. @@ -34,11 +40,11 @@ so it can be overlaid on other windows. When in transparent mode, the text can be repositioning by clicking and dragging it. To exit transparent mode, right click on any of the text, and select "Exit transparent mode" from the pop-up menu. -

4: Speech

+

5: Speech

When Speech mode is checked, whenever the displayed frequency and/or power value changes, the new value will be spoken. -

5: Units

+

6: Units

Specify the units for the frequency value: @@ -47,31 +53,31 @@ Specify the units for the frequency value: * MHz * GHz -

6: U - Display Units

+

7: U - Display Units

When the U button is checked, units will be displayed and spoken. -

7: Freq DP - Frequency Decimal Places

+

8: Freq DP - Frequency Decimal Places

-Freq DP specifies the number of decimal places used to display frequency values, when the units (5) are not Hz. +Freq DP specifies the number of decimal places used to display frequency values, when the units (6) are not Hz. -

8: Power DP - Power Decimal Places

+

9: Power DP - Power Decimal Places

Power DP specifies the number of decimal places used to display power values. -

9: Font

+

10: Font

Select the font used to display frequency and power values. -

10: Font Colour

+

11: Font Colour

Select the colour for the font used to display frequency and power values. -

11: DS - Drop Shadow

+

12: DS - Drop Shadow

Check to enable a drop shadow behind the frequency and power text, which can improve readability against complex backgrounds when in transparent mode. -

12: Drop Shadow Colour

+

13: Drop Shadow Colour

Select the colour for the drop shadow used behind the frequency and power text.