From 67937f4f46d94c2c79129acc74f0fc6db7d836e8 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 23 Oct 2022 10:18:49 +0200 Subject: [PATCH] [AX25] Added option to modify tone length for AFSK mode --- src/protocols/AX25/AX25.cpp | 6 ++++-- src/protocols/AX25/AX25.h | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index 19e3c416..b386a335 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -163,11 +163,13 @@ AX25Client::AX25Client(AFSKClient* audio) { _audio = audio; _afskMark = RADIOLIB_AX25_AFSK_MARK; _afskSpace = RADIOLIB_AX25_AFSK_SPACE; + _afskLen = RADIOLIB_AX25_AFSK_TONE_DURATION; } -int16_t AX25Client::setCorrection(int16_t mark, int16_t space) { +int16_t AX25Client::setCorrection(int16_t mark, int16_t space, float length) { _afskMark = RADIOLIB_AX25_AFSK_MARK + mark; _afskSpace = RADIOLIB_AX25_AFSK_SPACE + space; + _afskLen = length*(float)RADIOLIB_AX25_AFSK_TONE_DURATION; return(RADIOLIB_ERR_NONE); } #endif @@ -411,7 +413,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) { } else { _audio->tone(_afskSpace, false); } - while(mod->micros() - start < RADIOLIB_AX25_AFSK_TONE_DURATION) { + while(mod->micros() - start < _afskLen) { mod->yield(); } } diff --git a/src/protocols/AX25/AX25.h b/src/protocols/AX25/AX25.h index 050c39ea..dcf03334 100644 --- a/src/protocols/AX25/AX25.h +++ b/src/protocols/AX25/AX25.h @@ -300,9 +300,11 @@ class AX25Client { \param space Positive or negative correction offset for space audio frequency in Hz. + \param length Audio tone length modifier, defaults to 1.0. + \returns \ref status_codes */ - int16_t setCorrection(int16_t mark, int16_t space); + int16_t setCorrection(int16_t mark, int16_t space, float length = 1.0f); #endif // basic methods @@ -365,6 +367,7 @@ class AX25Client { AFSKClient* _audio; uint32_t _afskMark; uint32_t _afskSpace; + uint32_t _afskLen; #endif char _srcCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1] = {0, 0, 0, 0, 0, 0, 0};