[Morse] Update to 5.0.0
This commit is contained in:
parent
d7701c3ec7
commit
d0670fd997
4 changed files with 90 additions and 88 deletions
|
@ -49,7 +49,7 @@ void setup() {
|
|||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
@ -62,7 +62,7 @@ void setup() {
|
|||
// base frequency: 434.0 MHz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(434.0);
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
|
@ -52,7 +52,7 @@ void setup() {
|
|||
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
|
||||
// int state = radio.begin();
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
@ -65,7 +65,7 @@ void setup() {
|
|||
// AFSK tone frequency: 400 MHz
|
||||
// speed: 20 words per minute
|
||||
state = morse.begin(400);
|
||||
if(state == ERR_NONE) {
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
|
|
@ -48,6 +48,8 @@ size_t MorseClient::write(uint8_t* buff, size_t len) {
|
|||
}
|
||||
|
||||
size_t MorseClient::write(uint8_t b) {
|
||||
Module* mod = _phy->getMod();
|
||||
|
||||
// check unprintable ASCII characters and boundaries
|
||||
if((b < ' ') || (b == 0x60) || (b > 'z')) {
|
||||
return(0);
|
||||
|
@ -57,35 +59,35 @@ size_t MorseClient::write(uint8_t b) {
|
|||
if(b == ' ') {
|
||||
RADIOLIB_DEBUG_PRINTLN(F("space"));
|
||||
standby();
|
||||
Module::delay(4 * _dotLength);
|
||||
mod->delay(4 * _dotLength);
|
||||
return(1);
|
||||
}
|
||||
|
||||
// get morse code from lookup table
|
||||
uint8_t code = RADIOLIB_PROGMEM_READ_BYTE(&MorseTable[(uint8_t)(toupper(b) - 32)]);
|
||||
uint8_t code = RADIOLIB_NONVOLATILE_READ_BYTE(&MorseTable[(uint8_t)(toupper(b) - 32)]);
|
||||
|
||||
// check unsupported characters
|
||||
if(code == MORSE_UNSUPORTED) {
|
||||
if(code == RADIOLIB_MORSE_UNSUPORTED) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
// iterate through codeword until guard bit is reached
|
||||
while(code > MORSE_GUARDBIT) {
|
||||
while(code > RADIOLIB_MORSE_GUARDBIT) {
|
||||
|
||||
// send dot or dash
|
||||
if (code & MORSE_DASH) {
|
||||
if (code & RADIOLIB_MORSE_DASH) {
|
||||
RADIOLIB_DEBUG_PRINT('-');
|
||||
transmitDirect(_base, _baseHz);
|
||||
Module::delay(3 * _dotLength);
|
||||
mod->delay(3 * _dotLength);
|
||||
} else {
|
||||
RADIOLIB_DEBUG_PRINT('.');
|
||||
transmitDirect(_base, _baseHz);
|
||||
Module::delay(_dotLength);
|
||||
mod->delay(_dotLength);
|
||||
}
|
||||
|
||||
// symbol space
|
||||
standby();
|
||||
Module::delay(_dotLength);
|
||||
mod->delay(_dotLength);
|
||||
|
||||
// move onto the next bit
|
||||
code >>= 1;
|
||||
|
@ -93,7 +95,7 @@ size_t MorseClient::write(uint8_t b) {
|
|||
|
||||
// letter space
|
||||
standby();
|
||||
Module::delay(2 * _dotLength);
|
||||
mod->delay(2 * _dotLength);
|
||||
RADIOLIB_DEBUG_PRINTLN();
|
||||
|
||||
return(1);
|
||||
|
@ -103,7 +105,7 @@ size_t MorseClient::print(__FlashStringHelper* fstr) {
|
|||
PGM_P p = reinterpret_cast<PGM_P>(fstr);
|
||||
size_t n = 0;
|
||||
while(true) {
|
||||
char c = RADIOLIB_PROGMEM_READ_BYTE(p++);
|
||||
char c = RADIOLIB_NONVOLATILE_READ_BYTE(p++);
|
||||
if(c == '\0') {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
#if !defined(_RADIOLIB_MORSE_H) && !defined(RADIOLIB_EXCLUDE_MORSE)
|
||||
#define _RADIOLIB_MORSE_H
|
||||
#if !defined(_RADIOLIB_RADIOLIB_MORSE_H) && !defined(RADIOLIB_EXCLUDE_MORSE)
|
||||
#define _RADIOLIB_RADIOLIB_MORSE_H
|
||||
|
||||
#include "../../TypeDef.h"
|
||||
#include "../PhysicalLayer/PhysicalLayer.h"
|
||||
#include "../AFSK/AFSK.h"
|
||||
|
||||
#define MORSE_DOT 0b0
|
||||
#define MORSE_DASH 0b1
|
||||
#define MORSE_GUARDBIT 0b1
|
||||
#define MORSE_UNSUPORTED 0xFF
|
||||
#define RADIOLIB_MORSE_DOT 0b0
|
||||
#define RADIOLIB_MORSE_DASH 0b1
|
||||
#define RADIOLIB_MORSE_GUARDBIT 0b1
|
||||
#define RADIOLIB_MORSE_UNSUPORTED 0xFF
|
||||
|
||||
// Morse character table: - using codes defined in ITU-R M.1677-1
|
||||
// - Morse code representation is saved LSb first, using additional bit as guard
|
||||
// - position in array corresponds ASCII code minus MORSE_ASCII_OFFSET
|
||||
// - ASCII characters marked MORSE_UNSUPORTED do not have ITU-R M.1677-1 equivalent
|
||||
static const uint8_t MorseTable[] RADIOLIB_PROGMEM = {
|
||||
// - position in array corresponds ASCII code minus RADIOLIB_MORSE_ASCII_OFFSET
|
||||
// - ASCII characters marked RADIOLIB_MORSE_UNSUPORTED do not have ITU-R M.1677-1 equivalent
|
||||
static const uint8_t MorseTable[] RADIOLIB_NONVOLATILE = {
|
||||
0b00, // space
|
||||
0b110101, // ! (unsupported)
|
||||
0b1010010, // "
|
||||
MORSE_UNSUPORTED, // # (unsupported)
|
||||
MORSE_UNSUPORTED, // $ (unsupported)
|
||||
MORSE_UNSUPORTED, // % (unsupported)
|
||||
MORSE_UNSUPORTED, // & (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // # (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // $ (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // % (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // & (unsupported)
|
||||
0b1011110, // '
|
||||
0b101101, // (
|
||||
0b1101101, // )
|
||||
MORSE_UNSUPORTED, // * (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // * (unsupported)
|
||||
0b101010, // +
|
||||
0b1110011, // ,
|
||||
0b1100001, // -
|
||||
|
@ -42,10 +42,10 @@ static const uint8_t MorseTable[] RADIOLIB_PROGMEM = {
|
|||
0b100111, // 8
|
||||
0b101111, // 9
|
||||
0b1000111, // :
|
||||
MORSE_UNSUPORTED, // ; (unsupported)
|
||||
MORSE_UNSUPORTED, // < (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // ; (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // < (unsupported)
|
||||
0b110001, // =
|
||||
MORSE_UNSUPORTED, // > (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // > (unsupported)
|
||||
0b1001100, // ?
|
||||
0b1010110, // @
|
||||
0b110, // A
|
||||
|
@ -74,9 +74,9 @@ static const uint8_t MorseTable[] RADIOLIB_PROGMEM = {
|
|||
0b11001, // X
|
||||
0b11101, // Y
|
||||
0b10011, // Z
|
||||
MORSE_UNSUPORTED, // [ (unsupported)
|
||||
MORSE_UNSUPORTED, // \ (unsupported)
|
||||
MORSE_UNSUPORTED, // ] (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // [ (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // \ (unsupported)
|
||||
RADIOLIB_MORSE_UNSUPORTED, // ] (unsupported)
|
||||
0b1101000, // ^ (unsupported, used as alias for end of work)
|
||||
0b110101 // _ (unsupported, used as alias for starting signal)
|
||||
};
|
||||
|
@ -151,7 +151,7 @@ class MorseClient {
|
|||
size_t println(unsigned long, int = DEC);
|
||||
size_t println(double, int = 2);
|
||||
|
||||
#ifndef RADIOLIB_GODMODE
|
||||
#if !defined(RADIOLIB_GODMODE)
|
||||
private:
|
||||
#endif
|
||||
PhysicalLayer* _phy;
|
||||
|
|
Loading…
Add table
Reference in a new issue