From e9f25158f5c5b91506d1ae76cb3faadc653a9eea Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Thu, 15 Aug 2024 15:02:12 +0100 Subject: [PATCH] SRV_Channels: find_channel: use channel mask remove need for search over all channels --- libraries/SRV_Channel/SRV_Channel_aux.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/libraries/SRV_Channel/SRV_Channel_aux.cpp b/libraries/SRV_Channel/SRV_Channel_aux.cpp index 2d297930e678a..4c36ae332ccba 100644 --- a/libraries/SRV_Channel/SRV_Channel_aux.cpp +++ b/libraries/SRV_Channel/SRV_Channel_aux.cpp @@ -565,16 +565,25 @@ bool SRV_Channels::set_aux_channel_default(SRV_Channel::Aux_servo_function_t fun // find first channel that a function is assigned to bool SRV_Channels::find_channel(SRV_Channel::Aux_servo_function_t function, uint8_t &chan) { - if (!function_assigned(function)) { + // Must have populated channel masks + if (!initialised) { + update_aux_servo_function(); + } + + // Make sure function is valid + if (!SRV_Channel::valid_function(function)) { return false; } - for (uint8_t i=0; i