Add morseBool function

This commit is contained in:
Reed Nightingale 2020-01-25 16:31:32 -08:00
parent c6b21bfa6d
commit 9635d404b0
2 changed files with 11 additions and 4 deletions

View File

@ -105,12 +105,10 @@ static void morseLetter(char c, uint16_t dit_duration_ms){
}
}
static const uint8_t RELATIVE_OFFSET_HZ = 100;
void morseText(char *text, uint16_t dit_duration_ms){
int16_t total_counts = 0;
tone(CW_TONE, globalSettings.cwSideToneFreq-100);
delay(100);
noTone(CW_TONE);
delay(100);
morseBool(false);
enc_read();//Don't count initial tone against total_counts
while(*text && (abs(total_counts) < 10)){
morseLetter(*text++, dit_duration_ms);
@ -118,3 +116,9 @@ void morseText(char *text, uint16_t dit_duration_ms){
}
}
void morseBool(bool val){
tone(CW_TONE, globalSettings.cwSideToneFreq + (val ? RELATIVE_OFFSET_HZ : -RELATIVE_OFFSET_HZ));
delay(3*globalSettings.cwDitDurationMs);
noTone(CW_TONE);
delay(3*globalSettings.cwDitDurationMs);
}

View File

@ -2,3 +2,6 @@
//sends out morse code at the speed set by cwSpeed
void morseLetter(char c, uint16_t dit_duration_ms = globalSettings.cwDitDurationMs);
void morseText(char *text, uint16_t dit_duration_ms = globalSettings.cwDitDurationMs);
//Plays either a higher or lower tone to indicate a boolean value
void morseBool(bool val);