Implimented tuning knob, enhanced communication handling.

merge-requests/1/merge
Elliott Liggett 2018-07-03 17:20:03 -07:00 zatwierdzone przez Elliott Liggett
rodzic 0b8de1a08b
commit 3f7edad074
4 zmienionych plików z 85 dodań i 9 usunięć

Wyświetl plik

@ -16,7 +16,7 @@ commHandler::commHandler()
// Consider how to "re-setup" and how to save the state for next time. // Consider how to "re-setup" and how to save the state for next time.
baudrate = 115200; baudrate = 115200;
stopbits = 1; stopbits = 1;
portName = "/dev/ttyUSB1"; portName = "/dev/ttyUSB0";
setupComm(); // basic parameters setupComm(); // basic parameters
openPort(); openPort();

Wyświetl plik

@ -125,6 +125,7 @@ wfmain::wfmain(QWidget *parent) :
} }
getInitialRigState(); getInitialRigState();
oldFreqDialVal = ui->freqDial->value();
} }
@ -201,7 +202,7 @@ void wfmain::setPlotTheme(QCustomPlot *plot, bool isDark)
plot->xAxis->setTickPen(QPen(Qt::white)); plot->xAxis->setTickPen(QPen(Qt::white));
plot->yAxis->setBasePen(QPen(Qt::white)); plot->yAxis->setBasePen(QPen(Qt::white));
plot->yAxis->setTickPen(QPen(Qt::white)); plot->yAxis->setTickPen(QPen(Qt::white));
plot->graph(0)->setPen(QPen(Qt::lightGray)); // magenta, yellow, green, lightGray plot->graph(0)->setPen(QPen(Qt::yellow)); // magenta, yellow, green, lightGray
} else { } else {
//color = ui->groupBox->palette().color(QPalette::Button); //color = ui->groupBox->palette().color(QPalette::Button);
@ -285,6 +286,7 @@ void wfmain::receiveFreq(double freqMhz)
//qDebug() << "Frequency: " << freqMhz; //qDebug() << "Frequency: " << freqMhz;
ui->freqLabel->setText(QString("%1").arg(freqMhz, 0, 'f')); ui->freqLabel->setText(QString("%1").arg(freqMhz, 0, 'f'));
this->freqMhz = freqMhz; this->freqMhz = freqMhz;
this->knobFreqMhz = freqMhz;
} }
void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double endFreq) void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double endFreq)
@ -340,7 +342,9 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e
plot->graph(0)->setData(x,y); plot->graph(0)->setData(x,y);
if((freqMhz < endFreq) && (freqMhz > startFreq)) if((freqMhz < endFreq) && (freqMhz > startFreq))
{ {
tracer->setGraphKey(freqMhz); // tracer->setGraphKey(freqMhz);
tracer->setGraphKey(knobFreqMhz);
} }
if(drawPeaks) if(drawPeaks)
{ {
@ -658,5 +662,77 @@ void wfmain::on_freqDial_actionTriggered(int action)
void wfmain::on_freqDial_valueChanged(int value) void wfmain::on_freqDial_valueChanged(int value)
{ {
qDebug() << "Value changed to: " << value ; // qDebug() << "Old value: " << oldFreqDialVal << " New value: " << value ;
double stepSize = 0.001000; // 1kHz steps
double newFreqMhz = 0;
volatile int delta = 0;
int maxVal = ui->freqDial->maximum();
int directPath = 0;
int crossingPath = 0;
int distToMaxNew = 0;
int distToMaxOld = 0;
if(value == 0)
{
distToMaxNew = 0;
} else {
distToMaxNew = maxVal - value;
}
if(oldFreqDialVal != 0)
{
distToMaxOld = maxVal - oldFreqDialVal;
} else {
distToMaxOld = 0;
}
directPath = abs(value - oldFreqDialVal);
if(value < maxVal / 2)
{
crossingPath = value + distToMaxOld;
} else {
crossingPath = distToMaxNew + oldFreqDialVal;
}
if(directPath > crossingPath)
{
// use crossing path, it is shorter
delta = crossingPath;
// mnow calculate the direction:
if( value > oldFreqDialVal)
{
// CW
delta = delta;
} else {
// CCW
delta *= -1;
}
} else {
// use direct path
// crossing path is larger than direct path, use direct path
//delta = directPath;
// now calculate the direction
delta = value - oldFreqDialVal;
}
newFreqMhz = knobFreqMhz + (delta * stepSize);
// qDebug() << "old freq: " << knobFreqMhz << " new freq: " << newFreqMhz << "knobDelta: " << delta << " freq delta: " << newFreqMhz - knobFreqMhz;
this->knobFreqMhz = newFreqMhz; // the frequency we think we should be on.
oldFreqDialVal = value;
ui->freqLabel->setText(QString("%1").arg(knobFreqMhz, 0, 'f'));
emit setFrequency(newFreqMhz);
//emit getFrequency();
} }

Wyświetl plik

@ -145,9 +145,11 @@ private:
double oldLowerFreq; double oldLowerFreq;
double oldUpperFreq; double oldUpperFreq;
double freqMhz; double freqMhz;
double knobFreqMhz;
enum cmds {cmdNone, cmdGetFreq, cmdGetMode, cmdGetDataMode}; enum cmds {cmdNone, cmdGetFreq, cmdGetMode, cmdGetDataMode};
cmds cmdOut; cmds cmdOut;
QVector <cmds> cmdOutQue; QVector <cmds> cmdOutQue;
int oldFreqDialVal;
}; };

Wyświetl plik

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>583</width> <width>583</width>
<height>368</height> <height>582</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -18,7 +18,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="mainTab"> <widget class="QWidget" name="mainTab">
<attribute name="title"> <attribute name="title">
@ -36,9 +36,7 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<widget class="QCustomPlot" name="plot" native="true"> <widget class="QCustomPlot" name="plot" native="true"/>
<zorder>freqDial</zorder>
</widget>
<widget class="QCustomPlot" name="waterfall" native="true"/> <widget class="QCustomPlot" name="waterfall" native="true"/>
</widget> </widget>
</item> </item>