From cc2ec09659f939de7eceebe10545fd798ed1b96a Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Wed, 13 Oct 2021 14:48:31 +0200 Subject: [PATCH] ManualControl: fix arm button logic during testing The latching logic has to be different than for the arm switch this difference got lost in the rewrite of the old obfuscated arming trigger logic. --- src/modules/manual_control/ManualControl.cpp | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/modules/manual_control/ManualControl.cpp b/src/modules/manual_control/ManualControl.cpp index 91952b3740..d4996a9709 100644 --- a/src/modules/manual_control/ManualControl.cpp +++ b/src/modules/manual_control/ManualControl.cpp @@ -170,18 +170,19 @@ void ManualControl::Run() evaluate_mode_slot(switches.mode_slot); } - if (switches.arm_switch != _previous_switches.arm_switch) { - if (_param_com_arm_swisbtn.get()) { - // Arming button - _button_hysteresis.set_state_and_update(switches.arm_switch == manual_control_switches_s::SWITCH_POS_ON, now); + if (_param_com_arm_swisbtn.get()) { + // Arming button + const bool previous_button_hysteresis = _button_hysteresis.get_state(); + _button_hysteresis.set_state_and_update(switches.arm_switch == manual_control_switches_s::SWITCH_POS_ON, now); - if (_button_hysteresis.get_state()) { - send_arm_command(vehicle_command_s::ARMING_ACTION_TOGGLE, - vehicle_command_s::ARMING_ORIGIN_BUTTON); - } + if (!previous_button_hysteresis && _button_hysteresis.get_state()) { + send_arm_command(vehicle_command_s::ARMING_ACTION_TOGGLE, + vehicle_command_s::ARMING_ORIGIN_BUTTON); + } - } else { - // Arming switch + } else { + // Arming switch + if (switches.arm_switch != _previous_switches.arm_switch) { if (switches.arm_switch == manual_control_switches_s::SWITCH_POS_ON) { send_arm_command(vehicle_command_s::ARMING_ACTION_ARM, vehicle_command_s::ARMING_ORIGIN_SWITCH);