1
0
mirror of https://codeberg.org/mclemens/ubitxv6.git synced 2025-02-21 06:57:27 -05:00

Let morseText play back at any desired rate, not just the default one

This commit is contained in:
Reed Nightingale 2020-01-19 20:15:01 -08:00
parent 4265d56d32
commit ece69fff3a
2 changed files with 10 additions and 18 deletions

@ -56,12 +56,12 @@ static const PROGMEM struct Morse morse_table[] = {
{'?', 0x8c}, // 10001100 {'?', 0x8c}, // 10001100
}; };
static void morseLetter(char c){ static void morseLetter(char c, uint16_t dit_duration_ms){
unsigned char mask = 0x80; unsigned char mask = 0x80;
//handle space character as three dashes //handle space character as three dashes
if (c == ' '){ if (c == ' '){
active_delay(9 * globalSettings.cwDitDurationMs); active_delay(7 * dit_duration_ms);
//Serial.print(' '); //Serial.print(' ');
return; return;
} }
@ -81,36 +81,28 @@ static void morseLetter(char c){
while(mask){ while(mask){
tone(CW_TONE, globalSettings.cwSideToneFreq,10000); tone(CW_TONE, globalSettings.cwSideToneFreq,10000);
if (mask & code){ if (mask & code){
delay(3 * globalSettings.cwDitDurationMs); delay(3 * dit_duration_ms);
//Serial.print('-'); //Serial.print('-');
} }
else{ else{
delay(globalSettings.cwDitDurationMs); delay(dit_duration_ms);
//Serial.print('.'); //Serial.print('.');
} }
//Serial.print('#'); //Serial.print('#');
noTone(CW_TONE); noTone(CW_TONE);
delay(globalSettings.cwDitDurationMs); // space between dots and dashes delay(dit_duration_ms); // space between dots and dashes
mask = mask >> 1; mask = mask >> 1;
} }
//Serial.println('@'); //Serial.println('@');
delay(2*globalSettings.cwDitDurationMs); // space between letters is a dash (3 dots), one dot's space has already been sent delay(2*dit_duration_ms); // space between letters is a dash (3 dots), one dot's space has already been sent
break;//We've played the letter, so don't bother checking the rest of the list break;//We've played the letter, so don't bother checking the rest of the list
} }
} }
} }
void morseText(char *text){ void morseText(char *text, uint16_t dit_duration_ms){
// while (1){
noTone(CW_TONE);
delay(1000);
tone(CW_TONE, 600);
delay(1000);
// }
//Serial.println(globalSettings.cwSideToneFreq);
while(*text){ while(*text){
morseLetter(*text++); morseLetter(*text++, dit_duration_ms);
} }
} }

@ -1,3 +1,3 @@
#include "settings.h"
//sends out morse code at the speed set by cwSpeed //sends out morse code at the speed set by cwSpeed
extern int cwSpeed; //this is actuall the dot period in milliseconds void morseText(char *text, uint16_t dit_duration_ms = globalSettings.cwDitDurationMs);
void morseText(char *text);