-
Notifications
You must be signed in to change notification settings - Fork 0
/
flight-club-arduino-ide.ino
70 lines (54 loc) · 1.43 KB
/
flight-club-arduino-ide.ino
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
#include <Arduino.h>
#include "orientation_sensor.h"
#include "altitude_sensor.h"
#include "gps.h"
#include "airspeed_sensor.h"
using namespace FCAero;
AltitudeSensor altitude(DPS310_16HZ, DPS310_128SAMPLES);
OrientationSensor orientation(5);
GPS gps(&Serial1);
AirspeedSensor airspeed;
void setup() {
Serial.begin(115200);
while (!Serial) yield();
if (!altitude.init()) {
Serial.println("Failed to initialize altitude");
while (1) delay(500);
}
if (!orientation.init()) {
Serial.println("Failed to initialize orientation");
while (1) delay(500);
}
if (!gps.init()) {
Serial.println("Failed to initialize GPS");
while (1) delay(500);
}
if (!airspeed.init()) {
Serial.println("Failed to initialize airspeed");
while (1) delay(500);
}
Serial.println("Sensors OK and GPS OK!!!");
// run I2C at 400KHz
Wire.setClock(400000);
}
void loop() {
Orientation o;
if (altitude.available()) {
float alt = altitude.read();
altitude.writeReport(alt);
}
if (orientation.available()) {
orientation.readInto(&o);
orientation.writeReport(o);
}
if (gps.available()) {
gps.available();
GPSPosition p = gps.read();
gps.writeReport(p);
}
if (airspeed.available()) {
float speed = airspeed.read();
airspeed.writeReport(speed);
}
delay(1000);
}