From 432e2439a2ba8e26f21aec3214031a05c5765f7c Mon Sep 17 00:00:00 2001 From: Junwoo Hwang Date: Tue, 24 May 2022 17:20:06 +0200 Subject: [PATCH] WIP: Continue adding support for Trigger slots --- src/modules/rc_update/rc_update.cpp | 9 ++++++++- src/modules/rc_update/rc_update.h | 11 ++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/modules/rc_update/rc_update.cpp b/src/modules/rc_update/rc_update.cpp index a1200ddc2f..64f4754679 100644 --- a/src/modules/rc_update/rc_update.cpp +++ b/src/modules/rc_update/rc_update.cpp @@ -600,7 +600,14 @@ void RCUpdate::UpdateManualSwitches(const hrt_abstime ×tamp_sample) switches.mode_slot = num_slots; } - } else if (_param_rc_map_flightmode_buttons.get() > 0) { + } + + for (uint8_t trig_slot = 0; trig_slot < RC_TRIG_SLOT_COUNT; trig_slot++) { + + const bool is_btn = _param_rc_trig_btn_mask.get() && (1 << trig_slot); + } + + else if (_param_rc_map_flightmode_buttons.get() > 0) { switches.mode_slot = manual_control_switches_s::MODE_SLOT_NONE; bool is_consistent_button_press = false; diff --git a/src/modules/rc_update/rc_update.h b/src/modules/rc_update/rc_update.h index dace2f308a..03b729f552 100644 --- a/src/modules/rc_update/rc_update.h +++ b/src/modules/rc_update/rc_update.h @@ -66,6 +66,9 @@ using namespace time_literals; namespace rc_update { +// Number of Generic Trigger slots that can be configured +static constexpr uint8_t RC_TRIG_SLOT_COUNT = 6; + /** ** class RCUpdate * @@ -190,8 +193,9 @@ private: uint8_t _channel_count_previous{0}; uint8_t _input_source_previous{input_rc_s::RC_INPUT_SOURCE_UNKNOWN}; - uint8_t _potential_button_press_slot{0}; - systemlib::Hysteresis _trigger_slots_hysteresis[] + // Hysteresis objects to track status of the each trigger slots for generic action + systemlib::Hysteresis _trigger_slots_hysteresis[RC_TRIG_SLOT_COUNT]; + systemlib::Hysteresis _rc_signal_lost_hysteresis{true}; uint8_t _channel_count_max{0}; @@ -201,18 +205,15 @@ private: perf_counter_t _valid_data_interval_perf{perf_alloc(PC_INTERVAL, MODULE_NAME": valid data interval")}; DEFINE_PARAMETERS( - (ParamInt) _param_rc_map_roll, (ParamInt) _param_rc_map_pitch, (ParamInt) _param_rc_map_yaw, (ParamInt) _param_rc_map_throttle, (ParamInt) _param_rc_map_failsafe, - (ParamInt) _param_rc_map_fltmode, (ParamInt) _param_rc_trig_btn_mask, (ParamInt) _param_rc_trig1_chan, (ParamInt) _param_rc_trig1_action, - (ParamInt) _param_rc_map_flaps, (ParamInt) _param_rc_map_return_sw, (ParamInt) _param_rc_map_loiter_sw,