diff --git a/src/boards/Parafoil/Configs/FlightModeManagerConfig.h b/src/boards/Parafoil/Configs/FlightModeManagerConfig.h index c7f1b9a56796a629a455e721cd6cb7a194c06566..bb1843eb73cdcd2de5a19debeb0e4d66a2a17a9e 100644 --- a/src/boards/Parafoil/Configs/FlightModeManagerConfig.h +++ b/src/boards/Parafoil/Configs/FlightModeManagerConfig.h @@ -1,5 +1,5 @@ /* Copyright (c) 2022 Skyward Experimental Rocketry - * Author: Federico Mandelli + * Author: Federico Mandelli, Angelo Prete * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,4 +25,6 @@ namespace Parafoil { constexpr unsigned int LOGGING_DELAY = 5 * 1000; // [ms] +constexpr unsigned int CONTROL_DELAY = 5 * 1000; // [ms] + } // namespace Parafoil diff --git a/src/boards/Parafoil/StateMachines/FlightModeManager/FlightModeManager.cpp b/src/boards/Parafoil/StateMachines/FlightModeManager/FlightModeManager.cpp index 31788a9a03dc76e8effd45ffef01a525f6bf4235..14ba646b831eef0a6df872526de1ca2abe3734ab 100644 --- a/src/boards/Parafoil/StateMachines/FlightModeManager/FlightModeManager.cpp +++ b/src/boards/Parafoil/StateMachines/FlightModeManager/FlightModeManager.cpp @@ -346,16 +346,20 @@ State FlightModeManager::state_ready(const Event& event) State FlightModeManager::state_wing_descent(const Event& event) { + static uint16_t controlDelayId; + switch (event) { case EV_ENTRY: { logStatus(FlightModeManagerState::WING_DESCENT); - EventBroker::getInstance().post(FLIGHT_WING_DESCENT, TOPIC_FLIGHT); + controlDelayId = EventBroker::getInstance().postDelayed( + FLIGHT_WING_DESCENT, TOPIC_FLIGHT, CONTROL_DELAY); return HANDLED; } case EV_EXIT: { + EventBroker::getInstance().removeDelayed(controlDelayId); return HANDLED; } case EV_EMPTY: