kopia lustrzana https://gitlab.com/eliggett/wfview
Freq knob and beginnings of com port setup.
rodzic
989588f9e1
commit
0b8de1a08b
|
@ -11,10 +11,12 @@ commHandler::commHandler()
|
|||
|
||||
port = new QSerialPort();
|
||||
|
||||
// The following should become arguments and/or functions
|
||||
// TODO: The following should become arguments and/or functions
|
||||
// Add signal/slot everywhere for comm port setup.
|
||||
// Consider how to "re-setup" and how to save the state for next time.
|
||||
baudrate = 115200;
|
||||
stopbits = 1;
|
||||
portName = "/dev/ttyUSB0";
|
||||
portName = "/dev/ttyUSB1";
|
||||
|
||||
setupComm(); // basic parameters
|
||||
openPort();
|
||||
|
@ -62,9 +64,9 @@ void commHandler::sendDataOut(const QByteArray &writeData)
|
|||
void commHandler::receiveDataIn()
|
||||
{
|
||||
// connected to comm port data signal
|
||||
// inPortData.append(port->readAll());
|
||||
|
||||
// OLD: inPortData = port->readAll();
|
||||
// Here we get a little specific to CIV radios
|
||||
// because we know what constitutes a valid "frame" of data.
|
||||
|
||||
// new code:
|
||||
port->startTransaction();
|
||||
|
@ -76,10 +78,7 @@ void commHandler::receiveDataIn()
|
|||
// good!
|
||||
port->commitTransaction();
|
||||
emit haveDataFromPort(inPortData);
|
||||
// PRoblem: We often get several chunks together this way
|
||||
// if we can split and individually send them that would be better.
|
||||
// could emit several at each FE....FD segment.
|
||||
// should probbly make the buffer smaller to reduce this
|
||||
|
||||
if(rolledBack)
|
||||
{
|
||||
qDebug() << "Rolled back and was successfull. Length: " << inPortData.length();
|
||||
|
@ -99,22 +98,13 @@ void commHandler::receiveDataIn()
|
|||
qDebug() << "THIS SHOULD ONLY HAPPEN ONCE!!";
|
||||
// THIS SHOULD ONLY HAPPEN ONCE!
|
||||
|
||||
//qDebug() << "Data start: 0x" << (char)inPortData[00] << (char)inPortData[01]; // danger
|
||||
// unrecoverable. We did not receive the start and must
|
||||
// have missed it earlier because we did not roll back to
|
||||
// preserve the beginning.
|
||||
|
||||
//printHex(inPortData, false, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Here is where we can be smart about this:
|
||||
// port->startTransaction(); port->rollbackTransaction();
|
||||
// port->commitTransaction();
|
||||
|
||||
// qDebug() << "Data: " << inPortData;
|
||||
// OLD: emit haveDataFromPort(inPortData);
|
||||
}
|
||||
|
||||
void commHandler::openPort()
|
||||
|
|
|
@ -395,6 +395,13 @@ void rigCommander::parseCommand()
|
|||
//printHex(payloadIn, false, true);
|
||||
parseSpectrum();
|
||||
break;
|
||||
case '\x1A':
|
||||
if(payloadIn[01] == '\x05')
|
||||
{
|
||||
parseDetailedRegisters1A05();
|
||||
} else {
|
||||
parseRegisters1A();
|
||||
}
|
||||
case '\xFB':
|
||||
// Fine Business, ACK from rig.
|
||||
break;
|
||||
|
@ -412,6 +419,42 @@ void rigCommander::parseCommand()
|
|||
|
||||
}
|
||||
|
||||
void rigCommander::parseRegisters1A()
|
||||
{
|
||||
// The simpler of the 1A stuff:
|
||||
|
||||
// 1A 06: data mode on/off
|
||||
// 07: IP+ enable/disable
|
||||
// 00: memory contents
|
||||
// 01: band stacking memory contents (last freq used is stored here per-band)
|
||||
// 03: filter width
|
||||
// 04: AGC rate
|
||||
switch(payloadIn[02])
|
||||
{
|
||||
case '\x06':
|
||||
// data mode
|
||||
// emit havedataMode( (bool) payloadIn[somebit])
|
||||
// index
|
||||
// 03 04
|
||||
// XX YY
|
||||
// XX = 00 (off) or 01 (on)
|
||||
// YY: filter selected, 01 through 03.;
|
||||
// if YY is 00 then XX was also set to 00
|
||||
emit haveDataMode((bool)payloadIn[03]);
|
||||
break;
|
||||
case '\x07':
|
||||
// IP+
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rigCommander::parseDetailedRegisters1A05()
|
||||
{
|
||||
// It seems a lot of misc stuff is under this command and subcommand.
|
||||
}
|
||||
|
||||
void rigCommander::parseSpectrum()
|
||||
{
|
||||
// Here is what to expect:
|
||||
|
|
|
@ -40,6 +40,7 @@ signals:
|
|||
void haveSpectrumData(QByteArray spectrum, double startFreq, double endFreq); // pass along data to UI
|
||||
void haveFrequency(double frequencyMhz);
|
||||
void haveMode(QString mode);
|
||||
void haveDataMode(bool dataModeEnabled);
|
||||
void haveSpectrumBounds();
|
||||
void dataForComm(const QByteArray &outData);
|
||||
void getMoreDebug();
|
||||
|
@ -56,6 +57,8 @@ private:
|
|||
QByteArray makeFreqPayload(double frequency);
|
||||
void parseMode();
|
||||
void parseSpectrum();
|
||||
void parseDetailedRegisters1A05();
|
||||
void parseRegisters1A();
|
||||
void sendDataOut();
|
||||
void prepDataAndSend(QByteArray data);
|
||||
void debugMe();
|
||||
|
|
30
wfmain.cpp
30
wfmain.cpp
|
@ -35,8 +35,8 @@ wfmain::wfmain(QWidget *parent) :
|
|||
// TODO: FM is missing, should be where CW is, all other modes get +1?
|
||||
// 0 1 2 3 4
|
||||
modes << "LSB" << "USB" << "AM" << "CW" << "RTTY";
|
||||
// 5 6 7 8 9
|
||||
modes << "CW-R" << "RTTY-R" << "LSB-D" << "USB-D";
|
||||
// 5 6 7 8 9
|
||||
modes << "FM" << "CW-R" << "RTTY-R" << "LSB-D" << "USB-D";
|
||||
ui->modeSelectCombo->insertItems(0, modes);
|
||||
|
||||
spans << "2.5k" << "5.0k" << "10k" << "25k";
|
||||
|
@ -61,6 +61,7 @@ wfmain::wfmain(QWidget *parent) :
|
|||
connect(rig, SIGNAL(haveFrequency(double)), this, SLOT(receiveFreq(double)));
|
||||
connect(this, SIGNAL(getFrequency()), rig, SLOT(getFrequency()));
|
||||
connect(this, SIGNAL(getMode()), rig, SLOT(getMode()));
|
||||
connect(this, SIGNAL(getDataMode()), rig, SLOT(getDataMode()));
|
||||
connect(this, SIGNAL(getDebug()), rig, SLOT(getDebug()));
|
||||
connect(this, SIGNAL(spectOutputDisable()), rig, SLOT(disableSpectOutput()));
|
||||
connect(this, SIGNAL(spectOutputEnable()), rig, SLOT(enableSpectOutput()));
|
||||
|
@ -117,6 +118,12 @@ wfmain::wfmain(QWidget *parent) :
|
|||
delayedCommand->setSingleShot(true);
|
||||
connect(delayedCommand, SIGNAL(timeout()), this, SLOT(runDelayedCommand()));
|
||||
|
||||
foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts())
|
||||
{
|
||||
portList.append(serialPortInfo.portName());
|
||||
ui->commPortDrop->addItem(serialPortInfo.portName());
|
||||
}
|
||||
|
||||
getInitialRigState();
|
||||
|
||||
}
|
||||
|
@ -237,6 +244,7 @@ void wfmain::runDelayedCommand()
|
|||
default:
|
||||
break;
|
||||
}
|
||||
cmdOut = cmdNone; // yep. Hope this wasn't called twice in a row rapidly.
|
||||
|
||||
// Note: Commands that need a specific order should use this queue.
|
||||
// Commands that do not need a speific order should probably just
|
||||
|
@ -256,6 +264,7 @@ void wfmain::runDelayedCommand()
|
|||
emit getMode();
|
||||
break;
|
||||
case cmdGetDataMode:
|
||||
emit getDataMode();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -619,6 +628,14 @@ void wfmain::on_scopeEdgeCombo_currentIndexChanged(int index)
|
|||
|
||||
void wfmain::on_modeSelectCombo_currentIndexChanged(int index)
|
||||
{
|
||||
// do nothing. The change may be from receiving a mode status update or the user. Can't tell which is which here.
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wfmain::on_modeSelectCombo_activated(int index)
|
||||
{
|
||||
// the user initiated a mode change.
|
||||
if(index < 10)
|
||||
{
|
||||
qDebug() << "Mode selection changed. index: " << index;
|
||||
|
@ -631,6 +648,15 @@ void wfmain::on_modeSelectCombo_currentIndexChanged(int index)
|
|||
// set data mode off
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void wfmain::on_freqDial_actionTriggered(int action)
|
||||
{
|
||||
//qDebug() << "Action: " << action; // "7" == changed?
|
||||
}
|
||||
|
||||
void wfmain::on_freqDial_valueChanged(int value)
|
||||
{
|
||||
qDebug() << "Value changed to: " << value ;
|
||||
}
|
||||
|
|
9
wfmain.h
9
wfmain.h
|
@ -11,6 +11,7 @@
|
|||
#include "commhandler.h"
|
||||
#include "rigcommander.h"
|
||||
#include <qcustomplot.h>
|
||||
#include<qserialportinfo.h>
|
||||
|
||||
namespace Ui {
|
||||
class wfmain;
|
||||
|
@ -29,6 +30,7 @@ signals:
|
|||
void setFrequency(double freq);
|
||||
void getMode();
|
||||
void setMode(char modeIndex);
|
||||
void getDataMode();
|
||||
void getDebug();
|
||||
void spectOutputEnable();
|
||||
void spectOutputDisable();
|
||||
|
@ -96,6 +98,12 @@ private slots:
|
|||
|
||||
void on_useDarkThemeChk_clicked(bool checked);
|
||||
|
||||
void on_modeSelectCombo_activated(int index);
|
||||
|
||||
void on_freqDial_actionTriggered(int action);
|
||||
|
||||
void on_freqDial_valueChanged(int value);
|
||||
|
||||
private:
|
||||
Ui::wfmain *ui;
|
||||
QCustomPlot *plot; // line plot
|
||||
|
@ -106,6 +114,7 @@ private:
|
|||
void setPlotTheme(QCustomPlot *plot, bool isDark);
|
||||
void getInitialRigState();
|
||||
QWidget * theParent;
|
||||
QStringList portList;
|
||||
|
||||
rigCommander * rig;
|
||||
QThread * rigThread;
|
||||
|
|
36
wfmain.ui
36
wfmain.ui
|
@ -18,7 +18,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mainTab">
|
||||
<attribute name="title">
|
||||
|
@ -36,7 +36,9 @@
|
|||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</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>
|
||||
</item>
|
||||
|
@ -165,6 +167,34 @@
|
|||
<item>
|
||||
<widget class="QComboBox" name="modeSelectCombo"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDial" name="freqDial">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>60</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="wrapping">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="notchesVisible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
|
@ -1012,7 +1042,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>583</width>
|
||||
<height>19</height>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
Ładowanie…
Reference in New Issue