Skip to content

Commit

Permalink
Ignore ALL non-Morse characters
Browse files Browse the repository at this point in the history
  • Loading branch information
ridencww committed Sep 12, 2021
1 parent ab2313e commit a9546d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cww_MorseTx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "cww_MorseTx.h"

/*
version 1.2.1: Ignore all non-Morse characters
version 1.2.0: Change speed to float type to support speeds less than 1 word per minute
version 1.1.1: Isolate variables to support multiple instances. Fix divide by zero error when speed = 0
version 1.1.0: ESP32 support. Fixed compiler warning about a constant to char* conversion.
Expand Down Expand Up @@ -130,6 +131,7 @@ void cww_MorseTx::dash() {
}

void cww_MorseTx::send(char c) {
byte o;
byte morseByte;
byte offset = (byte)c < 97 ? 0 : 32;

Expand All @@ -139,8 +141,14 @@ void cww_MorseTx::send(char c) {
return;
}

// Ignore offsets (non-Morse) characters
o = ((byte) c) - 33 - offset;
if (o > 63) {
o = 2; // a non-Morse character
}

// Take the ASCII and retrieve the equivalent Morse character
morseByte = _morsetable[((byte) c) - 33 - offset];
morseByte = _morsetable[o];

// Output the CW character by rotating through the data byte
while (morseByte != 1) {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=CWW Morse Transmit
version=1.2.0
version=1.2.1
author=Ralph Iden
maintainer=Ralph <[email protected]>
sentence=Send Morse Code on a digital I/O pin with optional audio sidetone.
Expand Down

0 comments on commit a9546d8

Please sign in to comment.