Skip to content

Commit

Permalink
#45: Tests for mode handler timeout and active handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aul12 committed Dec 29, 2022
1 parent 2755b8d commit 5cf1160
Show file tree
Hide file tree
Showing 2 changed files with 257 additions and 39 deletions.
10 changes: 5 additions & 5 deletions Src/Application/mode_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

enum {
IMU_TIMEOUT = (uint16_t) (100 / 16.384),
FLIGHTCOMPUTER_TIMOUT = (uint16_t) ((2 * 100) / 16.384),
REMOTE_TIMEOUT = (uint16_t) (200 / 16.384),
FLIGHTCOMPUTER_TIMEOUT = (uint16_t) ((2 * 100) / 16.384),
REMOTE_TIMEOUT = (uint16_t) (100 / 16.384),
};

static uint8_t imu_timeout_counter;
Expand All @@ -21,7 +21,7 @@ static uint8_t remote_timeout_counter;

void mode_handler_init(void) {
imu_timeout_counter = IMU_TIMEOUT;
flightcomputer_timeout_counter = FLIGHTCOMPUTER_TIMOUT;
flightcomputer_timeout_counter = FLIGHTCOMPUTER_TIMEOUT;
remote_timeout_counter = REMOTE_TIMEOUT;
}

Expand Down Expand Up @@ -60,8 +60,8 @@ mode_handler_mode_t mode_handler_handle(imu_data_t *imu_data, remote_data_t *rem
flightcomputer_timeout_counter = 0;
}
bool flightcomputer_active = true;
if (flightcomputer_timeout_counter >= FLIGHTCOMPUTER_TIMOUT) {
flightcomputer_timeout_counter = FLIGHTCOMPUTER_TIMOUT;
if (flightcomputer_timeout_counter >= FLIGHTCOMPUTER_TIMEOUT) {
flightcomputer_timeout_counter = FLIGHTCOMPUTER_TIMEOUT;
flightcomputer_active = false;
}
*flightcomputer_setpoint = flightcomputer_get_setpoint();
Expand Down
Loading

0 comments on commit 5cf1160

Please sign in to comment.