From f610d6d9ad4dfb845c6eb9e65a72783e5a623373 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Mon, 30 Oct 2023 21:29:09 +0000 Subject: [PATCH] Various other fixes, including cwsender --- cachingqueue.cpp | 3 +- cwsender.cpp | 101 ++++++++++++++++++++++++----------------------- rigcommander.cpp | 30 +++++++++++--- wfmain.cpp | 1 - 4 files changed, 77 insertions(+), 58 deletions(-) diff --git a/cachingqueue.cpp b/cachingqueue.cpp index d1ac029..9fa269b 100644 --- a/cachingqueue.cpp +++ b/cachingqueue.cpp @@ -327,8 +327,7 @@ bool cachingQueue::compare(QVariant a, QVariant b) if (a.value() != b.value()) changed=true; } else if (!strcmp(a.typeName(),"QString")) { - if (a.value() != b.value()) - changed=true; + changed=true; } else if (!strcmp(a.typeName(),"uchar")) { if (a.value() != b.value()) changed=true; diff --git a/cwsender.cpp b/cwsender.cpp index bf9a712..5417013 100644 --- a/cwsender.cpp +++ b/cwsender.cpp @@ -20,6 +20,51 @@ cwSender::cwSender(QWidget *parent) : connect(ui->textToSendEdit->lineEdit(), &QLineEdit::textEdited, this, &cwSender::textChanged); this->setObjectName("CW Sender"); queue = cachingQueue::getInstance(this); + + connect(this, &cwSender::sendCW, queue, [=](const QString &cwMessage) { + queue->add(priorityImmediate,queueItem(funcSendCW,QVariant::fromValue(cwMessage))); + }); + + connect(this, &cwSender::stopCW, queue, [=]() { + queue->add(priorityImmediate,queueItem(funcSendCW,QVariant::fromValue(QChar(0xff)))); + }); + + connect(this, &cwSender::setBreakInMode, queue, [=](const unsigned char &bmode) { + queue->add(priorityImmediate,queueItem(funcBreakIn,QVariant::fromValue(bmode))); + }); + + + connect(this, &cwSender::setDashRatio, queue, [=](const unsigned char& ratio) { + queue->add(priorityImmediate,queueItem(funcDashRatio,QVariant::fromValue(ratio))); + }); + + connect(this, &cwSender::setPitch, queue, [=](const unsigned char& pitch) { + queue->add(priorityImmediate,queueItem(funcSendCW,QVariant::fromValue(pitch))); + }); + + connect(this, &cwSender::getCWSettings, queue, [=]() { + queue->add(priorityImmediate,funcKeySpeed); + queue->add(priorityImmediate,funcBreakIn); + queue->add(priorityImmediate,funcCwPitch); + queue->add(priorityImmediate,funcDashRatio); + }); + + connect(this, &cwSender::setKeySpeed, tone, + [=](const unsigned char& wpm) { tone->setSpeed(wpm); }); + + connect(this, &cwSender::setDashRatio, tone, + [=](const unsigned char& ratio) { tone->setRatio(ratio); }); + + connect(this, &cwSender::setPitch, tone, + [=](const unsigned char& pitch) { tone->setFrequency(pitch); }); + + connect(this, &cwSender::setLevel, tone, + [=](const unsigned char& level) { tone->setLevel(level); }); + + connect(this, &cwSender::stopCW, tone, + [=]() { tone->stopSending(); }); + + } cwSender::~cwSender() @@ -51,6 +96,7 @@ void cwSender::showEvent(QShowEvent *event) void cwSender::handleKeySpeed(unsigned char wpm) { + qInfo(logCW()) << "Received key speed" << wpm; if (wpm != ui->wpmSpin->value() && (wpm >= ui->wpmSpin->minimum()) && (wpm <= ui->wpmSpin->maximum())) { ui->wpmSpin->blockSignals(true); @@ -63,6 +109,7 @@ void cwSender::handleKeySpeed(unsigned char wpm) #else emit setKeySpeed(ratio); #endif + } } @@ -197,19 +244,19 @@ void cwSender::on_breakinCombo_activated(int brkmode) void cwSender::on_wpmSpin_valueChanged(int wpm) { emit setKeySpeed((unsigned char)wpm); + queue->add(priorityImmediate,queueItem(funcKeySpeed,QVariant::fromValue(wpm))); } void cwSender::on_dashSpin_valueChanged(double ratio) { - emit setDashRatio((unsigned char)double(ratio * 10)); + queue->add(priorityImmediate,queueItem(funcDashRatio,QVariant::fromValue(ratio*10.0))); } void cwSender::on_pitchSpin_valueChanged(int arg1) { // quint16 cwPitch = round((((600.0 / 255.0) * pitch) + 300) / 5.0) * 5.0; - unsigned char pitch = 0; - pitch = ceil((arg1 - 300) * (255.0 / 600.0)); - emit setPitch(pitch); + queue->add(priorityImmediate,queueItem(funcCwPitch,QVariant::fromValue(arg1))); + //emit setPitch(pitch); } void cwSender::on_macro1btn_clicked() @@ -283,52 +330,6 @@ void cwSender::on_sidetoneEnableChk_clicked(bool clicked) tone->send(text); ui->sidetoneEnableChk->setEnabled(false); }); - connect(this, &cwSender::sendCW, queue, [=](const QString &cwMessage) { - queue->add(priorityImmediate,queueItem(funcSendCW,QVariant::fromValue(cwMessage))); - }); - - connect(this, &cwSender::stopCW, queue, [=]() { - queue->add(priorityImmediate,queueItem(funcSendCW,QVariant::fromValue(QChar(0xff)))); - }); - - connect(this, &cwSender::setBreakInMode, queue, [=](const unsigned char &bmode) { - queue->add(priorityImmediate,queueItem(funcBreakIn,QVariant::fromValue(bmode))); - }); - - connect(this, &cwSender::setKeySpeed, queue, [=](const unsigned char& wpm) { - queue->add(priorityImmediate,queueItem(funcKeySpeed,QVariant::fromValue(wpm))); - }); - - connect(this, &cwSender::setDashRatio, queue, [=](const unsigned char& ratio) { - queue->add(priorityImmediate,queueItem(funcDashRatio,QVariant::fromValue(ratio))); - }); - - connect(this, &cwSender::setPitch, queue, [=](const unsigned char& pitch) { - queue->add(priorityImmediate,queueItem(funcSendCW,QVariant::fromValue(pitch))); - }); - - connect(this, &cwSender::getCWSettings, queue, [=]() { - queue->add(priorityImmediate,funcKeySpeed); - queue->add(priorityImmediate,funcBreakIn); - queue->add(priorityImmediate,funcCwPitch); - queue->add(priorityImmediate,funcDashRatio); - }); - - connect(this, &cwSender::setKeySpeed, tone, - [=](const unsigned char& wpm) { tone->setSpeed(wpm); }); - - connect(this, &cwSender::setDashRatio, tone, - [=](const unsigned char& ratio) { tone->setRatio(ratio); }); - - connect(this, &cwSender::setPitch, tone, - [=](const unsigned char& pitch) { tone->setFrequency(pitch); }); - - connect(this, &cwSender::setLevel, tone, - [=](const unsigned char& level) { tone->setLevel(level); }); - - connect(this, &cwSender::stopCW, tone, - [=]() { tone->stopSending(); }); - connect(tone, &cwSidetone::finished, this, [=]() { ui->sidetoneEnableChk->setEnabled(true); }); diff --git a/rigcommander.cpp b/rigcommander.cpp index 0ad4ffd..1d7030f 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -2081,6 +2081,12 @@ void rigCommander::parseCommand() } break; // The following group are 2 bytes converted to uchar (0-255) + case funcKeySpeed: { + uchar level = bcdHexToUChar(payloadIn[0],payloadIn[1]); + value.setValue(round((level / 6.071) + 6)); + break; + } + case funcAGCTime: case funcRfGain: case funcSquelch: @@ -2092,7 +2098,6 @@ void rigCommander::parseCommand() case funcCwPitch: case funcRFPower: case funcMicGain: - case funcKeySpeed: case funcNotchFilter: case funcCompressorLevel: case funcBreakInDelay: @@ -5313,6 +5318,7 @@ void rigCommander::receiveCommand(funcs func, QVariant value, bool sub) if (func == funcSendCW) { val = value.value().length(); + qInfo(logRig()) << "Send CW received"; } if (func == funcAfGain && value.isValid() && udp != Q_NULLPTR) { @@ -5355,7 +5361,7 @@ void rigCommander::receiveCommand(funcs func, QVariant value, bool sub) else if (!strcmp(value.typeName(),"QString")) { QString text = value.value(); - if (pttAllowed && func == funcSendCW) + if (func == funcSendCW) { QByteArray textData = text.toLocal8Bit(); unsigned char p=0; @@ -5369,7 +5375,7 @@ void rigCommander::receiveCommand(funcs func, QVariant value, bool sub) (p==0x2D) || (p==0x2C) || (p==0x3A) || (p==0x27) || (p==0x28) || (p==0x29) || (p==0x3D) || (p==0x2B) || (p==0x22) || - (p==0x40) || (p==0x20) ) + (p==0x40) || (p==0x20) || p == 0xff) { // Allowed character, continue } else { @@ -5378,11 +5384,16 @@ void rigCommander::receiveCommand(funcs func, QVariant value, bool sub) } } payload.append(textData); + qInfo(logRig()) << "Sending CW: payload:" << payload.toHex(' '); } } else if (!strcmp(value.typeName(),"uchar")) { - payload.append(value.value()); + if (func == funcDashRatio) { + payload.append(bcdEncodeChar(value.value())); + } else { + payload.append(value.value()); + } } else if (!strcmp(value.typeName(),"ushort")) { @@ -5391,6 +5402,15 @@ void rigCommander::receiveCommand(funcs func, QVariant value, bool sub) //qInfo() << "Setting filter width" << value.value() << "sub" << sub << "hex" << payload.toHex(); } + else if (func == funcKeySpeed){ + ushort wpm = round((value.value()-6) * (6.071)); + payload.append(bcdEncodeInt(wpm)); + } + else if (func == funcCwPitch) { + ushort pitch = 0; + pitch = ceil((value.value() - 300) * (255.0 / 600.0)); + payload.append(bcdEncodeInt(pitch)); + } else { payload.append(bcdEncodeInt(value.value())); } @@ -5701,7 +5721,7 @@ void rigCommander::receiveCommand(funcs func, QVariant value, bool sub) } // This was a set command, so queue a get straight after to retrieve the updated value // will fail on some commands so they would need to be added here: - if (func != funcScopeFixedEdgeFreq && func != funcSpeech && func != funcBandStackReg && func != funcMemoryContents) + if (func != funcScopeFixedEdgeFreq && func != funcSpeech && func != funcBandStackReg && func != funcMemoryContents && func != funcSendCW) { queue->addUnique(priorityImmediate,func,false,sub); } diff --git a/wfmain.cpp b/wfmain.cpp index f89c01b..a2c040b 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -5432,7 +5432,6 @@ void wfmain::receiveValue(cacheItem val){ // There is only a single CW Pitch setting, so send to both scopes. ui->mainScope->receiveCwPitch(val.value.value()); ui->subScope->receiveCwPitch(val.value.value()); - //receiveCwPitch(val.value.value()); cw->handlePitch(val.value.value()); break; case funcMicGain: