Merge branch 'ui-enhance' into lan-alpha

merge-requests/2/head
Phil Taylor 2021-04-25 10:58:40 +01:00
commit 119d328b17
5 zmienionych plików z 270 dodań i 36 usunięć

Wyświetl plik

@ -593,6 +593,63 @@ QByteArray rigCommander::makeFreqPayload(double freq)
return result;
}
void rigCommander::setRitEnable(bool ritEnabled)
{
QByteArray payload;
if(ritEnabled)
{
payload.setRawData("\x21\x01\x01", 3);
} else {
payload.setRawData("\x21\x01\x00", 3);
}
prepDataAndSend(payload);
}
void rigCommander::getRitEnabled()
{
QByteArray payload;
payload.setRawData("\x21\x01", 2);
prepDataAndSend(payload);
}
void rigCommander::getRitValue()
{
QByteArray payload;
payload.setRawData("\x21\x00", 2);
prepDataAndSend(payload);
}
void rigCommander::setRitValue(int ritValue)
{
QByteArray payload;
QByteArray freqBytes;
freqt f;
bool isNegative = false;
payload.setRawData("\x21\x00", 2);
if(ritValue < 0)
{
isNegative = true;
ritValue *= -1;
}
if(ritValue > 9999)
return;
f.Hz = ritValue;
freqBytes = makeFreqPayload(f);
freqBytes.truncate(2);
payload.append(freqBytes);
payload.append(QByteArray(1,(char)isNegative));
prepDataAndSend(payload);
}
void rigCommander::setMode(unsigned char mode, unsigned char modeFilter)
{
QByteArray payload;
@ -1123,6 +1180,10 @@ void rigCommander::parseCommand()
qDebug(logRig()) << "Have rig ID: decimal: " << (unsigned int)model;
break;
case '\x21':
// RIT and Delta TX:
parseRegister21();
break;
case '\x26':
if((int)payloadIn[1] == 0)
@ -1905,6 +1966,45 @@ void rigCommander::parseRegisters1C()
}
}
void rigCommander::parseRegister21()
{
// Register 21 is RIT and Delta TX
int ritHz = 0;
freqt f;
QByteArray longfreq;
// Example RIT value reply:
// Index: 00 01 02 03 04 05
// DATA: 21 00 32 03 00 fd
switch(payloadIn[01])
{
case '\x00':
// RIT frequency
//
longfreq = payloadIn.mid(2,2);
longfreq.append(QByteArray(3,'\x00'));
f = parseFrequency(longfreq, 3);
ritHz = f.Hz*((payloadIn.at(4)=='\x01')?-1:1);
emit haveRitFrequency(ritHz);
break;
case '\x01':
// RIT on/off
if(payloadIn.at(02) == '\x01')
{
emit haveRitEnabled(true);
} else {
emit haveRitEnabled(false);
}
break;
case '\x02':
// Delta TX setting on/off
break;
default:
break;
}
}
void rigCommander::parseATU()
{
// qDebug(logRig()) << "Have ATU status from radio. Emitting.";
@ -2174,6 +2274,8 @@ void rigCommander::parseDetailedRegisters1A05()
case 62:
emit haveLANGain(level);
break;
default:
break;
}
case model7610:
switch(subcmd)
@ -2247,6 +2349,8 @@ void rigCommander::parseDetailedRegisters1A05()
case 91:
emit haveModInput(input, true);
break;
default:
break;
}
case model705:
switch(subcmd)
@ -2861,6 +2965,9 @@ freqt rigCommander::parseFrequency(QByteArray data, unsigned char lastPosition)
// TODO: Check length of data array prior to reading +/- position
// NOTE: This function was written on the IC-7300, which has no need for 100 MHz and 1 GHz.
// Therefore, this function has to go to position +1 to retrieve those numbers for the IC-9700.
// TODO: 64-bit value is incorrect, multiplying by wrong numbers.
float freq = 0.0;
@ -2877,9 +2984,13 @@ freqt rigCommander::parseFrequency(QByteArray data, unsigned char lastPosition)
freq += 10*((data[lastPosition] & 0xf0) >> 4);
freqs.Hz += (data[lastPosition] & 0x0f) * 1E6;
freqs.Hz += ((data[lastPosition] & 0xf0) >> 4) * 1E6 * 10;
freqs.Hz += (data[lastPosition+1] & 0x0f) * 1E6 * 100;
freqs.Hz += ((data[lastPosition+1] & 0xf0) >> 4) * 1E6 * 1000;
freqs.Hz += ((data[lastPosition] & 0xf0) >> 4) * 1E6 * 10; // 10 MHz
if(data.length() >= lastPosition+1)
{
freqs.Hz += (data[lastPosition+1] & 0x0f) * 1E6 * 100; // 100 MHz
freqs.Hz += ((data[lastPosition+1] & 0xf0) >> 4) * 1E6 * 1000; // 1000 MHz
}
// Hz:
@ -2892,14 +3003,14 @@ freqt rigCommander::parseFrequency(QByteArray data, unsigned char lastPosition)
freq += ((data[lastPosition-3] & 0xf0) >> 4) / 100000.0;
freq += (data[lastPosition-3] & 0x0f) / 1000000.0;
freqs.Hz += (data[lastPosition-1] & 0x0f);
freqs.Hz += ((data[lastPosition-1] & 0xf0) >> 4) * 10;
freqs.Hz += (data[lastPosition-1] & 0x0f) * 10E3; // 10 KHz
freqs.Hz += ((data[lastPosition-1] & 0xf0) >> 4) * 100E3; // 100 KHz
freqs.Hz += (data[lastPosition-2] & 0x0f) * 100;
freqs.Hz += ((data[lastPosition-2] & 0xf0) >> 4) * 1000;
freqs.Hz += (data[lastPosition-2] & 0x0f) * 100; // 100 Hz
freqs.Hz += ((data[lastPosition-2] & 0xf0) >> 4) * 1000; // 1 KHz
freqs.Hz += (data[lastPosition-3] & 0x0f) * 10000;
freqs.Hz += ((data[lastPosition-3] & 0xf0) >> 4) * 100000;
freqs.Hz += (data[lastPosition-3] & 0x0f) * 1; // 1 Hz
freqs.Hz += ((data[lastPosition-3] & 0xf0) >> 4) * 10; // 10 Hz
freqs.MHzDouble = (double)freq;
return freqs;

Wyświetl plik

@ -95,6 +95,10 @@ public slots:
void setDataMode(bool dataOn);
void getDataMode();
void getBandStackReg(char band, char regCode);
void getRitEnabled();
void getRitValue();
void setRitValue(int ritValue);
void setRitEnable(bool ritEnabled);
// PTT, ATU, ATT, Antenna, and Preamp:
void getPTT();
@ -244,6 +248,8 @@ signals:
void haveMode(unsigned char mode, unsigned char filter);
void haveDataMode(bool dataModeEnabled);
void haveBandStackReg(float freq, char mode, bool dataOn);
void haveRitEnabled(bool ritEnabled);
void haveRitFrequency(int ritHz);
// Repeater:
void haveDuplexMode(duplexMode);
@ -325,6 +331,7 @@ private:
void parseRegister1B();
void parseRegisters1C();
void parseRegister16();
void parseRegister21();
void parseBandStackReg();
void parsePTT();
void parseATU();

Wyświetl plik

@ -305,8 +305,10 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
rigName->setText("NONE");
rigName->setFixedWidth(50);
delayedCmdInterval_ms = 100; // interval for regular delayed commands
delayedCmdStartupInterval_ms = 100; // interval for initial rig state polling
delayedCommand = new QTimer(this);
delayedCommand->setInterval(250); // 250ms until we find rig civ and id, then 100ms.
delayedCommand->setInterval(delayedCmdStartupInterval_ms); // 250ms until we find rig civ and id, then 100ms.
delayedCommand->setSingleShot(true);
connect(delayedCommand, SIGNAL(timeout()), this, SLOT(runDelayedCommand()));
@ -353,6 +355,13 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
connect(this, SIGNAL(setPTT(bool)), rig, SLOT(setPTT(bool)));
connect(this, SIGNAL(getPTT()), rig, SLOT(getPTT()));
connect(rig, SIGNAL(haveBandStackReg(float,char,bool)), this, SLOT(receiveBandStackReg(float,char,bool)));
connect(this, SIGNAL(setRitEnable(bool)), rig, SLOT(setRitEnable(bool)));
connect(this, SIGNAL(setRitValue(int)), rig, SLOT(setRitValue(int)));
connect(rig, SIGNAL(haveRitEnabled(bool)), this, SLOT(receiveRITStatus(bool)));
connect(rig, SIGNAL(haveRitFrequency(int)), this, SLOT(receiveRITValue(int)));
connect(this, SIGNAL(getRitEnabled()), rig, SLOT(getRitEnabled()));
connect(this, SIGNAL(getRitValue()), rig, SLOT(getRitValue()));
connect(this, SIGNAL(getDebug()), rig, SLOT(getDebug()));
connect(this, SIGNAL(spectOutputDisable()), rig, SLOT(disableSpectOutput()));
@ -738,7 +747,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
//now we know what the rig ID is:
//qDebug(logSystem()) << "In wfview, we now have a reply to our request for rig identity sent to CIV BROADCAST.";
delayedCommand->setInterval(100); // faster polling is ok now.
delayedCommand->setInterval(delayedCmdInterval_ms); // faster polling is ok now.
receiveRigID(rigCaps);
getInitialRigState();
@ -1520,6 +1529,9 @@ void wfmain:: getInitialRigState()
cmdOutQue.append(cmdGetPreamp);
}
cmdOutQue.append(cmdGetRitEnabled);
cmdOutQue.append(cmdGetRitValue);
cmdOutQue.append(cmdGetSpectrumMode);
cmdOutQue.append(cmdGetSpectrumSpan);
@ -1787,7 +1799,6 @@ void wfmain::runPeriodicCommands()
}
}
void wfmain::runDelayedCommand()
{
cmds qdCmd;
@ -1842,6 +1853,12 @@ void wfmain::runDelayedCommand()
case cmdSetDataModeOn:
emit setDataMode(true);
break;
case cmdGetRitEnabled:
emit getRitEnabled();
break;
case cmdGetRitValue:
emit getRitValue();
break;
case cmdGetModInput:
emit getModInput(false);
break;
@ -1930,6 +1947,9 @@ void wfmain::runDelayedCommand()
case cmdStopRegularPolling:
periodicPollingTimer->stop();
break;
case cmdQueNormalSpeed:
delayedCommand->setInterval(delayedCmdInterval_ms);
break;
default:
break;
}
@ -3300,7 +3320,6 @@ void wfmain::changeSliderQuietly(QSlider *slider, int value)
slider->blockSignals(true);
slider->setValue(value);
slider->blockSignals(false);
}
void wfmain::receiveTxPower(unsigned char power)
@ -3429,8 +3448,6 @@ void wfmain::receiveMeter(meterKind inMeter, unsigned char level)
unsigned int sum=0;
unsigned int average=0;
switch(inMeter)
{
case meterS:
@ -3753,7 +3770,7 @@ void wfmain::receiveSpectrumSpan(freqt freqspan, bool isSub)
void wfmain::on_rigPowerOnBtn_clicked()
{
emit sendPowerOn();
powerRigOn();
}
void wfmain::on_rigPowerOffBtn_clicked()
@ -3762,7 +3779,62 @@ void wfmain::on_rigPowerOffBtn_clicked()
reply = QMessageBox::question(this, "Power", "Power down the radio?",
QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes) {
//emit sendPowerOff();
powerRigOff();
}
}
void wfmain::powerRigOn()
{
emit sendPowerOn();
delayedCommand->setInterval(3000); // 3 seconds
if(ui->scopeEnableWFBtn->isChecked())
{
issueDelayedCommand(cmdDispEnable);
issueDelayedCommand(cmdQueNormalSpeed);
issueDelayedCommand(cmdSpecOn);
issueDelayedCommand(cmdStartRegularPolling); // s-meter, etc
} else {
issueDelayedCommand(cmdQueNormalSpeed);
}
delayedCommand->start();
}
void wfmain::powerRigOff()
{
periodicPollingTimer->stop();
delayedCommand->stop();
cmdOutQue.clear();
emit sendPowerOff();
}
void wfmain::on_ritTuneDial_valueChanged(int value)
{
emit setRitValue(value);
}
void wfmain::on_ritEnableChk_clicked(bool checked)
{
emit setRitEnable(checked);
}
void wfmain::receiveRITStatus(bool ritEnabled)
{
ui->ritEnableChk->blockSignals(true);
ui->ritEnableChk->setChecked(ritEnabled);
ui->ritEnableChk->blockSignals(false);
}
void wfmain::receiveRITValue(int ritValHz)
{
if((ritValHz > -500) and (ritValHz < 500))
{
ui->ritTuneDial->blockSignals(true);
ui->ritTuneDial->setValue(ritValHz);
ui->ritTuneDial->blockSignals(false);
} else {
qDebug(logSystem()) << "Warning: out of range RIT value received: " << ritValHz << " Hz";
}
}
@ -3771,15 +3843,6 @@ void wfmain::on_debugBtn_clicked()
{
qDebug(logSystem()) << "Debug button pressed.";
// TODO: Why don't these commands work?!
//emit getScopeMode();
//emit getScopeEdge(); // 1,2,3 only in "fixed" mode
//emit getScopeSpan(); // in khz, only in "center" mode
// emit getLevels();
// emit getMeters(amTransmitting);
// emit getTSQL();
qDebug(logSystem()) << "Getting scope mode";
emit getScopeMode(); // center or fixed
qDebug(logSystem()) << "Getting RIT enabled status: ";
emit getRitValue();
}

Wyświetl plik

@ -58,6 +58,10 @@ signals:
void setModInput(rigInput input, bool dataOn);
void getBandStackReg(char band, char regCode);
void getDebug();
void getRitEnabled();
void getRitValue();
void setRitValue(int ritValue);
void setRitEnable(bool ritEnabled);
// Repeater:
void getDuplexMode();
@ -181,6 +185,8 @@ private slots:
void receivePTTstatus(bool pttOn);
void receiveDataModeStatus(bool dataOn);
void receiveBandStackReg(float freq, char mode, bool dataOn); // freq, mode, (filter,) datamode
void receiveRITStatus(bool ritEnabled);
void receiveRITValue(int ritValHz);
void receiveModInput(rigInput input, bool dataOn);
//void receiveDuplexMode(duplexMode dm);
@ -407,6 +413,10 @@ private slots:
void on_rigPowerOffBtn_clicked();
void on_ritTuneDial_valueChanged(int value);
void on_ritEnableChk_clicked(bool checked);
private:
Ui::wfmain *ui;
QSettings settings;
@ -421,6 +431,8 @@ private:
void prepareWf();
void getInitialRigState();
void openRig();
void powerRigOff();
void powerRigOn();
QWidget * theParent;
QStringList portList;
QString serialPortRig;
@ -507,18 +519,21 @@ private:
freqt freq;
float tsKnobMHz;
enum cmds {cmdNone, cmdGetRigID, cmdGetRigCIV, cmdGetFreq, cmdGetMode, cmdGetDataMode, cmdSetDataModeOn, cmdSetDataModeOff,
enum cmds {cmdNone, cmdGetRigID, cmdGetRigCIV, cmdGetFreq, cmdGetMode, cmdGetDataMode,
cmdSetDataModeOn, cmdSetDataModeOff, cmdGetRitEnabled, cmdGetRitValue,
cmdSpecOn, cmdSpecOff, cmdDispEnable, cmdDispDisable, cmdGetRxGain, cmdGetAfGain,
cmdGetSql, cmdGetATUStatus, cmdGetSpectrumMode, cmdGetSpectrumSpan, cmdScopeCenterMode, cmdScopeFixedMode, cmdGetPTT,
cmdGetTxPower, cmdGetMicGain, cmdGetSpectrumRefLevel, cmdGetDuplexMode, cmdGetModInput, cmdGetModDataInput,
cmdGetCurrentModLevel, cmdStartRegularPolling, cmdStopRegularPolling, cmdGetVdMeter, cmdGetIdMeter,
cmdGetSMeter, cmdGetPowerMeter, cmdGetALCMeter, cmdGetCompMeter,
cmdGetCurrentModLevel, cmdStartRegularPolling, cmdStopRegularPolling, cmdQueNormalSpeed,
cmdGetVdMeter, cmdGetIdMeter, cmdGetSMeter, cmdGetPowerMeter, cmdGetALCMeter, cmdGetCompMeter,
cmdGetTone, cmdGetTSQL, cmdGetDTCS, cmdGetRptAccessMode, cmdGetPreamp, cmdGetAttenuator, cmdGetAntenna};
cmds cmdOut;
QVector <cmds> cmdOutQue;
QVector <cmds> periodicCmdQueue;
int pCmdNum = 0;
int delayedCmdInterval_ms = 100;
int delayedCmdStartupInterval_ms = 100;
freqMemory mem;
struct colors {
@ -568,10 +583,6 @@ private:
void useColors(); // set the plot up
void setDefPrefs(); // populate default values to default prefs
void setTuningSteps();
//double roundFrequency(double frequency);
//double roundFrequency(double frequency, unsigned int tsHz);
//double roundFrequencyWithStep(double oldFreq, int steps,
// unsigned int tsHz);
quint64 roundFrequency(quint64 frequency, unsigned int tsHz);
quint64 roundFrequencyWithStep(quint64 oldFreq, int steps,\

Wyświetl plik

@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="mainTab">
<attribute name="title">
@ -280,6 +280,48 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_25">
<item>
<widget class="QDial" name="ritTuneDial">
<property name="maximumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="minimum">
<number>-500</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="pageStep">
<number>50</number>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="notchTarget">
<double>10.000000000000000</double>
</property>
<property name="notchesVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ritEnableChk">
<property name="text">
<string>RIT</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>