kopia lustrzana https://gitlab.com/eliggett/wfview
Band Button widget works.
rodzic
977fa971fd
commit
455a9c7363
259
bandbuttons.cpp
259
bandbuttons.cpp
|
@ -13,102 +13,321 @@ bandbuttons::~bandbuttons()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
int bandbuttons::getBSRNumber()
|
||||
{
|
||||
return ui->bandStkPopdown->currentIndex()+1;
|
||||
}
|
||||
|
||||
void bandbuttons::acceptRigCaps(rigCapabilities rc)
|
||||
{
|
||||
this->rigCaps = rc;
|
||||
qDebug(logGui()) << "Accepting new rigcaps into band buttons.";
|
||||
if(haveRigCaps)
|
||||
qDebug(logGui()) << "Accepting additional rigcaps into band buttons.";
|
||||
|
||||
qDebug(logGui()) << "Bands in this rigcaps: ";
|
||||
for(size_t i=0; i < rigCaps.bands.size(); i++)
|
||||
{
|
||||
qDebug(logGui()) << "band[" << i << "]: " << (unsigned char)rigCaps.bands.at(i).band;
|
||||
}
|
||||
|
||||
for(size_t i=0; i < 20; i++)
|
||||
{
|
||||
qDebug(logGui()) << "bsr[" << i << "]: " << (unsigned char)rigCaps.bsr[i];
|
||||
}
|
||||
|
||||
setUIToRig();
|
||||
haveRigCaps = true;
|
||||
}
|
||||
|
||||
void bandbuttons::setUIToRig()
|
||||
{
|
||||
// Turn off each button first:
|
||||
hideButton(ui->band23cmbtn);
|
||||
hideButton(ui->band70cmbtn);
|
||||
hideButton(ui->band2mbtn);
|
||||
hideButton(ui->bandAirbtn);
|
||||
hideButton(ui->bandWFMbtn);
|
||||
hideButton(ui->band4mbtn);
|
||||
hideButton(ui->band6mbtn);
|
||||
|
||||
hideButton(ui->band10mbtn);
|
||||
hideButton(ui->band12mbtn);
|
||||
hideButton(ui->band15mbtn);
|
||||
hideButton(ui->band17mbtn);
|
||||
hideButton(ui->band20mbtn);
|
||||
hideButton(ui->band30mbtn);
|
||||
hideButton(ui->band40mbtn);
|
||||
hideButton(ui->band60mbtn);
|
||||
hideButton(ui->band80mbtn);
|
||||
hideButton(ui->band160mbtn);
|
||||
|
||||
hideButton(ui->band630mbtn);
|
||||
hideButton(ui->band2200mbtn);
|
||||
hideButton(ui->bandGenbtn);
|
||||
|
||||
bandType bandSel;
|
||||
for(unsigned int i=0; i < rigCaps.bands.size(); i++)
|
||||
{
|
||||
bandSel = rigCaps.bands.at(i);
|
||||
switch(bandSel.band)
|
||||
{
|
||||
case(band23cm):
|
||||
showButton(ui->band23cmbtn);
|
||||
break;
|
||||
case(band70cm):
|
||||
showButton(ui->band70cmbtn);
|
||||
break;
|
||||
case(band2m):
|
||||
showButton(ui->band2mbtn);
|
||||
break;
|
||||
case(bandAir):
|
||||
showButton(ui->bandAirbtn);
|
||||
break;
|
||||
case(bandWFM):
|
||||
showButton(ui->bandWFMbtn);
|
||||
break;
|
||||
case(band4m):
|
||||
showButton(ui->band4mbtn);
|
||||
break;
|
||||
case(band6m):
|
||||
showButton(ui->band6mbtn);
|
||||
break;
|
||||
|
||||
case(band10m):
|
||||
showButton(ui->band10mbtn);
|
||||
break;
|
||||
case(band12m):
|
||||
showButton(ui->band12mbtn);
|
||||
break;
|
||||
case(band15m):
|
||||
showButton(ui->band15mbtn);
|
||||
break;
|
||||
case(band17m):
|
||||
showButton(ui->band17mbtn);
|
||||
break;
|
||||
case(band20m):
|
||||
showButton(ui->band20mbtn);
|
||||
break;
|
||||
case(band30m):
|
||||
showButton(ui->band30mbtn);
|
||||
break;
|
||||
case(band40m):
|
||||
showButton(ui->band40mbtn);
|
||||
break;
|
||||
case(band60m):
|
||||
showButton(ui->band60mbtn);
|
||||
break;
|
||||
case(band80m):
|
||||
showButton(ui->band80mbtn);
|
||||
break;
|
||||
case(band160m):
|
||||
showButton(ui->band160mbtn);
|
||||
break;
|
||||
|
||||
case(band630m):
|
||||
showButton(ui->band630mbtn);
|
||||
break;
|
||||
case(band2200m):
|
||||
showButton(ui->band2200mbtn);
|
||||
break;
|
||||
case(bandGen):
|
||||
showButton(ui->bandGenbtn);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bandbuttons::showButton(QPushButton *b)
|
||||
{
|
||||
b->setVisible(true);
|
||||
}
|
||||
|
||||
void bandbuttons::hideButton(QPushButton *b)
|
||||
{
|
||||
b->setHidden(true);
|
||||
}
|
||||
|
||||
void bandbuttons::receiveBandStackReg(freqt freqGo, char mode, char filter, bool dataOn)
|
||||
{
|
||||
// This function is not currently used, but perhaps it should be?
|
||||
// Issue: wfmain is also waiting for a BSR and acts upon it.
|
||||
if(waitingForBSR)
|
||||
{
|
||||
qDebug(logGui()) << "Received band stack register and was waiting for one.";
|
||||
emit issueCmdF(cmdSetFreq, freqGo);
|
||||
emit issueCmd(cmdSetMode, mode);
|
||||
//emit issueCmd(cmdSetFilter, filter); // TODO
|
||||
if(dataOn)
|
||||
emit issueDelayedCommand(cmdSetDataModeOn);
|
||||
else
|
||||
emit issueDelayedCommand(cmdSetDataModeOff);
|
||||
|
||||
waitingForBSR = false;
|
||||
} else {
|
||||
qWarning(logGui()) << "Received a BSR but did not expect one.";
|
||||
}
|
||||
(void)filter;
|
||||
}
|
||||
|
||||
void bandbuttons::bandStackBtnClick(availableBands band)
|
||||
{
|
||||
if(haveRigCaps)
|
||||
{
|
||||
unsigned char bandRegister = rigCaps.bsr[band];
|
||||
if(bandRegister == 00)
|
||||
{
|
||||
qDebug(logGui()) << "requested to drop to band that does not have a BSR.";
|
||||
// TODO: Jump to reasonable frequency for the selected band
|
||||
jumpToBandWithoutBSR(band);
|
||||
} else {
|
||||
waitingForBSR = true;
|
||||
// TODO: request the BSR 1, 2, or 3
|
||||
emit issueCmd(cmdGetBandStackReg, (unsigned char)band);
|
||||
}
|
||||
} else {
|
||||
qWarning(logGui()) << "bandbuttons, Asked to go to a band but do not have rigCaps yet.";
|
||||
}
|
||||
}
|
||||
|
||||
void bandbuttons::jumpToBandWithoutBSR(availableBands band)
|
||||
{
|
||||
// Sometimes we do not have a BSR for these bands:
|
||||
freqt f;
|
||||
f.Hz = 0;
|
||||
|
||||
switch(band)
|
||||
{
|
||||
case band2200m:
|
||||
f.Hz = 136 * 1E3;
|
||||
break;
|
||||
case band630m:
|
||||
f.Hz = 475 * 1E3;
|
||||
break;
|
||||
case band60m:
|
||||
f.Hz = (5.3305) * 1E6;
|
||||
break;
|
||||
case band4m:
|
||||
f.Hz = (70.200) * 1E6;
|
||||
break;
|
||||
case bandAir:
|
||||
f.Hz = 121.5 * 1E6;
|
||||
break;
|
||||
case bandGen:
|
||||
f.Hz = 10.0 * 1E6;
|
||||
break;
|
||||
case bandWFM:
|
||||
f.Hz = (100.1) * 1E6;
|
||||
break;
|
||||
default:
|
||||
qCritical(logGui()) << "Band " << (unsigned char) band << " not understood.";
|
||||
break;
|
||||
}
|
||||
if(f.Hz != 0)
|
||||
{
|
||||
emit issueCmdF(cmdSetFreq, f);
|
||||
}
|
||||
}
|
||||
|
||||
void bandbuttons::on_band2200mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band2200m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band630mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band630m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band160mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band160m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band80mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band80m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band60mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band60m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band40mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band40m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band30mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band30m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band20mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band20m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band17mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band17m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band15mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band15m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band12mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band12m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band10mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band10m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band6mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band6m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band4mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band4m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band2mbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band2m);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band70cmbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band70cm);
|
||||
}
|
||||
|
||||
void bandbuttons::on_band23cmbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(band23cm);
|
||||
}
|
||||
|
||||
void bandbuttons::on_bandWFMbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(bandWFM);
|
||||
}
|
||||
|
||||
void bandbuttons::on_bandAirbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(bandAir);
|
||||
}
|
||||
|
||||
void bandbuttons::on_bandGenbtn_clicked()
|
||||
{
|
||||
|
||||
bandStackBtnClick(bandGen);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
#define BANDBUTTONS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "logcategories.h"
|
||||
#include "wfviewtypes.h"
|
||||
#include "rigidentities.h"
|
||||
|
||||
namespace Ui {
|
||||
class bandbuttons;
|
||||
|
@ -15,6 +20,40 @@ public:
|
|||
explicit bandbuttons(QWidget *parent = nullptr);
|
||||
~bandbuttons();
|
||||
|
||||
int getBSRNumber(); // returns the BSR combo box position
|
||||
|
||||
|
||||
// flow:
|
||||
// User presses button
|
||||
// this sends request for BSR information and flags waitingForBSR=true
|
||||
// When BSR data is received, and if we were waiting for it,
|
||||
// then we select the frequency and mode and act upon it,
|
||||
// by sending out a gotoFreqMode(freq, mode).
|
||||
// Or we could grant access to the command queue and not have to do these
|
||||
// custom functions.
|
||||
|
||||
// The BSR can presumably show up without having been invited.
|
||||
|
||||
// Most of the connections shall be to rigCommander and
|
||||
// to the command queue in wfmain (soon to be broken out).
|
||||
// One connection may also be made to update the UI when we change frequency and mode.
|
||||
|
||||
signals:
|
||||
// look at what cmdSetModeFilter does, can we depreciate it?
|
||||
void issueCmdUniquePriority(cmds cmd, char c); // to go to a mode
|
||||
void issueDelayedCommand(cmds cmd); // for data mode and filter
|
||||
void issueCmdF(cmds cmd, freqt f); // go to frequency
|
||||
void issueCmd(cmds, char); // to get BSR of a specific band
|
||||
|
||||
// void getBandStackReg(char band, char regCode); // no, use the queue.
|
||||
// void gotoFreqMode(); // TODO, arguments will contain BSR data
|
||||
|
||||
|
||||
public slots:
|
||||
// These should come from connections to rigCommander:
|
||||
void acceptRigCaps(rigCapabilities rc);
|
||||
void receiveBandStackReg(freqt freqGo, char mode, char filter, bool dataOn);
|
||||
|
||||
private slots:
|
||||
void on_band2200mbtn_clicked();
|
||||
|
||||
|
@ -58,10 +97,17 @@ private slots:
|
|||
|
||||
private:
|
||||
Ui::bandbuttons *ui;
|
||||
void bandStackBtnClick();
|
||||
|
||||
char bandStkBand;
|
||||
void bandStackBtnClick(availableBands band);
|
||||
void jumpToBandWithoutBSR(availableBands band);
|
||||
void setUIToRig();
|
||||
void showButton(QPushButton *b);
|
||||
void hideButton(QPushButton *b);
|
||||
char bandStkRegCode;
|
||||
|
||||
bool waitingForBSR = false;
|
||||
rigCapabilities rigCaps;
|
||||
bool haveRigCaps = false;
|
||||
|
||||
};
|
||||
|
||||
#endif // BANDBUTTONS_H
|
||||
|
|
|
@ -26,6 +26,7 @@ cwSender::~cwSender()
|
|||
void cwSender::showEvent(QShowEvent *event)
|
||||
{
|
||||
emit getCWSettings();
|
||||
QMainWindow::showEvent(event);
|
||||
(void)event;
|
||||
}
|
||||
|
||||
|
|
|
@ -446,7 +446,7 @@ void repeaterSetup::showEvent(QShowEvent *event)
|
|||
if(rig.hasRepeaterModes)
|
||||
emit getRptDuplexOffset();
|
||||
|
||||
(void)event;
|
||||
QMainWindow::showEvent(event);
|
||||
}
|
||||
|
||||
void repeaterSetup::on_splitEnableChk_clicked()
|
||||
|
|
|
@ -109,6 +109,11 @@ struct bandType {
|
|||
|
||||
model_kind determineRadioModel(unsigned char rigID);
|
||||
|
||||
struct bsrRequest {
|
||||
availableBands band;
|
||||
int bsrPosition=1;
|
||||
};
|
||||
|
||||
struct rigCapabilities {
|
||||
model_kind model;
|
||||
quint8 civ;
|
||||
|
|
52
wfmain.cpp
52
wfmain.cpp
|
@ -52,6 +52,7 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode
|
|||
shut = new controllerSetup();
|
||||
abtBox = new aboutbox();
|
||||
selRad = new selectRadio();
|
||||
bandbtns = new bandbuttons();
|
||||
|
||||
qRegisterMetaType<udpPreferences>(); // Needs to be registered early.
|
||||
qRegisterMetaType<rigCapabilities>();
|
||||
|
@ -364,7 +365,7 @@ void wfmain::rigConnections()
|
|||
connect(this->rig, &rigCommander::haveCWBreakMode,
|
||||
[=](const unsigned char &bm) { cw->handleBreakInMode(bm);});
|
||||
|
||||
connect(rig, SIGNAL(haveBandStackReg(freqt,char,char,bool)), this, SLOT(receiveBandStackReg(freqt,char,char,bool)));
|
||||
connect(rig, SIGNAL(haveBandStackReg(freqt,char,char,bool)), this, SLOT(handleBandStackReg(freqt,char,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)));
|
||||
|
@ -466,6 +467,43 @@ void wfmain::rigConnections()
|
|||
connect(this, SIGNAL(setRptDuplexOffset(freqt)), rig, SLOT(setRptDuplexOffset(freqt)));
|
||||
connect(this, SIGNAL(getDuplexMode()), rig, SLOT(getDuplexMode()));
|
||||
|
||||
// Band buttons:
|
||||
//connect(rig, SIGNAL(haveRigID(rigCapabilities)), bandbtns, SLOT(acceptRigCaps(rigCapabilities)));
|
||||
|
||||
connect(rig, &rigCommander::haveRigID,
|
||||
[=](const rigCapabilities &rigid) {
|
||||
bandbtns->acceptRigCaps(rigid);
|
||||
qDebug() << "Rig caps going to band buttons";
|
||||
});
|
||||
|
||||
if(haveRigCaps)
|
||||
{
|
||||
qDebug(logGui()) << "Already had rigCaps, sending to band buttons...";
|
||||
bandbtns->acceptRigCaps(rigCaps);
|
||||
}
|
||||
|
||||
connect(rig, SIGNAL(haveBandStackReg(freqt,char,char,bool)), bandbtns, SLOT(handleBandStackReg(freqt,char,char,bool)));
|
||||
|
||||
connect(this->bandbtns, &bandbuttons::issueCmdF,
|
||||
[=](const cmds cmd, freqt f) {
|
||||
issueCmd(cmd, f);
|
||||
});
|
||||
|
||||
connect(bandbtns, &bandbuttons::issueCmdUniquePriority,
|
||||
[=](const cmds cmd, char c) {
|
||||
issueCmdUniquePriority(cmd, c);
|
||||
});
|
||||
|
||||
connect(bandbtns, &bandbuttons::issueCmd,
|
||||
[=](cmds cmd, char c) {
|
||||
issueCmd(cmd, c);
|
||||
});
|
||||
|
||||
connect(bandbtns, &bandbuttons::issueDelayedCommand,
|
||||
[=](cmds cmd) {
|
||||
issueDelayedCommand(cmd);
|
||||
});
|
||||
|
||||
connect(this, SIGNAL(getPassband()), rig, SLOT(getPassband()));
|
||||
connect(this, SIGNAL(setPassband(quint16)), rig, SLOT(setPassband(quint16)));
|
||||
connect(this, SIGNAL(getCwPitch()), rig, SLOT(getCwPitch()));
|
||||
|
@ -3916,7 +3954,7 @@ void wfmain::doCmd(commandtype cmddata)
|
|||
char band = (*std::static_pointer_cast<char>(data));
|
||||
lastRequestedBand = (availableBands)band;
|
||||
bandStkBand = rigCaps.bsr[(availableBands)band]; // 23cm Needs fixing
|
||||
bandStkRegCode = ui->bandStkPopdown->currentIndex() + 1;
|
||||
bandStkRegCode = bandbtns->getBSRNumber(); // TODO, pass as argument
|
||||
emit getBandStackReg(bandStkBand, bandStkRegCode);
|
||||
break;
|
||||
}
|
||||
|
@ -4489,8 +4527,10 @@ void wfmain::receiveRigID(rigCapabilities rigCaps)
|
|||
{
|
||||
// Note: We intentionally request rigID several times
|
||||
// because without rigID, we can't do anything with the waterfall.
|
||||
bandbtns->acceptRigCaps(rigCaps);
|
||||
if(haveRigCaps)
|
||||
{
|
||||
// Note: This line makes it difficult to accept a different radio connecting.
|
||||
return;
|
||||
} else {
|
||||
|
||||
|
@ -6013,7 +6053,7 @@ void wfmain::on_freqDial_valueChanged(int value)
|
|||
}
|
||||
}
|
||||
|
||||
void wfmain::receiveBandStackReg(freqt freqGo, char mode, char filter, bool dataOn)
|
||||
void wfmain::handleBandStackReg(freqt freqGo, char mode, char filter, bool dataOn)
|
||||
{
|
||||
// read the band stack and apply by sending out commands
|
||||
|
||||
|
@ -7937,8 +7977,8 @@ void wfmain::on_underlayAverageBuffer_toggled(bool checked)
|
|||
void wfmain::on_debugBtn_clicked()
|
||||
{
|
||||
qInfo(logSystem()) << "Debug button pressed.";
|
||||
qDebug(logSystem()) << "Query for repeater access mode (tone, tsql, etc) sent.";
|
||||
issueDelayedCommand(cmdGetRptAccessMode);
|
||||
bandbtns->show();
|
||||
//emit getRigID();
|
||||
}
|
||||
|
||||
// ---------- color helper functions: ---------- //
|
||||
|
@ -9311,4 +9351,4 @@ void wfmain::resetUsbCommands()
|
|||
|
||||
void wfmain::receiveUsbSensitivity(int val) {
|
||||
prefs.usbSensitivity = val;
|
||||
}
|
||||
}
|
||||
|
|
4
wfmain.h
4
wfmain.h
|
@ -36,6 +36,7 @@
|
|||
#include "satellitesetup.h"
|
||||
#include "transceiveradjustments.h"
|
||||
#include "cwsender.h"
|
||||
#include "bandbuttons.h"
|
||||
#include "udpserver.h"
|
||||
#include "qledlabel.h"
|
||||
#include "rigctld.h"
|
||||
|
@ -289,7 +290,7 @@ private slots:
|
|||
void handleScopeOutOfRange(bool outOfRange);
|
||||
void receivePTTstatus(bool pttOn);
|
||||
void receiveDataModeStatus(bool dataOn);
|
||||
void receiveBandStackReg(freqt f, char mode, char filter, bool dataOn); // freq, mode, (filter,) datamode
|
||||
void handleBandStackReg(freqt f, char mode, char filter, bool dataOn); // freq, mode, (filter,) datamode
|
||||
void receiveRITStatus(bool ritEnabled);
|
||||
void receiveRITValue(int ritValHz);
|
||||
void receiveModInput(rigInput input, bool dataOn);
|
||||
|
@ -1100,6 +1101,7 @@ private:
|
|||
aboutbox *abtBox;
|
||||
selectRadio *selRad;
|
||||
loggingWindow *logWindow;
|
||||
bandbuttons *bandbtns;
|
||||
|
||||
udpServer* udp = Q_NULLPTR;
|
||||
rigCtlD* rigCtl = Q_NULLPTR;
|
||||
|
|
Ładowanie…
Reference in New Issue