mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 04:50:29 -04:00 
			
		
		
		
	BladerRF2 input support. Global gain handling
This commit is contained in:
		
							parent
							
								
									5ad52a4a1b
								
							
						
					
					
						commit
						81ad05cb64
					
				| @ -39,6 +39,7 @@ | ||||
| MESSAGE_CLASS_DEFINITION(BladeRF2Input::MsgConfigureBladeRF2, Message) | ||||
| MESSAGE_CLASS_DEFINITION(BladeRF2Input::MsgFileRecord, Message) | ||||
| MESSAGE_CLASS_DEFINITION(BladeRF2Input::MsgStartStop, Message) | ||||
| MESSAGE_CLASS_DEFINITION(BladeRF2Input::MsgReportGainRange, Message) | ||||
| 
 | ||||
| BladeRF2Input::BladeRF2Input(DeviceSourceAPI *deviceAPI) : | ||||
|     m_deviceAPI(deviceAPI), | ||||
| @ -688,7 +689,6 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo | ||||
|     bool forwardChangeTxBuddies = false; | ||||
| 
 | ||||
|     struct bladerf *dev = m_deviceShared.m_dev->getDev(); | ||||
|     qDebug() << "BladeRF2Input::applySettings: m_dev: " << dev; | ||||
| 
 | ||||
|     if ((m_settings.m_dcBlock != settings.m_dcBlock) || | ||||
|         (m_settings.m_iqCorrection != settings.m_iqCorrection) || force) | ||||
| @ -785,8 +785,18 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo | ||||
|             if (status < 0) { | ||||
|                 qWarning("BladeRF2Input::applySettings: bladerf_set_frequency(%lld) failed: %s", | ||||
|                         settings.m_centerFrequency, bladerf_strerror(status)); | ||||
|             } else { | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 qDebug("BladeRF2Input::applySettings: bladerf_set_frequency(%lld)", settings.m_centerFrequency); | ||||
| 
 | ||||
|                 if (getMessageQueueToGUI()) | ||||
|                 { | ||||
|                     int min, max, step; | ||||
|                     getGlobalGainRange(min, max, step); | ||||
|                     MsgReportGainRange *msg = MsgReportGainRange::create(min, max, step); | ||||
|                     getMessageQueueToGUI()->push(msg); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -803,6 +813,7 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo | ||||
| 
 | ||||
|         if (dev) | ||||
|         { | ||||
| //            qDebug("BladeRF2Input::applySettings: channel: %d gain: %d", m_deviceShared.m_channel, settings.m_globalGain);
 | ||||
|             int status = bladerf_set_gain(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), settings.m_globalGain); | ||||
| 
 | ||||
|             if (status < 0) { | ||||
|  | ||||
| @ -94,6 +94,31 @@ public: | ||||
|         { } | ||||
|     }; | ||||
| 
 | ||||
|     class MsgReportGainRange : public Message { | ||||
|         MESSAGE_CLASS_DECLARATION | ||||
| 
 | ||||
|     public: | ||||
|         int getMin() const { return m_min; } | ||||
|         int getMax() const { return m_max; } | ||||
|         int getStep() const { return m_step; } | ||||
| 
 | ||||
|         static MsgReportGainRange* create(int min, int max, int step) { | ||||
|             return new MsgReportGainRange(min, max, step); | ||||
|         } | ||||
| 
 | ||||
|     protected: | ||||
|         int m_min; | ||||
|         int m_max; | ||||
|         int m_step; | ||||
| 
 | ||||
|         MsgReportGainRange(int min, int max, int step) : | ||||
|             Message(), | ||||
|             m_min(min), | ||||
|             m_max(max), | ||||
|             m_step(step) | ||||
|         {} | ||||
|     }; | ||||
| 
 | ||||
|     BladeRF2Input(DeviceSourceAPI *deviceAPI); | ||||
|     virtual ~BladeRF2Input(); | ||||
|     virtual void destroy(); | ||||
|  | ||||
| @ -62,11 +62,21 @@ BladeRF2InputGui::BladeRF2InputGui(DeviceUISet *deviceUISet, QWidget* parent) : | ||||
| 
 | ||||
|     if (m_gainModes) | ||||
|     { | ||||
|         ui->gainMode->blockSignals(true); | ||||
| 
 | ||||
|         for (int i = 0; i < m_nbGainModes; i++) { | ||||
|             ui->gainMode->addItem(tr("%1").arg(m_gainModes[i].name)); | ||||
|         } | ||||
| 
 | ||||
|         ui->gainMode->blockSignals(false); | ||||
|     } | ||||
| 
 | ||||
|     m_sampleSource->getGlobalGainRange(min, max, step); | ||||
|     ui->gain->setMinimum(min); | ||||
|     ui->gain->setMaximum(max); | ||||
|     ui->gain->setPageStep(step); | ||||
|     ui->gain->setSingleStep(step); | ||||
| 
 | ||||
|     connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); | ||||
|     connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); | ||||
|     m_statusTimer.start(500); | ||||
| @ -143,8 +153,25 @@ bool BladeRF2InputGui::handleMessage(const Message& message) | ||||
|         const BladeRF2Input::MsgConfigureBladeRF2& cfg = (BladeRF2Input::MsgConfigureBladeRF2&) message; | ||||
|         m_settings = cfg.getSettings(); | ||||
|         blockApplySettings(true); | ||||
|         int min, max, step; | ||||
|         m_sampleSource->getGlobalGainRange(min, max, step); | ||||
|         ui->gain->setMinimum(min); | ||||
|         ui->gain->setMaximum(max); | ||||
|         ui->gain->setPageStep(step); | ||||
|         ui->gain->setSingleStep(step); | ||||
|         displaySettings(); | ||||
|         blockApplySettings(false); | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
|     else if (BladeRF2Input::MsgReportGainRange::match(message)) | ||||
|     { | ||||
|         const BladeRF2Input::MsgReportGainRange& cfg = (BladeRF2Input::MsgReportGainRange&) message; | ||||
|         ui->gain->setMinimum(cfg.getMin()); | ||||
|         ui->gain->setMaximum(cfg.getMax()); | ||||
|         ui->gain->setSingleStep(cfg.getStep()); | ||||
|         ui->gain->setPageStep(cfg.getStep()); | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
|     else if (BladeRF2Input::MsgStartStop::match(message)) | ||||
| @ -211,6 +238,7 @@ void BladeRF2InputGui::displaySettings() | ||||
|     ui->decim->setCurrentIndex(m_settings.m_log2Decim); | ||||
|     ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos); | ||||
| 
 | ||||
|     ui->gainText->setText(tr("%1").arg(m_settings.m_globalGain)); | ||||
|     ui->gain->setValue(m_settings.m_globalGain); | ||||
| 
 | ||||
|     blockApplySettings(false); | ||||
| @ -274,6 +302,22 @@ void BladeRF2InputGui::on_fcPos_currentIndexChanged(int index) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void BladeRF2InputGui::on_gainMode_currentIndexChanged(int index) | ||||
| { | ||||
|     if (index < m_nbGainModes) | ||||
|     { | ||||
|         m_settings.m_gainMode = m_gainModes[index].mode; | ||||
|         sendSettings(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void BladeRF2InputGui::on_gain_valueChanged(int value) | ||||
| { | ||||
|     ui->gainText->setText(tr("%1").arg(value)); | ||||
|     m_settings.m_globalGain = value; | ||||
|     sendSettings(); | ||||
| } | ||||
| 
 | ||||
| void BladeRF2InputGui::on_startStop_toggled(bool checked) | ||||
| { | ||||
|     if (m_doApplySettings) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user