1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-10 10:33:29 -05:00

CW keyer keyboard input: implemented controls in CW keyer

This commit is contained in:
f4exb 2019-07-30 09:27:55 +02:00
parent 1f30f527f5
commit 11eef9f02e
6 changed files with 64 additions and 0 deletions

View File

@ -205,6 +205,18 @@ int CWKeyer::getSample()
nextStateIambic();
return m_key ? 1 : 0;
}
else if (m_settings.m_mode == CWKeyerSettings::CWKeyboard)
{
if (m_settings.m_keyboardIambic)
{
nextStateIambic();
return m_key ? 1 : 0;
}
else
{
return (m_dot || m_dash) ? 1 : 0;
}
}
else
{
return 0;
@ -408,6 +420,27 @@ bool CWKeyer::eom()
return !(m_textPointer < m_settings.m_text.length());
}
void CWKeyer::setKeyboardDots()
{
m_dot = true;
m_dash = false;
m_keyIambicState = KeySilent;
}
void CWKeyer::setKeyboardDashes()
{
m_dot = false;
m_dash = true;
m_keyIambicState = KeySilent;
}
void CWKeyer::setKeyboardSilence()
{
m_dot = false;
m_dash = false;
m_keyIambicState = KeySilent;
}
CWSmoother::CWSmoother() :
m_fadeInCounter(0),
m_fadeOutCounter(0),
@ -547,6 +580,12 @@ void CWKeyer::applySettings(const CWKeyerSettings& settings, bool force)
m_dash = true;
m_keyIambicState = KeySilent;
}
else if (settings.m_mode == CWKeyerSettings::CWKeyboard)
{
m_dot = false;
m_dash = false;
m_keyIambicState = KeySilent;
}
}
if ((m_settings.m_text != settings.m_text) || force)

View File

@ -112,6 +112,9 @@ public:
bool eom();
void resetText() { m_textState = TextStart; }
void stopText() { m_textState = TextStop; }
void setKeyboardDots();
void setKeyboardDashes();
void setKeyboardSilence();
private:
QMutex m_mutex;

View File

@ -31,6 +31,7 @@ void CWKeyerSettings::resetToDefaults()
m_sampleRate = 48000;
m_text = "";
m_wpm = 13;
m_keyboardIambic = true;
m_dotKey = Qt::Key_Period;
m_dotKeyModifiers = Qt::NoModifier;
m_dashKey = Qt::Key_Minus;
@ -50,6 +51,7 @@ QByteArray CWKeyerSettings::serialize() const
s.writeU32(8, (unsigned int) m_dotKeyModifiers);
s.writeS32(9, (int) m_dashKey);
s.writeU32(10, (unsigned int) m_dashKeyModifiers);
s.writeBool(11, m_keyboardIambic);
return s.final();
}
@ -83,6 +85,7 @@ bool CWKeyerSettings::deserialize(const QByteArray& data)
m_dashKey = (Qt::Key) (intval < 0 ? 0 : intval);
d.readU32(10, &uintval, 0);
m_dashKeyModifiers = (Qt::KeyboardModifiers) uintval;
d.readBool(11, &m_keyboardIambic, true);
return true;
}

View File

@ -41,6 +41,7 @@ public:
int m_sampleRate;
QString m_text;
int m_wpm;
bool m_keyboardIambic;
Qt::Key m_dotKey;
Qt::KeyboardModifiers m_dotKeyModifiers;
Qt::Key m_dashKey;

View File

@ -156,6 +156,12 @@ void CWKeyerGUI::on_playStop_toggled(bool checked)
}
}
void CWKeyerGUI::on_keyingStyle_toggled(bool checked)
{
m_settings.m_keyboardIambic = !checked;
applySettings();
}
void CWKeyerGUI::on_keyDotCapture_toggled(bool checked)
{
if (checked && ui->keyDashCapture->isChecked())
@ -262,10 +268,20 @@ void CWKeyerGUI::keyboardKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifi
if ((key == settings.m_dotKey) && (keyModifiers == settings.m_dotKeyModifiers))
{
qDebug("CWKeyerGUI::keyboardKeyPressed: dot %s", release ? "released" : "pressed");
if (release) {
m_cwKeyer->setKeyboardSilence();
} else {
m_cwKeyer->setKeyboardDots();
}
}
else if ((key == settings.m_dashKey) && (keyModifiers == settings.m_dashKeyModifiers))
{
qDebug("CWKeyerGUI::keyboardKeyPressed: dash %s", release ? "released" : "pressed");
if (release) {
m_cwKeyer->setKeyboardSilence();
} else {
m_cwKeyer->setKeyboardDashes();
}
}
}
@ -301,6 +317,7 @@ void CWKeyerGUI::displaySettings()
ui->cwTextEdit->setText(m_settings.m_text);
ui->cwSpeed->setValue(m_settings.m_wpm);
ui->cwSpeedText->setText(QString("%1").arg(m_settings.m_wpm));
ui->keyingStyle->setChecked(!m_settings.m_keyboardIambic);
setKeyLabel(ui->keyDotLabel, m_settings.m_dotKey, m_settings.m_dotKeyModifiers);
setKeyLabel(ui->keyDashLabel, m_settings.m_dashKey, m_settings.m_dashKeyModifiers);

View File

@ -80,6 +80,7 @@ private slots:
void on_playText_toggled(bool checked);
void on_playLoopCW_toggled(bool checked);
void on_playStop_toggled(bool checked);
void on_keyingStyle_toggled(bool checked);
void on_keyDotCapture_toggled(bool checked);
void on_keyDashCapture_toggled(bool checked);
void on_keyboardKeyer_toggled(bool checked);