1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-01 21:54:55 -04:00

Multi device support: moved DSPDeviceEngine start/stop actions and status from main window to each source plugin GUI

This commit is contained in:
f4exb
2016-05-11 23:35:16 +02:00
parent 7992f3f428
commit ecd05096ad
31 changed files with 649 additions and 78 deletions
+54 -1
View File
@@ -15,6 +15,8 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QMessageBox>
#include <libhackrf/hackrf.h>
#include "plugin/pluginapi.h"
@@ -28,12 +30,17 @@ HackRFGui::HackRFGui(PluginAPI* pluginAPI, QWidget* parent) :
ui(new Ui::HackRFGui),
m_pluginAPI(pluginAPI),
m_settings(),
m_sampleSource(NULL)
m_sampleSource(NULL),
m_lastEngineState((DSPDeviceEngine::State)-1)
{
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->centerFrequency->setValueRange(7, 0U, 7250000U);
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
displaySettings();
m_sampleSource = new HackRFInput();
@@ -277,6 +284,23 @@ void HackRFGui::on_vga_valueChanged(int value)
sendSettings();
}
void HackRFGui::on_startStop_toggled(bool checked)
{
if (checked)
{
if (m_pluginAPI->initAcquisition())
{
m_pluginAPI->startAcquisition();
DSPEngine::instance()->startAudio();
}
}
else
{
m_pluginAPI->stopAcquistion();
DSPEngine::instance()->stopAudio();
}
}
void HackRFGui::updateHardware()
{
qDebug() << "HackRFGui::updateHardware";
@@ -285,6 +309,35 @@ void HackRFGui::updateHardware()
m_updateTimer.stop();
}
void HackRFGui::updateStatus()
{
int state = m_pluginAPI->state();
if(m_lastEngineState != state)
{
switch(state)
{
case DSPDeviceEngine::StNotStarted:
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
break;
case DSPDeviceEngine::StIdle:
ui->startStop->setStyleSheet("QToolButton { background-color : cyan; }");
break;
case DSPDeviceEngine::StRunning:
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
break;
case DSPDeviceEngine::StError:
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
QMessageBox::information(this, tr("Message"), m_pluginAPI->errorMessage());
break;
default:
break;
}
m_lastEngineState = state;
}
}
unsigned int HackRFSampleRates::m_rates_k[] = {2400, 3200, 4800, 5600, 6400, 8000, 9600, 12800, 19200};
unsigned int HackRFSampleRates::getRate(unsigned int rate_index)
+4
View File
@@ -62,7 +62,9 @@ private:
PluginAPI* m_pluginAPI;
HackRFSettings m_settings;
QTimer m_updateTimer;
QTimer m_statusTimer;
SampleSource* m_sampleSource;
int m_lastEngineState;
void displaySettings();
void displaySampleRates();
@@ -82,7 +84,9 @@ private slots:
void on_lna_valueChanged(int value);
void on_bbFilter_currentIndexChanged(int index);
void on_vga_valueChanged(int value);
void on_startStop_toggled(bool checked);
void updateHardware();
void updateStatus();
};
class HackRFSampleRates {
+1 -1
View File
@@ -41,7 +41,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_freq">
<item>
<widget class="ButtonSwitch" name="startStopButton">
<widget class="ButtonSwitch" name="startStop">
<property name="text">
<string/>
</property>