RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
Morse.h
1#if !defined(_RADIOLIB_MORSE_H) && !RADIOLIB_EXCLUDE_MORSE
2#define _RADIOLIB_MORSE_H
3
4#include "../../TypeDef.h"
5#include "../PhysicalLayer/PhysicalLayer.h"
6#include "../AFSK/AFSK.h"
7#include "../Print/Print.h"
8
9#define RADIOLIB_MORSE_DOT 0b0
10#define RADIOLIB_MORSE_DASH 0b1
11#define RADIOLIB_MORSE_GUARDBIT 0b1
12#define RADIOLIB_MORSE_UNSUPPORTED 0xFF
13#define RADIOLIB_MORSE_ASCII_OFFSET 32
14#define RADIOLIB_MORSE_INTER_SYMBOL 0x00
15#define RADIOLIB_MORSE_CHAR_COMPLETE 0x01
16#define RADIOLIB_MORSE_WORD_COMPLETE 0x02
17#define RADIOLIB_MORSE_UNKNOWN_SYMBOL '*'
18
24 public:
29 explicit MorseClient(PhysicalLayer* phy);
30
31 #if !RADIOLIB_EXCLUDE_AFSK
36 explicit MorseClient(AFSKClient* audio);
37 #endif
38
39 // basic methods
40
47 int16_t begin(float base, uint8_t speed = 20);
48
53 size_t startSignal();
54
61 static char decode(uint8_t symbol, uint8_t len);
62
72 #if !RADIOLIB_EXCLUDE_AFSK
73 int read(uint8_t* symbol, uint8_t* len, float low = 0.75f, float high = 1.25f);
74 #endif
75
81 size_t write(uint8_t b) override;
82
83#if !RADIOLIB_GODMODE
84 private:
85#endif
86 PhysicalLayer* phyLayer;
87 #if !RADIOLIB_EXCLUDE_AFSK
88 AFSKClient* audioClient;
89 #endif
90
91 uint32_t baseFreq = 0, baseFreqHz = 0;
92 float basePeriod = 0.0f;
93 uint32_t dotLength = 0;
94 uint32_t dashLength = 0;
95 uint32_t letterSpace = 0;
96 uint16_t wordSpace = 0;
97
98 // variables to keep decoding state
99 uint32_t signalCounter = 0;
100 RadioLibTime_t signalStart = 0;
101 uint32_t pauseCounter = 0;
102 RadioLibTime_t pauseStart = 0;
103
104 int16_t transmitDirect(uint32_t freq = 0, uint32_t freqHz = 0);
105 int16_t standby();
106};
107
108#endif
Client for audio-based transmissions. Requires Arduino tone() function, and a module capable of direc...
Definition AFSK.h:16
Client for Morse Code communication. The public interface is the same as Arduino Serial.
Definition Morse.h:23
size_t startSignal()
Send start signal.
Definition Morse.cpp:112
size_t write(uint8_t b) override
Write one byte. Implementation of interface of the RadioLibPrint/Print class.
Definition Morse.cpp:187
int16_t begin(float base, uint8_t speed=20)
Initialization method.
Definition Morse.cpp:94
int read(uint8_t *symbol, uint8_t *len, float low=0.75f, float high=1.25f)
Read Morse tone on input pin.
Definition Morse.cpp:135
static char decode(uint8_t symbol, uint8_t len)
Decode Morse symbol to ASCII.
Definition Morse.cpp:116
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition PhysicalLayer.h:390
Printing class, based on Arduino Print class with additional encodings.
Definition Print.h:17
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:679