[SSTV] Update to 5.0.0

This commit is contained in:
jgromes 2021-11-14 11:41:09 +01:00
parent 7f3ef0bff5
commit 9504bc24ab
4 changed files with 52 additions and 51 deletions

View file

@ -91,7 +91,7 @@ void setup() {
// initialize SX1278 with default settings
Serial.print(F("[SX1278] Initializing ... "));
int state = radio.beginFSK();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -117,7 +117,7 @@ void setup() {
// (lower number = shorter pulses).
// The value is usually around 0.95 (95%).
state = sstv.begin(434.0, Wrasse, 0.95);
if(state == ERR_NONE) {
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));

View file

@ -90,7 +90,7 @@ void setup() {
// initialize SX1278 with default settings
Serial.print(F("[SX1278] Initializing ... "));
int state = radio.beginFSK();
if (state == ERR_NONE) {
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
@ -115,7 +115,7 @@ void setup() {
// (lower number = shorter pulses).
// The value is usually around 0.95 (95%).
state = sstv.begin(Wrasse, 0.95);
if(state == ERR_NONE) {
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));

View file

@ -2,7 +2,7 @@
#if !defined(RADIOLIB_EXCLUDE_SSTV)
const SSTVMode_t Scottie1 {
.visCode = SSTV_SCOTTIE_1,
.visCode = RADIOLIB_SSTV_SCOTTIE_1,
.width = 320,
.height = 256,
.scanPixelLen = 432,
@ -19,7 +19,7 @@ const SSTVMode_t Scottie1 {
};
const SSTVMode_t Scottie2 {
.visCode = SSTV_SCOTTIE_2,
.visCode = RADIOLIB_SSTV_SCOTTIE_2,
.width = 320,
.height = 256,
.scanPixelLen = 275,
@ -36,7 +36,7 @@ const SSTVMode_t Scottie2 {
};
const SSTVMode_t ScottieDX {
.visCode = SSTV_SCOTTIE_DX,
.visCode = RADIOLIB_SSTV_SCOTTIE_DX,
.width = 320,
.height = 256,
.scanPixelLen = 1080,
@ -53,7 +53,7 @@ const SSTVMode_t ScottieDX {
};
const SSTVMode_t Martin1 {
.visCode = SSTV_MARTIN_1,
.visCode = RADIOLIB_SSTV_MARTIN_1,
.width = 320,
.height = 256,
.scanPixelLen = 458,
@ -71,7 +71,7 @@ const SSTVMode_t Martin1 {
};
const SSTVMode_t Martin2 {
.visCode = SSTV_MARTIN_2,
.visCode = RADIOLIB_SSTV_MARTIN_2,
.width = 320,
.height = 256,
.scanPixelLen = 229,
@ -89,7 +89,7 @@ const SSTVMode_t Martin2 {
};
const SSTVMode_t Wrasse {
.visCode = SSTV_WRASSE_SC2_180,
.visCode = RADIOLIB_SSTV_WRASSE_SC2_180,
.width = 320,
.height = 256,
.scanPixelLen = 734,
@ -104,7 +104,7 @@ const SSTVMode_t Wrasse {
};
const SSTVMode_t PasokonP3 {
.visCode = SSTV_PASOKON_P3,
.visCode = RADIOLIB_SSTV_PASOKON_P3,
.width = 640,
.height = 496,
.scanPixelLen = 208,
@ -121,7 +121,7 @@ const SSTVMode_t PasokonP3 {
};
const SSTVMode_t PasokonP5 {
.visCode = SSTV_PASOKON_P5,
.visCode = RADIOLIB_SSTV_PASOKON_P5,
.width = 640,
.height = 496,
.scanPixelLen = 312,
@ -138,7 +138,7 @@ const SSTVMode_t PasokonP5 {
};
const SSTVMode_t PasokonP7 {
.visCode = SSTV_PASOKON_P7,
.visCode = RADIOLIB_SSTV_PASOKON_P7,
.width = 640,
.height = 496,
.scanPixelLen = 417,
@ -172,7 +172,7 @@ SSTVClient::SSTVClient(AFSKClient* audio) {
int16_t SSTVClient::begin(const SSTVMode_t& mode, float correction) {
if(_audio == nullptr) {
// this initialization method can only be used in AFSK mode
return(ERR_WRONG_MODEM);
return(RADIOLIB_ERR_WRONG_MODEM);
}
return(begin(0, mode, correction));
@ -198,7 +198,7 @@ int16_t SSTVClient::begin(float base, const SSTVMode_t& mode, float correction)
void SSTVClient::idle() {
_phy->transmitDirect();
this->tone(SSTV_TONE_LEADER);
this->tone(RADIOLIB_SSTV_TONE_LEADER);
}
void SSTVClient::sendHeader() {
@ -207,44 +207,44 @@ void SSTVClient::sendHeader() {
_phy->transmitDirect();
// send the first part of header (leader-break-leader)
this->tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH);
this->tone(SSTV_TONE_BREAK, SSTV_HEADER_BREAK_LENGTH);
this->tone(SSTV_TONE_LEADER, SSTV_HEADER_LEADER_LENGTH);
this->tone(RADIOLIB_SSTV_TONE_LEADER, RADIOLIB_SSTV_HEADER_LEADER_LENGTH);
this->tone(RADIOLIB_SSTV_TONE_BREAK, RADIOLIB_SSTV_HEADER_BREAK_LENGTH);
this->tone(RADIOLIB_SSTV_TONE_LEADER, RADIOLIB_SSTV_HEADER_LEADER_LENGTH);
// VIS start bit
this->tone(SSTV_TONE_BREAK, SSTV_HEADER_BIT_LENGTH);
this->tone(RADIOLIB_SSTV_TONE_BREAK, RADIOLIB_SSTV_HEADER_BIT_LENGTH);
// VIS code
uint8_t parityCount = 0;
for(uint8_t mask = 0x01; mask < 0x80; mask <<= 1) {
if(_mode.visCode & mask) {
this->tone(SSTV_TONE_VIS_1, SSTV_HEADER_BIT_LENGTH);
this->tone(RADIOLIB_SSTV_TONE_VIS_1, RADIOLIB_SSTV_HEADER_BIT_LENGTH);
parityCount++;
} else {
this->tone(SSTV_TONE_VIS_0, SSTV_HEADER_BIT_LENGTH);
this->tone(RADIOLIB_SSTV_TONE_VIS_0, RADIOLIB_SSTV_HEADER_BIT_LENGTH);
}
}
// VIS parity
if(parityCount % 2 == 0) {
// even parity
this->tone(SSTV_TONE_VIS_0, SSTV_HEADER_BIT_LENGTH);
this->tone(RADIOLIB_SSTV_TONE_VIS_0, RADIOLIB_SSTV_HEADER_BIT_LENGTH);
} else {
// odd parity
this->tone(SSTV_TONE_VIS_1, SSTV_HEADER_BIT_LENGTH);
this->tone(RADIOLIB_SSTV_TONE_VIS_1, RADIOLIB_SSTV_HEADER_BIT_LENGTH);
}
// VIS stop bit
this->tone(SSTV_TONE_BREAK, SSTV_HEADER_BIT_LENGTH);
this->tone(RADIOLIB_SSTV_TONE_BREAK, RADIOLIB_SSTV_HEADER_BIT_LENGTH);
}
void SSTVClient::sendLine(uint32_t* imgLine) {
// check first line flag in Scottie modes
if(_firstLine && ((_mode.visCode == SSTV_SCOTTIE_1) || (_mode.visCode == SSTV_SCOTTIE_2) || (_mode.visCode == SSTV_SCOTTIE_DX))) {
if(_firstLine && ((_mode.visCode == RADIOLIB_SSTV_SCOTTIE_1) || (_mode.visCode == RADIOLIB_SSTV_SCOTTIE_2) || (_mode.visCode == RADIOLIB_SSTV_SCOTTIE_DX))) {
_firstLine = false;
// send start sync tone
this->tone(SSTV_TONE_BREAK, 9000);
this->tone(RADIOLIB_SSTV_TONE_BREAK, 9000);
}
// send all tones in sequence
@ -271,7 +271,7 @@ void SSTVClient::sendLine(uint32_t* imgLine) {
case(tone_t::GENERIC):
break;
}
this->tone(SSTV_TONE_BRIGHTNESS_MIN + ((float)color * 3.1372549), _mode.scanPixelLen);
this->tone(RADIOLIB_SSTV_TONE_BRIGHTNESS_MIN + ((float)color * 3.1372549), _mode.scanPixelLen);
}
}
}
@ -282,7 +282,8 @@ uint16_t SSTVClient::getPictureHeight() const {
}
void SSTVClient::tone(float freq, uint32_t len) {
uint32_t start = Module::micros();
Module* mod = _phy->getMod();
uint32_t start = mod->micros();
#if !defined(RADIOLIB_EXCLUDE_AFSK)
if(_audio != nullptr) {
_audio->tone(freq, false);
@ -292,8 +293,8 @@ void SSTVClient::tone(float freq, uint32_t len) {
#else
_phy->transmitDirect(_base + (freq / _phy->getFreqStep()));
#endif
while(Module::micros() - start < len) {
Module::yield();
while(mod->micros() - start < len) {
mod->yield();
}
}

View file

@ -1,5 +1,5 @@
#if !defined(_RADIOLIB_SSTV_H)
#define _RADIOLIB_SSTV_H
#if !defined(_RADIOLIB_RADIOLIB_SSTV_H)
#define _RADIOLIB_RADIOLIB_SSTV_H
#include "../../TypeDef.h"
@ -12,28 +12,28 @@
// http://www.barberdsp.com/downloads/Dayton%20Paper.pdf
// VIS codes
#define SSTV_SCOTTIE_1 60
#define SSTV_SCOTTIE_2 56
#define SSTV_SCOTTIE_DX 76
#define SSTV_MARTIN_1 44
#define SSTV_MARTIN_2 40
#define SSTV_WRASSE_SC2_180 55
#define SSTV_PASOKON_P3 113
#define SSTV_PASOKON_P5 114
#define SSTV_PASOKON_P7 115
#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
// SSTV tones in Hz
#define SSTV_TONE_LEADER 1900
#define SSTV_TONE_BREAK 1200
#define SSTV_TONE_VIS_1 1100
#define SSTV_TONE_VIS_0 1300
#define SSTV_TONE_BRIGHTNESS_MIN 1500
#define SSTV_TONE_BRIGHTNESS_MAX 2300
#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 SSTV_HEADER_LEADER_LENGTH 300000
#define SSTV_HEADER_BREAK_LENGTH 10000
#define SSTV_HEADER_BIT_LENGTH 30000
#define RADIOLIB_SSTV_HEADER_LEADER_LENGTH 300000
#define RADIOLIB_SSTV_HEADER_BREAK_LENGTH 10000
#define RADIOLIB_SSTV_HEADER_BIT_LENGTH 30000
/*!
\struct tone_t
@ -187,7 +187,7 @@ class SSTVClient {
*/
uint16_t getPictureHeight() const;
#ifndef RADIOLIB_GODMODE
#if !defined(RADIOLIB_GODMODE)
private:
#endif
PhysicalLayer* _phy;