forked from guido57/EBAZ4205_SDR_spectrum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreqvlinemulti.cpp
96 lines (80 loc) · 2.69 KB
/
freqvlinemulti.cpp
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
#include <QChart>
#include "freqvlinemulti.h"
FreqVLineMulti::FreqVLineMulti(QChart * qchart, demod_type_enum demod_type_):
QObject()
{
demod_type = demod_type_;
m_chart = qchart;
fvl_left = new FreqVLine(qchart, false, Qt::black);
fvl_right = new FreqVLine(qchart, false, Qt::black);
fvl_center = new FreqVLine(qchart, true, Qt::green);
}
FreqVLineMulti::~FreqVLineMulti() {};
void FreqVLineMulti::updateFrequency_hz(float frequency, float bw_, demod_type_enum demod_type_){
if( (int)demod_type_ != -1){
demod_type = demod_type_;
}
bw = bw_;
actual_freq_hz = frequency;
QPointF freq_center_xy(actual_freq_hz,0);
QPointF freq_left_xy(actual_freq_hz-bw,0);
QPointF freq_right_xy(actual_freq_hz+bw,0);
QPointF mtp = m_chart->mapToPosition(freq_center_xy);
fvl_center->updatePosition(mtp);
actualPosition = fvl_center->actualPosition;
fvl_left->updatePosition(m_chart->mapToPosition(freq_left_xy));
fvl_right->updatePosition(m_chart->mapToPosition(freq_right_xy));
setAMLSBUSB(demod_type);
}
void FreqVLineMulti::setBW_khz(int bw_khz)
{
bw = bw_khz * 1000;
updatePosition(actualPosition); // show updated bandwidth boundaries (black lines)
setAMLSBUSB(demod_type); // update actual freq_dds_hz accordinf to fvl_type and bandwidth
}
void FreqVLineMulti::setAMLSBUSB(demod_type_enum demod_type_ )
{
demod_type = demod_type_;
switch(demod_type){
case demod_type_am:
fvl_center->Show();
fvl_left->Show();
fvl_right->Show();
actual_freq_dds_hz = actual_freq_hz;
break;
case demod_type_lsb:
fvl_center->Show();
fvl_left->Show();
fvl_right->Hide();
actual_freq_dds_hz = actual_freq_hz - bw;
break;
case demod_type_usb:
fvl_center->Show();
fvl_left->Hide();
fvl_right->Show();
actual_freq_dds_hz = actual_freq_hz + bw;
break;
}
}
void FreqVLineMulti::updatePosition(QPointF position)
{
float frequency_hz = m_chart->mapToValue(position).x(); // store the actual frequency
updateFrequency_hz(frequency_hz, bw, demod_type);
// emit a SIGNAL to the dds when the vline is requested to move
emit tunedFrequencyChanged(actual_freq_dds_hz);
}
void FreqVLineMulti::incDecPosition(QPoint angledelta)
{
QPointF ap = m_chart->mapToValue(actualPosition);
if(angledelta.y() == 120)
ap.setX(ap.x()+100);
else
ap.setX(ap.x()-100);
updatePosition(m_chart->mapToPosition(ap));
}
bool FreqVLineMulti::IsVisible(){
return fvl_center->IsVisible();
}
float FreqVLineMulti::GetActualFreq_hz(){
return actual_freq_hz;
}