mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 13:00:26 -04:00 
			
		
		
		
	SoapySDR support: input GUI: implement fixed elements support
This commit is contained in:
		
							parent
							
								
									f79e6bc3ab
								
							
						
					
					
						commit
						5acac7b9fa
					
				| @ -385,7 +385,7 @@ void BladeRF2InputGui::on_transverter_clicked() | ||||
| { | ||||
|     m_settings.m_transverterMode = ui->transverter->getDeltaFrequencyAcive(); | ||||
|     m_settings.m_transverterDeltaFrequency = ui->transverter->getDeltaFrequency(); | ||||
|     qDebug("LimeSDRInputGUI::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off"); | ||||
|     qDebug("BladeRF2InputGui::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off"); | ||||
|     updateFrequencyLimits(); | ||||
|     setCenterFrequencySetting(ui->centerFrequency->getValueNew()); | ||||
|     sendSettings(); | ||||
|  | ||||
| @ -32,29 +32,67 @@ class SoapySDRInputThread; | ||||
| class SoapySDRInput : public DeviceSampleSource | ||||
| { | ||||
| public: | ||||
|     class MsgConfigureSoapySDR : public Message { | ||||
|     class MsgConfigureSoapySDRInput : public Message { | ||||
|         MESSAGE_CLASS_DECLARATION | ||||
| 
 | ||||
|     public: | ||||
|         const SoapySDRInputSettings& getSettings() const { return m_settings; } | ||||
|         bool getForce() const { return m_force; } | ||||
| 
 | ||||
|         static MsgConfigureSoapySDR* create(const SoapySDRInputSettings& settings, bool force) | ||||
|         static MsgConfigureSoapySDRInput* create(const SoapySDRInputSettings& settings, bool force) | ||||
|         { | ||||
|             return new MsgConfigureSoapySDR(settings, force); | ||||
|             return new MsgConfigureSoapySDRInput(settings, force); | ||||
|         } | ||||
| 
 | ||||
|     private: | ||||
|         SoapySDRInputSettings m_settings; | ||||
|         bool m_force; | ||||
| 
 | ||||
|         MsgConfigureSoapySDR(const SoapySDRInputSettings& settings, bool force) : | ||||
|         MsgConfigureSoapySDRInput(const SoapySDRInputSettings& settings, bool force) : | ||||
|             Message(), | ||||
|             m_settings(settings), | ||||
|             m_force(force) | ||||
|         { } | ||||
|     }; | ||||
| 
 | ||||
|     class MsgFileRecord : public Message { | ||||
|         MESSAGE_CLASS_DECLARATION | ||||
| 
 | ||||
|     public: | ||||
|         bool getStartStop() const { return m_startStop; } | ||||
| 
 | ||||
|         static MsgFileRecord* create(bool startStop) { | ||||
|             return new MsgFileRecord(startStop); | ||||
|         } | ||||
| 
 | ||||
|     protected: | ||||
|         bool m_startStop; | ||||
| 
 | ||||
|         MsgFileRecord(bool startStop) : | ||||
|             Message(), | ||||
|             m_startStop(startStop) | ||||
|         { } | ||||
|     }; | ||||
| 
 | ||||
|     class MsgStartStop : public Message { | ||||
|         MESSAGE_CLASS_DECLARATION | ||||
| 
 | ||||
|     public: | ||||
|         bool getStartStop() const { return m_startStop; } | ||||
| 
 | ||||
|         static MsgStartStop* create(bool startStop) { | ||||
|             return new MsgStartStop(startStop); | ||||
|         } | ||||
| 
 | ||||
|     protected: | ||||
|         bool m_startStop; | ||||
| 
 | ||||
|         MsgStartStop(bool startStop) : | ||||
|             Message(), | ||||
|             m_startStop(startStop) | ||||
|         { } | ||||
|     }; | ||||
| 
 | ||||
|     SoapySDRInput(DeviceSourceAPI *deviceAPI); | ||||
|     virtual ~SoapySDRInput(); | ||||
|     virtual void destroy(); | ||||
|  | ||||
| @ -14,11 +14,14 @@ | ||||
| // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | ||||
| ///////////////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| #include <QMessageBox> | ||||
| 
 | ||||
| #include "dsp/dspengine.h" | ||||
| #include "dsp/dspcommands.h" | ||||
| #include "device/devicesourceapi.h" | ||||
| #include "device/deviceuiset.h" | ||||
| #include "util/simpleserializer.h" | ||||
| #include "gui/glspectrum.h" | ||||
| 
 | ||||
| #include "ui_soapysdrinputgui.h" | ||||
| #include "discreterangegui.h" | ||||
| @ -174,3 +177,175 @@ void SoapySDRInputGui::sampleRateChanged(double sampleRate) | ||||
| { | ||||
|     qDebug("SoapySDRInputGui::sampleRateChanged: %lf", sampleRate); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::on_centerFrequency_changed(quint64 value) | ||||
| { | ||||
|     qDebug("SoapySDRInputGui::on_centerFrequency_changed: %llu", value); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::on_dcOffset_toggled(bool checked) | ||||
| { | ||||
|     m_settings.m_dcBlock = checked; | ||||
|     sendSettings(); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::on_iqImbalance_toggled(bool checked) | ||||
| { | ||||
|     m_settings.m_iqCorrection = checked; | ||||
|     sendSettings(); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::on_decim_currentIndexChanged(int index) | ||||
| { | ||||
|     if ((index <0) || (index > 6)) | ||||
|         return; | ||||
|     m_settings.m_log2Decim = index; | ||||
|     sendSettings(); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::on_fcPos_currentIndexChanged(int index) | ||||
| { | ||||
|     if (index == 0) { | ||||
|         m_settings.m_fcPos = SoapySDRInputSettings::FC_POS_INFRA; | ||||
|         sendSettings(); | ||||
|     } else if (index == 1) { | ||||
|         m_settings.m_fcPos = SoapySDRInputSettings::FC_POS_SUPRA; | ||||
|         sendSettings(); | ||||
|     } else if (index == 2) { | ||||
|         m_settings.m_fcPos = SoapySDRInputSettings::FC_POS_CENTER; | ||||
|         sendSettings(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::on_transverter_clicked() | ||||
| { | ||||
|     m_settings.m_transverterMode = ui->transverter->getDeltaFrequencyAcive(); | ||||
|     m_settings.m_transverterDeltaFrequency = ui->transverter->getDeltaFrequency(); | ||||
|     qDebug("SoapySDRInputGui::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off"); | ||||
|     updateFrequencyLimits(); | ||||
|     setCenterFrequencySetting(ui->centerFrequency->getValueNew()); | ||||
|     sendSettings(); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::on_startStop_toggled(bool checked) | ||||
| { | ||||
|     if (m_doApplySettings) | ||||
|     { | ||||
|         SoapySDRInput::MsgStartStop *message = SoapySDRInput::MsgStartStop::create(checked); | ||||
|         m_sampleSource->getInputMessageQueue()->push(message); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::on_record_toggled(bool checked) | ||||
| { | ||||
|     if (checked) { | ||||
|         ui->record->setStyleSheet("QToolButton { background-color : red; }"); | ||||
|     } else { | ||||
|         ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | ||||
|     } | ||||
| 
 | ||||
|     SoapySDRInput::MsgFileRecord* message = SoapySDRInput::MsgFileRecord::create(checked); | ||||
|     m_sampleSource->getInputMessageQueue()->push(message); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::displaySettings() | ||||
| { | ||||
|     blockApplySettings(true); | ||||
| 
 | ||||
|     ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); | ||||
|     m_sampleRateGUI->setValue(m_settings.m_devSampleRate); | ||||
| 
 | ||||
|     ui->dcOffset->setChecked(m_settings.m_dcBlock); | ||||
|     ui->iqImbalance->setChecked(m_settings.m_iqCorrection); | ||||
| 
 | ||||
|     ui->decim->setCurrentIndex(m_settings.m_log2Decim); | ||||
|     ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos); | ||||
| 
 | ||||
|     blockApplySettings(false); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::sendSettings() | ||||
| { | ||||
|     if (!m_updateTimer.isActive()) { | ||||
|         m_updateTimer.start(100); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::updateSampleRateAndFrequency() | ||||
| { | ||||
|     m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate); | ||||
|     m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); | ||||
|     ui->deviceRateText->setText(tr("%1k").arg(QString::number(m_sampleRate / 1000.0f, 'g', 5))); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::updateFrequencyLimits() | ||||
| { | ||||
|     // values in kHz
 | ||||
|     uint64_t f_min, f_max; | ||||
|     qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0; | ||||
|     m_sampleSource->getFrequencyRange(f_min, f_max); | ||||
|     qint64 minLimit = f_min/1000 + deltaFrequency; | ||||
|     qint64 maxLimit = f_max/1000 + deltaFrequency; | ||||
| 
 | ||||
|     minLimit = minLimit < 0 ? 0 : minLimit > 9999999 ? 9999999 : minLimit; | ||||
|     maxLimit = maxLimit < 0 ? 0 : maxLimit > 9999999 ? 9999999 : maxLimit; | ||||
| 
 | ||||
|     qDebug("SoapySDRInputGui::updateFrequencyLimits: delta: %lld min: %lld max: %lld", deltaFrequency, minLimit, maxLimit); | ||||
| 
 | ||||
|     ui->centerFrequency->setValueRange(7, minLimit, maxLimit); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::setCenterFrequencySetting(uint64_t kHzValue) | ||||
| { | ||||
|     int64_t centerFrequency = kHzValue*1000; | ||||
| 
 | ||||
|     m_settings.m_centerFrequency = centerFrequency < 0 ? 0 : (uint64_t) centerFrequency; | ||||
|     ui->centerFrequency->setToolTip(QString("Main center frequency in kHz (LO: %1 kHz)").arg(centerFrequency/1000)); | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::blockApplySettings(bool block) | ||||
| { | ||||
|     m_doApplySettings = !block; | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::updateHardware() | ||||
| { | ||||
|     if (m_doApplySettings) | ||||
|     { | ||||
|         qDebug() << "SoapySDRInputGui::updateHardware"; | ||||
|         SoapySDRInput::MsgConfigureSoapySDRInput* message = SoapySDRInput::MsgConfigureSoapySDRInput::create(m_settings, m_forceSettings); | ||||
|         m_sampleSource->getInputMessageQueue()->push(message); | ||||
|         m_forceSettings = false; | ||||
|         m_updateTimer.stop(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SoapySDRInputGui::updateStatus() | ||||
| { | ||||
|     int state = m_deviceUISet->m_deviceSourceAPI->state(); | ||||
| 
 | ||||
|     if(m_lastEngineState != state) | ||||
|     { | ||||
|         switch(state) | ||||
|         { | ||||
|             case DSPDeviceSourceEngine::StNotStarted: | ||||
|                 ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | ||||
|                 break; | ||||
|             case DSPDeviceSourceEngine::StIdle: | ||||
|                 ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); | ||||
|                 break; | ||||
|             case DSPDeviceSourceEngine::StRunning: | ||||
|                 ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); | ||||
|                 break; | ||||
|             case DSPDeviceSourceEngine::StError: | ||||
|                 ui->startStop->setStyleSheet("QToolButton { background-color : red; }"); | ||||
|                 QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceSourceAPI->errorMessage()); | ||||
|                 break; | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
| 
 | ||||
|         m_lastEngineState = state; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -60,6 +60,7 @@ private: | ||||
|     DeviceUISet* m_deviceUISet; | ||||
|     bool m_forceSettings; | ||||
|     bool m_doApplySettings; | ||||
|     SoapySDRInputSettings m_settings; | ||||
|     QTimer m_updateTimer; | ||||
|     QTimer m_statusTimer; | ||||
|     SoapySDRInput* m_sampleSource; | ||||
| @ -70,8 +71,25 @@ private: | ||||
| 
 | ||||
|     ItemSettingGUI *m_sampleRateGUI; | ||||
| 
 | ||||
|     void displaySettings(); | ||||
|     void sendSettings(); | ||||
|     void updateSampleRateAndFrequency(); | ||||
|     void updateFrequencyLimits(); | ||||
|     void setCenterFrequencySetting(uint64_t kHzValue); | ||||
|     void blockApplySettings(bool block); | ||||
| 
 | ||||
| private slots: | ||||
|     void on_centerFrequency_changed(quint64 value); | ||||
|     void sampleRateChanged(double sampleRate); | ||||
|     void on_dcOffset_toggled(bool checked); | ||||
|     void on_iqImbalance_toggled(bool checked); | ||||
|     void on_decim_currentIndexChanged(int index); | ||||
|     void on_fcPos_currentIndexChanged(int index); | ||||
|     void on_transverter_clicked(); | ||||
|     void on_startStop_toggled(bool checked); | ||||
|     void on_record_toggled(bool checked); | ||||
|     void updateHardware(); | ||||
|     void updateStatus(); | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -166,6 +166,159 @@ | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|    <item> | ||||
|     <layout class="QHBoxLayout" name="horizontalLayout_3"> | ||||
|      <property name="topMargin"> | ||||
|       <number>6</number> | ||||
|      </property> | ||||
|      <property name="bottomMargin"> | ||||
|       <number>6</number> | ||||
|      </property> | ||||
|      <item> | ||||
|       <widget class="QLabel" name="corrLabel"> | ||||
|        <property name="text"> | ||||
|         <string>Auto</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="ButtonSwitch" name="dcOffset"> | ||||
|        <property name="toolTip"> | ||||
|         <string>Software DC block</string> | ||||
|        </property> | ||||
|        <property name="text"> | ||||
|         <string>DC</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="ButtonSwitch" name="iqImbalance"> | ||||
|        <property name="toolTip"> | ||||
|         <string>Software IQ correction</string> | ||||
|        </property> | ||||
|        <property name="text"> | ||||
|         <string>IQ</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QLabel" name="labelFcPos"> | ||||
|        <property name="text"> | ||||
|         <string>Fp</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QComboBox" name="fcPos"> | ||||
|        <property name="minimumSize"> | ||||
|         <size> | ||||
|          <width>50</width> | ||||
|          <height>0</height> | ||||
|         </size> | ||||
|        </property> | ||||
|        <property name="toolTip"> | ||||
|         <string>Relative position of device center frequency</string> | ||||
|        </property> | ||||
|        <item> | ||||
|         <property name="text"> | ||||
|          <string>Inf</string> | ||||
|         </property> | ||||
|        </item> | ||||
|        <item> | ||||
|         <property name="text"> | ||||
|          <string>Sup</string> | ||||
|         </property> | ||||
|        </item> | ||||
|        <item> | ||||
|         <property name="text"> | ||||
|          <string>Cen</string> | ||||
|         </property> | ||||
|        </item> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QLabel" name="labelDecim"> | ||||
|        <property name="text"> | ||||
|         <string>Dec</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QComboBox" name="decim"> | ||||
|        <property name="minimumSize"> | ||||
|         <size> | ||||
|          <width>30</width> | ||||
|          <height>0</height> | ||||
|         </size> | ||||
|        </property> | ||||
|        <property name="toolTip"> | ||||
|         <string>Software decimation factor</string> | ||||
|        </property> | ||||
|        <item> | ||||
|         <property name="text"> | ||||
|          <string>1</string> | ||||
|         </property> | ||||
|        </item> | ||||
|        <item> | ||||
|         <property name="text"> | ||||
|          <string>2</string> | ||||
|         </property> | ||||
|        </item> | ||||
|        <item> | ||||
|         <property name="text"> | ||||
|          <string>4</string> | ||||
|         </property> | ||||
|        </item> | ||||
|        <item> | ||||
|         <property name="text"> | ||||
|          <string>8</string> | ||||
|         </property> | ||||
|        </item> | ||||
|        <item> | ||||
|         <property name="text"> | ||||
|          <string>16</string> | ||||
|         </property> | ||||
|        </item> | ||||
|        <item> | ||||
|         <property name="text"> | ||||
|          <string>32</string> | ||||
|         </property> | ||||
|        </item> | ||||
|        <item> | ||||
|         <property name="text"> | ||||
|          <string>64</string> | ||||
|         </property> | ||||
|        </item> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <spacer name="horizontalSpacer_4"> | ||||
|        <property name="orientation"> | ||||
|         <enum>Qt::Horizontal</enum> | ||||
|        </property> | ||||
|        <property name="sizeHint" stdset="0"> | ||||
|         <size> | ||||
|          <width>40</width> | ||||
|          <height>20</height> | ||||
|         </size> | ||||
|        </property> | ||||
|       </spacer> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="TransverterButton" name="transverter"> | ||||
|        <property name="maximumSize"> | ||||
|         <size> | ||||
|          <width>24</width> | ||||
|          <height>24</height> | ||||
|         </size> | ||||
|        </property> | ||||
|        <property name="text"> | ||||
|         <string>X</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="Line" name="line_freq"> | ||||
|      <property name="orientation"> | ||||
| @ -358,6 +511,11 @@ | ||||
|    <extends>QToolButton</extends> | ||||
|    <header>gui/buttonswitch.h</header> | ||||
|   </customwidget> | ||||
|   <customwidget> | ||||
|    <class>TransverterButton</class> | ||||
|    <extends>QPushButton</extends> | ||||
|    <header>gui/transverterbutton.h</header> | ||||
|   </customwidget> | ||||
|  </customwidgets> | ||||
|  <resources> | ||||
|   <include location="../../../sdrgui/resources/res.qrc"/> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user