diff --git a/shuttle.cpp b/shuttle.cpp
index fa166a2..f7937d3 100644
--- a/shuttle.cpp
+++ b/shuttle.cpp
@@ -21,6 +21,8 @@ void shuttle::init()
int shuttle::hidApiWrite(unsigned char* data, unsigned char length)
{
+ Q_UNUSED(data);
+ Q_UNUSED(length);
/* int res;
unsigned char realData[length + 1];
@@ -48,15 +50,35 @@ void shuttle::run()
{
handle = hid_open(0x0b33, 0x0020, NULL);
if (!handle) {
- qDebug() << "unable to open device";
- return;
+ handle = hid_open(0x0b33, 0x0030, NULL);
+ if (!handle) {
+ handle = hid_open(0x0C26, 0x001E, NULL);
+ if (!handle) {
+ QTimer::singleShot(1000, this, SLOT(run()));
+ }
+ else {
+ usbDevice = RC28;
+ }
+ }
+ else {
+ usbDevice = shuttlePro2;
+ }
+ }
+ else {
+ usbDevice = shuttleXpress;
+ }
+
+ if (handle)
+ {
+ int res;
+ wchar_t manufacturer[MAX_STR];
+ wchar_t product[MAX_STR];
+ res = hid_get_manufacturer_string(handle, manufacturer, MAX_STR);
+ res = hid_get_product_string(handle, product, MAX_STR);
+ qDebug() << QString("Found Device: %0 from %1").arg(QString::fromWCharArray(product)).arg(QString::fromWCharArray(manufacturer));
+ hid_set_nonblocking(handle, 1);
+ QTimer::singleShot(0, this, SLOT(runTimer()));
}
-
- qDebug() << "*************** open device success";
-
- hid_set_nonblocking(handle, 1);
- qDebug() << "************ Starting HID";
- QTimer::singleShot(0, this, SLOT(runTimer()));
}
void shuttle::runTimer()
@@ -68,7 +90,9 @@ void shuttle::runTimer()
;//printf("waiting...\n");
else if (res < 0)
{
- qDebug() << "Unable to read()";
+ qDebug() << "USB Device disconnected?";
+ hid_close(handle);
+ QTimer::singleShot(1000, this, SLOT(run()));
return;
}
else if (res == 5)
@@ -80,34 +104,69 @@ void shuttle::runTimer()
<< hex << (unsigned char)data[3] << ":"
<< hex << (unsigned char)data[4];
- unsigned char tempButtons = ((unsigned char)data[3] | (unsigned char)data[4]);
+ unsigned int tempButtons = unsigned int((unsigned char)data[3] | (unsigned char)data[4] << 8);
unsigned char tempJogpos = (unsigned char)data[1];
unsigned char tempShutpos = (unsigned char)data[0];
-
- if (tempJogpos == jogpos + 1 || tempJogpos == jogpos - 1 || tempJogpos == 0xff || tempJogpos == 0x00) {
- if (tempJogpos > jogpos || (tempJogpos == 0x00 && jogpos == 0xff))
- {
- qDebug() << "JOG UP";
- }
- else {
- qDebug() << "JOG DOWN";
- }
+ if (tempJogpos == jogpos +1 || (tempJogpos == 0 && jogpos == 0xff))
+ {
+ qDebug() << "JOG PLUS";
+ emit jogPlus();
}
+ else if (tempJogpos != jogpos) {
+ qDebug() << "JOG MINUS";
+ emit jogMinus();
+ }
+
+
if (tempShutpos == shutpos + 1)
{
- qDebug() << "SHUTTLE UP";
+ qDebug() << "SHUTTLE PLUS";
}
else if (tempShutpos == shutpos-1) {
- qDebug() << "SHUTTLE DOWN";
+ qDebug() << "SHUTTLE MINUS";
}
- buttons = ((unsigned char)data[3] | (unsigned char)data[4]);
+ /* Button matrix:
+ 1000000000000000 = button15
+ 0100000000000000 = button14
+ 0010000000000000 = button13
+ 0001000000000000 = button12
+ 0000100000000000 = button11
+ 0000010000000000 = button10
+ 0000001000000000 = button9
+ 0000000100000000 = button8 - xpress1
+ 0000000010000000 = button7 - xpress2
+ 0000000001000000 = button6 - xpress3
+ 0000000000100000 = button5 - xpress4
+ 0000000000010000 = button4 - xpress5
+ 0000000000001000 = button3
+ 0000000000000100 = button2
+ 0000000000000010 = button1
+ 0000000000000001 = button0
+ */
+ if (buttons != tempButtons)
+ {
+ qDebug() << "BUTTON: " << qSetFieldWidth(16) << bin << tempButtons;
+
+ // Step size down
+ if ((tempButtons >> 5 & 1) && !(buttons >> 5 & 1))
+ emit button5(true);
+ // PTT on and off
+ if ((tempButtons >> 6 & 1) && !(buttons >> 6 & 1))
+ emit button6(true);
+ else if ((buttons >> 6 & 1) && !(tempButtons >> 6 & 1))
+ emit button6(false);
+ // Step size up
+ if ((tempButtons >> 7 & 1) && !(buttons >> 7 & 1))
+ emit button7(true);
+ }
+
+ buttons = unsigned int((unsigned char)data[3] | (unsigned char)data[4] << 8);
jogpos = (unsigned char)data[1];
shutpos = (unsigned char)data[0];
- emit hidDataArrived(data);
}
- // Run every 50ms
- QTimer::singleShot(50, this, SLOT(runTimer()));
+ // Run every 25ms
+ QTimer::singleShot(25, this, SLOT(runTimer()));
}
diff --git a/shuttle.h b/shuttle.h
index 1347cca..77b1142 100644
--- a/shuttle.h
+++ b/shuttle.h
@@ -14,7 +14,9 @@
using namespace std;
-#define HIDDATALENGTH 5
+
+#define HIDDATALENGTH 64
+#define MAX_STR 255
class shuttle : public QObject
{
@@ -31,14 +33,33 @@ public slots:
void runTimer();
signals:
- void hidDataArrived(QByteArray data);
+ void jogPlus();
+ void jogMinus();
+
+ void button0(bool);
+ void button1(bool);
+ void button2(bool);
+ void button3(bool);
+ void button4(bool);
+ void button5(bool);
+ void button6(bool);
+ void button7(bool);
+ void button8(bool);
+ void button9(bool);
+ void button10(bool);
+ void button11(bool);
+ void button12(bool);
+ void button13(bool);
+ void button14(bool);
+ void button15(bool);
private:
hid_device* handle;
bool isOpen=false;
- unsigned char buttons;
- unsigned char jogpos;
- unsigned char shutpos;
+ unsigned int buttons=0;
+ unsigned char jogpos=0;
+ unsigned char shutpos=0;
+ enum { NONE, shuttleXpress, shuttlePro2, RC28 }usbDevice;
protected:
};
diff --git a/wfmain.cpp b/wfmain.cpp
index ab5f92b..844d0af 100644
--- a/wfmain.cpp
+++ b/wfmain.cpp
@@ -1058,13 +1058,42 @@ void wfmain::setupShuttleDevice()
shuttleDev->moveToThread(shuttleThread);
connect(shuttleThread, SIGNAL(started()), shuttleDev, SLOT(run()));
connect(shuttleThread, SIGNAL(finished()), shuttleDev, SLOT(deleteLater()));
- connect(shuttleDev, SIGNAL(hidDataArrived(QByteArray)), this, SLOT(hidDataArrived(QByteArray)));
+ connect(shuttleDev, SIGNAL(jogPlus()), this, SLOT(shortcutStepPlus()));
+ connect(shuttleDev, SIGNAL(jogMinus()), this, SLOT(shortcutStepMinus()));
+ connect(shuttleDev, SIGNAL(button5(bool)), this, SLOT(stepDown()));
+ connect(shuttleDev, SIGNAL(button6(bool)), this, SLOT(pttToggle(bool)));
+ connect(shuttleDev, SIGNAL(button7(bool)), this, SLOT(stepUp()));
shuttleThread->start();
}
-void wfmain::hidDataArrived(QByteArray data)
+void wfmain::pttToggle(bool status)
{
+ // is it enabled?
+ if (!ui->pttEnableChk->isChecked())
+ {
+ showStatusBarText("PTT is disabled, not sending command. Change under Settings tab.");
+ return;
+ }
+
+ emit setPTT(status);
+ // Start 3 minute timer
+ if (status)
+ pttTimer->start();
+
+ issueDelayedCommand(cmdGetPTT);
+}
+
+void wfmain::stepUp()
+{
+ if (ui->tuningStepCombo->currentIndex() < ui->tuningStepCombo->count() - 1)
+ ui->tuningStepCombo->setCurrentIndex(ui->tuningStepCombo->currentIndex() + 1);
+}
+
+void wfmain::stepDown()
+{
+ if (ui->tuningStepCombo->currentIndex() > 0)
+ ui->tuningStepCombo->setCurrentIndex(ui->tuningStepCombo->currentIndex() - 1);
}
void wfmain::setDefPrefs()
@@ -1778,7 +1807,7 @@ quint64 wfmain::roundFrequencyWithStep(quint64 frequency, int steps, unsigned in
void wfmain::shortcutMinus()
{
- if(freqLock) return;
+ if (freqLock) return;
freqt f;
f.Hz = roundFrequencyWithStep(freq.Hz, -1, tsPlusHz);
@@ -1791,7 +1820,7 @@ void wfmain::shortcutMinus()
void wfmain::shortcutPlus()
{
- if(freqLock) return;
+ if (freqLock) return;
freqt f;
f.Hz = roundFrequencyWithStep(freq.Hz, 1, tsPlusHz);
@@ -1802,6 +1831,32 @@ void wfmain::shortcutPlus()
issueDelayedCommandUnique(cmdGetFreq);
}
+void wfmain::shortcutStepMinus()
+{
+ if (freqLock) return;
+
+ freqt f;
+ f.Hz = roundFrequencyWithStep(freq.Hz, -1, ui->tuningStepCombo->currentData().toInt());
+
+ f.MHzDouble = f.Hz / (double)1E6;
+ setUIFreq();
+ emit setFrequency(f);
+ issueDelayedCommandUnique(cmdGetFreq);
+}
+
+void wfmain::shortcutStepPlus()
+{
+ if (freqLock) return;
+
+ freqt f;
+ f.Hz = roundFrequencyWithStep(freq.Hz, 1, ui->tuningStepCombo->currentData().toInt());
+
+ f.MHzDouble = f.Hz / (double)1E6;
+ setUIFreq();
+ emit setFrequency(f);
+ issueDelayedCommandUnique(cmdGetFreq);
+}
+
void wfmain::shortcutShiftMinus()
{
if(freqLock) return;
@@ -3230,7 +3285,7 @@ void wfmain::on_freqDial_valueChanged(int value)
f.Hz = roundFrequencyWithStep(freq.Hz, delta, tsKnobHz);
f.MHzDouble = f.Hz / (double)1E6;
- if(f.Hz > 0)
+ if (f.Hz > 0)
{
freq = f;
@@ -3239,7 +3294,8 @@ void wfmain::on_freqDial_valueChanged(int value)
ui->freqLabel->setText(QString("%1").arg(f.MHzDouble, 0, 'f'));
emit setFrequency(f);
- } else {
+ }
+ else {
ui->freqDial->blockSignals(true);
ui->freqDial->setValue(oldFreqDialVal);
ui->freqDial->blockSignals(false);
diff --git a/wfmain.h b/wfmain.h
index 36e193d..60d2105 100644
--- a/wfmain.h
+++ b/wfmain.h
@@ -170,6 +170,8 @@ private slots:
void shortcutSlash();
void shortcutMinus();
void shortcutPlus();
+ void shortcutStepMinus();
+ void shortcutStepPlus();
void shortcutShiftMinus();
void shortcutShiftPlus();
void shortcutControlMinus();
@@ -241,7 +243,9 @@ private slots:
void showStatusBarText(QString text);
void serverConfigRequested(SERVERCONFIG conf, bool store);
void receiveBaudRate(quint32 baudrate);
- void hidDataArrived(QByteArray data);
+ void pttToggle(bool);
+ void stepUp();
+ void stepDown();
// void on_getFreqBtn_clicked();
diff --git a/wfview.vcxproj b/wfview.vcxproj
index 33c7455..2d7cd77 100644
--- a/wfview.vcxproj
+++ b/wfview.vcxproj
@@ -48,7 +48,7 @@
- .;..\qcustomplot;opus-tools\src;rtaudio;release;/include;%(AdditionalIncludeDirectories)
+ .;..\hidapi\hidapi;..\qcustomplot;opus-tools\src;rtaudio;release;/include;%(AdditionalIncludeDirectories)
-Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions)
release\
false
@@ -57,7 +57,7 @@
Sync
release\
MaxSpeed
- _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;__WINDOWS_WASAPI__;GITSHORT="24ce16b";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions)
+ _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;__WINDOWS_WASAPI__;GITSHORT="7b9a911";HOST="wfview.org";UNAME="build";NDEBUG;QT_NO_DEBUG;QT_USB_LIB;%(PreprocessorDefinitions)
false
MultiThreadedDLL
@@ -66,8 +66,8 @@
Level3
true
- shell32.lib;%(AdditionalDependencies)
- C:\opensslx86\lib;C:\Utils\my_sql\mysql-5.7.25-win32\lib;C:\Utils\postgresqlx86\pgsql\lib;%(AdditionalLibraryDirectories)
+ ..\hidapi\windows\release\hidapi.lib;$(QTDIR)\lib\Qt5Usb.lib;shell32.lib;%(AdditionalDependencies)
+ ..\hidapi\windows\release;C:\opensslx86\lib;C:\Utils\my_sql\mysql-5.7.25-win32\lib;C:\Utils\postgresqlx86\pgsql\lib;%(AdditionalLibraryDirectories)
"/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions)
true
false
@@ -85,12 +85,12 @@
0
- _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;__WINDOWS_WASAPI__;GITSHORT=\"24ce16b\";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;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;__WINDOWS_WASAPI__;GITSHORT=\"7b9a911\";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_USB_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
- .;..\qcustomplot;opus-tools\src;rtaudio;debug;/include;%(AdditionalIncludeDirectories)
+ .;..\hidapi\hidapi;..\qcustomplot;opus-tools\src;rtaudio;debug;/include;%(AdditionalIncludeDirectories)
-Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions)
debug\
false
@@ -99,7 +99,7 @@
Sync
debug\
Disabled
- _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;__WINDOWS_WASAPI__;GITSHORT="24ce16b";HOST="wfview.org";UNAME="build";%(PreprocessorDefinitions)
+ _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;__WINDOWS_WASAPI__;GITSHORT="7b9a911";HOST="wfview.org";UNAME="build";QT_USB_LIB;%(PreprocessorDefinitions)
false
MultiThreadedDebugDLL
true
@@ -107,8 +107,8 @@
Level3
true
- shell32.lib;%(AdditionalDependencies)
- C:\opensslx86\lib;C:\Utils\my_sql\mysql-5.7.25-win32\lib;C:\Utils\postgresqlx86\pgsql\lib;%(AdditionalLibraryDirectories)
+ ..\hidapi\windows\release\hidapi.lib;$(QTDIR)\lib\Qt5Usbd.lib;shell32.lib;%(AdditionalDependencies)
+ ..\hidapi\windows\release;C:\opensslx86\lib;C:\Utils\my_sql\mysql-5.7.25-win32\lib;C:\Utils\postgresqlx86\pgsql\lib;%(AdditionalLibraryDirectories)
"/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions)
true
true
@@ -124,11 +124,10 @@
0
- _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_COMPILE_LIBRARY;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;__WINDOWS_WASAPI__;GITSHORT=\"24ce16b\";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;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;__WINDOWS_WASAPI__;GITSHORT=\"7b9a911\";HOST=\"wfview.org\";UNAME=\"build\";QT_MULTIMEDIA_LIB;QT_PRINTSUPPORT_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_SERIALPORT_LIB;QT_NETWORK_LIB;QT_USB_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
-
@@ -146,13 +145,13 @@
+
-
@@ -270,6 +269,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -367,6 +376,8 @@
+
+
diff --git a/wfview.vcxproj.filters b/wfview.vcxproj.filters
index 1c9e103..fe3ebcb 100644
--- a/wfview.vcxproj.filters
+++ b/wfview.vcxproj.filters
@@ -57,9 +57,6 @@
-
- Source Files
-
Source Files
@@ -111,6 +108,9 @@
Source Files
+
+ Source Files
+
Source Files
@@ -125,9 +125,6 @@
-
- Header Files
-
Header Files
@@ -185,6 +182,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -247,6 +247,8 @@
+
+