-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxBee.cpp
More file actions
115 lines (94 loc) · 2.26 KB
/
xBee.cpp
File metadata and controls
115 lines (94 loc) · 2.26 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "xBee.h"
extern int drivingMode;
bool xBee::inputReceivedManual() {
//if character is received form Serial1
if (Serial1.available()) {
//stores received character into a char varible
int inputChar = Serial1.read();
switch (inputChar) {
//if input char is "-", call lowerVolume() function. The same is done for every other key which call other functions
case '-':
buzzer.lowerVolume();
break;
case '=':
buzzer.increaseVolume();
break;
case 'a':
m.moveLeft();
buzzer.playSoundId = 1;
break;
case 'd':
m.moveRight();
buzzer.playSoundId = 2;
break;
case 's':
m.moveSlower();
buzzer.playSoundId = 3;
break;
case 'w':
m.moveFaster();
buzzer.playSoundId = 4;
break;
case 'q':
m.moveToMaxSpeed();
buzzer.playSoundId = 5;
break;
case 'R':
case 'r':
m.resetSpeed();
buzzer.playSoundId = 6;
break;
case 'e':
m.resetRotationalMovement();
buzzer.playSoundId = 7;
break;
case 'A':
m.rotateDeg(90);
break;
case 'S':
m.rotateDeg(-90);
break;
case 'D':
m.rotateDeg(-180);
break;
case 'F':
m.rotateDeg(360);
break;
case 'x':
drivingMode = 1;
buzzer.autonomousModeSound();
break;
//"default:" is ran if none of other cases were activated. This is needed for the ' ' character (SPACEBAR) because this gives an error in a regular case.
default:
if (inputChar == ' ') {
m.stopContinue();
if (m.isAllowDrive()) {
buzzer.playSoundId = 8;
} else {
buzzer.playSoundId = 9;
}
}
break;
}
return true;
}
return false;
}
void xBee::inputReceivedAutonomous() {
if (Serial1.available()) {
switch (Serial1.read()) {
case 'z':
drivingMode = 0;
buzzer.manualModeSound();
break;
case 'x':
drivingMode = 1;
buzzer.autonomousModeSound();
break;
case 'c':
drivingMode = 2;
buzzer.startupSound();
break;
}
}
}