diff --git a/wfmain.cpp b/wfmain.cpp index 21681d3..a1ab2ea 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -4031,15 +4031,28 @@ void wfmain::removeSimilarCommand(cmds cmd) // pop anything out that is of the same kind of command: // pop anything out that is of the same kind of command: // Start at 1 since we put one in at zero that we want to keep. + + for (auto it = delayedCmdQue.begin()+1; it != delayedCmdQue.end();) + { + if (it->cmd == cmd) + { + it = delayedCmdQue.erase(it); + } + else { + it++; + } + } + /* for(unsigned int i=1; i < delayedCmdQue.size(); i++) { - if(delayedCmdQue.at(i).cmd == cmd) + if (delayedCmdQue.at(i).cmd == cmd) { //delayedCmdQue[i].cmd = cmdNone; delayedCmdQue.erase(delayedCmdQue.begin()+i); // i -= 1; } } + */ } void wfmain::receiveRigID(rigCapabilities rigCaps) @@ -4743,9 +4756,8 @@ void wfmain::handlePlotClick(QMouseEvent* me) } else if (prefs.clickDragTuningEnable) { - double x = plot->xAxis->pixelToCoord(me->pos().x()); - showStatusBarText(QString("Selected %1 MHz").arg(x)); - this->mousePressFreq = x; + this->mousePressFreq = plot->xAxis->pixelToCoord(cursor); + showStatusBarText(QString("Selected %1 MHz").arg(this->mousePressFreq)); } } else if (me->button() == Qt::RightButton) @@ -4788,7 +4800,7 @@ void wfmain::handlePlotClick(QMouseEvent* me) { passbandAction = pbtMoving; } - clickedFrequency = plot->xAxis->pixelToCoord(me->pos().x()); + this->mousePressFreq = plot->xAxis->pixelToCoord(cursor); } } } @@ -4827,6 +4839,7 @@ void wfmain::handlePlotMouseMove(QMouseEvent* me) #endif int pbtCenterPix = pbtLeftPix + ((pbtRightPix - pbtLeftPix) / 2); int cursor = me->pos().x(); + double movedFrequency = plot->xAxis->pixelToCoord(cursor) - mousePressFreq; if (passbandAction == passbandStatic && rectItem != nullptr) { if ((cursor <= leftPix && cursor > leftPix - 10) || @@ -4836,7 +4849,7 @@ void wfmain::handlePlotMouseMove(QMouseEvent* me) { setCursor(Qt::SizeHorCursor); } - else if (me->pos().x() > pbtCenterPix - 20 && me->pos().x() < pbtCenterPix + 20) { + else if (cursor > pbtCenterPix - 20 && cursor < pbtCenterPix + 20) { setCursor(Qt::OpenHandCursor); } } @@ -4859,62 +4872,63 @@ void wfmain::handlePlotMouseMove(QMouseEvent* me) break; } - if (plot->xAxis->pixelToCoord(me->pos().x()) >= freq.MHzDouble + origin) { - pb = plot->xAxis->pixelToCoord(me->pos().x()) - passbandIndicator->topLeft->coords().x(); + if (plot->xAxis->pixelToCoord(cursor) >= freq.MHzDouble + origin) { + pb = plot->xAxis->pixelToCoord(cursor) - passbandIndicator->topLeft->coords().x(); } else { - pb = passbandIndicator->bottomRight->coords().x() - plot->xAxis->pixelToCoord(me->pos().x()); + pb = passbandIndicator->bottomRight->coords().x() - plot->xAxis->pixelToCoord(cursor); } issueCmdUniquePriority(cmdSetPassband, (quint16)(pb * 1000000)); } else if (passbandAction == pbtMoving) { - double movedFrequency = plot->xAxis->pixelToCoord(me->pos().x()) - clickedFrequency; - double pbFreq = 0.0; - if (currentModeInfo.mk == modeLSB || currentModeInfo.mk == modePSK_R) { - pbFreq = ((TPBFInner - movedFrequency) / passbandWidth) * 127; - } - else { - pbFreq = ((movedFrequency + TPBFInner) / passbandWidth) * 127; - } + //qint16 shift = (qint16)(level - 128); + //TPBFInner = (double)(shift / 127.0) * (passbandWidth); + // Only move if more than 100Hz + static double lastFreq = movedFrequency; + if (lastFreq - movedFrequency > 0.000049 || movedFrequency - lastFreq > 0.000049) { - qint16 newFreq = pbFreq + 128; - if (newFreq >= 0 && newFreq <= 255) { - //qDebug() << QString("Moving passband by %1 Hz (%2) (%3) Mode:%4").arg((qint16)(movedFrequency * 1000000)).arg(pbFreq).arg(newFreq).arg(currentModeInfo.mk); - issueCmdUniquePriority(cmdSetTPBFInner, (unsigned char)newFreq); - issueCmdUniquePriority(cmdSetTPBFOuter, (unsigned char)newFreq); + double innerFreq = ((double)(TPBFInner + movedFrequency) / passbandWidth) * 127.0; + double outerFreq = ((double)(TPBFOuter + movedFrequency) / passbandWidth) * 127.0; + + qint16 newInFreq = innerFreq + 128; + qint16 newOutFreq = outerFreq + 128; + + if (newInFreq >= 0 && newInFreq <= 255 && newOutFreq >= 0 && newOutFreq <= 255) { + qDebug() << QString("Moving passband by %1 Hz (Inner %2) (Outer %3) Mode:%4").arg((qint16)(movedFrequency * 1000000)) + .arg(newInFreq).arg(newOutFreq).arg(currentModeInfo.mk); + + issueCmd(cmdSetTPBFInner, (unsigned char)newInFreq); + issueCmd(cmdSetTPBFOuter, (unsigned char)newOutFreq); + //issueCmdUniquePriority(cmdSetTPBFInner, (unsigned char)newInFreq); + //issueCmdUniquePriority(cmdSetTPBFOuter, (unsigned char)newOutFreq); + + } + lastFreq = movedFrequency; } } else if (passbandAction == pbtInnerMove) { - double movedFrequency = plot->xAxis->pixelToCoord(me->pos().x()) - clickedFrequency; - if (TPBFInner + movedFrequency < passbandCenterFrequency) { - double pbFreq = 0.0; - - pbFreq = ((TPBFInner + movedFrequency) / passbandWidth) * 127; - + //if (TPBFInner + movedFrequency < passbandCenterFrequency) { + double pbFreq = ((double)(TPBFInner + movedFrequency) / passbandWidth) * 127.0; qint16 newFreq = pbFreq + 128; if (newFreq >= 0 && newFreq <= 255) { issueCmdUniquePriority(cmdSetTPBFInner, (unsigned char)newFreq); } - } + //} } else if (passbandAction == pbtOuterMove) { - double movedFrequency = plot->xAxis->pixelToCoord(me->pos().x()) - clickedFrequency; - if (movedFrequency + TPBFOuter > passbandCenterFrequency) { - double pbFreq = 0.0; - - pbFreq = ((movedFrequency + TPBFOuter) / passbandWidth) * 127; - + //if (movedFrequency + TPBFOuter > passbandCenterFrequency) { + double pbFreq = ((double)(TPBFOuter + movedFrequency) / passbandWidth) * 127.0; qint16 newFreq = pbFreq + 128; if (newFreq >= 0 && newFreq <= 255) { issueCmdUniquePriority(cmdSetTPBFOuter, (unsigned char)newFreq); } - } + //} } else if (passbandAction == passbandStatic && me->buttons() == Qt::LeftButton && textItem == nullptr && prefs.clickDragTuningEnable) { - double delta = plot->xAxis->pixelToCoord(me->pos().x()) - mousePressFreq; + double delta = plot->xAxis->pixelToCoord(cursor) - mousePressFreq; qDebug(logGui()) << "Mouse moving delta: " << delta; if( (( delta < -0.0001 ) || (delta > 0.0001)) && ((delta < 0.501) && (delta > -0.501)) ) { @@ -6349,12 +6363,14 @@ void wfmain::receiveTPBFInner(unsigned char level) { qint16 shift = (qint16)(level - 128); TPBFInner = (double)(shift / 127.0) * (passbandWidth); + //qDebug() << "Inner" << level; } void wfmain::receiveTPBFOuter(unsigned char level) { qint16 shift = (qint16)(level - 128); TPBFOuter = (double)(shift / 127.0) * (passbandWidth); + /// qDebug() << "Outer" << level; } diff --git a/wfmain.h b/wfmain.h index f5a26fd..9148094 100644 --- a/wfmain.h +++ b/wfmain.h @@ -1083,7 +1083,6 @@ private: rigstate* rigState = Q_NULLPTR; passbandActions passbandAction = passbandStatic; - double clickedFrequency = 0.0; double TPBFInner = 0.0; double TPBFOuter = 0.0; double passbandCenterFrequency = 0.0;