kopia lustrzana https://gitlab.com/eliggett/wfview
Various fixes
rodzic
aa002ed0b5
commit
96037cd055
|
@ -13,13 +13,6 @@ shuttleSetup::shuttleSetup(QWidget* parent) :
|
|||
textItem = scene->addText("No USB controller found");
|
||||
textItem->setDefaultTextColor(Qt::gray);
|
||||
|
||||
for (QString cmd : onEventCommands) {
|
||||
onEvent.addItem(cmd);
|
||||
}
|
||||
for (QString cmd : offEventCommands) {
|
||||
offEvent.addItem(cmd);
|
||||
}
|
||||
|
||||
connect(&onEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(onEventIndexChanged(int)));
|
||||
connect(&offEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(offEventIndexChanged(int)));
|
||||
}
|
||||
|
@ -78,9 +71,9 @@ void shuttleSetup::mousePressed(QPoint p)
|
|||
|
||||
void shuttleSetup::onEventIndexChanged(int index) {
|
||||
qDebug() << "On Event for button" << currentButton->num << "Event" << index;
|
||||
if (currentButton != Q_NULLPTR) {
|
||||
currentButton->onEvent = index;
|
||||
currentButton->onCommand.text->setPlainText(onEventCommands[index]);
|
||||
if (currentButton != Q_NULLPTR && index < commands->size()) {
|
||||
currentButton->onCommand = commands->at(index);
|
||||
currentButton->onText->setPlainText(currentButton->onCommand.text);
|
||||
currentButton->onCommand.index = index;
|
||||
}
|
||||
}
|
||||
|
@ -88,17 +81,18 @@ void shuttleSetup::onEventIndexChanged(int index) {
|
|||
|
||||
void shuttleSetup::offEventIndexChanged(int index) {
|
||||
qDebug() << "Off Event for button" << currentButton->num << "Event" << index;
|
||||
if (currentButton != Q_NULLPTR) {
|
||||
currentButton->offEvent = index;
|
||||
currentButton->offCommand.text->setPlainText(offEventCommands[index]);
|
||||
if (currentButton != Q_NULLPTR && index < commands->size()) {
|
||||
currentButton->offCommand = commands->at(index);
|
||||
currentButton->offText->setPlainText(currentButton->offCommand.text);
|
||||
currentButton->offCommand.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void shuttleSetup::newDevice(unsigned char devType, QVector<BUTTON>* but)
|
||||
void shuttleSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<COMMAND>* cmd)
|
||||
{
|
||||
buttons = but;
|
||||
commands = cmd;
|
||||
|
||||
if (bgImage != Q_NULLPTR) {
|
||||
scene->removeItem(bgImage);
|
||||
|
@ -133,17 +127,29 @@ void shuttleSetup::newDevice(unsigned char devType, QVector<BUTTON>* but)
|
|||
this->resize(this->sizeHint());
|
||||
currentDevice = devType;
|
||||
|
||||
onEvent.blockSignals(true);
|
||||
offEvent.blockSignals(true);
|
||||
onEvent.clear();
|
||||
offEvent.clear();
|
||||
for (COMMAND &c : *commands) {
|
||||
onEvent.addItem(c.text);
|
||||
offEvent.addItem(c.text);
|
||||
}
|
||||
onEvent.blockSignals(false);
|
||||
offEvent.blockSignals(false);
|
||||
|
||||
|
||||
// Set button text
|
||||
for (BUTTON& b : *buttons)
|
||||
{
|
||||
b.onCommand.text = new QGraphicsTextItem(onEventCommands[b.onEvent]);
|
||||
b.onCommand.text->setDefaultTextColor(b.textColour);
|
||||
scene->addItem(b.onCommand.text);
|
||||
b.onCommand.text->setPos(b.pos.x(), b.pos.y());
|
||||
b.onText = new QGraphicsTextItem(commands->at(0).text);
|
||||
b.onText->setDefaultTextColor(b.textColour);
|
||||
scene->addItem(b.onText);
|
||||
b.onText->setPos(b.pos.x(), b.pos.y());
|
||||
|
||||
b.offCommand.text = new QGraphicsTextItem(offEventCommands[b.onEvent]);
|
||||
b.offCommand.text->setDefaultTextColor(b.textColour);
|
||||
scene->addItem(b.offCommand.text);
|
||||
b.offCommand.text->setPos(b.pos.x(), b.pos.y()+10);
|
||||
b.offText = new QGraphicsTextItem(commands->at(0).text);
|
||||
b.offText->setDefaultTextColor(b.textColour);
|
||||
scene->addItem(b.offText);
|
||||
b.offText->setPos(b.pos.x(), b.pos.y()+10);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
#include <QGraphicsPixmapItem>
|
||||
#include <QPoint>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QVector.h>
|
||||
#include <QRect.h>
|
||||
#include <QComboBox.h>
|
||||
#include <QLabel.h>
|
||||
#include <QVector>
|
||||
#include <QRect>
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QGraphicsProxyWidget.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <qobject.h>
|
||||
#include <QObject>
|
||||
|
||||
#include "usbcontroller.h"
|
||||
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
~shuttleSetup();
|
||||
|
||||
public slots:
|
||||
void newDevice(unsigned char devType, QVector<BUTTON>* but);
|
||||
void newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<COMMAND>* cmd);
|
||||
void mousePressed(QPoint p);
|
||||
void onEventIndexChanged(int index);
|
||||
void offEventIndexChanged(int index);
|
||||
|
@ -48,19 +48,13 @@ private:
|
|||
QLabel* imgLabel;
|
||||
unsigned char currentDevice = 0;
|
||||
QVector<BUTTON>* buttons;
|
||||
QVector<COMMAND>* commands;
|
||||
BUTTON* currentButton=Q_NULLPTR;
|
||||
QComboBox onEvent;
|
||||
QComboBox offEvent;
|
||||
QGraphicsProxyWidget* onEventProxy=Q_NULLPTR;
|
||||
QGraphicsProxyWidget* offEventProxy=Q_NULLPTR;
|
||||
|
||||
|
||||
QStringList onEventCommands = {"None", "PTT Toggle", "PTT On", "Tune","Step+","Step-", "NR","NB","AGC","Mode+","Mode-","Band+", "Band-",
|
||||
"23cm","70cm","2m","AIR","WFM","4m","6m","10m","12m","15m","17m","20m","30m","40m","60m","80m","160m","630m","2200m","GEN" };
|
||||
|
||||
QStringList offEventCommands = { "None", "PTT Toggle", "PTT Off",
|
||||
"23cm", "70cm", "2m", "AIR","WFM","4m", "6m", "10m", "12m", "15m","17m", "20m", "30m", "40m", "60m", "80m", "160m","630m","2200m","GEN"};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -14,16 +14,15 @@ usbController::~usbController()
|
|||
hid_exit();
|
||||
for (BUTTON& b : buttonList)
|
||||
{
|
||||
if (b.onCommand.text)
|
||||
delete b.onCommand.text;
|
||||
if (b.offCommand.text)
|
||||
delete b.offCommand.text;
|
||||
if (b.onText)
|
||||
delete b.onText;
|
||||
if (b.offText)
|
||||
delete b.offText;
|
||||
}
|
||||
}
|
||||
|
||||
void usbController::init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,6 +55,45 @@ int usbController::hidApiWrite(unsigned char* data, unsigned char length)
|
|||
|
||||
void usbController::run()
|
||||
{
|
||||
|
||||
commands.append(COMMAND(0, "None", cmdNone, 0x0));
|
||||
commands.append(COMMAND(1, "PTT On", cmdSetPTT, 0x1));
|
||||
commands.append(COMMAND(2, "PTT Off", cmdSetPTT, 0x0));
|
||||
commands.append(COMMAND(3, "PTT Toggle", cmdSetPTT, 0x1));
|
||||
commands.append(COMMAND(4, "Tune", cmdNone, 0x0));
|
||||
commands.append(COMMAND(5, "Step+", cmdNone, 0x0));
|
||||
commands.append(COMMAND(6, "Step-", cmdNone, 0x0));
|
||||
commands.append(COMMAND(7, "Mode+", cmdNone, 0x0));
|
||||
commands.append(COMMAND(8, "Mode-", cmdNone, 0x0));
|
||||
commands.append(COMMAND(9, "Band+", cmdNone, 0x0));
|
||||
commands.append(COMMAND(10, "Band-", cmdNone, 0x0));
|
||||
commands.append(COMMAND(9, "NR", cmdNone, 0x0));
|
||||
commands.append(COMMAND(10, "NB", cmdNone, 0x0));
|
||||
commands.append(COMMAND(11, "AGC", cmdNone, 0x0));
|
||||
commands.append(COMMAND(12, "NB", cmdNone, 0x0));
|
||||
commands.append(COMMAND(14, "23cm", cmdGetBandStackReg, band23cm));
|
||||
commands.append(COMMAND(15, "70cm", cmdGetBandStackReg, band70cm));
|
||||
commands.append(COMMAND(16, "2m", cmdGetBandStackReg, band2m));
|
||||
commands.append(COMMAND(17, "AIR", cmdGetBandStackReg, bandAir));
|
||||
commands.append(COMMAND(18, "WFM", cmdGetBandStackReg, bandWFM));
|
||||
commands.append(COMMAND(19, "4m", cmdGetBandStackReg, band4m));
|
||||
commands.append(COMMAND(20, "6m", cmdGetBandStackReg, band6m));
|
||||
commands.append(COMMAND(21, "10m", cmdGetBandStackReg, band10m));
|
||||
commands.append(COMMAND(22, "12m", cmdGetBandStackReg, band12m));
|
||||
commands.append(COMMAND(23, "15m", cmdGetBandStackReg, band15m));
|
||||
commands.append(COMMAND(24, "17m", cmdGetBandStackReg, band17m));
|
||||
commands.append(COMMAND(25, "20m", cmdGetBandStackReg, band20m));
|
||||
commands.append(COMMAND(26, "30m", cmdGetBandStackReg, band30m));
|
||||
commands.append(COMMAND(27, "40m", cmdGetBandStackReg, band40m));
|
||||
commands.append(COMMAND(28, "60m", cmdGetBandStackReg, band60m));
|
||||
commands.append(COMMAND(29, "80m", cmdGetBandStackReg, band80m));
|
||||
commands.append(COMMAND(30, "160m", cmdGetBandStackReg, band160m));
|
||||
commands.append(COMMAND(31, "630m", cmdGetBandStackReg, band630m));
|
||||
commands.append(COMMAND(32, "2200m", cmdGetBandStackReg, band2200m));
|
||||
commands.append(COMMAND(33, "GEN", cmdGetBandStackReg, bandGen));
|
||||
|
||||
|
||||
|
||||
handle = hid_open(0x0b33, 0x0020, NULL);
|
||||
if (!handle) {
|
||||
handle = hid_open(0x0b33, 0x0030, NULL);
|
||||
|
@ -104,7 +142,7 @@ void usbController::run()
|
|||
res = hid_get_product_string(handle, product, MAX_STR);
|
||||
qInfo() << QString("Found Device: %0 from %1").arg(QString::fromWCharArray(product)).arg(QString::fromWCharArray(manufacturer));
|
||||
hid_set_nonblocking(handle, 1);
|
||||
emit newDevice(usbDevice,&buttonList);
|
||||
emit newDevice(usbDevice,&buttonList, &commands); // Let the UI know we have a new controller
|
||||
QTimer::singleShot(0, this, SLOT(runTimer()));
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +156,7 @@ void usbController::runTimer()
|
|||
if (res < 0)
|
||||
{
|
||||
qInfo() << "USB Device disconnected?";
|
||||
emit newDevice(0,&buttonList);
|
||||
emit newDevice(0,&buttonList,&commands);
|
||||
hid_close(handle);
|
||||
QTimer::singleShot(1000, this, SLOT(run()));
|
||||
return;
|
||||
|
@ -174,11 +212,11 @@ void usbController::runTimer()
|
|||
{
|
||||
if ((tempButtons >> i & 1) && !(buttons >> i & 1))
|
||||
{
|
||||
if (i < buttonList.size() && buttonList[i].onCommand.text && buttonList[i].onCommand.index>0) {
|
||||
qDebug() << "On Button event:" << buttonList[i].onCommand.text->toPlainText();
|
||||
if (buttonList[i].onCommand.index > 12) // Band selection
|
||||
if (i < buttonList.size()) {
|
||||
qDebug() << "On Button event:" << buttonList[i].onCommand.text;
|
||||
if (buttonList[i].onCommand.bandswitch)
|
||||
{
|
||||
emit setBand(buttonList[i].onCommand.index - 13);
|
||||
//emit setBand(buttonList[i].onCommand.index - 13);
|
||||
}
|
||||
else {
|
||||
emit button(true, i);
|
||||
|
@ -187,7 +225,7 @@ void usbController::runTimer()
|
|||
}
|
||||
else if ((buttons >> i & 1) && !(tempButtons >> i & 1))
|
||||
{
|
||||
if (i < buttonList.size() && buttonList[i].offCommand.text && buttonList[i].onCommand.index>0) {
|
||||
/* if (i < buttonList.size() && buttonList[i].offCommand.text && buttonList[i].onCommand.index>0) {
|
||||
qDebug() << "Off Button event:" << buttonList[i].offCommand.text->toPlainText();
|
||||
if (buttonList[i].offCommand.index > 2) // Band selection
|
||||
{
|
||||
|
@ -197,7 +235,7 @@ void usbController::runTimer()
|
|||
emit button(false, i);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <QRect>
|
||||
#include <QGraphicsTextItem>
|
||||
#include <QColor>
|
||||
#include <QVector>
|
||||
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
|
@ -48,19 +49,24 @@ enum cmds {
|
|||
cmdGetVdMeter, cmdGetIdMeter, cmdGetSMeter, cmdGetCenterMeter, cmdGetPowerMeter,
|
||||
cmdGetSWRMeter, cmdGetALCMeter, cmdGetCompMeter, cmdGetTxRxMeter,
|
||||
cmdGetTone, cmdGetTSQL, cmdGetDTCS, cmdGetRptAccessMode, cmdGetPreamp, cmdGetAttenuator, cmdGetAntenna,
|
||||
cmdGetBandStackReg,
|
||||
cmdSetTime, cmdSetDate, cmdSetUTCOffset
|
||||
};
|
||||
|
||||
struct COMMAND {
|
||||
/* COMMAND(cmds command, char suffix, bool bandswitch, bandType band) :
|
||||
command(command), suffix(suffix), bandswitch(bandswitch), band(band) {} */
|
||||
COMMAND(){}
|
||||
|
||||
COMMAND(int index, QString text, cmds command, char suffix) :
|
||||
index(index), text(text), command(command), suffix(suffix), bandswitch(false){}
|
||||
COMMAND(int index, QString text, cmds command, bandType band) :
|
||||
index(index), text(text), command(command),band(band), bandswitch(true) {}
|
||||
|
||||
int index;
|
||||
cmds command;
|
||||
char suffix;
|
||||
bool bandswitch;
|
||||
bandType band;
|
||||
QGraphicsTextItem* text;
|
||||
QString text;
|
||||
};
|
||||
|
||||
struct BUTTON {
|
||||
|
@ -74,6 +80,8 @@ struct BUTTON {
|
|||
COMMAND onCommand;
|
||||
COMMAND offCommand;
|
||||
const QColor textColour;
|
||||
QGraphicsTextItem* onText;
|
||||
QGraphicsTextItem* offText;
|
||||
};
|
||||
|
||||
class usbController : public QObject
|
||||
|
@ -99,7 +107,7 @@ signals:
|
|||
void setBand(int band);
|
||||
|
||||
void button(bool,unsigned char num);
|
||||
void newDevice(unsigned char devType, QVector<BUTTON>* but);
|
||||
void newDevice(unsigned char devType, QVector<BUTTON>* but,QVector<COMMAND>* cmd);
|
||||
private:
|
||||
hid_device* handle;
|
||||
enum { NONE, shuttleXpress, shuttlePro2, RC28 }usbDevice;
|
||||
|
@ -113,7 +121,7 @@ private:
|
|||
unsigned char lastDialPos=0;
|
||||
int counter = 0;
|
||||
QVector<BUTTON> buttonList;
|
||||
|
||||
QVector<COMMAND> commands;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
|
|
@ -47,6 +47,8 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s
|
|||
qRegisterMetaType<rigstate*>();
|
||||
qRegisterMetaType<QList<radio_cap_packet>>();
|
||||
qRegisterMetaType<QVector<BUTTON>*>();
|
||||
qRegisterMetaType<QVector<COMMAND>*>();
|
||||
qRegisterMetaType<COMMAND*>();
|
||||
qRegisterMetaType<networkStatus>();
|
||||
|
||||
haveRigCaps = false;
|
||||
|
@ -1292,7 +1294,7 @@ void wfmain::setupUsbControllerDevice()
|
|||
connect(usbControllerDev, SIGNAL(button(bool, unsigned char)), this, SLOT(buttonControl(bool, unsigned char)));
|
||||
connect(usbControllerDev, SIGNAL(setBand(int)), this, SLOT(setBand(int)));
|
||||
connect(this, SIGNAL(shuttleLed(bool, unsigned char)), usbControllerDev, SLOT(ledControl(bool, unsigned char)));
|
||||
connect(usbControllerDev, SIGNAL(newDevice(unsigned char, QVector<BUTTON>*)), shut, SLOT(newDevice(unsigned char, QVector<BUTTON>*)));
|
||||
connect(usbControllerDev, SIGNAL(newDevice(unsigned char, QVector<BUTTON>*, QVector<COMMAND>*)), shut, SLOT(newDevice(unsigned char, QVector<BUTTON>*,QVector<COMMAND>*)));
|
||||
usbControllerThread->start(QThread::LowestPriority);
|
||||
}
|
||||
|
||||
|
|
2
wfmain.h
2
wfmain.h
|
@ -926,6 +926,8 @@ Q_DECLARE_METATYPE(enum spectrumMode)
|
|||
Q_DECLARE_METATYPE(QList<radio_cap_packet>)
|
||||
Q_DECLARE_METATYPE(rigstate*)
|
||||
Q_DECLARE_METATYPE(QVector <BUTTON>*)
|
||||
Q_DECLARE_METATYPE(QVector <COMMAND>*)
|
||||
Q_DECLARE_METATYPE(COMMAND*)
|
||||
|
||||
#endif // WFMAIN_H
|
||||
#endif
|
Ładowanie…
Reference in New Issue