RadioLib
Universal wireless communication library for Arduino
SSTV.h
1 #if !defined(_RADIOLIB_SSTV_H)
2 #define _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 SSTV_SCOTTIE_1 60
16 #define SSTV_SCOTTIE_2 56
17 #define SSTV_SCOTTIE_DX 76
18 #define SSTV_MARTIN_1 44
19 #define SSTV_MARTIN_2 40
20 #define SSTV_WRASSE_SC2_180 55
21 #define SSTV_PASOKON_P3 113
22 #define SSTV_PASOKON_P5 114
23 #define SSTV_PASOKON_P7 115
24 
25 // SSTV tones in Hz
26 #define SSTV_TONE_LEADER 1900
27 #define SSTV_TONE_BREAK 1200
28 #define SSTV_TONE_VIS_1 1100
29 #define SSTV_TONE_VIS_0 1300
30 #define SSTV_TONE_BRIGHTNESS_MIN 1500
31 #define SSTV_TONE_BRIGHTNESS_MAX 2300
32 
33 // calibration header timing in us
34 #define SSTV_HEADER_LEADER_LENGTH 300000
35 #define SSTV_HEADER_BREAK_LENGTH 10000
36 #define 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)
130 
135  explicit SSTVClient(AFSKClient* audio);
136  #endif
137 
138  // basic methods
139 
151  int16_t begin(float base, const SSTVMode_t& mode, float correction = 1.0);
152 
153  #if !defined(RADIOLIB_EXCLUDE_AFSK)
154 
163  int16_t begin(const SSTVMode_t& mode, float correction = 1.0);
164  #endif
165 
169  void idle();
170 
174  void sendHeader();
175 
181  void sendLine(uint32_t* imgLine);
182 
188  uint16_t getPictureHeight() const;
189 
190 #ifndef RADIOLIB_GODMODE
191  private:
192 #endif
193  PhysicalLayer* _phy;
194  #if !defined(RADIOLIB_EXCLUDE_AFSK)
195  AFSKClient* _audio;
196  #endif
197 
198  uint32_t _base = 0;
199  SSTVMode_t _mode = Scottie1;
200  bool _firstLine = true;
201 
202  void tone(float freq, uint32_t len = 0);
203 };
204 
205 #endif
206 
207 #endif
SSTVClient::sendHeader
void sendHeader()
Sends synchronization header for the SSTV mode set in begin method.
Definition: SSTV.cpp:204
SSTVMode_t::height
uint16_t height
Picture height in pixels.
Definition: SSTV.h:86
SSTVMode_t::width
uint16_t width
Picture width in pixels.
Definition: SSTV.h:81
SSTVMode_t
Structure to save data about supported SSTV modes.
Definition: SSTV.h:71
SSTVMode_t::visCode
uint8_t visCode
Unique VIS code of the SSTV mode.
Definition: SSTV.h:76
AFSKClient
Client for audio-based transmissions. Requires Arduino tone() function, and a module capable of direc...
Definition: AFSK.h:17
tone_t
Structure to save data about tone.
Definition: SSTV.h:43
SSTVClient::sendLine
void sendLine(uint32_t *imgLine)
Sends single picture line in the currently configured SSTV mode.
Definition: SSTV.cpp:241
SSTVMode_t::scanPixelLen
uint16_t scanPixelLen
Pixel scan length in us.
Definition: SSTV.h:91
tone_t::freq
uint16_t freq
Frequency of tone in Hz, set to 0 for picture scan tones.
Definition: SSTV.h:63
SSTVClient::SSTVClient
SSTVClient(PhysicalLayer *phy)
Constructor for 2-FSK mode.
Definition: SSTV.cpp:157
SSTVMode_t::numTones
uint8_t numTones
Number of tones in each transmission line. Picture scan data is considered single tone.
Definition: SSTV.h:96
tone_t::len
uint32_t len
Length of tone in us, set to 0 for picture scan tones.
Definition: SSTV.h:58
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:101
SSTVClient::idle
void idle()
Sends out tone at 1900 Hz.
Definition: SSTV.cpp:199
PhysicalLayer
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition: PhysicalLayer.h:14
SSTVClient::begin
int16_t begin(float base, const SSTVMode_t &mode, float correction=1.0)
Initialization method for 2-FSK.
Definition: SSTV.cpp:182
SSTVClient
Client for SSTV transmissions.
Definition: SSTV.h:120
SSTVClient::getPictureHeight
uint16_t getPictureHeight() const
Get picture height of the currently configured SSTV mode.
Definition: SSTV.cpp:280
tone_t::type
enum tone_t::@0 type
Tone type: GENERIC for sync and porch tones, SCAN_GREEN, SCAN_BLUE and SCAN_RED for scan lines.