kopia lustrzana https://gitlab.com/eliggett/wfview
Some more changes
rodzic
54c75d5def
commit
80838e4f82
|
@ -132,7 +132,8 @@ void controllerSetup::onEventIndexChanged(int index) {
|
|||
currentButton->onCommand = &commands->at(onEvent->currentData().toInt());
|
||||
currentButton->onText->setPlainText(currentButton->onCommand->text);
|
||||
}
|
||||
emit programButtons(); // Signal that any button programming on the device should be completed.
|
||||
// Signal that any button programming on the device should be completed.
|
||||
emit programButton(onEvent->currentData().toInt(), currentButton->onCommand->text);
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,7 +144,6 @@ void controllerSetup::offEventIndexChanged(int index) {
|
|||
currentButton->offCommand = &commands->at(offEvent->currentData().toInt());
|
||||
currentButton->offText->setPlainText(currentButton->offCommand->text);
|
||||
}
|
||||
emit programButtons(); // Signal that any button programming on the device should be completed.
|
||||
}
|
||||
|
||||
void controllerSetup::knobEventIndexChanged(int index) {
|
||||
|
@ -153,7 +153,6 @@ void controllerSetup::knobEventIndexChanged(int index) {
|
|||
currentKnob->command = &commands->at(knobEvent->currentData().toInt());
|
||||
currentKnob->text->setPlainText(currentKnob->command->text);
|
||||
}
|
||||
emit programButtons(); // Signal that any button programming on the device should be completed.
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,7 +163,7 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
|
|||
commands = cmd;
|
||||
mutex = mut;
|
||||
|
||||
mutex->lock();
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
// Remove any existing button text:
|
||||
for (QGraphicsItem* item : scene->items())
|
||||
|
@ -290,6 +289,7 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
|
|||
b.onText->setDefaultTextColor(b.textColour);
|
||||
scene->addItem(b.onText);
|
||||
b.onText->setPos(b.pos.center().x() - b.onText->boundingRect().width() / 2, b.pos.y());
|
||||
emit programButton(b.num, b.onCommand->text); // Program the button with ontext if supported
|
||||
|
||||
b.offText = new QGraphicsTextItem(b.offCommand->text);
|
||||
b.offText->setDefaultTextColor(b.textColour);
|
||||
|
@ -322,8 +322,6 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
|
|||
knobEventProxy = scene->addWidget(knobEvent);
|
||||
connect(knobEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(knobEventIndexChanged(int)));
|
||||
|
||||
mutex->unlock();
|
||||
emit programButtons(); // Needs to take the mutex
|
||||
}
|
||||
|
||||
void controllerSetup::receiveSensitivity(int val)
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
signals:
|
||||
void sendSensitivity(int val);
|
||||
void programButtons();
|
||||
void programButton(int but, QString text);
|
||||
|
||||
public slots:
|
||||
void newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut);
|
||||
|
|
|
@ -106,25 +106,22 @@ void usbController::receiveKnobs(QVector<KNOB>* kbs)
|
|||
knobList = kbs;
|
||||
}
|
||||
|
||||
void usbController::programButtons() {
|
||||
QMutexLocker locker(mutex);
|
||||
void usbController::programButton(int val, QString text)
|
||||
{
|
||||
if (usbDevice == QuickKeys) {
|
||||
for (BUTTON* but = buttonList->begin(); but != buttonList->end(); but++) {
|
||||
QByteArray data(16, 0x0);
|
||||
data[0] = (qint8)0x02;
|
||||
data[1] = (qint8)0xb1;
|
||||
data[2] = but->num;
|
||||
data.replace(3,but->name.mid(0,8).length(), but->name.mid(0,8).toLocal8Bit());
|
||||
QByteArray data(16, 0x0);
|
||||
data[0] = (qint8)0x02;
|
||||
data[1] = (qint8)0xb1;
|
||||
data[2] = val;
|
||||
data.replace(3, text.mid(0, 8).length(), text.mid(0, 8).toLocal8Bit());
|
||||
|
||||
int res = hid_write(this->handle, (const unsigned char*)data.constData(), data.size());
|
||||
int res = hid_write(this->handle, (const unsigned char*)data.constData(), data.size());
|
||||
|
||||
if (res < 0) {
|
||||
qDebug(logUsbControl()) << "Unable to write(), Error:" << hid_error(this->handle);
|
||||
return;
|
||||
}
|
||||
if (res < 0) {
|
||||
qDebug(logUsbControl()) << "Unable to write(), Error:" << hid_error(this->handle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void usbController::run()
|
||||
|
@ -289,6 +286,9 @@ void usbController::run()
|
|||
knobSend.clear();
|
||||
knobValues.append({ 0,0,0 });
|
||||
knobSend.append({ 0,0,0 });
|
||||
}
|
||||
else if (usbDevice == QuickKeys) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -325,7 +325,6 @@ void usbController::runTimer()
|
|||
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
|
||||
while (res > 0) {
|
||||
QByteArray data(HIDDATALENGTH, 0x0);
|
||||
res = hid_read(this->handle, (unsigned char*)data.data(), HIDDATALENGTH);
|
||||
|
@ -386,30 +385,27 @@ void usbController::runTimer()
|
|||
if (buttons != tempButtons)
|
||||
{
|
||||
|
||||
|
||||
// Step through all buttons and emit ones that have been pressed.
|
||||
|
||||
for (unsigned char i = 0; i < 16; i++)
|
||||
{
|
||||
|
||||
for (BUTTON* but = buttonList->begin(); but != buttonList->end(); but++) {
|
||||
if (but->dev == usbDevice && but->num == i) {
|
||||
if ((tempButtons >> i & 1) && !(buttons >> i & 1) && but->onCommand->index > 0)
|
||||
{
|
||||
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
|
||||
emit button(but->onCommand);
|
||||
}
|
||||
else if ((buttons >> i & 1) && !(tempButtons >> i & 1) && but->offCommand->index > 0)
|
||||
{
|
||||
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
|
||||
emit button(but->offCommand);
|
||||
}
|
||||
auto but = std::find_if(buttonList->begin(), buttonList->end(), [this, i](const BUTTON& b)
|
||||
{ return (b.dev == this->usbDevice && b.num == i); });
|
||||
if (but != buttonList->end()) {
|
||||
if ((tempButtons >> i & 1) && !(buttons >> i & 1) && but->onCommand->index > 0)
|
||||
{
|
||||
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
|
||||
emit button(but->onCommand);
|
||||
}
|
||||
else if ((buttons >> i & 1) && !(tempButtons >> i & 1) && but->offCommand->index > 0)
|
||||
{
|
||||
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
|
||||
emit button(but->offCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
buttons = tempButtons;
|
||||
jogpos = tempJogpos;
|
||||
shutpos = tempShutpos;
|
||||
|
@ -431,9 +427,6 @@ void usbController::runTimer()
|
|||
BUTTON* butf1 = Q_NULLPTR;
|
||||
BUTTON* butf2 = Q_NULLPTR;;
|
||||
|
||||
|
||||
//delayedCmdQue.erase(std::remove_if(delayedCmdQue.begin() + 1, delayedCmdQue.end(), [cmd](const commandtype& c) { return (c.cmd == cmd); }),
|
||||
|
||||
for (BUTTON* but = buttonList->begin(); but != buttonList->end(); but++) {
|
||||
if (but->dev == usbDevice) {
|
||||
|
||||
|
@ -557,18 +550,18 @@ void usbController::runTimer()
|
|||
// Step through all buttons and emit ones that have been pressed.
|
||||
for (unsigned char i = 1; i < 23; i++)
|
||||
{
|
||||
for (BUTTON* but = buttonList->begin(); but != buttonList->end(); but++) {
|
||||
if (but->dev == usbDevice && but->num == i) {
|
||||
if ((tempButtons >> i & 1) && !(buttons >> i & 1) && but->onCommand->index > 0)
|
||||
{
|
||||
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
|
||||
emit button(but->onCommand);
|
||||
}
|
||||
else if ((buttons >> i & 1) && !(tempButtons >> i & 1) && but->offCommand->index > 0)
|
||||
{
|
||||
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
|
||||
emit button(but->offCommand);
|
||||
}
|
||||
auto but = std::find_if(buttonList->begin(), buttonList->end(), [this, i](const BUTTON& b)
|
||||
{ return (b.dev == this->usbDevice && b.num == i); });
|
||||
if (but != buttonList->end()) {
|
||||
if ((tempButtons >> i & 1) && !(buttons >> i & 1) && but->onCommand->index > 0)
|
||||
{
|
||||
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
|
||||
emit button(but->onCommand);
|
||||
}
|
||||
else if ((buttons >> i & 1) && !(tempButtons >> i & 1) && but->offCommand->index > 0)
|
||||
{
|
||||
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
|
||||
emit button(but->offCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public slots:
|
|||
void receiveKnobs(QVector<KNOB>*);
|
||||
void getVersion();
|
||||
void receiveSensitivity(int val);
|
||||
void programButtons();
|
||||
void programButton(int val, QString text);
|
||||
|
||||
signals:
|
||||
void jogPlus();
|
||||
|
|
36
wfmain.cpp
36
wfmain.cpp
|
@ -1680,7 +1680,7 @@ void wfmain::setupUsbControllerDevice()
|
|||
connect(shut, SIGNAL(sendSensitivity(int)), usbControllerDev, SLOT(receiveSensitivity(int)));
|
||||
connect(shut, SIGNAL(sendSensitivity(int)), this, SLOT(receiveUsbSensitivity(int)));
|
||||
connect(usbControllerDev, SIGNAL(sendSensitivity(int)), shut, SLOT(receiveSensitivity(int)));
|
||||
connect(usbControllerDev, SIGNAL(programButtons()), shut, SLOT(programButtons()));
|
||||
connect(shut, SIGNAL(programButton(int, QString)), usbControllerDev, SLOT(programButton(int, QString)));
|
||||
connect(this, SIGNAL(initUsbController(int,QMutex*)), usbControllerDev, SLOT(init(int,QMutex*)));
|
||||
#endif
|
||||
}
|
||||
|
@ -9375,20 +9375,20 @@ void wfmain::resetUsbCommands()
|
|||
usbCommands.append(COMMAND(num++, "Span-", commandButton, cmdSetSpanDown, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Mode+", commandButton, cmdSetModeUp, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Mode-", commandButton, cmdSetModeDown, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Mode LSB", commandButton, cmdSetMode, modeLSB));
|
||||
usbCommands.append(COMMAND(num++, "Mode USB", commandButton, cmdSetMode, modeUSB));
|
||||
usbCommands.append(COMMAND(num++, "Mode LSBD", commandButton, cmdSetMode, modeLSB_D));
|
||||
usbCommands.append(COMMAND(num++, "Mode USBD", commandButton, cmdSetMode, modeUSB_D));
|
||||
usbCommands.append(COMMAND(num++, "Mode CW", commandButton, cmdSetMode, modeCW));
|
||||
usbCommands.append(COMMAND(num++, "Mode CWR", commandButton, cmdSetMode, modeCW_R));
|
||||
usbCommands.append(COMMAND(num++, "Mode FM", commandButton, cmdSetMode, modeFM));
|
||||
usbCommands.append(COMMAND(num++, "Mode AM", commandButton, cmdSetMode, modeAM));
|
||||
usbCommands.append(COMMAND(num++, "Mode RTTY", commandButton, cmdSetMode, modeRTTY));
|
||||
usbCommands.append(COMMAND(num++, "Mode RTTYR", commandButton, cmdSetMode, modeRTTY_R));
|
||||
usbCommands.append(COMMAND(num++, "Mode PSK", commandButton, cmdSetMode, modePSK));
|
||||
usbCommands.append(COMMAND(num++, "Mode PSKR", commandButton, cmdSetMode, modePSK_R));
|
||||
usbCommands.append(COMMAND(num++, "Mode DV", commandButton, cmdSetMode, modeDV));
|
||||
usbCommands.append(COMMAND(num++, "Mode DD", commandButton, cmdSetMode, modeDD));
|
||||
usbCommands.append(COMMAND(num++, "LSB", commandButton, cmdSetMode, modeLSB));
|
||||
usbCommands.append(COMMAND(num++, "USB", commandButton, cmdSetMode, modeUSB));
|
||||
usbCommands.append(COMMAND(num++, "LSBD", commandButton, cmdSetMode, modeLSB_D));
|
||||
usbCommands.append(COMMAND(num++, "USBD", commandButton, cmdSetMode, modeUSB_D));
|
||||
usbCommands.append(COMMAND(num++, "CW", commandButton, cmdSetMode, modeCW));
|
||||
usbCommands.append(COMMAND(num++, "CWR", commandButton, cmdSetMode, modeCW_R));
|
||||
usbCommands.append(COMMAND(num++, "FM", commandButton, cmdSetMode, modeFM));
|
||||
usbCommands.append(COMMAND(num++, "AM", commandButton, cmdSetMode, modeAM));
|
||||
usbCommands.append(COMMAND(num++, "RTTY", commandButton, cmdSetMode, modeRTTY));
|
||||
usbCommands.append(COMMAND(num++, "RTTYR", commandButton, cmdSetMode, modeRTTY_R));
|
||||
usbCommands.append(COMMAND(num++, "PSK", commandButton, cmdSetMode, modePSK));
|
||||
usbCommands.append(COMMAND(num++, "PSKR", commandButton, cmdSetMode, modePSK_R));
|
||||
usbCommands.append(COMMAND(num++, "DV", commandButton, cmdSetMode, modeDV));
|
||||
usbCommands.append(COMMAND(num++, "DD", commandButton, cmdSetMode, modeDD));
|
||||
usbCommands.append(COMMAND(num++, "Band+", commandButton, cmdSetBandUp, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Band-", commandButton, cmdSetBandDown, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "23cm", commandButton, cmdGetBandStackReg, band23cm));
|
||||
|
@ -9417,7 +9417,7 @@ void wfmain::resetUsbCommands()
|
|||
usbCommands.append(COMMAND(num++, "NB Off", commandButton, cmdNone, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Split On", commandButton, cmdNone, 0x01));
|
||||
usbCommands.append(COMMAND(num++, "Split Off", commandButton, cmdNone, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Swap VFOs", commandButton, cmdVFOSwap, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Swap VFO", commandButton, cmdVFOSwap, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "AF Gain", commandKnob, cmdSetAfGain, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "RF Gain", commandKnob, cmdSetRxRfGain, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "TX Power", commandKnob, cmdSetTxPower, 0xff));
|
||||
|
@ -9425,8 +9425,8 @@ void wfmain::resetUsbCommands()
|
|||
usbCommands.append(COMMAND(num++, "Mod Level", commandKnob, cmdSetModLevel, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "Squelch", commandKnob, cmdSetSql, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "IF Shift", commandKnob, cmdSetIFShift, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "Inner PBT", commandKnob, cmdSetTPBFInner, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "Outer PBT", commandKnob, cmdSetTPBFOuter, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "In PBT", commandKnob, cmdSetTPBFInner, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "Out PBT", commandKnob, cmdSetTPBFOuter, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "CW Pitch", commandKnob, cmdSetCwPitch, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "CW Speed", commandKnob, cmdSetKeySpeed, 0xff));
|
||||
emit sendUsbControllerCommands(&usbCommands);
|
||||
|
|
Ładowanie…
Reference in New Issue