1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-20 16:41:01 -05:00
sdrangel/sdrbase/dsp/cwkeyer.h

105 lines
2.9 KiB
C
Raw Normal View History

2016-12-08 19:35:49 -05:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 F4EXB //
// written by Edouard Griffiths //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_DSP_CWKEYER_H_
#define SDRBASE_DSP_CWKEYER_H_
#include <QObject>
2016-12-11 05:35:25 -05:00
#include <QMutex>
2016-12-08 19:35:49 -05:00
#include "util/export.h"
class SDRANGEL_API CWKeyer : public QObject {
Q_OBJECT
public:
typedef enum
{
2016-12-11 05:35:25 -05:00
CWNone,
2016-12-08 19:35:49 -05:00
CWText,
CWDots,
CWDashes
2016-12-08 19:35:49 -05:00
} CWMode;
typedef enum
{
KeySilent,
KeyDot,
KeyDash
2016-12-09 13:34:38 -05:00
} CWKeyIambicState;
typedef enum
{
TextStart,
TextStartChar,
TextStartElement,
TextElement,
TextCharSpace,
TextWordSpace,
2016-12-11 05:35:25 -05:00
TextEnd,
TextStop
2016-12-09 13:34:38 -05:00
} CWTextState;
2016-12-08 19:35:49 -05:00
CWKeyer();
~CWKeyer();
2016-12-11 05:35:25 -05:00
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
void setSampleRate(int sampleRate);
2016-12-08 19:35:49 -05:00
void setWPM(int wpm);
2016-12-11 05:35:25 -05:00
void setText(const QString& text);
void setMode(CWMode mode);
void setLoop(bool loop) { m_loop = loop; }
2016-12-08 19:35:49 -05:00
int getSample();
bool eom();
void resetText() { m_textState = TextStart; }
2016-12-11 05:35:25 -05:00
void stopText() { m_textState = TextStop; }
2016-12-08 19:35:49 -05:00
private:
2016-12-11 05:35:25 -05:00
QMutex m_mutex;
2016-12-08 19:35:49 -05:00
int m_sampleRate;
int m_wpm;
int m_dotLength; //!< dot length in samples
QString m_text;
int m_textPointer;
int m_elementPointer;
2016-12-09 13:34:38 -05:00
int m_samplePointer;
2016-12-08 19:35:49 -05:00
bool m_elementSpace;
bool m_characterSpace;
bool m_key;
bool m_dot;
bool m_dash;
bool m_elementOn;
2016-12-11 05:35:25 -05:00
bool m_loop;
2016-12-09 13:34:38 -05:00
char m_asciiChar;
2016-12-08 19:35:49 -05:00
CWMode m_mode;
2016-12-09 13:34:38 -05:00
CWKeyIambicState m_keyIambicState;
CWTextState m_textState;
2016-12-08 19:35:49 -05:00
static const char m_asciiToMorse[128][7];
2016-12-09 13:34:38 -05:00
void nextStateIambic();
void nextStateText();
2016-12-08 19:35:49 -05:00
};
#endif /* SDRBASE_DSP_CWKEYER_H_ */