1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
/////////////////////////////////////////////////////////////////////
// sdrsetupdlg.cpp: implementation of the CSdrSetupDlg class.
//
// This class implements a dialog to setup SDR parameters.
//
// History:
// 2010-09-15 Initial creation MSW
// 2011-03-27 Initial release
// 2011-08-07 Added Spectrum inversion Support
/////////////////////////////////////////////////////////////////////
//==========================================================================================
// + + + This Software is released under the "Simplified BSD License" + + +
//Copyright 2010 Moe Wheatley. All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are
//permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY Moe Wheatley ``AS IS'' AND ANY EXPRESS OR IMPLIED
//WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Moe Wheatley OR
//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
//CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
//ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
//ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//The views and conclusions contained in the software and documentation are those of the
//authors and should not be interpreted as representing official policies, either expressed
//or implied, of Moe Wheatley.
//==========================================================================================
#include "gui/sdrsetupdlg.h"
#include "ui_sdrsetupdlg.h"
#include "gui/mainwindow.h"
#include <QDebug>
CSdrSetupDlg::CSdrSetupDlg(QWidget *parent, CSdrInterface* pSdrInterface) :
QDialog(parent),
m_pSdrInterface(pSdrInterface),
ui(new Ui::CSdrSetupDlg)
{
ui->setupUi(this);
m_BandwidthIndex = 0;
m_RfGain = pSdrInterface->GetSdrRfGain();
m_RadioType = pSdrInterface->GetRadioType();
m_SampleRate = pSdrInterface->GetSdrSampleRate();
}
CSdrSetupDlg::~CSdrSetupDlg()
{
delete ui;
}
//Fill in initial data
void CSdrSetupDlg::InitDlg()
{
m_Str1 = QString().number( m_pSdrInterface->GetMaxBWFromIndex(0)/1000 )+ " KHz ";
m_Str2 = QString().number(m_pSdrInterface->GetSampleRateFromIndex(0)/1000.0)+ " Ksps";
ui->radioButtonRate0->setText(m_Str1 + m_Str2 );
m_Str1 = QString().number( m_pSdrInterface->GetMaxBWFromIndex(1)/1000 )+ " KHz ";
m_Str2 = QString().number(m_pSdrInterface->GetSampleRateFromIndex(1)/1000.0)+ " Ksps";
ui->radioButtonRate1->setText(m_Str1 + m_Str2 );
m_Str1 = QString().number( m_pSdrInterface->GetMaxBWFromIndex(2)/1000 )+ " KHz ";
m_Str2 = QString().number(m_pSdrInterface->GetSampleRateFromIndex(2)/1000.0)+ " Ksps";
ui->radioButtonRate2->setText(m_Str1 + m_Str2 );
m_Str1 = QString().number( m_pSdrInterface->GetMaxBWFromIndex(3)/1000 )+ " KHz ";
m_Str2 = QString().number(m_pSdrInterface->GetSampleRateFromIndex(3)/1000.0)+ " Ksps";
ui->radioButtonRate3->setText(m_Str1 + m_Str2 );
m_Str1 = QString().number( m_pSdrInterface->GetMaxBWFromIndex(4)/1000 )+ " KHz ";
m_Str2 = QString().number(m_pSdrInterface->GetSampleRateFromIndex(4)/1000.0)+ " Ksps";
ui->radioButtonRate4->setText(m_Str1 + m_Str2 );
if(0==m_RfGain)
ui->radioButtonAttn0->setChecked(true);
else if(-10==m_RfGain)
ui->radioButtonAttn10->setChecked(true);
else if(-20==m_RfGain)
ui->radioButtonAttn20->setChecked(true);
else if(-30==m_RfGain)
ui->radioButtonAttn30->setChecked(true);
if(0 == m_BandwidthIndex)
ui->radioButtonRate0->setChecked(true);
else if(1 == m_BandwidthIndex)
ui->radioButtonRate1->setChecked(true);
else if(2 == m_BandwidthIndex)
ui->radioButtonRate2->setChecked(true);
else if(3 == m_BandwidthIndex)
ui->radioButtonRate3->setChecked(true);
else if(4 == m_BandwidthIndex)
ui->radioButtonRate4->setChecked(true);
if(m_USFm)
ui->checkBoxUSFmVer->setChecked(true);
else
ui->checkBoxUSFmVer->setChecked(false);
ui->labelRadioType->setText(m_pSdrInterface->m_DeviceName);
}
void CSdrSetupDlg::RfGainChanged()
{
if(ui->radioButtonAttn0->isChecked())
m_RfGain = 0;
else if(ui->radioButtonAttn10->isChecked())
m_RfGain = -10;
else if(ui->radioButtonAttn20->isChecked())
m_RfGain = -20;
else if(ui->radioButtonAttn30->isChecked())
m_RfGain = -30;
m_pSdrInterface->SetSdrRfGain(m_RfGain);
}
//Called when OK button pressed so get all the dialog data
void CSdrSetupDlg::accept()
{
if(ui->radioButtonRate0->isChecked())
m_BandwidthIndex = 0;
else if(ui->radioButtonRate1->isChecked())
m_BandwidthIndex = 1;
else if(ui->radioButtonRate2->isChecked())
m_BandwidthIndex = 2;
else if(ui->radioButtonRate3->isChecked())
m_BandwidthIndex = 3;
else if(ui->radioButtonRate4->isChecked())
m_BandwidthIndex = 4;
if( ui->checkBoxUSFmVer->isChecked() )
m_USFm = true;
else
m_USFm = false;
QDialog::accept();
}
|