This repository has been archived by the owner on Mar 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
iqbalance.cc
150 lines (123 loc) · 4.37 KB
/
iqbalance.cc
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
/***************************************************************************
* This file is part of Qthid.
*
* CopyRight (C) 2011 Alexandru Csete, OZ9AEC
*
* Qthid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Qthid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Qthid. If not, see <http://www.gnu.org/licenses/>.
*
***************************************************************************/
#include <QSettings>
#include <QDebug>
#include "iqbalance.h"
#include "ui_iqbalance.h"
#include "fcd.h"
#include "fcdhidcmd.h"
CIqBalance::CIqBalance(QWidget *parent) :
QDialog(parent),
ui(new Ui::CIqBalance)
{
ui->setupUi(this);
/* load stored values */
QSettings settings;
ui->doubleSpinBoxDCI->setValue(settings.value("DCICorr","0.0").toDouble());
ui->doubleSpinBoxDCQ->setValue(settings.value("DCQCorr","0.0").toDouble());
ui->doubleSpinBoxPhase->setValue(settings.value("PhaseCorr","0.0").toDouble());
ui->doubleSpinBoxGain->setValue(settings.value("GainCorr","1.0").toDouble());
}
CIqBalance::~CIqBalance()
{
/* store values */
QSettings settings;
settings.setValue("DCICorr",ui->doubleSpinBoxDCI->value());
settings.setValue("DCQCorr",ui->doubleSpinBoxDCQ->value());
settings.setValue("PhaseCorr",ui->doubleSpinBoxPhase->value());
settings.setValue("GainCorr",ui->doubleSpinBoxGain->value());
delete ui;
}
/*! \brief In-phase DC offset correction changed. */
void CIqBalance::on_doubleSpinBoxDCI_valueChanged(double value)
{
union {
unsigned char auc[4];
struct {
qint16 dci;
qint16 dcq;
};
} dcinfo;
dcinfo.dci = static_cast<signed short>(value*32768.0);
dcinfo.dcq = static_cast<signed short>(ui->doubleSpinBoxDCQ->value()*32768.0);
fcdAppSetParam(FCD_CMD_APP_SET_DC_CORR, dcinfo.auc, 4);
}
/*! \brief Quadrature DC offset correction changed. */
void CIqBalance::on_doubleSpinBoxDCQ_valueChanged(double value)
{
union {
unsigned char auc[4];
struct {
qint16 dci;
qint16 dcq;
};
} dcinfo;
dcinfo.dci = static_cast<signed short>(ui->doubleSpinBoxDCI->value()*32768.0);
dcinfo.dcq = static_cast<signed short>(value*32768.0);
fcdAppSetParam(FCD_CMD_APP_SET_DC_CORR, dcinfo.auc, 4);
}
/*! \brief IQ correction phase changed. */
void CIqBalance::on_doubleSpinBoxPhase_valueChanged(double value)
{
union {
unsigned char auc[4];
struct {
qint16 phase;
qint16 gain;
};
} iqinfo;
iqinfo.phase = static_cast<signed short>(value*32768.0);
iqinfo.gain = static_cast<signed short>(ui->doubleSpinBoxGain->value()*32768.0);
fcdAppSetParam(FCD_CMD_APP_SET_IQ_CORR, iqinfo.auc, 4);
}
/*! \brief IQ correction gain changed. */
void CIqBalance::on_doubleSpinBoxGain_valueChanged(double value)
{
union {
unsigned char auc[4];
struct {
qint16 phase;
qint16 gain;
};
} iqinfo;
iqinfo.phase = static_cast<signed short>(ui->doubleSpinBoxPhase->value()*32768.0);
iqinfo.gain = static_cast<signed short>(value*32768.0);
fcdAppSetParam(FCD_CMD_APP_SET_IQ_CORR, iqinfo.auc, 4);
}
/*! \brief Revert button has been clicked.
*
* Revert I/Q correction values to the previously stored values.
*/
void CIqBalance::on_revertButton_clicked()
{
QSettings settings;
ui->doubleSpinBoxDCI->setValue(settings.value("DCICorr","0.0").toDouble());
ui->doubleSpinBoxDCQ->setValue(settings.value("DCQCorr","0.0").toDouble());
ui->doubleSpinBoxPhase->setValue(settings.value("PhaseCorr","0.0").toDouble());
ui->doubleSpinBoxGain->setValue(settings.value("GainCorr","1.0").toDouble());
}
/*! \brief Reset button has been clicked. */
void CIqBalance::on_resetButton_clicked()
{
ui->doubleSpinBoxDCI->setValue(0.0);
ui->doubleSpinBoxDCQ->setValue(0.0);
ui->doubleSpinBoxPhase->setValue(0.0);
ui->doubleSpinBoxGain->setValue(1.0);
}