-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.h
55 lines (46 loc) · 1.46 KB
/
menu.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
void print_menu() {
Serial.println("Enter some text to hear it in morse.");
Serial.println("or enter: *** followed by a command from below:");
Serial.println("- \"keying\" to switch to key input decoded to text");
Serial.println("- \"playmorse\" to switch to playing text in morse sounds");
Serial.println("- \"speed\" followed by a number for play speed (e.g. 250 = 0.25 sec)");
Serial.println("- \"frequency\" followed by a number for the sound frequency (e.g. 900)");
}
bool is_menu_input(String input) {
if(!input.startsWith("***")) {
return false;
}
input.remove(0,3); // remove the ****
Serial.print("command received: ");
Serial.println(input);
if(input.startsWith("speed")) {
input.remove(0,5);
if(input.toInt() > 0) {
unit_length = input.toInt();
Serial.print("Speed is now ");
Serial.println(unit_length);
return true;
}
}
if(input.startsWith("frequency")) {
input.remove(0,9);
if(input.toInt() > 0) {
frequency = input.toInt();
Serial.print("Frequency is now ");
Serial.println(frequency);
return true;
}
}
if(input.equals("keying")) {
p_mode = program_mode::record;
Serial.println("Switched to keying mode");
return true;
}
if(input.equals("playmorse")) {
p_mode = program_mode::play;
Serial.println("Switched to playing mode");
return true;
}
print_menu(); // for everything not catched, including help
return true;
}