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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
/////////////////////////////////////////////////////////////////////
// demodsetupdlg.cpp: implementation of the CDemodSetupDlg class.
//
// This class implements a dialog to setup the demodulation parameters
//
// History:
// 2010-09-15 Initial creation MSW
// 2011-03-27 Initial release
// 2011-08-07 Added WFM Support
// 2012-02-11 Fixed compiler warning
/////////////////////////////////////////////////////////////////////
//==========================================================================================
// + + + 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/demodsetupdlg.h"
#include "ui_demodsetupdlg.h"
#include "gui/mainwindow.h"
#include <QDebug>
CDemodSetupDlg::CDemodSetupDlg(QWidget *parent) :
QDialog(parent),
ui(new Ui::CDemodSetupDlg)
{
ui->setupUi(this);
m_pDemodInfo = NULL;
m_DemodMode = DEMOD_AM;
connect(ui->frameSlope, SIGNAL(sliderValChanged(int)), this, SLOT(OnAgcSlope(int)));
connect(ui->frameThresh, SIGNAL(sliderValChanged(int)), this, SLOT(OnAgcThresh(int)));
connect(ui->frameDecay, SIGNAL(sliderValChanged(int)), this, SLOT(OnAgcDecay(int)));
ui->frameSlope->SetName("Slope");
ui->frameSlope->SetSuffix(" dB");
ui->frameSlope->setRange(0, 10);
ui->frameSlope->setSingleStep(1);
ui->frameSlope->setPageStep(1);
ui->frameSlope->setTickInterval(1);
ui->frameThresh->SetName("Knee");
ui->frameThresh->SetSuffix(" dB");
ui->frameThresh->setRange(-120, -30);
ui->frameThresh->setSingleStep(5);
ui->frameThresh->setPageStep(5);
ui->frameThresh->setTickInterval(10);
ui->frameDecay->SetName("Decay");
ui->frameDecay->SetSuffix(" mS");
ui->frameDecay->setRange(20, 2000);
ui->frameDecay->setSingleStep(10);
ui->frameDecay->setPageStep(100);
ui->frameDecay->setTickInterval(200);
}
CDemodSetupDlg::~CDemodSetupDlg()
{
delete ui;
}
void CDemodSetupDlg::OnAgcOn(bool On)
{
if(m_pDemodInfo)
{
m_pDemodInfo->AgcOn = On;
UpdateDemodInfo();
((MainWindow*)this->parent())->SetupDemod(m_DemodMode);
}
}
void CDemodSetupDlg::OnHangOn(bool On)
{
if(m_pDemodInfo)
{
m_pDemodInfo->AgcHangOn = On;
UpdateDemodInfo();
((MainWindow*)this->parent())->SetupDemod(m_DemodMode);
}
}
void CDemodSetupDlg::OnUSFm(bool Us)
{
Q_UNUSED(Us);
((MainWindow*)this->parent())->SetupDemod(m_DemodMode);
}
//Fill in initial data
void CDemodSetupDlg::InitDlg()
{
switch(m_DemodMode)
{
case DEMOD_AM:
ui->AMradioButton->setChecked(true);
break;
case DEMOD_SAM:
ui->SAMradioButton->setChecked(true);
break;
case DEMOD_FM:
ui->FMradioButton->setChecked(true);
break;
case DEMOD_WFM:
ui->WFMradioButton->setChecked(true);
break;
case DEMOD_USB:
ui->USBradioButton->setChecked(true);
break;
case DEMOD_LSB:
ui->LSBradioButton->setChecked(true);
break;
case DEMOD_CWU:
ui->CWUradioButton->setChecked(true);
break;
case DEMOD_CWL:
ui->CWLradioButton->setChecked(true);
break;
case DEMOD_PSK:
ui->PSKradioButton->setChecked(true);
break;
case DEMOD_FSK:
ui->FSKradioButton->setChecked(true);
break;
}
m_pDemodInfo = &(((MainWindow*)this->parent())->m_DemodSettings[m_DemodMode]);
UpdateDemodInfo();
}
void CDemodSetupDlg::UpdateDemodInfo()
{
int tmp;
ui->checkBoxAgcOn->setChecked(m_pDemodInfo->AgcOn);
ui->checkBoxHang->setChecked(m_pDemodInfo->AgcHangOn);
if(m_pDemodInfo->AgcOn)
{
ui->frameThresh->SetName("Knee");
tmp = m_pDemodInfo->AgcThresh;//save since range change triggers a value change for some reason
ui->frameThresh->setRange(-120, -20);
ui->frameThresh->SetValue(tmp);
}
else
{
ui->frameThresh->SetName("Gain");
tmp = m_pDemodInfo->AgcManualGain;//save since range change triggers a value change for some reason
ui->frameThresh->setRange(0, 100);
ui->frameThresh->SetValue(tmp);
}
if(m_pDemodInfo->AgcHangOn)
{
ui->frameDecay->SetName("Hang");
}
else
{
ui->frameDecay->SetName("Decay");
}
ui->spinBoxOffset->setValue(m_pDemodInfo->Offset);
ui->horizontalSliderSquelch->setValue(m_pDemodInfo->SquelchValue);
ui->frameSlope->SetValue(m_pDemodInfo->AgcSlope);
ui->frameDecay->SetValue(m_pDemodInfo->AgcDecay);
}
void CDemodSetupDlg::OnOffsetChanged(int Offset)
{
if(m_pDemodInfo)
{
m_pDemodInfo->Offset = Offset;
((MainWindow*)this->parent())->SetupDemod(m_DemodMode);
}
}
void CDemodSetupDlg::OnSquelchChanged(int SquelchValue)
{
if(m_pDemodInfo)
{
m_pDemodInfo->SquelchValue = SquelchValue;
((MainWindow*)this->parent())->SetupDemod(m_DemodMode);
}
}
//Called when new mode is pressed so set the dialog data
void CDemodSetupDlg::ModeChanged()
{
if(ui->AMradioButton->isChecked())
m_DemodMode = DEMOD_AM;
else if(ui->SAMradioButton->isChecked())
m_DemodMode = DEMOD_SAM;
else if(ui->FMradioButton->isChecked())
m_DemodMode = DEMOD_FM;
else if(ui->WFMradioButton->isChecked())
m_DemodMode = DEMOD_WFM;
else if(ui->USBradioButton->isChecked())
m_DemodMode = DEMOD_USB;
else if(ui->LSBradioButton->isChecked())
m_DemodMode = DEMOD_LSB;
else if(ui->CWUradioButton->isChecked())
m_DemodMode = DEMOD_CWU;
else if(ui->CWLradioButton->isChecked())
m_DemodMode = DEMOD_CWL;
else if(ui->PSKradioButton->isChecked())
m_DemodMode = DEMOD_PSK;
else if(ui->FSKradioButton->isChecked())
m_DemodMode = DEMOD_FSK;
((MainWindow*)this->parent())->SetupDemod(m_DemodMode);
m_pDemodInfo = &(((MainWindow*)this->parent())->m_DemodSettings[m_DemodMode]);
UpdateDemodInfo();
}
void CDemodSetupDlg::OnAgcSlope(int val)
{
if(m_pDemodInfo)
{
m_pDemodInfo->AgcSlope = val;
((MainWindow*)this->parent())->SetupDemod(m_DemodMode);
}
}
void CDemodSetupDlg::OnAgcThresh(int val)
{
if(m_pDemodInfo)
{
if(m_pDemodInfo->AgcOn)
m_pDemodInfo->AgcThresh = val;
else
m_pDemodInfo->AgcManualGain = val;
((MainWindow*)this->parent())->SetupDemod(m_DemodMode);
}
}
void CDemodSetupDlg::OnAgcDecay(int val)
{
if(m_pDemodInfo)
{
m_pDemodInfo->AgcDecay = val;
((MainWindow*)this->parent())->SetupDemod(m_DemodMode);
}
}
|