-
Notifications
You must be signed in to change notification settings - Fork 0
/
3milestone.cpp
62 lines (41 loc) · 1.11 KB
/
3milestone.cpp
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
// Do not remove the include below
#include "PlutoPilot.h"
#include "Xshield.h"
#include "Control.h"
#include "Led.h"
#include "Print.h"
//The setup function is called once at Pluto's hardware startup
void plutoInit()
{
// Add your hardware initialization code here
Xshield.init();
}
//The function is called once before plutoPilot() when you activate Developer Mode
void onPilotStart()
{
// do your one time stuffs here
Xshield.startRanging();
Control.disableFlightStatus(true);
}
void plutoPilot()
{
//Add your repeated code here
Print.monitor("LEFT RANGE: ", Xshield.getRange(LS_LEFT));
Print.monitor("RIGHT RANGE: ", Xshield.getRange(LS_RIGHT));
if(Xshield.getRange(LS_LEFT)<300){
Control.setRcCommand(RC_ROLL, 2000);
ledOp(L_LEFT, ON);
ledOp(L_RIGHT, OFF);
}
if(Xshield.getRange(LS_RIGHT)<300){
Control.setRcCommand(RC_ROLL, 1000);
ledOp(L_LEFT, OFF);
ledOp(L_RIGHT, ON);
}
}
void onPilotFinish()
{
// do your cleanup stuffs here
Xshield.stopRanging();
Control.disableFlightStatus(false);
}