Skip to content

Commit

Permalink
update blims
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-goddard committed Dec 5, 2024
1 parent 7f1f35d commit 3fb6bbd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
10 changes: 5 additions & 5 deletions src/blims/blims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ void BLIMS::execute() {
}
printf("TEST 5\n");
// check altitude
if (state::alt::altitude < constants::brake_alt) {
set_motor_position(0.5);
state::blims::below_brake_alt = true;
state::flight::events.emplace_back(Event::below_brake_alt); // logs the event to SD
}
// if (state::alt::altitude < constants::brake_alt) {
// set_motor_position(0.5);
// state::blims::below_brake_alt = true;
// state::flight::events.emplace_back(Event::below_brake_alt); // logs the event to SD
// }
}
49 changes: 24 additions & 25 deletions src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,39 @@
#endif

enum class Event : uint8_t {
key_armed = 0,
alt_armed = 1,
alt_armed = 0,

alt_init_fail = 2,
alt_read_fail = 3,
alt_turn_off = 4,
alt_init_fail = 1,
alt_read_fail = 2,
alt_turn_off = 3,

gps_init_fail = 5,
gps_read_fail = 6,
gps_turn_off = 7,
gps_init_fail = 4,
gps_read_fail = 5,
gps_turn_off = 6,

imu_init_fail = 8,
imu_read_fail = 9,
imu_turn_off = 10,
imu_init_fail = 7,
imu_read_fail = 8,
imu_turn_off = 9,

accel_init_fail = 11,
accel_read_fail = 12,
accel_turn_off = 13,
accel_init_fail = 10,
accel_read_fail = 11,
accel_turn_off = 12,

therm_init_fail = 14,
therm_read_fail = 15,
therm_turn_off = 16,
therm_init_fail = 13,
therm_read_fail = 14,
therm_turn_off = 15,

sd_init_fail = 17,
sd_write_fail = 18,
sd_init_fail = 16,
sd_write_fail = 17,

rfm_init_fail = 19,
rfm_tx_fail = 20,
rfm_init_fail = 18,
rfm_tx_fail = 19,

main_deploy_wait_end = 21,
main_log_shutoff = 22,
main_deploy_wait_end = 20,
main_log_shutoff = 21,

below_brake_alt = 23,
blims_threshold_reached = 24
below_brake_alt = 22,
blims_threshold_reached = 23

};

Expand Down
9 changes: 4 additions & 5 deletions src/core/flight_mode.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#include "flight_mode.hpp"
// #include "../../sim/sim_data.hpp"
#include "../../sim/sim_data.hpp"
#include "../constants.hpp"
#include "../pins.hpp"
#include "hardware/gpio.h"
#include "modules.hpp"
#include "state.hpp"
// SimData sim_data;
SimData sim_data;

void FlightMode::execute() {
if (!state::alt::status == OFF) {
ret = modules::altimeter.read_altitude(&state::alt::altitude, state::alt::ref_pressure);
ret = modules::altimeter.read_pressure(&state::alt::pressure);
check_sensor(ALT);
}
// state::alt::altitude = sim_data.get_alt();
state::alt::altitude = sim_data.get_alt();

if (!state::gps::status == OFF) {
ret = modules::gps.read_data(&state::gps::data);
Expand Down Expand Up @@ -55,7 +55,7 @@ void FlightMode::execute() {
);
check_sensor(ACCEL);
}
// state::accel::accel_z = sim_data.get_accel();
state::accel::accel_z = sim_data.get_accel();

if (!state::therm::status == OFF) {
ret = modules::therm.read_temperature(&state::therm::temp);
Expand Down Expand Up @@ -171,7 +171,6 @@ void StartupMode::execute() {
if (gpio_get(ARMED_IN)) {
state::flight::key_armed = true;
gpio_put(ARMED_OUT, 1);
state::flight::events.emplace_back(Event::key_armed);
}

// Attempt to initialize all modules
Expand Down

0 comments on commit 3fb6bbd

Please sign in to comment.