UI cleanup and PTT, F5 functions.

merge-requests/1/merge
Elliott Liggett 2019-01-23 17:19:35 -08:00
rodzic 0da6babb7a
commit 2f16c6c2bb
4 zmienionych plików z 85 dodań i 85 usunięć

Wyświetl plik

@ -20,7 +20,7 @@ commHandler::commHandler()
setupComm(); // basic parameters
openPort();
qDebug() << "Serial buffer size: " << port->readBufferSize();
//qDebug() << "Serial buffer size: " << port->readBufferSize();
//port->setReadBufferSize(1024); // manually. 256 never saw any return from the radio. why...
//qDebug() << "Serial buffer size: " << port->readBufferSize();
@ -62,7 +62,7 @@ commHandler::commHandler(QString portName)
void commHandler::initializePt()
{
qDebug() << "init pt";
// qDebug() << "init pt";
pseudoterm = new QSerialPort();
setupPtComm();
openPtPort();
@ -70,7 +70,7 @@ void commHandler::initializePt()
void commHandler::setupPtComm()
{
qDebug() << "Setting up pt";
// qDebug() << "Setting up pt";
pseudoterm->setPortName("/dev/ptmx");
// pseudoterm->setBaudRate(baudrate);
// pseudoterm->setStopBits(QSerialPort::OneStop);
@ -78,15 +78,15 @@ void commHandler::setupPtComm()
void commHandler::openPtPort()
{
qDebug() << "opening pt port";
// qDebug() << "opening pt port";
bool success;
char ptname[128];
success = pseudoterm->open(QIODevice::ReadWrite);
if(success)
{
qDebug() << "Opened pt device, attempting to grant pt status";
// qDebug() << "Opened pt device, attempting to grant pt status";
ptfd = pseudoterm->handle();
qDebug() << "ptfd: " << ptfd;
// qDebug() << "ptfd: " << ptfd;
if(grantpt(ptfd))
{
qDebug() << "Failed to grantpt";
@ -241,7 +241,7 @@ void commHandler::openPort()
return;
} else {
// debug?
qDebug() << "Could not open serial port " << portName;
qDebug() << "Could not open serial port " << portName << " , please restart.";
isConnected = false;
return;
}

Wyświetl plik

@ -4,6 +4,9 @@
#include "commhandler.h"
#include "rigidentities.h"
// This code is copyright 2018-2019 Elliott H. Liggett
// All rights reserved
wfmain::wfmain(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::wfmain)
@ -11,6 +14,11 @@ wfmain::wfmain(QWidget *parent) :
ui->setupUi(this);
theParent = parent;
ui->bandStkLastUsedBtn->setVisible(false);
ui->bandStkVoiceBtn->setVisible(false);
ui->bandStkDataBtn->setVisible(false);
ui->bandStkCWBtn->setVisible(false);
keyF11 = new QShortcut(this);
keyF11->setKey(Qt::Key_F11);
connect(keyF11, SIGNAL(activated()), this, SLOT(shortcutF11()));
@ -31,6 +39,10 @@ wfmain::wfmain(QWidget *parent) :
keyF4->setKey(Qt::Key_F4);
connect(keyF4, SIGNAL(activated()), this, SLOT(shortcutF4()));
keyF5 = new QShortcut(this);
keyF5->setKey(Qt::Key_F5);
connect(keyF5, SIGNAL(activated()), this, SLOT(shortcutF5()));
keyStar = new QShortcut(this);
keyStar->setKey(Qt::Key_Asterisk);
connect(keyStar, SIGNAL(activated()), this, SLOT(shortcutStar()));
@ -54,7 +66,7 @@ wfmain::wfmain(QWidget *parent) :
serialPortRig = it.filePath(); // first? last?
if(serialPortRig.isEmpty())
{
qDebug() << "Cannot find valid serial port. Trying /dev/ttyUSB0";
qDebug() << "Cannot find IC-7300 serial port. Trying /dev/ttyUSB0";
serialPortRig = QString("/dev/ttyUSB0");
}
// end finding the 7300 code
@ -197,11 +209,19 @@ wfmain::wfmain(QWidget *parent) :
delayedCommand->setSingleShot(true);
connect(delayedCommand, SIGNAL(timeout()), this, SLOT(runDelayedCommand()));
pttTimer = new QTimer(this);
pttTimer->setInterval(180*1000); // 3 minute max transmit time in ms
pttTimer->setSingleShot(true);
connect(pttTimer, SIGNAL(timeout()), this, SLOT(handlePttLimit()));
// Not needed since we automate this now.
/*
foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts())
{
portList.append(serialPortInfo.portName());
ui->commPortDrop->addItem(serialPortInfo.portName());
// ui->commPortDrop->addItem(serialPortInfo.portName());
}
*/
// Initial state of UI:
ui->fullScreenChk->setChecked(prefs.useFullScreen);
@ -434,6 +454,8 @@ void wfmain::shortcutF4()
void wfmain::shortcutF5()
{
QString buildInfo = QString("Build " + QString(GITSHORT) + " on " + QString(__DATE__) + " at " + __TIME__ + " by " + UNAME + "@" + HOST);
showStatusBarText(buildInfo);
}
@ -544,7 +566,6 @@ void wfmain::setDefaultColors()
void wfmain::setPlotTheme(QCustomPlot *plot, bool isDark)
{
QColor color;
if(isDark)
{
plot->setBackground(QColor(0,0,0,255));
@ -1420,17 +1441,36 @@ void wfmain::on_pttOnBtn_clicked()
{
// is it enabled?
// Are we already PTT?
if(!ui->pttEnableChk->isChecked())
{
showStatusBarText("PTT is disabled, not sending command.");
return;
}
// Are we already PTT? Not a big deal, just send again anyway.
showStatusBarText("Sending PTT ON command");
emit setPTT(true);
// send PTT
// Start 3 minute timer
pttTimer->start();
}
void wfmain::on_pttOffBtn_clicked()
{
// Send the PTT OFF command (more than once?)
showStatusBarText("Sending PTT OFF command");
emit setPTT(false);
// Stop the 3 min timer
pttTimer->stop();
}
void wfmain::handlePttLimit()
{
// transmission time exceeded!
showStatusBarText("Transmit timeout at 3 minutes. Sending PTT OFF command now.");
emit setPTT(false);
}

Wyświetl plik

@ -68,6 +68,7 @@ private slots:
void shortcutF5();
void shortcutStar();
void handlePttLimit(); // hit at 3 min transmit length
void on_startBtn_clicked();
void receiveFreq(double);
@ -225,6 +226,7 @@ private:
QCPColorMapData * colorMapData;
QCPColorScale * colorScale;
QTimer * delayedCommand;
QTimer * pttTimer;
QStringList modes;
int currentModeIndex;
@ -298,6 +300,7 @@ private:
void useColors(); // set the plot up
void setDefPrefs(); // populate default values to default prefs
int oldFreqDialVal;
void bandStackBtnClick();

105
wfmain.ui
Wyświetl plik

@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>3</number>
<number>1</number>
</property>
<widget class="QWidget" name="mainTab">
<attribute name="title">
@ -537,7 +537,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QRadioButton" name="radioButton_4">
<widget class="QRadioButton" name="bandStkLastUsedBtn">
<property name="text">
<string>&amp;Last Used</string>
</property>
@ -552,46 +552,66 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Band Stack Selection:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="bandStkPopdown">
<item>
<property name="text">
<string>0 - Latest Used</string>
<string>1 - Latest Used</string>
</property>
</item>
<item>
<property name="text">
<string>1 - Older</string>
<string>2 - Older</string>
</property>
</item>
<item>
<property name="text">
<string>2 - Oldest Used</string>
<string>3 - Oldest Used</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_3">
<widget class="QRadioButton" name="bandStkVoiceBtn">
<property name="text">
<string>Voice</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_2">
<widget class="QRadioButton" name="bandStkDataBtn">
<property name="text">
<string>Data</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton">
<widget class="QRadioButton" name="bandStkCWBtn">
<property name="text">
<string>&amp;CW</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
@ -1063,62 +1083,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Radio CIV Address (decimal)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="civAddrSpin">
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>148</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Port Baudrate</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="baudRateDropdown"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Comm Port</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="commPortDrop"/>
</item>
<item>
<widget class="QPushButton" name="initCommBtn">
<property name="text">
<string>Initialize Comm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<property name="topMargin">
@ -1141,19 +1105,12 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableXmlRpcChk">
<property name="text">
<string>Enable XML RPC server</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<property name="topMargin">
<number>9</number>
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pttOnBtn">
@ -1222,7 +1179,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<property name="topMargin">
<number>20</number>
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="tuneEnableChk">
@ -1278,7 +1235,7 @@
<x>0</x>
<y>0</y>
<width>703</width>
<height>20</height>
<height>22</height>
</rect>
</property>
</widget>