From 28ba131135b9e2f3c0872d35475f370cba102ecc Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 8 Jun 2021 08:04:41 +0100 Subject: [PATCH] Improve shuttle control --- shuttle.cpp | 41 ++++++++++++++++++++++++----------------- shuttle.h | 3 +++ wfmain.cpp | 1 - wfmain.h | 2 ++ 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/shuttle.cpp b/shuttle.cpp index d16a86a..786de23 100644 --- a/shuttle.cpp +++ b/shuttle.cpp @@ -3,7 +3,7 @@ shuttle::shuttle() { - qInfo() << "Starting USB device detection"; + qInfo() << "Starting HID USB device detection"; } shuttle::~shuttle() @@ -119,14 +119,6 @@ void shuttle::runTimer() emit jogMinus(); } - - if (tempShutpos == shutpos + 1) - { - qDebug() << "SHUTTLE PLUS"; - } - else if (tempShutpos == shutpos-1) { - qDebug() << "SHUTTLE MINUS"; - } /* Button matrix: 1000000000000000 = button15 0100000000000000 = button14 @@ -135,11 +127,11 @@ void shuttle::runTimer() 0000100000000000 = button11 0000010000000000 = button10 0000001000000000 = button9 - 0000000100000000 = button8 - xpress1 - 0000000010000000 = button7 - xpress2 - 0000000001000000 = button6 - xpress3 - 0000000000100000 = button5 - xpress4 - 0000000000010000 = button4 - xpress5 + 0000000100000000 = button8 - xpress0 + 0000000010000000 = button7 - xpress1 + 0000000001000000 = button6 - xpress2 + 0000000000100000 = button5 - xpress3 + 0000000000010000 = button4 - xpress4 0000000000001000 = button3 0000000000000100 = button2 0000000000000010 = button1 @@ -162,9 +154,9 @@ void shuttle::runTimer() 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]; + buttons = tempButtons; + jogpos = tempJogpos; + shutpos = tempShutpos; } else if (res == 64 && usbDevice == RC28) @@ -185,6 +177,21 @@ void shuttle::runTimer() } } + + + if (shutpos > 0 && shutpos < 8) + { + shutMult = shutpos; + emit doShuttle(true,shutMult); + qDebug() << "SHUTTLE PLUS" << shutMult; + + } + else if (shutpos <= 0xff && shutpos >= 0xf0) { + shutMult = abs(shutpos - 0xff)+1; + emit doShuttle(false,shutMult); + qDebug() << "SHUTTLE MINUS" << shutMult; + } + // Run every 25ms QTimer::singleShot(25, this, SLOT(runTimer())); } diff --git a/shuttle.h b/shuttle.h index 8e9e7f5..2e24688 100644 --- a/shuttle.h +++ b/shuttle.h @@ -41,6 +41,8 @@ signals: void jogPlus(); void jogMinus(); + void doShuttle(bool plus, quint8 level); + void button0(bool); void button1(bool); void button2(bool); @@ -64,6 +66,7 @@ private: unsigned int buttons=0; unsigned char jogpos=0; unsigned char shutpos=0; + unsigned char shutMult = 0; enum { NONE, shuttleXpress, shuttlePro2, RC28 }usbDevice; protected: diff --git a/wfmain.cpp b/wfmain.cpp index 20f112d..f4d4816 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -1066,7 +1066,6 @@ void wfmain::setupShuttleDevice() connect(shuttleDev, SIGNAL(jogPlus()), this, SLOT(shortcutStepPlus())); connect(shuttleDev, SIGNAL(jogMinus()), this, SLOT(shortcutStepMinus())); connect(shuttleDev, SIGNAL(doShuttle(bool,quint8)), this, SLOT(doShuttle(bool,quint8))); - connect(shuttleDev, SIGNAL(shuttleMinus()), this, SLOT(shortcutShiftMinus())); 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())); diff --git a/wfmain.h b/wfmain.h index 60d2105..7494e04 100644 --- a/wfmain.h +++ b/wfmain.h @@ -185,6 +185,8 @@ private slots: void handlePttLimit(); // hit at 3 min transmit length + void doShuttle(bool up, quint8 level); + void receiveCommReady(); void receiveFreq(freqt); void receiveMode(unsigned char mode, unsigned char filter);