kopia lustrzana https://gitlab.com/eliggett/wfview
Receive current knob values from rig
rodzic
75288b5e78
commit
cadf835d95
|
@ -1418,17 +1418,17 @@ void usbController::loadCommands()
|
|||
commands.append(COMMAND(num++, "Split On", commandButton, cmdNone, 0x01));
|
||||
commands.append(COMMAND(num++, "Split Off", commandButton, cmdNone, 0x0));
|
||||
commands.append(COMMAND(num++, "Swap VFO", commandButton, cmdVFOSwap, 0x0));
|
||||
commands.append(COMMAND(num++, "AF Gain", commandKnob, cmdSetAfGain, 0xff));
|
||||
commands.append(COMMAND(num++, "RF Gain", commandKnob, cmdSetRxRfGain, 0xff));
|
||||
commands.append(COMMAND(num++, "TX Power", commandKnob, cmdSetTxPower, 0xff));
|
||||
commands.append(COMMAND(num++, "Mic Gain", commandKnob, cmdSetMicGain, 0xff));
|
||||
commands.append(COMMAND(num++, "Mod Level", commandKnob, cmdSetModLevel, 0xff));
|
||||
commands.append(COMMAND(num++, "Squelch", commandKnob, cmdSetSql, 0xff));
|
||||
commands.append(COMMAND(num++, "IF Shift", commandKnob, cmdSetIFShift, 0xff));
|
||||
commands.append(COMMAND(num++, "In PBT", commandKnob, cmdSetTPBFInner, 0xff));
|
||||
commands.append(COMMAND(num++, "Out PBT", commandKnob, cmdSetTPBFOuter, 0xff));
|
||||
commands.append(COMMAND(num++, "CW Pitch", commandKnob, cmdSetCwPitch, 0xff));
|
||||
commands.append(COMMAND(num++, "CW Speed", commandKnob, cmdSetKeySpeed, 0xff));
|
||||
commands.append(COMMAND(num++, "AF Gain", commandKnob, cmdSetAfGain, cmdGetAfGain, 0xff));
|
||||
commands.append(COMMAND(num++, "RF Gain", commandKnob, cmdSetRxRfGain, cmdGetRxGain, 0xff));
|
||||
commands.append(COMMAND(num++, "TX Power", commandKnob, cmdSetTxPower, cmdGetTxPower, 0xff));
|
||||
commands.append(COMMAND(num++, "Mic Gain", commandKnob, cmdSetMicGain, cmdGetMicGain, 0xff));
|
||||
commands.append(COMMAND(num++, "Mod Level", commandKnob, cmdSetModLevel, cmdNone, 0xff));
|
||||
commands.append(COMMAND(num++, "Squelch", commandKnob, cmdSetSql, cmdGetSql, 0xff));
|
||||
commands.append(COMMAND(num++, "IF Shift", commandKnob, cmdSetIFShift, cmdGetIFShift, 0xff));
|
||||
commands.append(COMMAND(num++, "In PBT", commandKnob, cmdSetTPBFInner, cmdGetTPBFInner, 0xff));
|
||||
commands.append(COMMAND(num++, "Out PBT", commandKnob, cmdSetTPBFOuter, cmdGetTPBFOuter, 0xff));
|
||||
commands.append(COMMAND(num++, "CW Pitch", commandKnob, cmdSetCwPitch, cmdGetCwPitch, 0xff));
|
||||
commands.append(COMMAND(num++, "CW Speed", commandKnob, cmdSetKeySpeed, cmdGetKeySpeed, 0xff));
|
||||
commands.append(COMMAND(num++, "Waterfall", commandButton, cmdLCDWaterfall, 0x0));
|
||||
commands.append(COMMAND(num++, "Spectrum", commandButton, cmdLCDSpectrum, 0x0));
|
||||
commands.append(COMMAND(num++, "Page Down", commandButton, cmdPageDown, 0x0));
|
||||
|
@ -1563,5 +1563,22 @@ void usbController::buttonState(QString name, double val)
|
|||
|
||||
/* End of Gamepad functions*/
|
||||
|
||||
void usbController::receiveLevel(cmds cmd, unsigned char level)
|
||||
{
|
||||
// Update knob if relevant, step through all devices
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
for (auto dev = usbDevices.begin(); dev != usbDevices.end(); dev++)
|
||||
{
|
||||
auto kb = std::find_if(knobList->begin(), knobList->end(), [dev, cmd](const KNOB& k)
|
||||
{ return (k.command && k.path == dev->path && k.page == dev->currentPage && k.command->getCommand == cmd);});
|
||||
if (kb != knobList->end() && kb->num < dev->knobValues.size()) {
|
||||
qInfo(logUsbControl()) << "Received value:" << level << "for knob" << kb->num;
|
||||
// Set both current and previous knobvalue to the received value
|
||||
dev->knobValues[kb->num] = level;
|
||||
dev->knobPrevious[kb->num] = level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -123,6 +123,8 @@ struct COMMAND {
|
|||
COMMAND() {}
|
||||
COMMAND(int index, QString text, usbCommandType cmdType, int command, unsigned char suffix) :
|
||||
index(index), text(text), cmdType(cmdType), command(command), suffix(suffix) {}
|
||||
COMMAND(int index, QString text, usbCommandType cmdType, int command, int getCommand, unsigned char suffix) :
|
||||
index(index), text(text), cmdType(cmdType), command(command), getCommand(getCommand), suffix(suffix) {}
|
||||
COMMAND(int index, QString text, usbCommandType cmdType, int command, availableBands band) :
|
||||
index(index), text(text), cmdType(cmdType), command(command), band(band) {}
|
||||
COMMAND(int index, QString text, usbCommandType cmdType, int command, mode_kind mode) :
|
||||
|
@ -132,6 +134,7 @@ struct COMMAND {
|
|||
QString text;
|
||||
usbCommandType cmdType = commandButton;
|
||||
int command=0;
|
||||
int getCommand=0;
|
||||
unsigned char suffix=0x0;
|
||||
int value=0;
|
||||
availableBands band=bandGen;
|
||||
|
@ -222,6 +225,7 @@ public slots:
|
|||
void runTimer();
|
||||
void ledControl(bool on, unsigned char num);
|
||||
void receivePTTStatus(bool on);
|
||||
void receiveLevel(cmds cmd, unsigned char level);
|
||||
void programPages(USBDEVICE* dev, int pages);
|
||||
void programDisable(USBDEVICE* dev, bool disabled);
|
||||
|
||||
|
|
58
wfmain.cpp
58
wfmain.cpp
|
@ -174,8 +174,7 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode
|
|||
#if !defined(USB_CONTROLLER)
|
||||
ui->enableUsbChk->setVisible(false);
|
||||
ui->usbControllerBtn->setVisible(false);
|
||||
ui->usbButtonsResetBtn->setVisible(false);
|
||||
ui->usbCommandsResetBtn->setVisible(false);
|
||||
ui->usbControllersResetBtn->setVisible(false);
|
||||
ui->usbResetLbl->setVisible(false);
|
||||
#endif
|
||||
|
||||
|
@ -1694,6 +1693,7 @@ void wfmain::setupUsbControllerDevice()
|
|||
connect(shut, SIGNAL(programPages(USBDEVICE*, int)), usbControllerDev, SLOT(programPages(USBDEVICE*, int)));
|
||||
connect(shut, SIGNAL(programDisable(USBDEVICE*, bool)), usbControllerDev, SLOT(programDisable(USBDEVICE*, bool)));
|
||||
connect(this, SIGNAL(setPTT(bool)), usbControllerDev, SLOT(receivePTTStatus(bool)));
|
||||
connect(this, SIGNAL(sendLevel(cmds, unsigned char)), usbControllerDev, SLOT(receiveLevel(cmds, unsigned char)));
|
||||
connect(this, SIGNAL(initUsbController(QMutex*,usbMap*,QVector<BUTTON>*,QVector<KNOB>*)), usbControllerDev, SLOT(init(QMutex*,usbMap*,QVector<BUTTON>*,QVector<KNOB>*)));
|
||||
|
||||
|
||||
|
@ -2476,8 +2476,7 @@ void wfmain::loadSettings()
|
|||
ui->enableUsbChk->setChecked(prefs.enableUSBControllers);
|
||||
ui->enableUsbChk->blockSignals(false);
|
||||
ui->usbControllerBtn->setEnabled(prefs.enableUSBControllers);
|
||||
ui->usbButtonsResetBtn->setEnabled(prefs.enableUSBControllers);
|
||||
ui->usbCommandsResetBtn->setEnabled(prefs.enableUSBControllers);
|
||||
ui->usbControllersResetBtn->setEnabled(prefs.enableUSBControllers);
|
||||
ui->usbResetLbl->setVisible(prefs.enableUSBControllers);
|
||||
|
||||
/*Ensure that no operations on the usb commands/buttons/knobs take place*/
|
||||
|
@ -4813,6 +4812,7 @@ void wfmain::receiveRigID(rigCapabilities rigCaps)
|
|||
if(usingLAN)
|
||||
{
|
||||
ui->afGainSlider->setValue(prefs.localAFgain);
|
||||
emit sendLevel(cmdGetAfGain,prefs.localAFgain);
|
||||
}
|
||||
// Adding these here because clearly at this point we have valid
|
||||
// rig comms. In the future, we should establish comms and then
|
||||
|
@ -4999,6 +4999,7 @@ void wfmain::receiveFreq(freqt freqStruct)
|
|||
} else {
|
||||
freqb = freqStruct;
|
||||
}
|
||||
|
||||
} else {
|
||||
qDebug(logSystem()) << "Rejecting stale frequency: " << freqStruct.Hz << " Hz, delta time ms = " << tnow_ms - lastFreqCmdTime_ms\
|
||||
<< ", tnow_ms " << tnow_ms << ", last: " << lastFreqCmdTime_ms;
|
||||
|
@ -6454,6 +6455,7 @@ void wfmain::on_afGainSlider_valueChanged(int value)
|
|||
{
|
||||
rxSetup.localAFgain = (unsigned char)(value);
|
||||
prefs.localAFgain = (unsigned char)(value);
|
||||
emit sendLevel(cmdGetAfGain,value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6463,6 +6465,7 @@ void wfmain::receiveRfGain(unsigned char level)
|
|||
ui->rfGainSlider->blockSignals(true);
|
||||
ui->rfGainSlider->setValue(level);
|
||||
ui->rfGainSlider->blockSignals(false);
|
||||
emit sendLevel(cmdGetRxGain,level);
|
||||
}
|
||||
|
||||
void wfmain::receiveAfGain(unsigned char level)
|
||||
|
@ -6471,26 +6474,31 @@ void wfmain::receiveAfGain(unsigned char level)
|
|||
ui->afGainSlider->blockSignals(true);
|
||||
ui->afGainSlider->setValue(level);
|
||||
ui->afGainSlider->blockSignals(false);
|
||||
emit sendLevel(cmdGetAfGain,level);
|
||||
}
|
||||
|
||||
void wfmain::receiveSql(unsigned char level)
|
||||
{
|
||||
ui->sqlSlider->setValue(level);
|
||||
emit sendLevel(cmdGetSql,level);
|
||||
}
|
||||
|
||||
void wfmain::receiveIFShift(unsigned char level)
|
||||
{
|
||||
trxadj->updateIFShift(level);
|
||||
emit sendLevel(cmdGetIFShift,level);
|
||||
}
|
||||
|
||||
void wfmain::receiveTBPFInner(unsigned char level)
|
||||
{
|
||||
trxadj->updateTPBFInner(level);
|
||||
emit sendLevel(cmdGetTPBFInner,level);
|
||||
}
|
||||
|
||||
void wfmain::receiveTBPFOuter(unsigned char level)
|
||||
{
|
||||
trxadj->updateTPBFOuter(level);
|
||||
emit sendLevel(cmdGetTPBFOuter,level);
|
||||
}
|
||||
|
||||
void wfmain::on_tuneNowBtn_clicked()
|
||||
|
@ -6964,11 +6972,14 @@ void wfmain::statusFromSliderPercent(QString name, int rawValue)
|
|||
void wfmain::receiveTxPower(unsigned char power)
|
||||
{
|
||||
changeSliderQuietly(ui->txPowerSlider, power);
|
||||
emit sendLevel(cmdGetTxPower,power);
|
||||
|
||||
}
|
||||
|
||||
void wfmain::receiveMicGain(unsigned char gain)
|
||||
{
|
||||
processModLevel(inputMic, gain);
|
||||
emit sendLevel(cmdGetMicGain,gain);
|
||||
}
|
||||
|
||||
void wfmain::processModLevel(rigInput source, unsigned char level)
|
||||
|
@ -7012,6 +7023,7 @@ void wfmain::processModLevel(rigInput source, unsigned char level)
|
|||
if(currentIn == source)
|
||||
{
|
||||
changeSliderQuietly(ui->micGainSlider, level);
|
||||
emit sendLevel(cmdGetModLevel,level);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7094,6 +7106,7 @@ void wfmain::receiveCwPitch(unsigned char pitch) {
|
|||
if (currentModeInfo.mk == modeCW || currentModeInfo.mk == modeCW_R) {
|
||||
cwPitch = round((((600.0 / 255.0) * pitch) + 300) / 5.0) * 5.0;
|
||||
passbandCenterFrequency = cwPitch / 2000000.0;
|
||||
emit sendLevel(cmdGetCwPitch,pitch);
|
||||
}
|
||||
//qDebug() << "CW" << pitch << "Pitch" << cwPitch;
|
||||
}
|
||||
|
@ -7113,6 +7126,7 @@ void wfmain::receiveTPBFInner(unsigned char level) {
|
|||
pitch = (600.0 - cwPitch) / 1000000.0;
|
||||
}
|
||||
TPBFInner = round((tempVar + pitch) * 200000.0) / 200000.0; // Nearest 5Hz.
|
||||
emit sendLevel(cmdGetTPBFInner,level);
|
||||
//qDebug() << "Inner" << level << "TPBFInner" << TPBFInner;
|
||||
}
|
||||
|
||||
|
@ -7131,6 +7145,7 @@ void wfmain::receiveTPBFOuter(unsigned char level) {
|
|||
pitch = (600.0 - cwPitch) / 1000000.0;
|
||||
}
|
||||
TPBFOuter = round((tempVar + pitch) * 200000.0) / 200000.0; // Nearest 5Hz.
|
||||
emit sendLevel(cmdGetTPBFOuter,level);
|
||||
//qDebug() << "Outer" << level << "TPBFOuter" << TPBFOuter;
|
||||
}
|
||||
|
||||
|
@ -7167,7 +7182,7 @@ void wfmain::receiveMeter(meterKind inMeter, unsigned char level)
|
|||
|
||||
void wfmain::receiveCompLevel(unsigned char compLevel)
|
||||
{
|
||||
(void)compLevel;
|
||||
(void)compLevel;
|
||||
}
|
||||
|
||||
void wfmain::receiveMonitorGain(unsigned char monitorGain)
|
||||
|
@ -9220,8 +9235,7 @@ void wfmain::on_enableUsbChk_clicked(bool checked)
|
|||
{
|
||||
prefs.enableUSBControllers = checked;
|
||||
ui->usbControllerBtn->setEnabled(checked);
|
||||
ui->usbButtonsResetBtn->setEnabled(checked);
|
||||
ui->usbCommandsResetBtn->setEnabled(checked);
|
||||
ui->usbControllersResetBtn->setEnabled(checked);
|
||||
ui->usbResetLbl->setVisible(checked);
|
||||
|
||||
#if defined (USB_CONTROLLER)
|
||||
|
@ -9260,33 +9274,25 @@ void wfmain::on_usbControllerBtn_clicked()
|
|||
}
|
||||
|
||||
|
||||
void wfmain::on_usbButtonsResetBtn_clicked()
|
||||
void wfmain::on_usbControllersResetBtn_clicked()
|
||||
{
|
||||
int ret = QMessageBox::warning(this, tr("wfview"),
|
||||
tr("Are you sure you wish to reset the USB buttons?"),
|
||||
tr("Are you sure you wish to reset the USB controllers?"),
|
||||
QMessageBox::Ok | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok) {
|
||||
qInfo(logUsbControl()) << "Resetting USB buttons to default values";
|
||||
//resetUsbButtons();
|
||||
//resetUsbKnobs();
|
||||
on_enableUsbChk_clicked(true); // Force disconnect/reconnect of USB controller.
|
||||
qInfo(logUsbControl()) << "Resetting USB controllers to default values";
|
||||
bool enabled = ui->enableUsbChk->isChecked();
|
||||
if (enabled) on_enableUsbChk_clicked(false); // Force disconnect of USB controllers
|
||||
|
||||
usbButtons.clear();
|
||||
usbKnobs.clear();
|
||||
usbControllers.clear();
|
||||
|
||||
if (enabled) on_enableUsbChk_clicked(true); // Force connect of USB controllers
|
||||
}
|
||||
}
|
||||
|
||||
void wfmain::on_usbCommandsResetBtn_clicked()
|
||||
{
|
||||
int ret = QMessageBox::warning(this, tr("wfview"),
|
||||
tr("Are you sure you wish to reset the USB commands?"),
|
||||
QMessageBox::Ok | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok) {
|
||||
qInfo(logUsbControl()) << "Resetting USB commands to default values";
|
||||
//resetUsbCommands();
|
||||
on_enableUsbChk_clicked(true); // Force disconnect/reconnect of USB controller.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void wfmain::on_autoPollBtn_clicked(bool checked)
|
||||
{
|
||||
|
|
5
wfmain.h
5
wfmain.h
|
@ -80,6 +80,8 @@ public:
|
|||
void handleLogText(QString text);
|
||||
|
||||
signals:
|
||||
// Signal levels received to other parts of wfview
|
||||
void sendLevel(cmds cmd, unsigned char level);
|
||||
// Basic to rig:
|
||||
void setCIVAddr(unsigned char newRigCIVAddr);
|
||||
void setRigID(unsigned char rigID);
|
||||
|
@ -402,8 +404,7 @@ private slots:
|
|||
void on_fEnterBtn_clicked();
|
||||
void on_usbControllerBtn_clicked();
|
||||
|
||||
void on_usbButtonsResetBtn_clicked();
|
||||
void on_usbCommandsResetBtn_clicked();
|
||||
void on_usbControllersResetBtn_clicked();
|
||||
|
||||
void on_enableUsbChk_clicked(bool checked);
|
||||
|
||||
|
|
21
wfmain.ui
21
wfmain.ui
|
@ -3443,8 +3443,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>820</width>
|
||||
<height>302</height>
|
||||
<width>579</width>
|
||||
<height>254</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
|
@ -5015,7 +5015,7 @@
|
|||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Setup USB Controller</string>
|
||||
<string>Setup USB Controllers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -5033,23 +5033,16 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="usbButtonsResetBtn">
|
||||
<widget class="QPushButton" name="usbControllersResetBtn">
|
||||
<property name="text">
|
||||
<string>Reset Buttons</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="usbCommandsResetBtn">
|
||||
<property name="text">
|
||||
<string>Reset Commands</string>
|
||||
<string>Reset Controllers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="usbResetLbl">
|
||||
<property name="text">
|
||||
<string>Only reset buttons/commands if you have issues. </string>
|
||||
<string>Reset all USB controllers to defaults (delete all knobs/buttons)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -5537,8 +5530,8 @@
|
|||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="pollingButtonGroup"/>
|
||||
<buttongroup name="underlayButtonGroup"/>
|
||||
<buttongroup name="buttonGroup"/>
|
||||
<buttongroup name="pollingButtonGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
|
|
@ -156,7 +156,7 @@ enum cmds {
|
|||
cmdSetATU, cmdStartATU, cmdGetATUStatus,
|
||||
cmdGetSpectrumMode, cmdGetSpectrumSpan, cmdScopeCenterMode, cmdScopeFixedMode,
|
||||
cmdGetPTT, cmdSetPTT,cmdPTTToggle,
|
||||
cmdGetTxPower, cmdSetTxPower, cmdGetMicGain, cmdSetMicGain, cmdSetModLevel,
|
||||
cmdGetTxPower, cmdSetTxPower, cmdGetMicGain, cmdSetMicGain, cmdGetModLevel, cmdSetModLevel,
|
||||
cmdGetSpectrumRefLevel, cmdGetDuplexMode, cmdGetModInput, cmdGetModDataInput,
|
||||
cmdGetCurrentModLevel, cmdStartRegularPolling, cmdStopRegularPolling, cmdQueNormalSpeed,
|
||||
cmdGetVdMeter, cmdGetIdMeter, cmdGetSMeter, cmdGetCenterMeter, cmdGetPowerMeter,
|
||||
|
|
Ładowanie…
Reference in New Issue