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 
43 struct tone_t {
44 
48  enum {
49  GENERIC = 0,
50  SCAN_GREEN,
51  SCAN_BLUE,
52  SCAN_RED
53  } type;
54 
58  uint32_t len;
59 
63  uint16_t freq;
64 };
65 
71 struct SSTVMode_t {
72 
76  uint8_t visCode;
77 
81  uint16_t width;
82 
86  uint16_t height;
87 
91  uint16_t scanPixelLen;
92 
96  uint8_t numTones;
97 
102 };
103 
104 // all currently supported SSTV modes
105 extern const SSTVMode_t Scottie1;
106 extern const SSTVMode_t Scottie2;
107 extern const SSTVMode_t ScottieDX;
108 extern const SSTVMode_t Martin1;
109 extern const SSTVMode_t Martin2;
110 extern const SSTVMode_t Wrasse;
111 extern const SSTVMode_t PasokonP3;
112 extern const SSTVMode_t PasokonP5;
113 extern const SSTVMode_t PasokonP7;
114 
120 class SSTVClient {
121  public:
127  explicit SSTVClient(PhysicalLayer* phy);
128 
129  #if !defined(RADIOLIB_EXCLUDE_AFSK)
135  explicit SSTVClient(AFSKClient* audio);
136  #endif
137 
138  // basic methods
139 
149  int16_t begin(float base, const SSTVMode_t& mode);
150 
151  #if !defined(RADIOLIB_EXCLUDE_AFSK)
159  int16_t begin(const SSTVMode_t& mode);
160  #endif
161 
169  int16_t setCorrection(float correction);
170 
174  void idle();
175 
179  void sendHeader();
180 
186  void sendLine(uint32_t* imgLine);
187 
193  uint16_t getPictureHeight() const;
194 
195 #if !defined(RADIOLIB_GODMODE)
196  private:
197 #endif
198  PhysicalLayer* _phy;
199  #if !defined(RADIOLIB_EXCLUDE_AFSK)
200  AFSKClient* _audio;
201  #endif
202 
203  uint32_t _base = 0;
204  SSTVMode_t _mode = Scottie1;
205  bool _firstLine = true;
206 
207  void tone(float freq, uint32_t len = 0);
208 };
209 
210 #endif
211 
212 #endif
Client for audio-based transmissions. Requires Arduino tone() function, and a module capable of direc...
Definition: AFSK.h:17
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition: PhysicalLayer.h:14
Client for SSTV transmissions.
Definition: SSTV.h:120
void idle()
Sends out tone at 1900 Hz.
Definition: SSTV.cpp:207
int16_t setCorrection(float correction)
Set correction coefficient for tone length.
Definition: SSTV.cpp:193
void sendHeader()
Sends synchronization header for the SSTV mode set in begin method.
Definition: SSTV.cpp:212
int16_t begin(float base, const SSTVMode_t &mode)
Initialization method for 2-FSK.
Definition: SSTV.cpp:182
void sendLine(uint32_t *imgLine)
Sends single picture line in the currently configured SSTV mode.
Definition: SSTV.cpp:249
uint16_t getPictureHeight() const
Get picture height of the currently configured SSTV mode.
Definition: SSTV.cpp:288
SSTVClient(PhysicalLayer *phy)
Constructor for 2-FSK mode.
Definition: SSTV.cpp:157
Structure to save data about supported SSTV modes.
Definition: SSTV.h:71
tone_t tones[8]
Sequence of tones in each transmission line. This is used to create the correct encoding sequence.
Definition: SSTV.h:101
uint8_t visCode
Unique VIS code of the SSTV mode.
Definition: SSTV.h:76
uint16_t scanPixelLen
Pixel scan length in us.
Definition: SSTV.h:91
uint16_t height
Picture height in pixels.
Definition: SSTV.h:86
uint16_t width
Picture width in pixels.
Definition: SSTV.h:81
uint8_t numTones
Number of tones in each transmission line. Picture scan data is considered single tone.
Definition: SSTV.h:96
Structure to save data about tone.
Definition: SSTV.h:43
uint16_t freq
Frequency of tone in Hz, set to 0 for picture scan tones.
Definition: SSTV.h:63
uint32_t len
Length of tone in us, set to 0 for picture scan tones.
Definition: SSTV.h:58
enum tone_t::@0 type
Tone type: GENERIC for sync and porch tones, SCAN_GREEN, SCAN_BLUE and SCAN_RED for scan lines.