Skip to content

Commit

Permalink
fix index issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-goddard committed Dec 5, 2024
1 parent 3fb6bbd commit 8fa11ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/blims/blims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion src/blims/blims.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/core/flight_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ void StartupMode::execute() {
}
}
}
modules::blims.pwm_setup();
}

void StartupMode::transition() {
Expand Down

0 comments on commit 8fa11ad

Please sign in to comment.