From 97d361333dbebc7f4c7df6242144b6911596233b Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 14 Mar 2016 10:56:26 -0300 Subject: [PATCH] ArduCopter: SET_SENSORS_OFFSETS support for third compass --- ArduCopter/GCS_Mavlink.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ArduCopter/GCS_Mavlink.cpp b/ArduCopter/GCS_Mavlink.cpp index 719c099029..80593fdb96 100644 --- a/ArduCopter/GCS_Mavlink.cpp +++ b/ArduCopter/GCS_Mavlink.cpp @@ -1396,17 +1396,21 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg) break; case MAV_CMD_PREFLIGHT_SET_SENSOR_OFFSETS: - if (is_equal(packet.param1,2.0f)) { - // save first compass's offsets - copter.compass.set_and_save_offsets(0, packet.param2, packet.param3, packet.param4); - result = MAV_RESULT_ACCEPTED; + { + uint8_t compassNumber = -1; + if (is_equal(packet.param1, 2.0f)) { + compassNumber = 0; + } else if (is_equal(packet.param1, 5.0f)) { + compassNumber = 1; + } else if (is_equal(packet.param1, 6.0f)) { + compassNumber = 2; + } + if (compassNumber != (uint8_t) -1) { + copter.compass.set_and_save_offsets(compassNumber, packet.param2, packet.param3, packet.param4); + result = MAV_RESULT_ACCEPTED; + } + break; } - if (is_equal(packet.param1,5.0f)) { - // save secondary compass's offsets - copter.compass.set_and_save_offsets(1, packet.param2, packet.param3, packet.param4); - result = MAV_RESULT_ACCEPTED; - } - break; case MAV_CMD_COMPONENT_ARM_DISARM: if (is_equal(packet.param1,1.0f)) {