Skip to content

Commit c171362

Browse files
committed
Fix .,? morse encodings, and use correct letter spacing based on settings, not hard coded
1 parent 79fd056 commit c171362

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

morse.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
#include "ubitx.h"
33
#include "settings.h"
44
#include "morse.h"
5-
/*
6-
* Each byte of the morse table stores one letter.
7-
* The 0 is a dot, a 1 is a dash
8-
* From the Most significant byte onwards, the letter is padded with 1s.
9-
* The first zero after the 1s indicates the start of the letter, it MUST be discarded
10-
*/
115

126
struct Morse {
137
char letter;
148
unsigned char code;
159
};
1610

11+
/*
12+
* Each byte of the morse table stores one letter.
13+
* The 0 is a dot, a 1 is a dash
14+
* From the Most significant byte onwards, the letter is padded with 1s.
15+
* The first zero after the 1s indicates the start of the letter, it MUST be discarded
16+
*/
1717
static const PROGMEM struct Morse morse_table[] = {
1818
{'a', 0xf9}, // 11111001
1919
{'b', 0xe8}, // 11101000
@@ -51,9 +51,9 @@ static const PROGMEM struct Morse morse_table[] = {
5151
{'8', 0xdc}, // 11011100
5252
{'9', 0xde}, // 11011110
5353
{'0', 0xdf}, // 11011111
54-
{'.', 0xd5}, // 11010101
55-
{',', 0xd3}, // 11010011 //AD7U 20191217
56-
{'?', 0xcc}, // 11001100 //AD7U 20191217 - Added
54+
{'.', 0x95}, // 10010101
55+
{',', 0xb3}, // 10110011
56+
{'?', 0x8c}, // 10001100
5757
};
5858

5959
static void morseLetter(char c){
@@ -62,7 +62,7 @@ static void morseLetter(char c){
6262
//handle space character as three dashes
6363
if (c == ' '){
6464
active_delay(9 * globalSettings.cwDitDurationMs);
65-
Serial.print(' ');
65+
//Serial.print(' ');
6666
return;
6767
}
6868

@@ -94,7 +94,8 @@ static void morseLetter(char c){
9494
mask = mask >> 1;
9595
}
9696
//Serial.println('@');
97-
delay(200); // space between letters is a dash (3 dots), one dot's space has already been sent
97+
delay(2*globalSettings.cwDitDurationMs); // space between letters is a dash (3 dots), one dot's space has already been sent
98+
break;//We've played the letter, so don't bother checking the rest of the list
9899
}
99100
}
100101
}
@@ -107,7 +108,7 @@ void morseText(char *text){
107108
delay(1000);
108109
// }
109110

110-
Serial.println(globalSettings.cwSideToneFreq);
111+
//Serial.println(globalSettings.cwSideToneFreq);
111112
while(*text){
112113
morseLetter(*text++);
113114
}

0 commit comments

Comments
 (0)