1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-22 01:20:56 -05:00

Change settings from main context.

This commit is contained in:
John Greb 2014-12-02 19:00:12 +00:00
parent 9d18a9a1e9
commit 6704651786
4 changed files with 16 additions and 20 deletions

View File

@ -93,8 +93,7 @@ bool FCDInput::startInput(int device)
m_deviceDescription = QString("Funcube Dongle");
// if (!applySettings(m_generalSettings, m_settings, true))
// qCritical("FCD: Unable to set config at start");
applySettings(m_generalSettings, m_settings, true);
qDebug("FCDInput: start");
return true;
@ -132,8 +131,7 @@ bool FCDInput::handleMessage(Message* message)
{
if(MsgConfigureFCD::match(message)) {
MsgConfigureFCD* conf = (MsgConfigureFCD*)message;
if(!applySettings(conf->getGeneralSettings(), conf->getSettings(), false))
qDebug("FCD config error");
applySettings(conf->getGeneralSettings(), conf->getSettings(), false);
message->completed();
return true;
} else {
@ -141,14 +139,10 @@ bool FCDInput::handleMessage(Message* message)
}
}
bool FCDInput::applySettings(const GeneralSettings& generalSettings, const Settings& settings, bool force)
void FCDInput::applySettings(const GeneralSettings& generalSettings, const Settings& settings, bool force)
{
QMutexLocker mutexLocker(&m_mutex);
bool freqChange;
if(!m_FCDThread)
return false;
if((m_generalSettings.m_centerFrequency != generalSettings.m_centerFrequency))
freqChange = true;
else
@ -156,13 +150,14 @@ bool FCDInput::applySettings(const GeneralSettings& generalSettings, const Setti
if(freqChange || force) {
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
m_FCDThread->set_center_freq( (double)(generalSettings.m_centerFrequency) );
set_center_freq( (double)(generalSettings.m_centerFrequency) );
}
if(!freqChange || force) {
m_FCDThread->set_lna_gain(settings.gain);
m_FCDThread->set_bias_t(settings.bias);
set_lna_gain(settings.gain);
set_bias_t(settings.bias);
}
return true;
}

View File

@ -72,6 +72,9 @@ public:
const QString& getDeviceDescription() const;
int getSampleRate() const;
void set_center_freq(double freq);
void set_bias_t(bool on);
void set_lna_gain(bool on);
quint64 getCenterFrequency() const;
bool handleMessage(Message* message);
@ -80,7 +83,7 @@ private:
Settings m_settings;
FCDThread* m_FCDThread;
QString m_deviceDescription;
bool applySettings(const GeneralSettings& generalSettings, const Settings& settings, bool force);
void applySettings(const GeneralSettings& generalSettings, const Settings& settings, bool force);
};
#endif // INCLUDE_FCD_H

View File

@ -9,6 +9,7 @@
* it under the terms of the GNU General Public Licence version 3.
*/
#include "fcdinput.h"
#include "fcdthread.h"
#include "hid-libusb.h"
#include "qthid.h"
@ -54,20 +55,20 @@ void FCDThread::CloseSource()
fcd_handle = NULL;
}
void FCDThread::set_center_freq(double freq)
void FCDInput::set_center_freq(double freq)
{
if (fcdAppSetFreq(freq) == FCD_MODE_NONE)
qDebug("No FCD HID found for frquency change");
}
void FCDThread::set_bias_t(bool on)
void FCDInput::set_bias_t(bool on)
{
quint8 cmd = on ? 1 : 0;
fcdAppSetParam(FCD_CMD_APP_SET_BIAS_TEE, &cmd, 1);
}
void FCDThread::set_lna_gain(bool on)
void FCDInput::set_lna_gain(bool on)
{
quint8 cmd = on ? 1 : 0;

View File

@ -38,9 +38,6 @@ public:
void stopWork();
bool OpenSource(const char *filename);
void CloseSource();
void set_center_freq(double freq);
void set_bias_t(bool on);
void set_lna_gain(bool on);
int work(int n_items);
private:
snd_pcm_format_t fcd_format;