Skip to content

Commit d73f7dc

Browse files
Updating example
1 parent ae94174 commit d73f7dc

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

sample_firmware/sample.cc

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
#include "pins.h"
22
#include "mbed.h"
3-
#include "MPL3115A2.h"
3+
#include "BMP388.h"
44

5-
DigitalOut myled(STATE_LED_RED);
5+
// TODO Define your pins here
6+
// Syntax: DigitalOut <pin_name>(<pin_number>); (without the angle brackets)
67

78
float max_alt;
9+
// TODO What other vars might it be useful to define?
810

911
I2C i2c_sensors(I2C_SENSOR_SDA, I2C_SENSOR_SCL);
1012
Serial debug(DEBUG_TX, DEBUG_RX);
1113

12-
Altitude altitude;
13-
MPL3115A2 altimeter(&i2c_sensors, &debug);
14+
Pressure pressure;
15+
BMP388 barometer(&i2c_sensors, &debug);
16+
1417

1518
void start() {
19+
//Assign any other variables here.
1620
max_alt = 0;
17-
altimeter.init();
21+
barometer.init();
1822
}
1923

2024
void loop() {
21-
myled = (micros() / 1000000) & 1; // Flash every second
22-
23-
altimeter.readAltitude(&altitude);
24-
const float alt = altitude.altitude();
25+
// Read pressure using the BMP388 library
26+
barometer.readPressure(&pressure);
27+
float pressure_pascals = pressure.pressure();
28+
29+
// TODO Convert pressure to altitude.
30+
// TODO Update max altitude
31+
// TODO Deploy parachutes at the correct time by setting pins to a boolean true value
2532

26-
max_alt = max(max_alt, alt);
2733
}
2834

2935
int main() {

0 commit comments

Comments
 (0)