[Morse] Added support for interrupt-based timing

This commit is contained in:
jgromes 2022-11-18 17:55:08 +01:00
parent e1c217305f
commit f69723b96c
3 changed files with 9 additions and 9 deletions

View file

@ -28,7 +28,7 @@
// DIO0 pin: 2
// RESET pin: 9
// DIO1 pin: 3
SX1278 radio = new Module(5, 2, 9, 3);
SX1278 radio = new Module(10, 2, 9, 3);
// or using RadioShield
// https://github.com/jgromes/RadioShield

View file

@ -137,7 +137,7 @@ size_t MorseClient::write(uint8_t b) {
if(b == ' ') {
RADIOLIB_DEBUG_PRINTLN(F("space"));
standby();
mod->delay(_wordSpace);
mod->waitForMicroseconds(mod->micros(), _wordSpace*1000);
return(1);
}
@ -156,16 +156,16 @@ size_t MorseClient::write(uint8_t b) {
if (code & RADIOLIB_MORSE_DASH) {
RADIOLIB_DEBUG_PRINT('-');
transmitDirect(_base, _baseHz);
mod->delay(_dashLength);
mod->waitForMicroseconds(mod->micros(), _dashLength*1000);
} else {
RADIOLIB_DEBUG_PRINT('.');
transmitDirect(_base, _baseHz);
mod->delay(_dotLength);
mod->waitForMicroseconds(mod->micros(), _dotLength*1000);
}
// symbol space
standby();
mod->delay(_dotLength);
mod->waitForMicroseconds(mod->micros(), _dotLength*1000);
// move onto the next bit
code >>= 1;
@ -173,7 +173,7 @@ size_t MorseClient::write(uint8_t b) {
// letter space
standby();
mod->delay(_letterSpace - _dotLength);
mod->waitForMicroseconds(mod->micros(), _letterSpace*1000 - _dotLength*1000);
RADIOLIB_DEBUG_PRINTLN();
return(1);

View file

@ -193,9 +193,9 @@ class MorseClient {
uint32_t _base = 0, _baseHz = 0;
float _basePeriod = 0.0f;
uint16_t _dotLength = 0;
uint16_t _dashLength = 0;
uint16_t _letterSpace = 0;
uint32_t _dotLength = 0;
uint32_t _dashLength = 0;
uint32_t _letterSpace = 0;
uint16_t _wordSpace = 0;
// variables to keep decoding state