[Morse] Added support for interrupt-based timing
This commit is contained in:
parent
e1c217305f
commit
f69723b96c
3 changed files with 9 additions and 9 deletions
|
@ -28,7 +28,7 @@
|
||||||
// DIO0 pin: 2
|
// DIO0 pin: 2
|
||||||
// RESET pin: 9
|
// RESET pin: 9
|
||||||
// DIO1 pin: 3
|
// DIO1 pin: 3
|
||||||
SX1278 radio = new Module(5, 2, 9, 3);
|
SX1278 radio = new Module(10, 2, 9, 3);
|
||||||
|
|
||||||
// or using RadioShield
|
// or using RadioShield
|
||||||
// https://github.com/jgromes/RadioShield
|
// https://github.com/jgromes/RadioShield
|
||||||
|
|
|
@ -137,7 +137,7 @@ size_t MorseClient::write(uint8_t b) {
|
||||||
if(b == ' ') {
|
if(b == ' ') {
|
||||||
RADIOLIB_DEBUG_PRINTLN(F("space"));
|
RADIOLIB_DEBUG_PRINTLN(F("space"));
|
||||||
standby();
|
standby();
|
||||||
mod->delay(_wordSpace);
|
mod->waitForMicroseconds(mod->micros(), _wordSpace*1000);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,16 +156,16 @@ size_t MorseClient::write(uint8_t b) {
|
||||||
if (code & RADIOLIB_MORSE_DASH) {
|
if (code & RADIOLIB_MORSE_DASH) {
|
||||||
RADIOLIB_DEBUG_PRINT('-');
|
RADIOLIB_DEBUG_PRINT('-');
|
||||||
transmitDirect(_base, _baseHz);
|
transmitDirect(_base, _baseHz);
|
||||||
mod->delay(_dashLength);
|
mod->waitForMicroseconds(mod->micros(), _dashLength*1000);
|
||||||
} else {
|
} else {
|
||||||
RADIOLIB_DEBUG_PRINT('.');
|
RADIOLIB_DEBUG_PRINT('.');
|
||||||
transmitDirect(_base, _baseHz);
|
transmitDirect(_base, _baseHz);
|
||||||
mod->delay(_dotLength);
|
mod->waitForMicroseconds(mod->micros(), _dotLength*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// symbol space
|
// symbol space
|
||||||
standby();
|
standby();
|
||||||
mod->delay(_dotLength);
|
mod->waitForMicroseconds(mod->micros(), _dotLength*1000);
|
||||||
|
|
||||||
// move onto the next bit
|
// move onto the next bit
|
||||||
code >>= 1;
|
code >>= 1;
|
||||||
|
@ -173,7 +173,7 @@ size_t MorseClient::write(uint8_t b) {
|
||||||
|
|
||||||
// letter space
|
// letter space
|
||||||
standby();
|
standby();
|
||||||
mod->delay(_letterSpace - _dotLength);
|
mod->waitForMicroseconds(mod->micros(), _letterSpace*1000 - _dotLength*1000);
|
||||||
RADIOLIB_DEBUG_PRINTLN();
|
RADIOLIB_DEBUG_PRINTLN();
|
||||||
|
|
||||||
return(1);
|
return(1);
|
||||||
|
|
|
@ -193,9 +193,9 @@ class MorseClient {
|
||||||
|
|
||||||
uint32_t _base = 0, _baseHz = 0;
|
uint32_t _base = 0, _baseHz = 0;
|
||||||
float _basePeriod = 0.0f;
|
float _basePeriod = 0.0f;
|
||||||
uint16_t _dotLength = 0;
|
uint32_t _dotLength = 0;
|
||||||
uint16_t _dashLength = 0;
|
uint32_t _dashLength = 0;
|
||||||
uint16_t _letterSpace = 0;
|
uint32_t _letterSpace = 0;
|
||||||
uint16_t _wordSpace = 0;
|
uint16_t _wordSpace = 0;
|
||||||
|
|
||||||
// variables to keep decoding state
|
// variables to keep decoding state
|
||||||
|
|
Loading…
Add table
Reference in a new issue