SoDaRadio-5.0.3-master:8901fb5
main_setup_top.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017 Matthew H. Reilly (kb1vc)
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #include "mainwindow.hpp"
30 #include "ui_mainwindow.h"
31 #include <iostream>
32 #include <boost/format.hpp>
33 #include "soda_comboboxes.hpp"
34 #include "soda_listener.hpp"
35 
37 {
38  // setup the top row of controls under the tabbed pages.
39  // these are the basic radio settings... gain, frequency and such
40  // we connect the report side and then the command side.
41  connect(listener, SIGNAL(addModulation(QString, int)),
42  ui->Mode_cb, SLOT(addValue(QString, int)));
43  connect(ui->Mode_cb, SIGNAL(valueChanged(int)),
44  listener, SLOT(setModulation(int)));
45 
46  connect(listener, SIGNAL(addFilterName(QString, int)),
47  ui->AFBw_cb, SLOT(addValue(QString, int)));
48  connect(ui->AFBw_cb, SIGNAL(valueChanged(int)),
49  listener, SLOT(setAFFilter(int)));
50 
51  connect(ui->RFGain_slide, SIGNAL(valueChanged(int)),
52  listener, SLOT(setRXGain(int)));
53  connect(ui->AFGain_slide, SIGNAL(valueChanged(int)),
54  listener, SLOT(setAFGain(int)));
55 
56  connect(ui->RXFreq_lab, SIGNAL(newFreq(double)),
57  this, SLOT(setRXFreq(double)));
58 
59  connect(ui->TXFreq_lab, SIGNAL(newFreq(double)),
60  this, SLOT(setTXFreq(double)));
61 
62  connect(ui->RXfreq2TXfreq_btn, &QPushButton::clicked,
63  this, [=] (bool checked) {
64  setTXFreq(ui->RXFreq_lab->getFreq());
65  });
66  connect(ui->TXfreq2RXfreq_btn, &QPushButton::clicked,
67  this, [=] (bool checked) {
68  setRXFreq(ui->TXFreq_lab->getFreq());
69  });
70 }
71 
72 
73 void MainWindow::setRXFreq(double freq)
74 {
75  // coordinate all settings for new frequencies.
76  setRXFreq_nocross(freq);
77  // if we are TX/RX frequency locked, tell the TX unit
78  if(ui->TXRXLock_chk->isChecked()) setTXFreq_nocross(freq);
79 }
80 
81 void MainWindow::setTXFreq(double freq)
82 {
83  setTXFreq_nocross(freq);
84  if(ui->TXRXLock_chk->isChecked()) setRXFreq_nocross(freq);
85 }
86 
88 {
89  // change the band setting, if we need to.
90  // but don't modify any other settings.
91  QString band_name = band_map.findBand(freq);
92  if(band_name != "") {
93  int idx;
94  // make sure that we don't modify the MODE and such.
95  auto_bandswitch_target = band_name;
96  if((idx = ui->bandSel_cb->findText(band_name)) >= 0) {
97  // remember the mode
98  int cur_mode = ui->Mode_cb->value();
99 
100  ui->bandSel_cb->setCurrentIndex(idx);
101 
102  // undo the mode switching...
103  ui->Mode_cb->setValue(cur_mode);
104 
105  listener->setSpectrumCenter(freq);
106  }
107  }
108 }
109 
111 {
112  // tell the radio.
113  listener->setRXFreq(freq);
114 
115  // tell the waterfall
116  ui->waterfall_plt->setFreqMarker(freq);
117 
118  // tell the spectrum plot
119  ui->spectrum_plt->setFreqMarker(freq);
120 
121  // tell the RX freq display
122  ui->RXFreq_lab->setFreq(freq);
123 
124 }
125 
127 {
128  // tell the radio.
129  listener->setTXFreq(freq);
130 
131  // tell the RX freq display
132  ui->TXFreq_lab->setFreq(freq);
133 }
134 
135 
QString findBand(double freq) const
Definition: soda_band.hpp:174
GUISoDa::Listener * listener
Definition: mainwindow.hpp:151
Ui::MainWindow * ui
Definition: mainwindow.hpp:149
void setTXFreq_nocross(double freq)
QString auto_bandswitch_target
Definition: mainwindow.hpp:144
void setRXFreq_nocross(double freq)
void setRXFreq(double freq)
void setupTopControls()
void setSpectrumCenter(double freq)
void setTXFreq(double freq)
GUISoDa::BandMap band_map
Definition: mainwindow.hpp:141
void updateBandDisplay(double freq)
void setTXFreq(double freq)
set the TX frequency label to freq, and send the requested frequency to the SDR radio server...
void setRXFreq(double freq)
set the RX frequency label to freq, and send the requested frequency to the SDR radio server...