RadioLib Universal wireless communication library for Arduino

SSTV.h
1 #if !defined(_RADIOLIB_RADIOLIB_SSTV_H)
2 #define _RADIOLIB_RADIOLIB_SSTV_H
3
4 #include "../../TypeDef.h"
5
6 #if !defined(RADIOLIB_EXCLUDE_SSTV)
7
8 #include "../PhysicalLayer/PhysicalLayer.h"
9 #include "../AFSK/AFSK.h"
10
11 // the following implementation is based on information from
12 // http://www.barberdsp.com/downloads/Dayton%20Paper.pdf
13
14 // VIS codes
15 #define RADIOLIB_SSTV_SCOTTIE_1 60
16 #define RADIOLIB_SSTV_SCOTTIE_2 56
17 #define RADIOLIB_SSTV_SCOTTIE_DX 76
18 #define RADIOLIB_SSTV_MARTIN_1 44
19 #define RADIOLIB_SSTV_MARTIN_2 40
20 #define RADIOLIB_SSTV_WRASSE_SC2_180 55
21 #define RADIOLIB_SSTV_PASOKON_P3 113
22 #define RADIOLIB_SSTV_PASOKON_P5 114
23 #define RADIOLIB_SSTV_PASOKON_P7 115
24
25 // SSTV tones in Hz
26 #define RADIOLIB_SSTV_TONE_LEADER 1900
27 #define RADIOLIB_SSTV_TONE_BREAK 1200
28 #define RADIOLIB_SSTV_TONE_VIS_1 1100
29 #define RADIOLIB_SSTV_TONE_VIS_0 1300
30 #define RADIOLIB_SSTV_TONE_BRIGHTNESS_MIN 1500
31 #define RADIOLIB_SSTV_TONE_BRIGHTNESS_MAX 2300
32
33 // calibration header timing in us
34 #define RADIOLIB_SSTV_HEADER_LEADER_LENGTH 300000
35 #define RADIOLIB_SSTV_HEADER_BREAK_LENGTH 10000
36 #define RADIOLIB_SSTV_HEADER_BIT_LENGTH 30000
37
42 struct tone_t {
43
47 enum {
48 GENERIC = 0,
49 SCAN_GREEN,
50 SCAN_BLUE,
51 SCAN_RED
52 } type;
53
57 uint32_t len;
58
62 uint16_t freq;
63 };
64
69 struct SSTVMode_t {
70
74 uint8_t visCode;
75
79 uint16_t width;
80
84 uint16_t height;
85
89 uint16_t scanPixelLen;
90
94 uint8_t numTones;
95
99 tone_t tones[8];
100 };
101
102 // all currently supported SSTV modes
103 extern const SSTVMode_t Scottie1;
104 extern const SSTVMode_t Scottie2;
105 extern const SSTVMode_t ScottieDX;
106 extern const SSTVMode_t Martin1;
107 extern const SSTVMode_t Martin2;
108 extern const SSTVMode_t Wrasse;
109 extern const SSTVMode_t PasokonP3;
110 extern const SSTVMode_t PasokonP5;
111 extern const SSTVMode_t PasokonP7;
112
117 class SSTVClient {
118 public:
123 explicit SSTVClient(PhysicalLayer* phy);
124
125 #if !defined(RADIOLIB_EXCLUDE_AFSK)
130 explicit SSTVClient(AFSKClient* audio);
131 #endif
132
133 // basic methods
134
142 int16_t begin(float base, const SSTVMode_t& mode);
143
144 #if !defined(RADIOLIB_EXCLUDE_AFSK)
151 int16_t begin(const SSTVMode_t& mode);
152 #endif
153
160 int16_t setCorrection(float correction);
161
165 void idle();
166
170 void sendHeader();
171
177 void sendLine(uint32_t* imgLine);
178
183 uint16_t getPictureHeight() const;
184
185 #if !defined(RADIOLIB_GODMODE)
186 private:
187 #endif
188 PhysicalLayer* phyLayer;
189 #if !defined(RADIOLIB_EXCLUDE_AFSK)
190 AFSKClient* audioClient;
191 #endif
192
193 uint32_t baseFreq = 0;
194 SSTVMode_t txMode = Scottie1;
195 bool firstLine = true;
196
197 void tone(float freq, uint32_t len = 0);
198 };
199
200 #endif
201
202 #endif
AFSKClient
Client for audio-based transmissions. Requires Arduino tone() function, and a module capable of direc...
Definition: AFSK.h:16
PhysicalLayer
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition: PhysicalLayer.h:15
SSTVClient
Client for SSTV transmissions.
Definition: SSTV.h:117
SSTVClient::idle
void idle()
Sends out tone at 1900 Hz.
Definition: SSTV.cpp:207
SSTVClient::setCorrection
int16_t setCorrection(float correction)
Set correction coefficient for tone length.
Definition: SSTV.cpp:193
SSTVClient::sendHeader
void sendHeader()
Sends synchronization header for the SSTV mode set in begin method.
Definition: SSTV.cpp:212
SSTVClient::begin
int16_t begin(float base, const SSTVMode_t &mode)
Initialization method for 2-FSK.
Definition: SSTV.cpp:182
SSTVClient::sendLine
void sendLine(uint32_t *imgLine)
Sends single picture line in the currently configured SSTV mode.
Definition: SSTV.cpp:249
SSTVClient::getPictureHeight
uint16_t getPictureHeight() const
Get picture height of the currently configured SSTV mode.
Definition: SSTV.cpp:288
SSTVClient::SSTVClient
SSTVClient(PhysicalLayer *phy)
Constructor for 2-FSK mode.
Definition: SSTV.cpp:157
SSTVMode_t
Structure to save data about supported SSTV modes.
Definition: SSTV.h:69
SSTVMode_t::tones
tone_t tones[8]
Sequence of tones in each transmission line. This is used to create the correct encoding sequence.
Definition: SSTV.h:99
SSTVMode_t::visCode
uint8_t visCode
Unique VIS code of the SSTV mode.
Definition: SSTV.h:74
SSTVMode_t::scanPixelLen
uint16_t scanPixelLen
Pixel scan length in us.
Definition: SSTV.h:89
SSTVMode_t::height
uint16_t height
Picture height in pixels.
Definition: SSTV.h:84
SSTVMode_t::width
uint16_t width
Picture width in pixels.
Definition: SSTV.h:79
SSTVMode_t::numTones
uint8_t numTones
Number of tones in each transmission line. Picture scan data is considered single tone.
Definition: SSTV.h:94
tone_t
Structure to save data about tone.
Definition: SSTV.h:42
tone_t::freq
uint16_t freq
Frequency of tone in Hz, set to 0 for picture scan tones.
Definition: SSTV.h:62
tone_t::len
uint32_t len
Length of tone in us, set to 0 for picture scan tones.
Definition: SSTV.h:57
tone_t::type
enum tone_t::@1 type
Tone type: GENERIC for sync and porch tones, SCAN_GREEN, SCAN_BLUE and SCAN_RED for scan lines.