# RadioLib: src/protocols/SSTV/SSTV.h Source File

SSTV.h
#if !defined(_RADIOLIB_SSTV_H)
#define _RADIOLIB_SSTV_H
#include "../../TypeDef.h"
#if !RADIOLIB_EXCLUDE_SSTV
#include "../PhysicalLayer/PhysicalLayer.h"
#include "../AFSK/AFSK.h"
// the following implementation is based on information from
// http://www.barberdsp.com/downloads/Dayton%20Paper.pdf
// VIS codes
#define RADIOLIB_SSTV_SCOTTIE_1 60
#define RADIOLIB_SSTV_SCOTTIE_2 56
#define RADIOLIB_SSTV_SCOTTIE_DX 76
#define RADIOLIB_SSTV_MARTIN_1 44
#define RADIOLIB_SSTV_MARTIN_2 40
#define RADIOLIB_SSTV_WRASSE_SC2_180 55
#define RADIOLIB_SSTV_PASOKON_P3 113
#define RADIOLIB_SSTV_PASOKON_P5 114
#define RADIOLIB_SSTV_PASOKON_P7 115
#define RADIOLIB_SSTV_ROBOT_36 8
#define RADIOLIB_SSTV_ROBOT_72 12
// SSTV tones in Hz
#define RADIOLIB_SSTV_TONE_LEADER 1900
#define RADIOLIB_SSTV_TONE_BREAK 1200
#define RADIOLIB_SSTV_TONE_VIS_1 1100
#define RADIOLIB_SSTV_TONE_VIS_0 1300
#define RADIOLIB_SSTV_TONE_BRIGHTNESS_MIN 1500
#define RADIOLIB_SSTV_TONE_BRIGHTNESS_MAX 2300
// calibration header timing in us
#define RADIOLIB_SSTV_HEADER_LEADER_LENGTH 300000
#define RADIOLIB_SSTV_HEADER_BREAK_LENGTH 10000
#define RADIOLIB_SSTV_HEADER_BIT_LENGTH 30000
struct tone_t {
enum {
GENERIC = 0,
SCAN_GREEN_Y,
SCAN_BLUE_CB,
SCAN_RED_CR
} type;
RadioLibTime_t len;
uint16_t freq;
};
struct SSTVMode_t {
uint8_t visCode;
uint16_t width;
uint16_t height;
uint16_t scanPixelLen;
uint8_t numTones;
tone_t tones[9];
};
// all currently supported SSTV modes
extern const SSTVMode_t Scottie1;
extern const SSTVMode_t Scottie2;
extern const SSTVMode_t ScottieDX;
extern const SSTVMode_t Martin1;
extern const SSTVMode_t Martin2;
extern const SSTVMode_t Wrasse;
extern const SSTVMode_t PasokonP3;
extern const SSTVMode_t PasokonP5;
extern const SSTVMode_t PasokonP7;
extern const SSTVMode_t Robot36;
extern const SSTVMode_t Robot72;
class SSTVClient {
public:
explicit SSTVClient(PhysicalLayer* phy);
#if !RADIOLIB_EXCLUDE_AFSK
explicit SSTVClient(AFSKClient* audio);
#endif
// basic methods
int16_t begin(float base, const SSTVMode_t& mode);
#if !RADIOLIB_EXCLUDE_AFSK
int16_t begin(const SSTVMode_t& mode);
#endif
int16_t setCorrection(float correction);
void idle();
void sendHeader();
void sendLine(const uint32_t* imgLine);
uint16_t getPictureHeight() const;
#if !RADIOLIB_GODMODE
private:
#endif
PhysicalLayer* phyLayer;
#if !RADIOLIB_EXCLUDE_AFSK
AFSKClient* audioClient;
#endif
uint32_t baseFreq = 0;
SSTVMode_t txMode = Scottie1;
uint32_t lineCount = 0;
void tone(float freq, RadioLibTime_t len = 0);
};
#endif
#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:135
SSTVClient
Client for SSTV transmissions.
Definition: SSTV.h:121
SSTVClient::idle
void idle()
Sends out tone at 1900 Hz.
Definition: SSTV.cpp:242
SSTVClient::setCorrection
int16_t setCorrection(float correction)
Set correction coefficient for tone length.
Definition: SSTV.cpp:228
SSTVClient::sendHeader
void sendHeader()
Sends synchronization header for the SSTV mode set in begin method.
Definition: SSTV.cpp:247
SSTVClient::begin
int16_t begin(float base, const SSTVMode_t &mode)
Initialization method for 2-FSK.
Definition: SSTV.cpp:217
SSTVClient::sendLine
void sendLine(const uint32_t *imgLine)
Sends single picture line in the currently configured SSTV mode.
Definition: SSTV.cpp:284
SSTVClient::getPictureHeight
uint16_t getPictureHeight() const
Get picture height of the currently configured SSTV mode.
Definition: SSTV.cpp:357
SSTVClient::SSTVClient
SSTVClient(PhysicalLayer *phy)
Constructor for 2-FSK mode.
Definition: SSTV.cpp:192
RadioLibTime_t
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition: TypeDef.h:621
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
SSTVMode_t::tones
tone_t tones[9]
Sequence of tones in each transmission line. This is used to create the correct encoding sequence.
Definition: SSTV.h:101
SSTVMode_t::scanPixelLen
uint16_t scanPixelLen
Pixel scan length in us.
Definition: SSTV.h:91
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::numTones
uint8_t numTones
Number of tones in each transmission line. Picture scan data is considered single tone.
Definition: SSTV.h:96
tone_t
Structure to save data about tone.
Definition: SSTV.h:44
tone_t::freq
uint16_t freq
Frequency of tone in Hz, set to 0 for picture scan tones.
Definition: SSTV.h:64
tone_t::len
RadioLibTime_t len
Length of tone in us, set to 0 for picture scan tones.
Definition: SSTV.h:59
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.