diff --git a/src/blims/blims.cpp b/src/blims/blims.cpp index 66c7f6a..4dab554 100644 --- a/src/blims/blims.cpp +++ b/src/blims/blims.cpp @@ -53,13 +53,15 @@ void BLIMS::execute() { run_init_hold = false; printf("TEST 2\n\n\n\n\n"); } + // don't want to increase curr_action duration during initial hold + if (run_init_hold) { + return; + } state::blims::curr_action_duration -= (state::flight::timestamp - curr_time); curr_time = to_ms_since_boot(get_absolute_time()); - pwm_setup(); if (state::blims::curr_action_duration <= 0 && !run_init_hold) { - state::blims::curr_action_index = state::blims::curr_action_index + 1; if (state::blims::curr_action_index >= 10) { // length calculation - need to fix and get size of action_arr state::blims::curr_action_index = 0; printf("TEST 4\n"); @@ -68,6 +70,7 @@ void BLIMS::execute() { printf("Action Index: %d\n", state::blims::curr_action_index); state::blims::curr_action_duration = action_arr[state::blims::curr_action_index].duration; set_motor_position(action_arr[state::blims::curr_action_index].position); + state::blims::curr_action_index = state::blims::curr_action_index + 1; state::flight::events.emplace_back(Event::blims_threshold_reached); // we've completed a motor action in action_arr } printf("TEST 5\n"); diff --git a/src/blims/blims.hpp b/src/blims/blims.hpp index 762cbd6..c3e9950 100644 --- a/src/blims/blims.hpp +++ b/src/blims/blims.hpp @@ -31,13 +31,14 @@ class BLIMS { {1.0f, constants::turn_hold_threshold}, {0.5f, constants::neutral_hold_threshold}, }; + void pwm_setup(); private: // sets position of motor on a 0-1 scale void set_motor_position(float position); // pwm_setup configures the pwm signal - void pwm_setup(); + // want wrap to be as large as possible, increases the amount of steps so that we have as much control as possible uint16_t wrap_cycle_count = 65535; diff --git a/src/core/flight_mode.cpp b/src/core/flight_mode.cpp index 61ce5fa..a382bda 100644 --- a/src/core/flight_mode.cpp +++ b/src/core/flight_mode.cpp @@ -250,6 +250,7 @@ void StartupMode::execute() { } } } + modules::blims.pwm_setup(); } void StartupMode::transition() {