diff --git a/src/protocols/SSTV/SSTV.cpp b/src/protocols/SSTV/SSTV.cpp index 1e7b0c5a..107674fd 100644 --- a/src/protocols/SSTV/SSTV.cpp +++ b/src/protocols/SSTV/SSTV.cpp @@ -155,22 +155,22 @@ const SSTVMode_t PasokonP7 { }; SSTVClient::SSTVClient(PhysicalLayer* phy) { - _phy = phy; + phyLayer = phy; #if !defined(RADIOLIB_EXCLUDE_AFSK) - _audio = nullptr; + audioClient = nullptr; #endif } #if !defined(RADIOLIB_EXCLUDE_AFSK) SSTVClient::SSTVClient(AFSKClient* audio) { - _phy = audio->_phy; - _audio = audio; + phyLayer = audio->phyLayer; + audioClient = audio; } #endif #if !defined(RADIOLIB_EXCLUDE_AFSK) int16_t SSTVClient::begin(const SSTVMode_t& mode) { - if(_audio == nullptr) { + if(audioClient == nullptr) { // this initialization method can only be used in AFSK mode return(RADIOLIB_ERR_WRONG_MODEM); } @@ -181,38 +181,38 @@ int16_t SSTVClient::begin(const SSTVMode_t& mode) { int16_t SSTVClient::begin(float base, const SSTVMode_t& mode) { // save mode - _mode = mode; + txMode = mode; // calculate 24-bit frequency - _base = (base * 1000000.0) / _phy->getFreqStep(); + baseFreq = (base * 1000000.0) / phyLayer->getFreqStep(); // configure for direct mode - return(_phy->startDirect()); + return(phyLayer->startDirect()); } int16_t SSTVClient::setCorrection(float correction) { // check if mode is initialized - if(_mode.visCode == 0) { + if(txMode.visCode == 0) { return(RADIOLIB_ERR_WRONG_MODEM); } // apply correction factor to all timings - _mode.scanPixelLen *= correction; - for(uint8_t i = 0; i < _mode.numTones; i++) { - _mode.tones[i].len *= correction; + txMode.scanPixelLen *= correction; + for(uint8_t i = 0; i < txMode.numTones; i++) { + txMode.tones[i].len *= correction; } return(RADIOLIB_ERR_NONE); } void SSTVClient::idle() { - _phy->transmitDirect(); + phyLayer->transmitDirect(); this->tone(RADIOLIB_SSTV_TONE_LEADER); } void SSTVClient::sendHeader() { // save first header flag for Scottie modes - _firstLine = true; - _phy->transmitDirect(); + firstLine = true; + phyLayer->transmitDirect(); // send the first part of header (leader-break-leader) this->tone(RADIOLIB_SSTV_TONE_LEADER, RADIOLIB_SSTV_HEADER_LEADER_LENGTH); @@ -225,7 +225,7 @@ void SSTVClient::sendHeader() { // VIS code uint8_t parityCount = 0; for(uint8_t mask = 0x01; mask < 0x80; mask <<= 1) { - if(_mode.visCode & mask) { + if(txMode.visCode & mask) { this->tone(RADIOLIB_SSTV_TONE_VIS_1, RADIOLIB_SSTV_HEADER_BIT_LENGTH); parityCount++; } else { @@ -248,23 +248,23 @@ void SSTVClient::sendHeader() { void SSTVClient::sendLine(uint32_t* imgLine) { // check first line flag in Scottie modes - if(_firstLine && ((_mode.visCode == RADIOLIB_SSTV_SCOTTIE_1) || (_mode.visCode == RADIOLIB_SSTV_SCOTTIE_2) || (_mode.visCode == RADIOLIB_SSTV_SCOTTIE_DX))) { - _firstLine = false; + if(firstLine && ((txMode.visCode == RADIOLIB_SSTV_SCOTTIE_1) || (txMode.visCode == RADIOLIB_SSTV_SCOTTIE_2) || (txMode.visCode == RADIOLIB_SSTV_SCOTTIE_DX))) { + firstLine = false; // send start sync tone this->tone(RADIOLIB_SSTV_TONE_BREAK, 9000); } // send all tones in sequence - for(uint8_t i = 0; i < _mode.numTones; i++) { - if((_mode.tones[i].type == tone_t::GENERIC) && (_mode.tones[i].len > 0)) { + for(uint8_t i = 0; i < txMode.numTones; i++) { + if((txMode.tones[i].type == tone_t::GENERIC) && (txMode.tones[i].len > 0)) { // sync/porch tones - this->tone(_mode.tones[i].freq, _mode.tones[i].len); + this->tone(txMode.tones[i].freq, txMode.tones[i].len); } else { // scan lines - for(uint16_t j = 0; j < _mode.width; j++) { + for(uint16_t j = 0; j < txMode.width; j++) { uint32_t color = imgLine[j]; - switch(_mode.tones[i].type) { + switch(txMode.tones[i].type) { case(tone_t::SCAN_RED): color &= 0x00FF0000; color >>= 16; @@ -279,27 +279,27 @@ void SSTVClient::sendLine(uint32_t* imgLine) { case(tone_t::GENERIC): break; } - this->tone(RADIOLIB_SSTV_TONE_BRIGHTNESS_MIN + ((float)color * 3.1372549), _mode.scanPixelLen); + this->tone(RADIOLIB_SSTV_TONE_BRIGHTNESS_MIN + ((float)color * 3.1372549), txMode.scanPixelLen); } } } } uint16_t SSTVClient::getPictureHeight() const { - return(_mode.height); + return(txMode.height); } void SSTVClient::tone(float freq, uint32_t len) { - Module* mod = _phy->getMod(); + Module* mod = phyLayer->getMod(); uint32_t start = mod->hal->micros(); #if !defined(RADIOLIB_EXCLUDE_AFSK) - if(_audio != nullptr) { - _audio->tone(freq, false); + if(audioClient != nullptr) { + audioClient->tone(freq, false); } else { - _phy->transmitDirect(_base + (freq / _phy->getFreqStep())); + phyLayer->transmitDirect(baseFreq + (freq / phyLayer->getFreqStep())); } #else - _phy->transmitDirect(_base + (freq / _phy->getFreqStep())); + phyLayer->transmitDirect(baseFreq + (freq / phyLayer->getFreqStep())); #endif mod->waitForMicroseconds(start, len); } diff --git a/src/protocols/SSTV/SSTV.h b/src/protocols/SSTV/SSTV.h index 5a094cd6..df73d8f2 100644 --- a/src/protocols/SSTV/SSTV.h +++ b/src/protocols/SSTV/SSTV.h @@ -37,7 +37,6 @@ /*! \struct tone_t - \brief Structure to save data about tone. */ struct tone_t { @@ -65,7 +64,6 @@ struct tone_t { /*! \struct SSTVMode_t - \brief Structure to save data about supported SSTV modes. */ struct SSTVMode_t { @@ -114,14 +112,12 @@ extern const SSTVMode_t PasokonP7; /*! \class SSTVClient - \brief Client for SSTV transmissions. */ class SSTVClient { public: /*! \brief Constructor for 2-FSK mode. - \param phy Pointer to the wireless module providing PhysicalLayer communication. */ explicit SSTVClient(PhysicalLayer* phy); @@ -129,7 +125,6 @@ class SSTVClient { #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! \brief Constructor for AFSK mode. - \param audio Pointer to the AFSK instance providing audio. */ explicit SSTVClient(AFSKClient* audio); @@ -139,11 +134,9 @@ class SSTVClient { /*! \brief Initialization method for 2-FSK. - \param base Base "0 Hz tone" RF frequency to be used in MHz. - - \param mode SSTV mode to be used. Currently supported modes are Scottie1, Scottie2, ScottieDX, Martin1, Martin2, Wrasse, PasokonP3, PasokonP5 and PasokonP7. - + \param mode SSTV mode to be used. Currently supported modes are Scottie1, Scottie2, + ScottieDX, Martin1, Martin2, Wrasse, PasokonP3, PasokonP5 and PasokonP7. \returns \ref status_codes */ int16_t begin(float base, const SSTVMode_t& mode); @@ -151,9 +144,8 @@ class SSTVClient { #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! \brief Initialization method for AFSK. - - \param mode SSTV mode to be used. Currently supported modes are Scottie1, Scottie2, ScottieDX, Martin1, Martin2, Wrasse, PasokonP3, PasokonP5 and PasokonP7. - + \param mode SSTV mode to be used. Currently supported modes are Scottie1, Scottie2, + ScottieDX, Martin1, Martin2, Wrasse, PasokonP3, PasokonP5 and PasokonP7. \returns \ref status_codes */ int16_t begin(const SSTVMode_t& mode); @@ -161,9 +153,8 @@ class SSTVClient { /*! \brief Set correction coefficient for tone length. - - \param correction Timing correction factor, used to adjust the length of timing pulses. Less than 1.0 leads to shorter timing pulses, defaults to 1.0 (no correction). - + \param correction Timing correction factor, used to adjust the length of timing pulses. + Less than 1.0 leads to shorter timing pulses, defaults to 1.0 (no correction). \returns \ref status_codes */ int16_t setCorrection(float correction); @@ -180,14 +171,13 @@ class SSTVClient { /*! \brief Sends single picture line in the currently configured SSTV mode. - - \param imgLine Image line to send, in 24-bit RGB. It is up to the user to ensure that imgLine has enough pixels to send it in the current SSTV mode. + \param imgLine Image line to send, in 24-bit RGB. It is up to the user to ensure that + imgLine has enough pixels to send it in the current SSTV mode. */ void sendLine(uint32_t* imgLine); /*! \brief Get picture height of the currently configured SSTV mode. - \returns Picture height of the currently configured SSTV mode in pixels. */ uint16_t getPictureHeight() const; @@ -195,14 +185,14 @@ class SSTVClient { #if !defined(RADIOLIB_GODMODE) private: #endif - PhysicalLayer* _phy; + PhysicalLayer* phyLayer; #if !defined(RADIOLIB_EXCLUDE_AFSK) - AFSKClient* _audio; + AFSKClient* audioClient; #endif - uint32_t _base = 0; - SSTVMode_t _mode = Scottie1; - bool _firstLine = true; + uint32_t baseFreq = 0; + SSTVMode_t txMode = Scottie1; + bool firstLine = true; void tone(float freq, uint32_t len = 0); };