Merge remote-tracking branch 'origin/pollprefs' into various-fixes

half-duplex
Phil Taylor 2022-11-28 09:27:53 +00:00
commit 0a1a7b2336
8 zmienionych plików z 246 dodań i 122 usunięć

Wyświetl plik

@ -17,7 +17,7 @@
#include <eigen3/Eigen/Eigen>
#endif
enum audioType {qtAudio,portAudio,rtAudio};
#include "wfviewtypes.h"
#include "resampler/speex_resampler.h"

52
prefs.h 100644
Wyświetl plik

@ -0,0 +1,52 @@
#ifndef PREFS_H
#define PREFS_H
#include <QString>
#include "wfviewtypes.h"
struct preferences {
QString version;
bool useFullScreen;
bool useSystemTheme;
bool drawPeaks;
underlay_t underlayMode = underlayNone;
int underlayBufferSize = 64;
bool wfAntiAlias;
bool wfInterpolate;
QString stylesheetPath;
unsigned char radioCIVAddr;
bool CIVisRadioModel;
bool forceRTSasPTT;
QString serialPortRadio;
quint32 serialPortBaud;
int polling_ms;
bool enablePTT;
bool niceTS;
bool enableLAN;
bool enableRigCtlD;
quint16 rigCtlPort;
int currentColorPresetNumber = 0;
QString virtualSerialPort;
unsigned char localAFgain;
unsigned int wflength;
int wftheme;
int plotFloor;
int plotCeiling;
bool confirmExit;
bool confirmPowerOff;
meterKind meter2Type;
quint16 tcpPort;
quint8 waterfallFormat;
audioType audioSystem;
bool clusterUdpEnable;
bool clusterTcpEnable;
int clusterUdpPort;
QString clusterTcpServerName;
QString clusterTcpUserName;
QString clusterTcpPassword;
int clusterTimeout;
bool clickDragTuningEnable;
};
#endif // PREFS_H

Wyświetl plik

@ -5,7 +5,7 @@
#include <QMutexLocker>
#include <QDebug>
#include "wfviewtypes.h"
#include "commhandler.h"
#include "pttyhandler.h"
#include "udphandler.h"
@ -23,48 +23,6 @@
// note: using a define because switch case doesn't even work with const unsigned char. Surprised me.
#define compCivAddr 0xE1
enum meterKind {
meterNone=0,
meterS,
meterCenter,
meterSWR,
meterPower,
meterALC,
meterComp,
meterVoltage,
meterCurrent,
meterRxdB,
meterTxMod,
meterRxAudio,
meterAudio,
meterLatency
};
enum spectrumMode {
spectModeCenter=0x00,
spectModeFixed=0x01,
spectModeScrollC=0x02,
spectModeScrollF=0x03,
spectModeUnknown=0xff
};
struct freqt {
quint64 Hz;
double MHzDouble;
};
struct datekind {
uint16_t year;
unsigned char month;
unsigned char day;
};
struct timekind {
unsigned char hours;
unsigned char minutes;
bool isMinus;
};
class rigCommander : public QObject
{
Q_OBJECT

Wyświetl plik

@ -1422,6 +1422,7 @@ void wfmain::setDefPrefs()
defPrefs.forceRTSasPTT = false;
defPrefs.serialPortRadio = QString("auto");
defPrefs.serialPortBaud = 115200;
defPrefs.polling_ms = 0; // 0 = Automatic
defPrefs.enablePTT = false;
defPrefs.niceTS = true;
defPrefs.enableRigCtlD = false;
@ -1570,6 +1571,27 @@ void wfmain::loadSettings()
serverConfig.baudRate = prefs.serialPortBaud;
}
prefs.polling_ms = settings->value("polling_ms", defPrefs.polling_ms).toInt();
if(prefs.polling_ms == 0)
{
// Automatic
ui->pollingButtonGroup->blockSignals(true);
ui->autoPollBtn->setChecked(true);
ui->manualPollBtn->setChecked(false);
ui->pollingButtonGroup->blockSignals(false);
ui->pollTimeMsSpin->setEnabled(false);
} else {
// Manual
ui->pollingButtonGroup->blockSignals(true);
ui->autoPollBtn->setChecked(false);
ui->manualPollBtn->setChecked(true);
ui->pollingButtonGroup->blockSignals(false);
ui->pollTimeMsSpin->blockSignals(true);
ui->pollTimeMsSpin->setValue(prefs.polling_ms);
ui->pollTimeMsSpin->blockSignals(false);
ui->pollTimeMsSpin->setEnabled(true);
}
prefs.virtualSerialPort = settings->value("VirtualSerialPort", defPrefs.virtualSerialPort).toString();
int vspIndex = ui->vspCombo->findText(prefs.virtualSerialPort);
if (vspIndex != -1) {
@ -2100,6 +2122,10 @@ void wfmain::saveSettings()
qInfo(logSystem()) << "Saving settings to " << settings->fileName();
// Basic things to load:
settings->beginGroup("Program");
settings->setValue("version", QString(WFVIEW_VERSION));
settings->endGroup();
// UI: (full screen, dark theme, draw peaks, colors, etc)
settings->beginGroup("Interface");
settings->setValue("UseFullScreen", prefs.useFullScreen);
@ -2129,6 +2155,7 @@ void wfmain::saveSettings()
settings->setValue("RigCIVuInt", prefs.radioCIVAddr);
settings->setValue("CIVisRadioModel", prefs.CIVisRadioModel);
settings->setValue("ForceRTSasPTT", prefs.forceRTSasPTT);
settings->setValue("polling_ms", prefs.polling_ms); // 0 = automatic
settings->setValue("SerialPortRadio", prefs.serialPortRadio);
settings->setValue("SerialPortBaud", prefs.serialPortBaud);
settings->setValue("VirtualSerialPort", prefs.virtualSerialPort);
@ -3711,7 +3738,12 @@ void wfmain::receiveRigID(rigCapabilities rigCaps)
issueDelayedCommand(cmdGetFreq);
issueDelayedCommand(cmdGetMode);
// recalculate command timing now that we know the rig better:
calculateTimingParameters();
if(prefs.polling_ms != 0)
{
changePollTiming(prefs.polling_ms, true);
} else {
calculateTimingParameters();
}
initPeriodicCommands();
// Set the second meter here as I suspect we need to be connected for it to work?
@ -5883,6 +5915,10 @@ void wfmain::calculateTimingParameters()
qInfo(logSystem()) << "Delay command interval timing: " << delayedCommand->interval() << "ms";
ui->pollTimeMsSpin->blockSignals(true);
ui->pollTimeMsSpin->setValue(delayedCommand->interval());
ui->pollTimeMsSpin->blockSignals(false);
// Normal:
delayedCmdIntervalLAN_ms = delayedCommand->interval();
delayedCmdIntervalSerial_ms = delayedCommand->interval();
@ -6164,20 +6200,6 @@ void wfmain::on_wfLengthSlider_valueChanged(int value)
prepareWf(value);
}
void wfmain::on_pollingBtn_clicked()
{
bool ok;
int timing = 0;
timing = QInputDialog::getInt(this, "wfview Radio Polling Setup", "Poll Timing Interval (ms)", delayedCommand->interval(), 1, 200, 1, &ok );
if(ok && timing)
{
delayedCommand->setInterval( timing );
qInfo(logSystem()) << "User changed radio polling interval to " << timing << "ms.";
showStatusBarText("User changed radio polling interval to " + QString("%1").arg(timing) + "ms.");
}
}
void wfmain::on_wfAntiAliasChk_clicked(bool checked)
{
colorMap->setAntialiased(checked);
@ -7840,3 +7862,46 @@ void wfmain::on_clickDragTuningEnableChk_clicked(bool checked)
}
void wfmain::on_autoPollBtn_clicked(bool checked)
{
ui->pollTimeMsSpin->setEnabled(!checked);
if(checked)
{
prefs.polling_ms = 0;
qInfo(logSystem()) << "User set radio polling interval to automatic.";
calculateTimingParameters();
}
}
void wfmain::on_manualPollBtn_clicked(bool checked)
{
ui->pollTimeMsSpin->setEnabled(checked);
if(checked)
{
prefs.polling_ms = ui->pollTimeMsSpin->value();
changePollTiming(prefs.polling_ms);
}
}
void wfmain::on_pollTimeMsSpin_valueChanged(int timing_ms)
{
if(ui->manualPollBtn->isChecked())
{
changePollTiming(timing_ms);
}
}
void wfmain::changePollTiming(int timing_ms, bool setUI)
{
delayedCommand->setInterval(timing_ms);
qInfo(logSystem()) << "User changed radio polling interval to " << timing_ms << "ms.";
showStatusBarText("User changed radio polling interval to " + QString("%1").arg(timing_ms) + "ms.");
prefs.polling_ms = timing_ms;
if(setUI)
{
ui->pollTimeMsSpin->blockSignals(true);
ui->pollTimeMsSpin->setValue(timing_ms);
ui->pollTimeMsSpin->blockSignals(false);
}
}

Wyświetl plik

@ -20,6 +20,8 @@
#include <QColor>
#include "logcategories.h"
#include "wfviewtypes.h"
#include "prefs.h"
#include "commhandler.h"
#include "rigcommander.h"
#include "rigstate.h"
@ -511,8 +513,6 @@ private slots:
void on_wfLengthSlider_valueChanged(int value);
void on_pollingBtn_clicked();
void on_wfAntiAliasChk_clicked(bool checked);
void on_wfInterpolateChk_clicked(bool checked);
@ -684,6 +684,12 @@ private slots:
void receiveClusterOutput(QString text);
void receiveSpots(QList<spotData> spots);
void on_autoPollBtn_clicked(bool checked);
void on_manualPollBtn_clicked(bool checked);
void on_pollTimeMsSpin_valueChanged(int arg1);
private:
Ui::wfmain *ui;
void closeEvent(QCloseEvent *event);
@ -801,9 +807,6 @@ private:
quint16 wfLength;
bool spectrumDrawLock;
enum underlay_t { underlayNone, underlayPeakHold, underlayPeakBuffer, underlayAverageBuffer };
QByteArray spectrumPeaks;
QVector <double> spectrumPlasmaLine;
QVector <QByteArray> spectrumPlasma;
@ -904,49 +907,7 @@ private:
colorPrefsType colorPreset[numColorPresetsTotal];
struct preferences {
bool useFullScreen;
bool useSystemTheme;
bool drawPeaks;
underlay_t underlayMode = underlayNone;
int underlayBufferSize = 64;
bool wfAntiAlias;
bool wfInterpolate;
QString stylesheetPath;
unsigned char radioCIVAddr;
bool CIVisRadioModel;
bool forceRTSasPTT;
QString serialPortRadio;
quint32 serialPortBaud;
bool enablePTT;
bool niceTS;
bool enableLAN;
bool enableRigCtlD;
quint16 rigCtlPort;
int currentColorPresetNumber = 0;
QString virtualSerialPort;
unsigned char localAFgain;
unsigned int wflength;
int wftheme;
int plotFloor;
int plotCeiling;
bool confirmExit;
bool confirmPowerOff;
meterKind meter2Type;
quint16 tcpPort;
quint8 waterfallFormat;
audioType audioSystem;
bool clusterUdpEnable;
bool clusterTcpEnable;
int clusterUdpPort;
QString clusterTcpServerName;
QString clusterTcpUserName;
QString clusterTcpPassword;
int clusterTimeout;
bool clusterSkimmerSpotsEnable;
bool clickDragTuningEnable;
} prefs;
preferences prefs;
preferences defPrefs;
udpPreferences udpPrefs;
udpPreferences udpDefPrefs;
@ -1016,6 +977,7 @@ private:
void insertSlowPeriodicCommand(cmds cmd, unsigned char priority);
void calculateTimingParameters();
void changePollTiming(int timing_ms, bool setUI=false);
void changeMode(mode_kind mode);
void changeMode(mode_kind mode, bool dataOn);

Wyświetl plik

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1023</width>
<width>1082</width>
<height>660</height>
</rect>
</property>
@ -3147,18 +3147,51 @@
<widget class="QComboBox" name="meter2selectionCombo"/>
</item>
<item>
<widget class="QPushButton" name="pollingBtn">
<widget class="QRadioButton" name="autoPollBtn">
<property name="toolTip">
<string>Set up radio polling. The radio's meter is polled every-other interval.</string>
</property>
<property name="accessibleName">
<string>Polling</string>
</property>
<property name="accessibleDescription">
<string/>
<string>wfview will automatically calculate command polling. Recommended.</string>
</property>
<property name="text">
<string>Polling</string>
<string>AutoPolling</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">pollingButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="manualPollBtn">
<property name="toolTip">
<string>Manual (user-defined) command polling</string>
</property>
<property name="text">
<string>Manual Polling Inteval:</string>
</property>
<attribute name="buttonGroup">
<string notr="true">pollingButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QSpinBox" name="pollTimeMsSpin">
<property name="toolTip">
<string>Sets the polling interval, in ms. Automatic polling is recommended. Serial port and USB port radios should not poll quicker than about 75ms.</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>250</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_50">
<property name="text">
<string>ms</string>
</property>
</widget>
</item>
@ -3350,8 +3383,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>801</width>
<height>311</height>
<width>858</width>
<height>287</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@ -5295,7 +5328,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1023</width>
<width>1082</width>
<height>21</height>
</rect>
</property>
@ -5323,7 +5356,8 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
<buttongroup name="underlayButtonGroup"/>
<buttongroup name="pollingButtonGroup"/>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>

Wyświetl plik

@ -185,6 +185,7 @@ HEADERS += wfmain.h \
colorprefs.h \
commhandler.h \
loggingwindow.h \
prefs.h \
rigcommander.h \
freqmemory.h \
rigidentities.h \
@ -218,7 +219,8 @@ HEADERS += wfmain.h \
tcpserver.h \
cluster.h \
database.h \
aboutbox.h
aboutbox.h \
wfviewtypes.h
FORMS += wfmain.ui \

51
wfviewtypes.h 100644
Wyświetl plik

@ -0,0 +1,51 @@
#ifndef WFVIEWTYPES_H
#define WFVIEWTYPES_H
enum underlay_t { underlayNone, underlayPeakHold, underlayPeakBuffer, underlayAverageBuffer };
enum meterKind {
meterNone=0,
meterS,
meterCenter,
meterSWR,
meterPower,
meterALC,
meterComp,
meterVoltage,
meterCurrent,
meterRxdB,
meterTxMod,
meterRxAudio,
meterAudio,
meterLatency
};
enum spectrumMode {
spectModeCenter=0x00,
spectModeFixed=0x01,
spectModeScrollC=0x02,
spectModeScrollF=0x03,
spectModeUnknown=0xff
};
struct freqt {
quint64 Hz;
double MHzDouble;
};
struct datekind {
uint16_t year;
unsigned char month;
unsigned char day;
};
struct timekind {
unsigned char hours;
unsigned char minutes;
bool isMinus;
};
enum audioType {qtAudio,portAudio,rtAudio};
#endif // WFVIEWTYPES_H