Allow main knob to be used for other values than VFO

qcpfix
Phil Taylor 2023-03-18 01:34:40 +00:00
rodzic a461babf73
commit 898d5960d8
3 zmienionych plików z 20 dodań i 7 usunięć

Wyświetl plik

@ -363,6 +363,8 @@ void usbController::run()
dev.knobSend.append(0);
}
dev.knobPrevious.append(dev.knobValues);
// Find our defaults/knobs/buttons for this controller:
// First see if we have any stored and add them to the list if not.
@ -764,7 +766,8 @@ void usbController::runTimer()
for (unsigned char i = 0; i < dev.knobValues.size(); i++) {
for (KNOB* kb = knobList->begin(); kb != knobList->end(); kb++) {
if (kb != knobList->end() && kb->command && kb->devicePath == dev.path && kb->num == i && dev.knobValues[i]) {
COMMAND cmd(*kb->command);
// sendCommand mustn't be deleted so we ensure it stays in-scope by declaring it private.
sendCommand = *kb->command;
if (kb->num >0) {
if (dev.knobSend[i] + (dev.knobValues[i] * 10) <= 0)
{
@ -777,14 +780,23 @@ void usbController::runTimer()
else {
dev.knobSend[i] = dev.knobSend[i] + (dev.knobValues[i] * 10);
}
cmd.suffix = dev.knobSend[i];
sendCommand.suffix = dev.knobSend[i];
} else {
cmd.value = dev.knobValues[i]/dev.sensitivity;
int tempVal = dev.knobValues[i] * dev.sensitivity;
tempVal = qMin(qMax(tempVal,0),255);
sendCommand.suffix = quint8(tempVal);
dev.knobValues[i]=tempVal/dev.sensitivity; // This ensures that dial can't go outside 0-255
}
qInfo(logUsbControl()) << "Sending Knob:" << kb->num << "Command:" << cmd.command << " Value:" << cmd.suffix << "Raw value:" << dev.knobValues[i];
emit button(&cmd);
dev.knobValues[i] = 0;
if (dev.knobValues[i] != dev.knobPrevious[i]) {
emit button(&sendCommand);
}
if (sendCommand.command == cmdSetFreq) {
dev.knobValues[i] = 0;
} else {
dev.knobPrevious[i]=dev.knobValues[i];
}
}
}
}

Wyświetl plik

@ -78,6 +78,7 @@ struct USBDEVICE {
quint32 buttons = 0;
quint32 knobs = 0;
QList<int> knobValues;
QList<int> knobPrevious;
QList<quint8> knobSend;
QTime lastusbController = QTime::currentTime();
QByteArray lastData = QByteArray(8,0x0);
@ -218,6 +219,7 @@ private:
QColor currentColour;
QMutex* mutex=Q_NULLPTR;
COMMAND sendCommand;
unsigned short knownUsbDevices[6][5] = {
{shuttleXpress,0x0b33,0x0020,0x0000,0x0000},

Wyświetl plik

@ -1860,7 +1860,6 @@ void wfmain::buttonControl(const COMMAND* cmd)
}
default:
issueCmdUniquePriority((cmds)cmd->command, cmd->suffix);
qInfo(logUsbControl()) << "Command fell through command:" << cmd->command << "suffix" << cmd->suffix;
break;
}
}