From bb4e6cf9467bf391cb8eaff38beb4e6d8b8aa92a Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 22 Apr 2023 19:35:23 +0200 Subject: [PATCH] [Morse] Use compact Doxygen and stop using reserved format --- src/protocols/Morse/Morse.cpp | 66 +++++++++++++++++------------------ src/protocols/Morse/Morse.h | 34 ++++++------------ 2 files changed, 43 insertions(+), 57 deletions(-) diff --git a/src/protocols/Morse/Morse.cpp b/src/protocols/Morse/Morse.cpp index afbb03a7..377b6c01 100644 --- a/src/protocols/Morse/Morse.cpp +++ b/src/protocols/Morse/Morse.cpp @@ -5,35 +5,35 @@ #if !defined(RADIOLIB_EXCLUDE_MORSE) MorseClient::MorseClient(PhysicalLayer* phy) { - _phy = phy; + phyLayer = phy; #if !defined(RADIOLIB_EXCLUDE_AFSK) - _audio = nullptr; + audioClient = nullptr; #endif } #if !defined(RADIOLIB_EXCLUDE_AFSK) MorseClient::MorseClient(AFSKClient* audio) { - _phy = audio->_phy; - _audio = audio; + phyLayer = audio->phyLayer; + audioClient = audio; } #endif int16_t MorseClient::begin(float base, uint8_t speed) { // calculate 24-bit frequency - _baseHz = base; - _base = (base * 1000000.0) / _phy->getFreqStep(); + baseFreqHz = base; + baseFreq = (base * 1000000.0) / phyLayer->getFreqStep(); // calculate tone period for decoding - _basePeriod = (1000000.0f/base)/2.0f; + basePeriod = (1000000.0f/base)/2.0f; // calculate symbol lengths (assumes PARIS as typical word) - _dotLength = 1200 / speed; - _dashLength = 3*_dotLength; - _letterSpace = 3*_dotLength; - _wordSpace = 4*_dotLength; + dotLength = 1200 / speed; + dashLength = 3*dotLength; + letterSpace = 3*dotLength; + wordSpace = 4*dotLength; // configure for direct mode - return(_phy->startDirect()); + return(phyLayer->startDirect()); } size_t MorseClient::startSignal() { @@ -59,13 +59,13 @@ char MorseClient::decode(uint8_t symbol, uint8_t len) { #if !defined(RADIOLIB_EXCLUDE_AFSK) int MorseClient::read(uint8_t* symbol, uint8_t* len, float low, float high) { - Module* mod = _phy->getMod(); + Module* mod = phyLayer->getMod(); // measure pulse duration in us - uint32_t duration = mod->hal->pulseIn(_audio->_pin, mod->hal->GpioLevelLow, 4*_basePeriod); + uint32_t duration = mod->hal->pulseIn(audioClient->outPin, mod->hal->GpioLevelLow, 4*basePeriod); // decide if this is a signal, or pause - if((duration > low*_basePeriod) && (duration < high*_basePeriod)) { + if((duration > low*basePeriod) && (duration < high*basePeriod)) { // this is a signal signalCounter++; } else if(duration == 0) { @@ -80,9 +80,9 @@ int MorseClient::read(uint8_t* symbol, uint8_t* len, float low, float high) { signalStart = mod->hal->millis(); uint32_t pauseLen = mod->hal->millis() - pauseStart; - if((pauseLen >= low*(float)_letterSpace) && (pauseLen <= high*(float)_letterSpace)) { + if((pauseLen >= low*(float)letterSpace) && (pauseLen <= high*(float)letterSpace)) { return(RADIOLIB_MORSE_CHAR_COMPLETE); - } else if(pauseLen > _wordSpace) { + } else if(pauseLen > wordSpace) { RADIOLIB_DEBUG_PRINTLN("\n"); return(RADIOLIB_MORSE_WORD_COMPLETE); } @@ -93,11 +93,11 @@ int MorseClient::read(uint8_t* symbol, uint8_t* len, float low, float high) { pauseStart = mod->hal->millis(); uint32_t signalLen = mod->hal->millis() - signalStart; - if((signalLen >= low*(float)_dotLength) && (signalLen <= high*(float)_dotLength)) { + if((signalLen >= low*(float)dotLength) && (signalLen <= high*(float)dotLength)) { RADIOLIB_DEBUG_PRINT("."); (*symbol) |= (RADIOLIB_MORSE_DOT << (*len)); (*len)++; - } else if((signalLen >= low*(float)_dashLength) && (signalLen <= high*(float)_dashLength)) { + } else if((signalLen >= low*(float)dashLength) && (signalLen <= high*(float)dashLength)) { RADIOLIB_DEBUG_PRINT("-"); (*symbol) |= (RADIOLIB_MORSE_DASH << (*len)); (*len)++; @@ -127,7 +127,7 @@ size_t MorseClient::write(uint8_t* buff, size_t len) { } size_t MorseClient::write(uint8_t b) { - Module* mod = _phy->getMod(); + Module* mod = phyLayer->getMod(); // check unprintable ASCII characters and boundaries if((b < ' ') || (b == 0x60) || (b > 'z')) { @@ -138,7 +138,7 @@ size_t MorseClient::write(uint8_t b) { if(b == ' ') { RADIOLIB_DEBUG_PRINTLN("space"); standby(); - mod->waitForMicroseconds(mod->hal->micros(), _wordSpace*1000); + mod->waitForMicroseconds(mod->hal->micros(), wordSpace*1000); return(1); } @@ -156,17 +156,17 @@ size_t MorseClient::write(uint8_t b) { // send dot or dash if (code & RADIOLIB_MORSE_DASH) { RADIOLIB_DEBUG_PRINT("-"); - transmitDirect(_base, _baseHz); - mod->waitForMicroseconds(mod->hal->micros(), _dashLength*1000); + transmitDirect(baseFreq, baseFreqHz); + mod->waitForMicroseconds(mod->hal->micros(), dashLength*1000); } else { RADIOLIB_DEBUG_PRINT("."); - transmitDirect(_base, _baseHz); - mod->waitForMicroseconds(mod->hal->micros(), _dotLength*1000); + transmitDirect(baseFreq, baseFreqHz); + mod->waitForMicroseconds(mod->hal->micros(), dotLength*1000); } // symbol space standby(); - mod->waitForMicroseconds(mod->hal->micros(), _dotLength*1000); + mod->waitForMicroseconds(mod->hal->micros(), dotLength*1000); // move onto the next bit code >>= 1; @@ -174,7 +174,7 @@ size_t MorseClient::write(uint8_t b) { // letter space standby(); - mod->waitForMicroseconds(mod->hal->micros(), _letterSpace*1000 - _dotLength*1000); + mod->waitForMicroseconds(mod->hal->micros(), letterSpace*1000 - dotLength*1000); RADIOLIB_DEBUG_PRINTLN(); return(1); @@ -381,20 +381,20 @@ size_t MorseClient::printFloat(double number, uint8_t digits) { int16_t MorseClient::transmitDirect(uint32_t freq, uint32_t freqHz) { #if !defined(RADIOLIB_EXCLUDE_AFSK) - if(_audio != nullptr) { - return(_audio->tone(freqHz)); + if(audioClient != nullptr) { + return(audioClient->tone(freqHz)); } #endif - return(_phy->transmitDirect(freq)); + return(phyLayer->transmitDirect(freq)); } int16_t MorseClient::standby() { #if !defined(RADIOLIB_EXCLUDE_AFSK) - if(_audio != nullptr) { - return(_audio->noTone(true)); + if(audioClient != nullptr) { + return(audioClient->noTone(true)); } #endif - return(_phy->standby()); + return(phyLayer->standby()); } #endif diff --git a/src/protocols/Morse/Morse.h b/src/protocols/Morse/Morse.h index 3f0fc5cb..374ccd55 100644 --- a/src/protocols/Morse/Morse.h +++ b/src/protocols/Morse/Morse.h @@ -87,14 +87,12 @@ static const uint8_t MorseTable[] RADIOLIB_NONVOLATILE = { /*! \class MorseClient - \brief Client for Morse Code communication. The public interface is the same as Arduino Serial. */ class MorseClient { public: /*! \brief Constructor for 2-FSK mode. - \param phy Pointer to the wireless module providing PhysicalLayer communication. */ explicit MorseClient(PhysicalLayer* phy); @@ -102,7 +100,6 @@ class MorseClient { #if !defined(RADIOLIB_EXCLUDE_AFSK) /*! \brief Constructor for AFSK mode. - \param audio Pointer to the AFSK instance providing audio. */ explicit MorseClient(AFSKClient* audio); @@ -112,45 +109,34 @@ class MorseClient { /*! \brief Initialization method. - \param base Base RF frequency to be used in MHz (in 2-FSK mode), or the tone frequency in Hz (in AFSK mode) - \param speed Coding speed in words per minute. - \returns \ref status_codes */ int16_t begin(float base, uint8_t speed = 20); /*! \brief Send start signal. - \returns Number of bytes sent (always 0). */ size_t startSignal(); /*! \brief Decode Morse symbol to ASCII. - \param symbol Morse code symbol, respresented as outlined in MorseTable. - \param len Symbol length (number of dots and dashes). - \returns ASCII character matching the symbol, or 0xFF if no match is found. */ static char decode(uint8_t symbol, uint8_t len); /*! \brief Read Morse tone on input pin. - \param symbol Pointer to the symbol buffer. - \param len Pointer to the length counter. - \param low Low threshold for decision limit (dot length, pause length etc.), defaults to 0.75. - \param high High threshold for decision limit (dot length, pause length etc.), defaults to 1.25. - - \returns 0 if not enough symbols were decoded, 1 if inter-character space was detected, 2 if inter-word space was detected. + \returns 0 if not enough symbols were decoded, 1 if inter-character space was detected, + 2 if inter-word space was detected. */ #if !defined(RADIOLIB_EXCLUDE_AFSK) int read(uint8_t* symbol, uint8_t* len, float low = 0.75f, float high = 1.25f); @@ -190,17 +176,17 @@ class MorseClient { #if !defined(RADIOLIB_GODMODE) private: #endif - PhysicalLayer* _phy; + PhysicalLayer* phyLayer; #if !defined(RADIOLIB_EXCLUDE_AFSK) - AFSKClient* _audio; + AFSKClient* audioClient; #endif - uint32_t _base = 0, _baseHz = 0; - float _basePeriod = 0.0f; - uint32_t _dotLength = 0; - uint32_t _dashLength = 0; - uint32_t _letterSpace = 0; - uint16_t _wordSpace = 0; + uint32_t baseFreq = 0, baseFreqHz = 0; + float basePeriod = 0.0f; + uint32_t dotLength = 0; + uint32_t dashLength = 0; + uint32_t letterSpace = 0; + uint16_t wordSpace = 0; // variables to keep decoding state uint32_t signalCounter = 0;