-
Notifications
You must be signed in to change notification settings - Fork 0
/
SDMorse.h
34 lines (32 loc) · 926 Bytes
/
SDMorse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Read a text file and send the characters through a MorseEncoderSine
//
// Requirements before calling:
// - SD set up and valid filename passed in
// - AudioSynthWaveform configured with connections to output and pointer passed in
//
// TODO:
// - If first character is *, read the line for WPM (and frequency?)
void SDMorse(AudioSynthWaveform *sineP, char *morseFilename) {
morseEncoderSine morseSine(sineP);
morseSine.setspeed(13);
morseSine.encode();
File morseFile = SD.open(morseFilename);
char rc;
if (morseFile) {
Serial.print("opened ");
Serial.println(morseFilename);
while (morseFile.available()) {
rc = morseFile.read();
Serial.print(rc);
morseSine.write(rc);
morseSine.encode();
while (! morseSine.available()) {
morseSine.encode();
}
}
}
else {
Serial.println("unable to open ");
Serial.println(morseFilename);
}
}