From 5b89edc7204535e3fe47e570aac0879ec61a6c05 Mon Sep 17 00:00:00 2001 From: Ettore Pane <ettore.pane@skywarder.eu> Date: Sat, 7 Dec 2024 01:03:28 +0000 Subject: [PATCH] [CONRIG] Added new buttons and updated mavlink to orion --- src/ConRIG/Buttons/Buttons.cpp | 89 +++++++++++++++++++++++++++----- src/ConRIG/Buttons/Buttons.h | 2 +- src/ConRIG/Configs/RadioConfig.h | 2 +- src/ConRIG/Radio/Radio.cpp | 60 +++++++++++++-------- src/ConRIG/Radio/Radio.h | 2 +- src/ConRIG/Serial/Serial.h | 2 +- 6 files changed, 118 insertions(+), 39 deletions(-) diff --git a/src/ConRIG/Buttons/Buttons.cpp b/src/ConRIG/Buttons/Buttons.cpp index dd7314edd..f4214f4b6 100644 --- a/src/ConRIG/Buttons/Buttons.cpp +++ b/src/ConRIG/Buttons/Buttons.cpp @@ -50,12 +50,18 @@ mavlink_conrig_state_tc_t Buttons::getState() { return state; } void Buttons::resetState() { - state.ignition_btn = false; - state.filling_valve_btn = false; - state.venting_valve_btn = false; - state.release_pressure_btn = false; - state.quick_connector_btn = false; - state.start_tars_btn = false; + state.n2o_filling_btn = false; + state.n2o_release_btn = false; + state.n2_filling_btn = false; + state.n2_release_btn = false; + state.n2_detach_btn = false; + state.n2o_venting_btn = false; + state.nitrogen_btn = false; + state.n2o_detach_btn = false; + state.n2_quenching_btn = false; + state.n2_3way_btn = false; + state.tars_btn = false; + state.ignition_btn = false; } void Buttons::periodicStatusCheck() @@ -68,6 +74,7 @@ void Buttons::periodicStatusCheck() { guard = 0; state.ignition_btn = true; + LOG_DEBUG(logger, "Ignition button pressed"); } else { @@ -78,8 +85,35 @@ void Buttons::periodicStatusCheck() { if (guard > Config::Buttons::GUARD_THRESHOLD) { - guard = 0; - state.filling_valve_btn = true; + guard = 0; + state.n2o_filling_btn = true; + LOG_DEBUG(logger, "n2o filling button pressed"); + } + else + { + guard++; + } + } + else if (btns::n2o_release::value()) + { + if (guard > Config::Buttons::GUARD_THRESHOLD) + { + guard = 0; + state.n2o_release_btn = true; + LOG_DEBUG(logger, "n2o release button pressed"); + } + else + { + guard++; + } + } + else if (btns::n2_release::value()) + { + if (guard > Config::Buttons::GUARD_THRESHOLD) + { + guard = 0; + state.n2_release_btn = true; + LOG_DEBUG(logger, "n2 release button pressed"); } else { @@ -90,27 +124,54 @@ void Buttons::periodicStatusCheck() { if (guard > Config::Buttons::GUARD_THRESHOLD) { - guard = 0; - state.venting_valve_btn = true; + guard = 0; + state.n2o_venting_btn = true; + LOG_DEBUG(logger, "n2o venting button pressed"); } else { guard++; } } - else if (btns::n2o_release::value()) + else if (btns::n2_detach::value()) { if (guard > Config::Buttons::GUARD_THRESHOLD) { - guard = 0; - state.release_pressure_btn = true; + guard = 0; + state.n2_detach_btn = true; + LOG_DEBUG(logger, "n2 detach button pressed"); + } + else + { + guard++; + } + } + else if (btns::n2_filling::value()) + { + if (guard > Config::Buttons::GUARD_THRESHOLD) + { + guard = 0; + state.n2_filling_btn = true; + LOG_DEBUG(logger, "n2 filling button pressed"); + } + else + { + guard++; + } + } + else if (btns::nitrogen::value()) + { + if (guard > Config::Buttons::GUARD_THRESHOLD) + { + guard = 0; + state.nitrogen_btn = true; + LOG_DEBUG(logger, "nitrogen button pressed"); } else { guard++; } } - // TODO: implement missing buttons else { // Reset all the states and guard diff --git a/src/ConRIG/Buttons/Buttons.h b/src/ConRIG/Buttons/Buttons.h index 362207778..efe691daa 100644 --- a/src/ConRIG/Buttons/Buttons.h +++ b/src/ConRIG/Buttons/Buttons.h @@ -23,7 +23,7 @@ #pragma once #include <ConRIG/BoardScheduler.h> -#include <common/MavlinkLyra.h> +#include <common/MavlinkOrion.h> #include <diagnostic/PrintLogger.h> #include <scheduler/TaskScheduler.h> #include <utils/DependencyManager/DependencyManager.h> diff --git a/src/ConRIG/Configs/RadioConfig.h b/src/ConRIG/Configs/RadioConfig.h index 712e4466c..735ae3f51 100644 --- a/src/ConRIG/Configs/RadioConfig.h +++ b/src/ConRIG/Configs/RadioConfig.h @@ -22,7 +22,7 @@ #pragma once -#include <common/MavlinkLyra.h> +#include <common/MavlinkOrion.h> #include <units/Frequency.h> namespace ConRIG diff --git a/src/ConRIG/Radio/Radio.cpp b/src/ConRIG/Radio/Radio.cpp index a1092628f..b43337517 100644 --- a/src/ConRIG/Radio/Radio.cpp +++ b/src/ConRIG/Radio/Radio.cpp @@ -22,7 +22,7 @@ #include "Radio.h" -#include <common/MavlinkLyra.h> +#include <common/MavlinkOrion.h> #include <common/Radio.h> #include <diagnostic/SkywardStack.h> #include <drivers/interrupt/external_interrupts.h> @@ -88,13 +88,19 @@ void Radio::handleMessage(const mavlink_message_t& msg) { Lock<FastMutex> lock{buttonsMutex}; // Reset the internal button state - buttonState.ignition_btn = false; - buttonState.filling_valve_btn = false; - buttonState.venting_valve_btn = false; - buttonState.release_pressure_btn = false; - buttonState.quick_connector_btn = false; - buttonState.start_tars_btn = false; - buttonState.arm_switch = false; + buttonState.n2o_filling_btn = false; + buttonState.n2o_release_btn = false; + buttonState.n2_filling_btn = false; + buttonState.n2_release_btn = false; + buttonState.n2_detach_btn = false; + buttonState.n2o_venting_btn = false; + buttonState.nitrogen_btn = false; + buttonState.n2o_detach_btn = false; + buttonState.n2_quenching_btn = false; + buttonState.n2_3way_btn = false; + buttonState.tars_btn = false; + buttonState.arm_switch = false; + buttonState.ignition_btn = false; } break; @@ -173,13 +179,19 @@ void Radio::setButtonsState(mavlink_conrig_state_tc_t state) Lock<FastMutex> lock{buttonsMutex}; // The OR operator is introduced to make sure that the receiver // understood the command - buttonState.ignition_btn |= state.ignition_btn; - buttonState.filling_valve_btn |= state.filling_valve_btn; - buttonState.venting_valve_btn |= state.venting_valve_btn; - buttonState.release_pressure_btn |= state.release_pressure_btn; - buttonState.quick_connector_btn |= state.quick_connector_btn; - buttonState.start_tars_btn |= state.start_tars_btn; + buttonState.n2o_filling_btn |= state.n2o_filling_btn; + buttonState.n2o_release_btn |= state.n2o_release_btn; + buttonState.n2_filling_btn |= state.n2_filling_btn; + buttonState.n2_release_btn |= state.n2_release_btn; + buttonState.n2_detach_btn |= state.n2_detach_btn; + buttonState.n2o_venting_btn |= state.n2o_venting_btn; + buttonState.nitrogen_btn |= state.nitrogen_btn; + buttonState.n2o_detach_btn |= state.n2o_detach_btn; + buttonState.n2_quenching_btn |= state.n2_quenching_btn; + buttonState.n2_3way_btn |= state.n2_3way_btn; + buttonState.tars_btn |= state.tars_btn; buttonState.arm_switch |= state.arm_switch; + buttonState.ignition_btn |= state.ignition_btn; } bool Radio::start() @@ -239,11 +251,17 @@ MavlinkStatus Radio::getMavlinkStatus() { return mavDriver->getStatus(); } Radio::Radio() { - buttonState.ignition_btn = false; - buttonState.filling_valve_btn = false; - buttonState.venting_valve_btn = false; - buttonState.release_pressure_btn = false; - buttonState.quick_connector_btn = false; - buttonState.start_tars_btn = false; - buttonState.arm_switch = false; + buttonState.n2o_filling_btn = false; + buttonState.n2o_release_btn = false; + buttonState.n2_filling_btn = false; + buttonState.n2_release_btn = false; + buttonState.n2_detach_btn = false; + buttonState.n2o_venting_btn = false; + buttonState.nitrogen_btn = false; + buttonState.n2o_detach_btn = false; + buttonState.n2_quenching_btn = false; + buttonState.n2_3way_btn = false; + buttonState.tars_btn = false; + buttonState.arm_switch = false; + buttonState.ignition_btn = false; } \ No newline at end of file diff --git a/src/ConRIG/Radio/Radio.h b/src/ConRIG/Radio/Radio.h index 6c0508892..f9d5edb29 100644 --- a/src/ConRIG/Radio/Radio.h +++ b/src/ConRIG/Radio/Radio.h @@ -27,7 +27,7 @@ #include <ConRIG/Buttons/Buttons.h> #include <ConRIG/Configs/RadioConfig.h> #include <ConRIG/Serial/Serial.h> -#include <common/MavlinkLyra.h> +#include <common/MavlinkOrion.h> #include <diagnostic/PrintLogger.h> #include <radio/MavlinkDriver/MavlinkDriver.h> #include <radio/SX1278/SX1278Lora.h> diff --git a/src/ConRIG/Serial/Serial.h b/src/ConRIG/Serial/Serial.h index 6d53219d1..a7a52c355 100644 --- a/src/ConRIG/Serial/Serial.h +++ b/src/ConRIG/Serial/Serial.h @@ -22,7 +22,7 @@ #pragma once -#include <common/MavlinkLyra.h> +#include <common/MavlinkOrion.h> #include <radio/MavlinkDriver/MavlinkDriver.h> #include <utils/DependencyManager/DependencyManager.h> -- GitLab