Skip to content

Commit

Permalink
AP_KDECAN: re-order fields in AP_ESC_Telem_Backend::TelemetryData str…
Browse files Browse the repository at this point in the history
…uct to save memory
  • Loading branch information
amilcarlucas committed Feb 13, 2024
1 parent 491921a commit 8056237
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libraries/AP_KDECAN/AP_KDECAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,12 @@ void AP_KDECAN_Driver::handle_frame(AP_HAL::CANFrame &frame)
update_rpm(idx, uint16_t(uint16_t(frame.data[4] << 8 | frame.data[5]) * 60UL * 2 / num_poles));

const TelemetryData t {
.temperature_cdeg = int16_t(frame.data[6] * 100),
.voltage = float(uint16_t(frame.data[0] << 8 | frame.data[1])) * 0.01f,
.current = float(uint16_t(frame.data[2] << 8 | frame.data[3])) * 0.01f,
.consumption_mah = 0.0f,
.usage_s = 0,
.last_update_ms = 0,
.temperature_cdeg = int16_t(frame.data[6] * 100),
};
update_telem_data(idx, t,
AP_ESC_Telem_Backend::TelemetryType::CURRENT |
Expand Down

0 comments on commit 8056237

Please sign in to comment.