diff --git a/resources/rc28.png b/resources/rc28.png new file mode 100644 index 0000000..1e2d33f Binary files /dev/null and b/resources/rc28.png differ diff --git a/resources/resources.qrc b/resources/resources.qrc index 71cabe5..740423c 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -1,5 +1,8 @@ wfview.png + shuttlexpress.png + shuttlepro.png + rc28.png diff --git a/resources/shuttlepro.png b/resources/shuttlepro.png new file mode 100644 index 0000000..79b97c9 Binary files /dev/null and b/resources/shuttlepro.png differ diff --git a/resources/shuttlexpress.png b/resources/shuttlexpress.png new file mode 100644 index 0000000..bc64bdd Binary files /dev/null and b/resources/shuttlexpress.png differ diff --git a/shuttle.cpp b/shuttle.cpp index 5cf62d3..d799d18 100644 --- a/shuttle.cpp +++ b/shuttle.cpp @@ -55,6 +55,7 @@ void shuttle::run() if (!handle) { handle = hid_open(0x0C26, 0x001E, NULL); if (!handle) { + usbDevice = NONE; // No devices found, schedule another check in 1000ms QTimer::singleShot(1000, this, SLOT(run())); } @@ -69,7 +70,8 @@ void shuttle::run() else { usbDevice = shuttleXpress; } - + + if (handle) { int res; @@ -79,6 +81,7 @@ void shuttle::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); QTimer::singleShot(0, this, SLOT(runTimer())); } } @@ -92,6 +95,7 @@ void shuttle::runTimer() if (res < 0) { qInfo() << "USB Device disconnected?"; + emit newDevice(0); hid_close(handle); QTimer::singleShot(1000, this, SLOT(run())); return; @@ -160,6 +164,11 @@ void shuttle::runTimer() { // This is a response from the Icom RC28 data.resize(8); // Might as well get rid of the unused data. + + if (lastData.size() != 8) { + lastData = data; + } + if (((unsigned char)data[5] == 0x06) && ((unsigned char)lastData[5] != 0x06)) { emit button(true, 6); @@ -198,6 +207,7 @@ void shuttle::runTimer() emit jogMinus(); } } + lastData = data; } diff --git a/shuttle.h b/shuttle.h index 61cc5ff..2ced3f5 100644 --- a/shuttle.h +++ b/shuttle.h @@ -24,6 +24,7 @@ using namespace std; #define HIDDATALENGTH 64 #define MAX_STR 255 + class shuttle : public QObject { Q_OBJECT @@ -46,15 +47,16 @@ signals: void doShuttle(bool plus, quint8 level); void button(bool,unsigned char num); + void newDevice(unsigned char devType); private: hid_device* handle; + enum { NONE, shuttleXpress, shuttlePro2, RC28 }usbDevice; bool isOpen=false; unsigned int buttons=0; unsigned char jogpos=0; unsigned char shutpos=0; unsigned char shutMult = 0; - enum { NONE, shuttleXpress, shuttlePro2, RC28 }usbDevice; QTime lastShuttle = QTime::currentTime(); QByteArray lastData=""; unsigned char lastDialPos=0; diff --git a/shuttlesetup.cpp b/shuttlesetup.cpp new file mode 100644 index 0000000..4d5df6e --- /dev/null +++ b/shuttlesetup.cpp @@ -0,0 +1,56 @@ +#include "shuttlesetup.h" +#include "ui_shuttlesetup.h" +#include "logcategories.h" + +shuttleSetup::shuttleSetup(QWidget* parent) : + QDialog(parent), + ui(new Ui::shuttleSetup) +{ + ui->setupUi(this); + scene = new QGraphicsScene(); + ui->graphicsView->setScene(scene); + textItem = scene->addText("No USB controller found"); + textItem->setDefaultTextColor(Qt::gray); +} + +shuttleSetup::~shuttleSetup() +{ + delete textItem; + delete scene; + delete ui; + + if (bgImage != Q_NULLPTR) { + delete bgImage; + } +} + +void shuttleSetup::newDevice(unsigned char devType) +{ + if (bgImage != Q_NULLPTR) { + scene->removeItem(bgImage); + delete bgImage; + bgImage = Q_NULLPTR; + } + QImage image; + + switch (devType) { + case shuttleXpress: + image.load(":/resources/shuttlexpress.png"); + break; + case shuttlePro2: + image.load(":/resources/shuttlepro.png"); + break; + case RC28: + image.load(":/resources/rc28.png"); + break; + default: + textItem->show(); + return; + } + textItem->hide(); + bgImage = new QGraphicsPixmapItem(QPixmap::fromImage(image)); + scene->addItem(bgImage); + + ui->graphicsView->setMinimumSize(bgImage->boundingRect().width() + 2, bgImage->boundingRect().height() + 2); + this->resize(this->sizeHint()); +} diff --git a/shuttlesetup.h b/shuttlesetup.h new file mode 100644 index 0000000..e4aaad4 --- /dev/null +++ b/shuttlesetup.h @@ -0,0 +1,39 @@ +#ifndef SHUTTLESETUP_H +#define SHUTTLESETUP_H + +#include +#include +#include +#include +#include + +#include +#include + +#include "shuttle.h" + +namespace Ui { + class shuttleSetup; +} + +class shuttleSetup : public QDialog +{ + Q_OBJECT + +public: + explicit shuttleSetup(QWidget* parent = 0); + ~shuttleSetup(); + +public slots: + void newDevice(unsigned char devType); + + +private: + enum { NONE, shuttleXpress, shuttlePro2, RC28 }usbDevice; + Ui::shuttleSetup* ui; + QGraphicsScene* scene; + QGraphicsTextItem* textItem; + QGraphicsPixmapItem* bgImage = Q_NULLPTR; +}; + +#endif \ No newline at end of file diff --git a/shuttlesetup.ui b/shuttlesetup.ui new file mode 100644 index 0000000..48ce3ff --- /dev/null +++ b/shuttlesetup.ui @@ -0,0 +1,107 @@ + + + shuttleSetup + + + + 0 + 0 + 300 + 300 + + + + Shuttle setup + + + + + + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + + okButton + clicked() + shuttleSetup + accept() + + + 278 + 253 + + + 96 + 254 + + + + + cancelButton + clicked() + shuttleSetup + reject() + + + 369 + 253 + + + 179 + 282 + + + + + diff --git a/udphandler.cpp b/udphandler.cpp index 59fbb66..d5368a4 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -732,7 +732,6 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio rxaudio = new audioHandler(); rxAudioThread = new QThread(this); - rxAudioThread->setPriority(QThread::TimeCriticalPriority); rxaudio->moveToThread(rxAudioThread); @@ -750,7 +749,6 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, audio txaudio = new audioHandler(); txAudioThread = new QThread(this); - txAudioThread->setPriority(QThread::TimeCriticalPriority); txaudio->moveToThread(txAudioThread); diff --git a/udpserver.cpp b/udpserver.cpp index 0612a02..c6bfe6b 100644 --- a/udpserver.cpp +++ b/udpserver.cpp @@ -382,7 +382,6 @@ void udpServer::controlReceived() txaudio = new audioHandler(); txAudioThread = new QThread(this); - txAudioThread->setPriority(QThread::TimeCriticalPriority); txaudio->moveToThread(txAudioThread); txAudioThread->start(QThread::TimeCriticalPriority); diff --git a/wfmain.cpp b/wfmain.cpp index f61a580..c6b9b17 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -27,6 +27,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s sat = new satelliteSetup(); trxadj = new transceiverAdjustments(); srv = new udpServerSetup(); + shut = new shuttleSetup(); abtBox = new aboutbox(); connect(this, SIGNAL(sendServerConfig(SERVERCONFIG)), srv, SLOT(receiveServerConfig(SERVERCONFIG))); @@ -1225,7 +1226,6 @@ void wfmain::setupShuttleDevice() { shuttleDev = new shuttle(); shuttleThread = new QThread(this); - shuttleThread->setPriority(QThread::LowestPriority); shuttleDev->moveToThread(shuttleThread); connect(shuttleThread, SIGNAL(started()), shuttleDev, SLOT(run())); connect(shuttleThread, SIGNAL(finished()), shuttleDev, SLOT(deleteLater())); @@ -1234,7 +1234,8 @@ void wfmain::setupShuttleDevice() connect(shuttleDev, SIGNAL(doShuttle(bool, unsigned char)), this, SLOT(doShuttle(bool, unsigned char))); connect(shuttleDev, SIGNAL(button(bool, unsigned char)), this, SLOT(buttonControl(bool, unsigned char))); connect(this, SIGNAL(shuttleLed(bool, unsigned char)), shuttleDev, SLOT(ledControl(bool, unsigned char))); - shuttleThread->start(); + connect(shuttleDev, SIGNAL(newDevice(unsigned char)), shut, SLOT(newDevice(unsigned char))); + shuttleThread->start(QThread::LowestPriority); } void wfmain::pttToggle(bool status) @@ -5458,6 +5459,7 @@ void wfmain::on_rigctldPortTxt_editingFinished() void wfmain::on_debugBtn_clicked() { qInfo(logSystem()) << "Debug button pressed."; + shut->show(); //trxadj->show(); //setRadioTimeDatePrep(); //wf->setInteraction(QCP::iRangeZoom, true); diff --git a/wfmain.h b/wfmain.h index 155a023..dd0c8e8 100644 --- a/wfmain.h +++ b/wfmain.h @@ -32,6 +32,7 @@ #include #include #include "shuttle.h" +#include "shuttlesetup.h" #include #include @@ -798,6 +799,7 @@ private: satelliteSetup *sat; transceiverAdjustments *trxadj; udpServerSetup *srv; + shuttleSetup* shut; aboutbox *abtBox; diff --git a/wfview.pro b/wfview.pro index 08753d8..4fb4a70 100644 --- a/wfview.pro +++ b/wfview.pro @@ -150,6 +150,7 @@ SOURCES += main.cpp\ rigctld.cpp \ ring/ring.cpp \ shuttle.cpp \ + shuttlesetup.cpp \ transceiveradjustments.cpp \ aboutbox.cpp @@ -178,6 +179,7 @@ HEADERS += wfmain.h \ ulaw.h \ ring/ring.h \ shuttle.h \ + shuttlesetup.h \ transceiveradjustments.h \ audiotaper.h \ aboutbox.h @@ -188,6 +190,7 @@ FORMS += wfmain.ui \ udpserversetup.ui \ repeatersetup.ui \ transceiveradjustments.ui \ + shuttlesetup.ui aboutbox.ui diff --git a/wfview.vcxproj b/wfview.vcxproj index bfdd557..301d4fe 100644 --- a/wfview.vcxproj +++ b/wfview.vcxproj @@ -57,7 +57,7 @@ Sync release\ MaxSpeed - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="87dc468";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="52070dd";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) false MultiThreadedDLL @@ -85,7 +85,7 @@ 0 - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"87dc468\";HOST=\"wfview.org\";UNAME=\"build\";NDEBUG;QT_NO_DEBUG;QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"52070dd\";HOST=\"wfview.org\";UNAME=\"build\";NDEBUG;QT_NO_DEBUG;QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h @@ -99,7 +99,7 @@ Sync debug\ Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="87dc468";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX="/usr/local";__WINDOWS_WASAPI__;GITSHORT="52070dd";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions) false MultiThreadedDebugDLL true @@ -124,7 +124,7 @@ 0 - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"87dc468\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;USE_SSE;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;PREFIX=\"/usr/local\";__WINDOWS_WASAPI__;GITSHORT=\"52070dd\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h @@ -148,6 +148,7 @@ + @@ -293,6 +294,16 @@ + + + + + + + + + + @@ -408,22 +419,13 @@ + + - - - - - - - - - - - @@ -456,6 +458,17 @@ + + + + + + + + + + + @@ -521,6 +534,7 @@ + @@ -534,6 +548,8 @@ resourcesresources + + diff --git a/wfview.vcxproj.filters b/wfview.vcxproj.filters index 445e538..b071586 100644 --- a/wfview.vcxproj.filters +++ b/wfview.vcxproj.filters @@ -117,6 +117,9 @@ Source Files + + Source Files + Source Files @@ -200,6 +203,9 @@ Header Files + + Header Files + Header Files @@ -273,14 +279,13 @@ + + - - Form Files - Form Files @@ -290,6 +295,9 @@ Form Files + + Form Files + Form Files @@ -388,6 +396,9 @@ Resource Files + + Resource Files + Resource Files @@ -397,6 +408,12 @@ Resource Files + + Resource Files + + + Resource Files + Resource Files