From 1fe056abcdc1e373f3d3ba248fef017ad154a561 Mon Sep 17 00:00:00 2001 From: adityaomar3 Date: Wed, 17 Apr 2024 16:19:14 +0530 Subject: [PATCH] AP_ESC_TELEM: Updated the logic for grouping of ESCs --- libraries/AP_ESC_Telem/AP_ESC_Telem.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/AP_ESC_Telem/AP_ESC_Telem.cpp b/libraries/AP_ESC_Telem/AP_ESC_Telem.cpp index 5da5b9dac651ce..3dacf98fe913d8 100644 --- a/libraries/AP_ESC_Telem/AP_ESC_Telem.cpp +++ b/libraries/AP_ESC_Telem/AP_ESC_Telem.cpp @@ -321,9 +321,8 @@ void AP_ESC_Telem::send_esc_telemetry_mavlink(uint8_t mav_chan) const uint8_t esc_offset = constrain_int16(mavlink_offset, 0, ESC_TELEM_MAX_ESCS-1); // ensure we send out partially-full groups: - const uint8_t num_idx = (ESC_TELEM_MAX_ESCS % 4 == 0) ? ESC_TELEM_MAX_ESCS / 4 : (ESC_TELEM_MAX_ESCS / 4) + 1; + const uint8_t num_idx = (ESC_TELEM_MAX_ESCS + 3) / 4; - for (uint8_t idx = 0; idx < num_idx; idx++) { const uint8_t i = (next_idx + idx) % num_idx;