mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 17:58:43 -05:00
Multi device support: Aligned HackRF plugin
This commit is contained in:
parent
deee1ada34
commit
ea1f2208f7
@ -21,7 +21,10 @@
|
||||
|
||||
#include "plugin/pluginapi.h"
|
||||
#include "gui/colormapper.h"
|
||||
#include "gui/glspectrum.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/filesink.h"
|
||||
#include "hackrfgui.h"
|
||||
#include "ui_hackrfgui.h"
|
||||
|
||||
@ -49,10 +52,19 @@ HackRFGui::HackRFGui(PluginAPI* pluginAPI, QWidget* parent) :
|
||||
displayBandwidths();
|
||||
|
||||
DSPEngine::instance()->setSource(m_sampleSource);
|
||||
|
||||
char recFileNameCStr[30];
|
||||
sprintf(recFileNameCStr, "test_%d.sdriq", m_pluginAPI->getDeviceUID());
|
||||
m_fileSink = new FileSink(std::string(recFileNameCStr));
|
||||
m_pluginAPI->addSink(m_fileSink);
|
||||
|
||||
connect(m_pluginAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
HackRFGui::~HackRFGui()
|
||||
{
|
||||
m_pluginAPI->removeSink(m_fileSink);
|
||||
delete m_fileSink;
|
||||
delete m_sampleSource; // Valgrind memcheck
|
||||
delete ui;
|
||||
}
|
||||
@ -113,6 +125,35 @@ bool HackRFGui::handleMessage(const Message& message)
|
||||
return false;
|
||||
}
|
||||
|
||||
void HackRFGui::handleDSPMessages()
|
||||
{
|
||||
Message* message;
|
||||
|
||||
while ((message = m_pluginAPI->getDeviceOutputMessageQueue()->pop()) != 0)
|
||||
{
|
||||
qDebug("HackRFGui::handleDSPMessages: message: %s", message->getIdentifier());
|
||||
|
||||
if (DSPSignalNotification::match(*message))
|
||||
{
|
||||
DSPSignalNotification* notif = (DSPSignalNotification*) message;
|
||||
m_sampleRate = notif->getSampleRate();
|
||||
m_deviceCenterFrequency = notif->getCenterFrequency();
|
||||
qDebug("HackRFGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
||||
updateSampleRateAndFrequency();
|
||||
m_fileSink->handleMessage(*notif); // forward to file sink
|
||||
|
||||
delete message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HackRFGui::updateSampleRateAndFrequency()
|
||||
{
|
||||
m_pluginAPI->getSpectrum()->setSampleRate(m_sampleRate);
|
||||
m_pluginAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
|
||||
ui->deviceRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000));
|
||||
}
|
||||
|
||||
void HackRFGui::displaySettings()
|
||||
{
|
||||
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
|
||||
@ -301,6 +342,20 @@ void HackRFGui::on_startStop_toggled(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void HackRFGui::on_record_toggled(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
ui->record->setStyleSheet("QToolButton { background-color : red; }");
|
||||
m_fileSink->startRecording();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
m_fileSink->stopRecording();
|
||||
}
|
||||
}
|
||||
|
||||
void HackRFGui::updateHardware()
|
||||
{
|
||||
qDebug() << "HackRFGui::updateHardware";
|
||||
|
@ -25,6 +25,7 @@
|
||||
#define HACKRF_MAX_DEVICE (32)
|
||||
|
||||
class PluginAPI;
|
||||
class FileSink;
|
||||
|
||||
namespace Ui {
|
||||
class HackRFGui;
|
||||
@ -64,14 +65,19 @@ private:
|
||||
QTimer m_updateTimer;
|
||||
QTimer m_statusTimer;
|
||||
SampleSource* m_sampleSource;
|
||||
FileSink *m_fileSink; //!< File sink to record device I/Q output
|
||||
int m_sampleRate;
|
||||
quint64 m_deviceCenterFrequency; //!< Center frequency in device
|
||||
int m_lastEngineState;
|
||||
|
||||
void displaySettings();
|
||||
void displaySampleRates();
|
||||
void displayBandwidths();
|
||||
void sendSettings();
|
||||
void updateSampleRateAndFrequency();
|
||||
|
||||
private slots:
|
||||
void handleDSPMessages();
|
||||
void on_centerFrequency_changed(quint64 value);
|
||||
void on_LOppm_valueChanged(int value);
|
||||
void on_dcOffset_toggled(bool checked);
|
||||
@ -85,6 +91,7 @@ private slots:
|
||||
void on_bbFilter_currentIndexChanged(int index);
|
||||
void on_vga_valueChanged(int value);
|
||||
void on_startStop_toggled(bool checked);
|
||||
void on_record_toggled(bool checked);
|
||||
void updateHardware();
|
||||
void updateStatus();
|
||||
};
|
||||
|
@ -40,6 +40,10 @@
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_freq">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="deviceUILayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="deviceButtonsLayout">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="startStop">
|
||||
<property name="toolTip">
|
||||
@ -55,6 +59,41 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="record">
|
||||
<property name="toolTip">
|
||||
<string>Toggle record I/Q samples from device</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../sdrbase/resources/res.qrc">
|
||||
<normaloff>:/record_off.png</normaloff>:/record_off.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="deviceRateLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="deviceRateText">
|
||||
<property name="toolTip">
|
||||
<string>I/Q sample rate kS/s</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>00000k</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="freqLeftSpacer">
|
||||
<property name="orientation">
|
||||
|
Loading…
Reference in New Issue
Block a user