Skip to content

Commit

Permalink
AP_ESC_TELEM: solved the logical error in grouping of escs into 4
Browse files Browse the repository at this point in the history
  • Loading branch information
adityaomar3 committed Apr 17, 2024
1 parent 4ca2277 commit 407e8b2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libraries/AP_ESC_Telem/AP_ESC_Telem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ void AP_ESC_Telem::send_esc_telemetry_mavlink(uint8_t mav_chan)

// loop through groups of 4 ESCs
const uint8_t esc_offset = constrain_int16(mavlink_offset, 0, ESC_TELEM_MAX_ESCS-1);
const uint8_t num_idx = ESC_TELEM_MAX_ESCS/4;

// 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;

for (uint8_t idx = 0; idx < num_idx; idx++) {
const uint8_t i = (next_idx + idx) % num_idx;

Expand Down

0 comments on commit 407e8b2

Please sign in to comment.